[ELF][test] Test that thunks are processed before finalizeSynthetic(in.symTab)

finalizeSynthetic(in.symTab) calls sortSymTabSymbols() to order local
symbols before non-local symbols.

The newly added tests ensure that thunk symbols are added before
finalizeSynthetic(in.symTab), otherwise .symtab would be out of order.
This commit is contained in:
Fangrui Song 2020-04-04 10:24:48 -07:00
parent 6d34374043
commit a13212582a
3 changed files with 32 additions and 0 deletions

View File

@ -6,6 +6,7 @@
// RUN: } " > %t.script
// RUN: ld.lld --script %t.script %t.o -o %t
// RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t | FileCheck %s
// RUN: llvm-nm --no-sort %t | FileCheck --check-prefix=NM %s
// Check that we have the out of branch range calculation right. The immediate
// field is signed so we have a slightly higher negative displacement.
@ -50,3 +51,17 @@ high_target:
// CHECK-NEXT: <high_target>:
// CHECK-NEXT: 8002000: bl #-0x8000000 <_start>
// CHECK-NEXT: ret
/// Local symbols copied from %t.o
// NM: t $x.0
// NM-NEXT: t $x.1
/// Local thunk symbols.
// NM-NEXT: t __AArch64AbsLongThunk_high_target
// NM-NEXT: t $x
// NM-NEXT: t $d
// NM-NEXT: t __AArch64AbsLongThunk_{{$}}
// NM-NEXT: t $x
// NM-NEXT: t $d
/// Global symbols.
// NM-NEXT: T _start
// NM-NEXT: T high_target

View File

@ -8,10 +8,12 @@
# RUN: ld.lld -T %t.script %t.o -o %t
# RUN: llvm-readelf -r %t | FileCheck --check-prefix=SEC %s
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefixes=CHECK,PD %s
# RUN: llvm-nm --no-sort %t | FileCheck --check-prefix=NM %s
# RUN: ld.lld -T %t.script -pie %t.o -o %t
# RUN: llvm-readelf -r %t | FileCheck --check-prefix=SEC %s
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefixes=CHECK,PI %s
# RUN: llvm-nm --no-sort %t | FileCheck --check-prefix=NM %s
# SEC: There are no relocations in this file.
@ -85,3 +87,9 @@ nop
high:
bl .text_low+8
bl .text_low+8 # Need a thunk
# NM: t __LongThunk_high
# NM-NEXT: t __LongThunk_
# NM-NEXT: t __LongThunk_
# NM-NEXT: T _start
# NM-NEXT: T high

View File

@ -9,12 +9,14 @@
# RUN: llvm-readelf -S -r %t | FileCheck --check-prefix=SEC %s
# RUN: llvm-readelf -x .branch_lt %t | FileCheck --check-prefix=BRANCH-LE %s
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
# RUN: llvm-nm --no-sort %t | FileCheck --check-prefix=NM %s
# RUN: llvm-mc -filetype=obj -triple=ppc64 %s -o %t.o
# RUN: ld.lld -T %t.script %t.o -o %t
# RUN: llvm-readelf -S -r %t | FileCheck --check-prefix=SEC %s
# RUN: llvm-readelf -x .branch_lt %t | FileCheck --check-prefix=BRANCH-BE %s
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
# RUN: llvm-nm --no-sort %t | FileCheck --check-prefix=NM %s
# SEC: Name Type Address Off Size ES Flg Lk Inf Al
# SEC: .got PROGBITS 0000000002002028 2002028 000008 00 WA 0 0 8
@ -80,3 +82,10 @@ addi 2, 2, .TOC.-high@l
bl .text_low+8
bl .text_low+8 # Need a thunk
blr
# NM: d .TOC.
# NM-NEXT: t __long_branch_high
# NM-NEXT: t __long_branch_{{$}}
# NM-NEXT: t __long_branch_{{$}}
# NM-NEXT: T _start
# NM-NEXT: T high