In processRelocAux(), our handling of 1) link-time constant and 2) weak undef is the same, so put them together to simplify the logic. This moves the weak undef code around. The result is that: in a writable section (or -z notext), we will no longer emit dynamic relocations for weak undefined symbols. The new behavior seems to match GNU linkers, and improves consistency with the case of a readonly section. The condition `!Config->Shared` was there probably because it is common for a -shared link not to specify full dependencies. Keep it now but we may revisit the decision in the future. gABI says: > The behavior of weak symbols in areas not specified by this document is > implementation defined. Weak symbols are intended primarily for use in > system software. Applications using weak symbols are unreliable since > changes in the runtime environment might cause the execution to fail. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D63003 llvm-svn: 363399
17 lines
501 B
ArmAsm
17 lines
501 B
ArmAsm
# REQUIRES: x86
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
|
|
# RUN: ld.lld %t.o -o %t --export-dynamic
|
|
# RUN: llvm-readelf -r %t | FileCheck %s
|
|
|
|
## gABI leaves the behavior of weak undefined references implementation defined.
|
|
## We choose to resolve it statically and not create a dynamic relocation for
|
|
## implementation simplicity. This also matches ld.bfd and gold.
|
|
|
|
# CHECK: no relocations
|
|
|
|
.global _start
|
|
_start:
|
|
.data
|
|
.weak foobar
|
|
.quad foobar
|