Bug 26928 - [2.35 regression] -Bsymbolic-functions --dynamic-list does not imply --dynamic-list-data any more
Summary: [2.35 regression] -Bsymbolic-functions --dynamic-list does not imply --dynami...
Status: RESOLVED DUPLICATE of bug 26407
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.36
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-21 08:49 UTC by Joachim Priesner
Modified: 2020-11-21 17:16 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
test.cpp, reduced from Qt qbytearray.cpp (136 bytes, text/plain)
2020-11-21 08:49 UTC, Joachim Priesner
Details
dummy.dynlist (41 bytes, text/plain)
2020-11-21 08:50 UTC, Joachim Priesner
Details
For the record: libqt4 build fix (911 bytes, patch)
2020-11-21 10:53 UTC, Hans-Peter Jansen
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joachim Priesner 2020-11-21 08:49:52 UTC
Created attachment 12988 [details]
test.cpp, reduced from Qt qbytearray.cpp

Since the following commit:

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

there has been a behavior change when linking with "-Bsymbolic-functions --dynamic-list"

To reproduce, use the attached test.cpp and dummy.dynlist and run:

g++-9 -fPIC test.cpp -shared -Wl,-Bsymbolic-functions -Wl,--dynamic-list dummy.dynlist && objdump -R a.out | grep 'R_X86_64_GLOB_DAT.*_ZN1A10sharedDataE@@Base'

ld before the change (309cae1f7b): match
ld HEAD (abd20cb637): no match
gold HEAD (abd20cb637): match
ld HEAD (abd20cb637) when additionally specifying --dynamic-list-data: match

-> It seems that -Bsymbolic-functions used to imply --dynamic-list-data, but after the change does not any more.

The change was found when debugging a regression when compiling Qt 4 (qbytearray.cpp).
Comment 1 Joachim Priesner 2020-11-21 08:50:29 UTC
Created attachment 12989 [details]
dummy.dynlist
Comment 2 Hans-Peter Jansen 2020-11-21 10:53:08 UTC
Created attachment 12990 [details]
For the record: libqt4 build fix
Comment 3 H.J. Lu 2020-11-21 12:23:43 UTC
Dup.

*** This bug has been marked as a duplicate of bug 26407 ***
Comment 4 Fangrui Song 2020-11-21 17:04:22 UTC
"ld: Handle --dynamic-list* before -Bsymbolic -Bsymbolic-functions" actually fixes a bug.

For a shared object, --dynamic-list dummy.dynlist means references to matched non-local STV_DEFAULT symbols shouldn't be bound to definitions within the shared object. Other references can be bound within the shared object.


If you don't consider the DF_SYMBOLIC difference, --dynamic-list dummy.dynlist is identical to

  -Bsymbolic --dynamic-list dummy.dynlist

Then, -Bsymbolic-functions -Bsymbolic --dynamic-list dummy.dynlist should be identical to

  -Bsymbolic --dynamic-list dummy.dynlist

i.e. -Bsymbolic-functions should be a no-op. The old behavior does not make sense.
Comment 5 Joachim Priesner 2020-11-21 17:16:02 UTC
Thanks for clarifying. I was not sure whether the behavior change was intentional, since gold and ld behave differently now and I lack the domain knowledge to say which behavior is the right one.