Bug 26018 - --dynamic-list* doesn't work before -Bsymbolic and -Bsymbolic-functions
Summary: --dynamic-list* doesn't work before -Bsymbolic and -Bsymbolic-functions
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.35
: P2 normal
Target Milestone: 2.35
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2020-05-21 01:26 UTC by Fangrui Song
Modified: 2020-05-24 11:54 UTC (History)
1 user (show)

See Also:
Last reconfirmed: 2020-05-23 00:00:00


Note You need to log in before you can comment on or make changes to this bug.
Description Fangrui Song 2020-05-21 01:26:56 UTC
The interaction is currently quite complex. To make the behavior easier to reasonable, let's make --dynamic-list* override -Bsymbolic and -Bsymbolic-functions.

This also helps PR ld/25910, which would make the situation more difficult to understand.
Comment 1 H.J. Lu 2020-05-22 13:02:20 UTC
     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.  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.  So making the --dynamic-list* options override -Bsymbolic
and -Bsymbolic-functions is incorrect since there is NOTHING to override.
Comment 2 H.J. Lu 2020-05-23 14:39:47 UTC
Nothing to fix.
Comment 3 Fangrui Song 2020-05-23 16:10:26 UTC
I don't agree with the resolution. Copying my reply https://sourceware.org/pipermail/binutils/2020-May/111223.html here

IIRC, currently -Bsymbolic --dynamic-list a.list != --dynamic-list a.list

This order dependency is error-prone. It is still fixable because I don't think any project makes uses of the combination. Order dependency also makes it unclear how --dynamic-list associates with other symbol exporting options.

--dynamic-list* work for both executables and shared libraries.
For an executable, export some symbols.
For a shared library, specify preemptible symbols.

--dynamic-list* have function overlay
with -Bsymbolic. When two options overlap in functionality, many users
expect the more fine-grained option to win, thus it is preferable for 
--dynamic-list* to override -Bsymbolic and -Bsymbolic-functions.

We could also emit a warning and say -Bsymbolic is ignored, if that matters.
Comment 4 H.J. Lu 2020-05-23 18:59:56 UTC
--dynamic-list* should work -Bsymbolic and -Bsymbolic-functions.
Comment 5 cvs-commit@gcc.gnu.org 2020-05-24 03:56:46 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:


commit 309cae1f7bbb6c4de0234e9f592d7dad3d6c61ba
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sat May 23 20:49:16 2020 -0700

    ld: Add -Bsymbolic-functions tests
            PR ld/26018
            * testsuite/ld-i386/i386.exp: Add a -Bsymbolic-functions test.
            * testsuite/ld-x86-64/x86-64.exp: Likewise.
            * testsuite/ld-i386/pr26018.d: New file.
            * testsuite/ld-x86-64/pr26018.d: Likewise.
            * testsuite/ld-x86-64/pr26018.s: Likewise.
Comment 6 cvs-commit@gcc.gnu.org 2020-05-24 11:51:11 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:


commit bb68f22c8e648032a0d1c1d17353eec599ff5e6a
Author: Fangrui Song <maskray@google.com>
Date:   Wed May 20 18:31:39 2020 -0700

    ld: Handle --dynamic-list* before -Bsymbolic -Bsymbolic-functions
    --dynamic-list* should work both before and after -Bsymbolic and
            PR ld/26018
            * lexsup.c (parse_args): Simplify.
            * testsuite/ld-elf/dl4e.out: New.
            * testsuite/ld-elf/shared.exp: Updated for PR ld/26018 tests.
Comment 7 H.J. Lu 2020-05-24 11:54:11 UTC
Fixed for 2.35.