[lld] 0996cee - [ELF][test] Improve relocatable link & /DISCARD/ test

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 17 12:49:22 PDT 2023


Author: Fangrui Song
Date: 2023-10-17T12:49:17-07:00
New Revision: 0996ceece605ccba3f4c0079e0204e3c0b068d0e

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

LOG: [ELF][test] Improve relocatable link & /DISCARD/ test

Check that #69295 will fix symbols referenced by relocations that are
defined in discarded sections.

Added: 
    

Modified: 
    lld/test/ELF/linkerscript/discard-section.s

Removed: 
    


################################################################################
diff  --git a/lld/test/ELF/linkerscript/discard-section.s b/lld/test/ELF/linkerscript/discard-section.s
index 9e021ac83f563a4..0ede36c7351f294 100644
--- a/lld/test/ELF/linkerscript/discard-section.s
+++ b/lld/test/ELF/linkerscript/discard-section.s
@@ -6,7 +6,27 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64 b.s -o b.o
 # RUN: ld.lld -T a.lds a.o b.o -z undefs -o /dev/null 2>&1 | count 0
 # RUN: ld.lld -T a.lds a.o b.o -o /dev/null 2>&1 | count 0
-# RUN: ld.lld -r -T a.lds a.o b.o -o /dev/null 2>&1 | count 0
+# RUN: ld.lld -r -T a.lds a.o b.o -o a.ro 2>&1 | count 0
+# RUN: llvm-readelf -r -s a.ro | FileCheck %s --check-prefix=RELOC
+
+# RELOC:      Relocation section '.rela.bbb' at offset {{.*}} contains 1 entries:
+# RELOC-NEXT:     Offset             Info             Type               Symbol's Value  Symbol's Name + Addend
+# RELOC-NEXT: 0000000000000000  0000000000000000 R_X86_64_NONE                             0
+# RELOC-EMPTY:
+# RELOC-NEXT: Relocation section '.rela.data' at offset {{.*}} contains 4 entries:
+# RELOC-NEXT:     Offset             Info             Type               Symbol's Value  Symbol's Name + Addend
+# RELOC-NEXT: 0000000000000000  0000000000000001 R_X86_64_64                               0
+# RELOC-NEXT: 0000000000000008  0000000000000001 R_X86_64_64                               0
+# RELOC-NEXT: 0000000000000010  0000000000000001 R_X86_64_64                               0
+# RELOC-NEXT: 0000000000000018  0000000000000001 R_X86_64_64                               0
+
+# RELOC:      Num:    Value          Size Type    Bind   Vis      Ndx Name
+# RELOC-NEXT:   0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
+# RELOC-NEXT:   1: 0000000000000000     0 SECTION LOCAL  DEFAULT    1 .text
+# RELOC-NEXT:   2: 0000000000000000     0 SECTION LOCAL  DEFAULT    2 .bbb
+# RELOC-NEXT:   3: 0000000000000000     0 SECTION LOCAL  DEFAULT    4 .data
+# RELOC-NEXT:   4: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT    1 _start
+# RELOC-EMPTY:
 
 #--- a.s
 .globl _start


        


More information about the llvm-commits mailing list