Hello All,
Lets say I have a library foo.a which inside has many object files (bar1.o, bar2.o .. barN.o).
How can I tell the linker to not remove the unused sections of the complete library? Not all object files are being used but I would like to keep them in the final image.
I could use the --keep command and specify every barN.o file but it would be too many. Is there a way to tell it to keep the whole library?
In GCC I could write: KEEP(*foo.a:*) in the linker script. Is there something alike for the scatter file/command like.
Thanks
Hello, to answer in general, because libraries are searched to resolve symbols rather than automatically linked in totality, you should list the objects explicitly, and then either use --no_remove or --keep <object> to keep them in the final image.
If the objects are indeed named as your example, then you can simplify it with wildcard characters, to something like:
armlink main.o foo.a(bar*.o) --keep bar*.o -o image.axf
Another option may be to partially link all the library objects into one object, and then link that to the final image. This may be the better solution if the objects are named more generally:
armlink --partial foo.a(*.o) -o partial.o
armlink main.o partial.o -o image.axf