[PATCH] ld: Make --dynamic-list* override -Bsymbolic -Bsymbolic-functions

H.J. Lu hjl.tools@gmail.com
Sat May 23 19:29:36 GMT 2020


On Fri, May 22, 2020 at 8:56 AM Fangrui Song <maskray@google.com> wrote:
>
>
> On 2020-05-22, H.J. Lu wrote:
> >On Wed, May 20, 2020 at 6:48 PM Fangrui Song via Binutils
> ><binutils@sourceware.org> wrote:
> >>
> >> They aren't used together in reality, so it is safe to change the
> >> semantics. --dynamic-list is refined -Bsymbolic. -Bsymbolic-functions
> >> should be considered as a subset of -Bsymbolic, so --dynamic-list
> >> overridding -Bsymbolic implies that --dynamic-list overridding
> >> -Bsymbolic-functions.
> >
> >--dynamic-list=DYNAMIC-LIST-FILE'
> >     Specify the name of a dynamic list file to the linker.  This is
> >     typically used when creating shared libraries to specify a list of
> >     global symbols whose references shouldn't be bound to the
> >     definition within the shared library, or creating dynamically
> >     linked executables to specify a list of symbols which should be
> >     added to the symbol table in the executable.  This option is only
> >     meaningful on ELF platforms which support shared libraries.
> >
> >The --dynamic-list* options are intended for shared libraries.
>
> --dynamic-list* work for both executables and shared libraries.
> For an executable, export some symbols.
> For a shared library, specify preemptible symbols.
>
> >The goal
> >IS NOT put them in dynamic symbol table since all global symbols are in
> >dynamic symbol table already in a shared library.  The goal is to make
> >them PREEMPTIBLE.
>
> I agree with this sentence and the patch respects it.
>
> >So making the --dynamic-list* options override -Bsymbolic
> >and -Bsymbolic-functions is incorrect since there is NOTHING to override.
>
> I don't agree with this statement. --dynamic-list* have function overlay
> with -Bsymbolic. When two options overlap in functionality, many users
> expect the more fine-grained option to win, thus my thought that
> --dynamic-list* override -Bsymbolic and -Bsymbolic-functions.
>
> (FWIW LLD's preemptibility logic is
>    ...
>    if (config->hasDynamicList)
>      return sym.inDynamicList;
>    return !(config->bsymbolic || config->bsymbolicFunctions && sym.isFunc());
>    This works fine and I won't change it.
> )
>
> >To do it properly:
> >
> >1.  Extend  --dynamic-list* to executables.  Symbol binding is unchanged.
> >Only add symbols to dynamic symbol table.
>
> This was already implemented when you implemented --dynamic-list in
> 2006. This patch does not change the fact.
>
> >2. Make --export-dynamic-symbol an alias of  --dynamic-list* for executables.
> >and ignore --export-dynamic-symbol for -shared.  It has to be done at the
> >end of command-line parsing.

There is no need to change linker manual.  --dynamic-list* should work both
before and after -Bsymbolic and -Bsymbolic-functions.  Your patch used
libdl2d.so without creating it first.

Here is the updated version of your patch.  I took the liberty to make
the changes above.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ld-Make-dynamic-list-work-before-Bsymbolic-Bsymbolic.patch
Type: text/x-patch
Size: 5365 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20200523/58bb3f18/attachment.bin>


More information about the Binutils mailing list