Richard Sandiford richard.sandiford@linaro.org writes:
Dave Martin dave.martin@linaro.org writes:
Another way of doing a similar thing is to mark __mylib_constructor as undefined in all the objects that make up the library.
Unfortunately, there seems to be no obvious way of doing that: the assembler generates undefined symbol references automatically for unresolved references at assembly time. There's no way for force the existence of an undefined symbol without an actual reference to it.
One way of doing this is to create an R_ARM_NONE relocation against it, such as:
.reloc .,R_ARM_NONE,__mylib_constructor
This isn't as hacky as it might sound, because undefined references don't really make much sense without an associated reloc.
Not that I recommend this as a fix for the original problem btw. :-) Just FYI.
As Kito says, the easiest way of treating a static link like a shared one is to use --whole-archive -lfoo --no-whole-archive. If the library is compiled with -ffunction-sections -fdata-sections, --gc-sections should remove the unnecessary code.
Richard