[llvm-bugs] [Bug 34053] New: LLD doesn't handle --dynamic-list correctly for shared libraries

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 3 13:37:20 PDT 2017


            Bug ID: 34053
           Summary: LLD doesn't handle --dynamic-list correctly for shared
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: smeenai at fb.com
                CC: grimar at accesssoftek.com, llvm-bugs at lists.llvm.org,
                    rafael.espindola at gmail.com, ruiu at google.com

According to the binutils documentation [1], --dynamic-list on a shared library
should mean that the symbols in the dynamic list are always preemptible. Some
experimentation shows that it also implies that other symbols shouldn't be
preemptible. An example, for clarity.

% cat dyn.c
void a() {}
void b() {}
void c() { a(); b(); }

% cat dyn.list
{ a; };

% clang -fPIC -c dyn.c
% ld.bfd -shared --dynamic-list dyn.list -o libdyn.so dyn.o
% objdump -d libdyn.so
00000000000002d0 <c>:
 2d0:   55                      push   %rbp
 2d1:   48 89 e5                mov    %rsp,%rbp
 2d4:   e8 c7 ff ff ff          callq  2a0 <a at plt>
 2d9:   e8 e2 ff ff ff          callq  2c0 <b>
 2de:   5d                      pop    %rbp
 2df:   c3                      retq

gold exhibits the same behavior. LLD, on the other hand, still calls both a and
b through the PLT.

The LLD source [2] appears to treat dynamic lists as equivalent to version
scripts with an implicit local: * at the end, except I can't see where it's
injecting the implicit local: *. Even if it were, however, I don't think that's
correct; the dynamic list for shared libraries only controls preemption,
whereas the version script controls visibility. For example, the dynamic symbol
table for libdyn.so linked with BFD above contains all three of a, b, and c,
even though only a was in the dynamic list. Similarly, I can pass BFD a version
script which explicitly marks b as global, but the call to b still won't be

Some further experimentation shows that when both -Bsymbolic and --dynamic-list
are specificied, BFD gives the last option precedence, whereas gold always
gives --dynamic-list precedence. I personally prefer gold's behavior here.

Additionally, gold appears to limit this behavior to --dynamic-list.
--export-dynamic-symbol doesn't change preemptibility, only dynamic symbol
table population. (BFD doesn't have the --export-dynamic-symbol option, so
that's not a consideration for it.)

[1] https://sourceware.org/binutils/docs/ld/Options.html

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170803/38e726a6/attachment.html>

More information about the llvm-bugs mailing list