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

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 4 10:57:46 PDT 2020


Author: Fangrui Song
Date: 2020-04-04T10:57:37-07:00
New Revision: a13212582a901beb57f9c041df68c7b34eef0524

URL: https://github.com/llvm/llvm-project/commit/a13212582a901beb57f9c041df68c7b34eef0524
DIFF: https://github.com/llvm/llvm-project/commit/a13212582a901beb57f9c041df68c7b34eef0524.diff

LOG: [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.

Added: 
    

Modified: 
    lld/test/ELF/aarch64-thunk-script.s
    lld/test/ELF/ppc32-long-thunk.s
    lld/test/ELF/ppc64-long-branch.s

Removed: 
    


################################################################################
diff  --git a/lld/test/ELF/aarch64-thunk-script.s b/lld/test/ELF/aarch64-thunk-script.s
index 5b5a53be206d..02bf115ce9a5 100644
--- a/lld/test/ELF/aarch64-thunk-script.s
+++ b/lld/test/ELF/aarch64-thunk-script.s
@@ -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

diff  --git a/lld/test/ELF/ppc32-long-thunk.s b/lld/test/ELF/ppc32-long-thunk.s
index 90c284ded5fa..4f370ddc028e 100644
--- a/lld/test/ELF/ppc32-long-thunk.s
+++ b/lld/test/ELF/ppc32-long-thunk.s
@@ -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

diff  --git a/lld/test/ELF/ppc64-long-branch.s b/lld/test/ELF/ppc64-long-branch.s
index 35286e101587..cf23364431b2 100644
--- a/lld/test/ELF/ppc64-long-branch.s
+++ b/lld/test/ELF/ppc64-long-branch.s
@@ -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 at 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


        


More information about the llvm-commits mailing list