This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] PR ld/19617: Always create dynamic sections for -E/--dynamic-list
- From: Rich Felker <dalias at libc dot org>
- To: Szabolcs Nagy <szabolcs dot nagy at arm dot com>
- Cc: "H.J. Lu" <hjl dot tools at gmail dot com>, binutils at sourceware dot org, nd at arm dot com
- Date: Wed, 25 Jan 2017 11:52:37 -0500
- Subject: Re: [PATCH] PR ld/19617: Always create dynamic sections for -E/--dynamic-list
- Authentication-results: sourceware.org; auth=none
- References: <20160217224138.GA31323@intel.com> <5888BE2E.8060509@arm.com>
On Wed, Jan 25, 2017 at 03:03:10PM +0000, Szabolcs Nagy wrote:
> On 17/02/16 22:41, H.J. Lu wrote:
> > In embedded environments, including boot loaders, the non-PIC executable
> > needs to export its symbols to modules loaded in the future. We should
> > always create dynamic sections for -E/--dynamic-list.
> >
> > Any comments?
> >
> > Thanks.
> >
> >
> > H.J.
> > --
> > bfd/
> >
> > PR ld/19617
> > * elflink.c (elf_link_add_object_symbols): Always create dynamic
> > sections for -E/--dynamic-list.
> >
>
> since this commit
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bf89386a862ace008f0152bca8bddf996d3993c8
>
> static linking with --dynamic-list adds a nonsense
> dynamic-loader to the executable e.g.
>
> echo 'int main(){}' >a.c
> echo '{main;};' >foo.list
> gcc -static -Wl,--dynamic-list=foo.list a.c
> readelf -l a.out |grep interpreter
> [Requesting program interpreter: /lib/ld64.so.1]
>
> i don't think --dynamic-list should imply dynamic section
> (--export-dynamic is not specified) and even if there is
> a dynamic section, why is there a loader? (static linked
> binary may be able to relocate itself)
>
> this broke static linking of gdb which always adds
> --dynamic-list to the link command line.
>
> i opened
> https://sourceware.org/bugzilla/show_bug.cgi?id=21086
It makes sense for -E/-rdynamic to produce a dynamic section, but
unless an explicit --dynamic-linker was passed, it should default to
--no-dynamic-linker.
It does not make sense for --dynamic-list to produce a dynamic
section. Semantically --dynamic-list is just a list of symbols not to
leave interposable, but when static linking nothing is interposable
anyway.
Rich