This is the mail archive of the
mailing list for the binutils project.
Re: [PATCH] Implement a command line switch to prevent section GC from removing exported symbols
On Wed, Dec 14, 2016 at 4:45 AM, Alan Modra <firstname.lastname@example.org> wrote:
> Why doesn't --export-dynamic work for you?
Thank you for your suggestion. But first, let me better explain my
current situation. I am building a program for an embedded device that
runs directly on bare metal and I am not targeting an OS (my toolchain
is aarch64-none-elf). However I'd like to process the ELF executable
before being converted to raw binary format with a custom tool to save
the values of all default-visibility (i.e. exported) symbols for use
by several other additional components that will also run on bare
metal (but they aren't immediately loaded in). Using --export-dynamic
indeed makes sure that all default-visibility symbols stay in the
executable even if they are not referenced, however it also outputs a
full ELF .dynamic section with many other ancillary sections. Since
there is no dynamic linker under the hood nor anything else that may
need to use those sections, I'd prefer not to include them in the
final binary since they take up unnecessary space (also part of the
reason why I'm using --gc-sections). The alternatives that currently
exist involve explicitly listing all symbols to keep, which seems
inelegant and unmaintainable to me, especially in the cases where
there may be hundreds of symbols to export.