[lld][Hexagon] Test undefined weak branches (#186613)
Undefined weak branches do not needsThunk(). Add a test case to cover undef weak.
This commit is contained in:
parent
1dc5b0c8f3
commit
51c3f971a0
@ -370,7 +370,10 @@ bool Hexagon::inBranchRange(RelType type, uint64_t src, uint64_t dst) const {
|
||||
bool Hexagon::needsThunk(RelExpr expr, RelType type, const InputFile *file,
|
||||
uint64_t branchAddr, const Symbol &s,
|
||||
int64_t a) const {
|
||||
// Only check branch range for supported branch relocation types
|
||||
// Undefined weak symbols without PLT entries resolve to address zero.
|
||||
// Thunks are not needed since the branch target is fixed.
|
||||
if (s.isUndefined() && !s.isInPlt(ctx))
|
||||
return false;
|
||||
switch (type) {
|
||||
case R_HEX_B22_PCREL:
|
||||
case R_HEX_PLT_B22_PCREL:
|
||||
|
||||
28
lld/test/ELF/hexagon-undefined-weak.s
Normal file
28
lld/test/ELF/hexagon-undefined-weak.s
Normal file
@ -0,0 +1,28 @@
|
||||
# REQUIRES: hexagon
|
||||
# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %s -o %t.o
|
||||
# RUN: ld.lld %t.o -o %t
|
||||
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
|
||||
|
||||
## Undefined weak branch targets resolve to address zero. Verify that
|
||||
## no thunks are created and that branches encode without error.
|
||||
|
||||
.weak undefined_weak
|
||||
.globl _start
|
||||
.type _start, @function
|
||||
_start:
|
||||
## Simple call -- single-word packet.
|
||||
call undefined_weak
|
||||
|
||||
## Call in a two-word packet with an ALU op.
|
||||
{ r0 = #0
|
||||
call undefined_weak }
|
||||
|
||||
jumpr r31
|
||||
|
||||
## All branches target address zero.
|
||||
# CHECK: <_start>:
|
||||
# CHECK-NEXT: { call 0x0 <undefined_weak> }
|
||||
# CHECK-NEXT: { call 0x0 <undefined_weak>
|
||||
# CHECK-NEXT: r0 = #0x0 }
|
||||
# CHECK-NEXT: { jumpr r31 }
|
||||
# CHECK-NOT: __hexagon_thunk
|
||||
Loading…
x
Reference in New Issue
Block a user