Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lld
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2022-04-15 09:58:13 +0300
committerFangrui Song <i@maskray.me>2022-04-15 09:58:13 +0300
commitb483ce12281e31311efacf0047f95767517dcde9 (patch)
treeb8b4cd2a4bbe0e9c1aecee9c34c5c6151856e92f /lld
parentf097088b0515eea5fb8a3bb6d6a4ad66a907eee2 (diff)
[ELF][ARM] Fix unneeded thunk for branches to hidden undefined weak
Similar to D123750 for AArch64.
Diffstat (limited to 'lld')
-rw-r--r--lld/ELF/Arch/ARM.cpp8
-rw-r--r--lld/test/ELF/arm-undefined-weak.s8
2 files changed, 13 insertions, 3 deletions
diff --git a/lld/ELF/Arch/ARM.cpp b/lld/ELF/Arch/ARM.cpp
index 6e2932f10166..425c45884330 100644
--- a/lld/ELF/Arch/ARM.cpp
+++ b/lld/ELF/Arch/ARM.cpp
@@ -294,9 +294,11 @@ void ARM::addPltSymbols(InputSection &isec, uint64_t off) const {
bool ARM::needsThunk(RelExpr expr, RelType type, const InputFile *file,
uint64_t branchAddr, const Symbol &s,
int64_t a) const {
- // If S is an undefined weak symbol and does not have a PLT entry then it
- // will be resolved as a branch to the next instruction.
- if (s.isUndefWeak() && !s.isInPlt())
+ // If s is an undefined weak symbol and does not have a PLT entry then it will
+ // be resolved as a branch to the next instruction. If it is hidden, its
+ // binding has been converted to local, so we just check isUndefined() here. A
+ // undefined non-weak symbol will have been errored.
+ if (s.isUndefined() && !s.isInPlt())
return false;
// A state change from ARM to Thumb and vice versa must go through an
// interworking thunk if the relocation type is not R_ARM_CALL or
diff --git a/lld/test/ELF/arm-undefined-weak.s b/lld/test/ELF/arm-undefined-weak.s
index 8e4ccff7b6c4..e50829181697 100644
--- a/lld/test/ELF/arm-undefined-weak.s
+++ b/lld/test/ELF/arm-undefined-weak.s
@@ -13,6 +13,9 @@
.weak target
.type target, %function
+ .weak undefweak2
+ .hidden undefweak2
+ .type undefweak2, %function
.text
.global _start
@@ -30,6 +33,9 @@ _start:
/// R_ARM_REL32
.word target - .
+bl_undefweak2:
+ bl undefweak2
+
// CHECK: Disassembly of section .text:
// CHECK-EMPTY:
// CHECK-NEXT: 100100b4 <_start>:
@@ -39,3 +45,5 @@ _start:
// CHECK-NEXT: 100100c0: movt r0, #0
// CHECK-NEXT: 100100c4: movw r0, #0
// CHECK: 100100c8: 00 00 00 00 .word 0x00000000
+// CHECK-LABEL: <bl_undefweak2>
+// CHECK-NEXT: bl {{.*}} <bl_undefweak2+0x4>