This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Implement a command line switch to prevent section GC from removing exported symbols


On Wed, Dec 14, 2016 at 05:25:38PM +0100, fincs fincs wrote:
> On Wed, Dec 14, 2016 at 4:45 AM, Alan Modra <amodra@gmail.com> 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.

Thanks for the explanation.  That all makes sense, and the patch looks
reasonable.  It just lacks a ChangeLog and ld.texinfo documentation.
The documentaion should mention that the option is for executables and
that it keeps default and protected visibility defined global symbols
and their sections.

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]