Reputation: 101
I have used EXCLUDE_FILE to explicitly omit placing certain sections of certain object files in the master object file that I want to generate. I was wondering if there is a way to omit out just a particular symbol rather than an entire section.
Example:
Say I have a library a.lib which consists of 1.o, 2.o and 3.o with .text and .data sections. .text section of 1.o contains func1, func2 and func3.
using EXCLUDE_FILE, I can only omit out the entire .text or .data section from 1.o. I want to be able to omit out only func1 and place func2 and func3. Is this possible?
Upvotes: 4
Views: 2885
Reputation: 129
If you use GCC, you can put your function into a seperate section. And move or omit the section with a linker script.
int f3(void) __attribute__((section(".excl")));
int f3(void) {
...
}
These tell GCC to compile f3 into .excl section. Then with you linker script you can place it somewhere else.
SECTIONS
{
.text :
{
*(.text)
}
....
.excl :
{
*(.excl)
}
}
Upvotes: 3