[PATCH] D63974: [ELF] Only allow the binding of SharedSymbol to change for the first undef ref

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 29 05:42:46 PDT 2019


MaskRay created this revision.
MaskRay added reviewers: brooksmoses, grimar, ruiu.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

Fixes PR42442

t.o has a STB_GLOBAL undef ref to f
t2.so has a STB_WEAK undef ref to f
t1.so defines f

ld.lld t.o t1.so t2.so currently resolves f to STB_WEAK. This is not
correct because there exists a STB_GLOBAL undef ref from a regular object.
This behavior is resolveUndefined() doesn't check if the undef ref is
seen for the first time:

  if (isShared() || isLazy() || (isUndefined() && Other.Binding != STB_WEAK))
    Binding = Other.Binding;

When an undef ref is seen for a shared definition, the rule should
check: `isShared() && !BindingFinalized` where BindingFinalized is set
to true after an undef ref is seen.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D63974

Files:
  ELF/Symbols.cpp
  ELF/Symbols.h
  test/ELF/weak-undef-shared.s
  test/ELF/weak-undef-shared2.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63974.207198.patch
Type: text/x-patch
Size: 4920 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190629/1c3cfa21/attachment.bin>


More information about the llvm-commits mailing list