[lld] ab301d8 - [ELF][test] --emit-relocs: test ALLOC sections discarded by --gc-sections and referenced by non-ALLOC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 18 18:14:16 PDT 2023


Author: Fangrui Song
Date: 2023-10-18T18:14:11-07:00
New Revision: ab301d833a207c717adff9612a4e58fe963e6ff0

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

LOG: [ELF][test] --emit-relocs: test ALLOC sections discarded by --gc-sections and referenced by non-ALLOC

bbf7b9d805f5773b4fe5bfb69081fe3691a90fb5 accidentally caused a regression that
is fixed by #69425. Add test to prevent regression.

Added: 
    

Modified: 
    lld/test/ELF/debug-dead-reloc.s

Removed: 
    


################################################################################
diff  --git a/lld/test/ELF/debug-dead-reloc.s b/lld/test/ELF/debug-dead-reloc.s
index e1adf4e2a25efcb..fcf53205079ed6a 100644
--- a/lld/test/ELF/debug-dead-reloc.s
+++ b/lld/test/ELF/debug-dead-reloc.s
@@ -5,20 +5,47 @@
 
 # RUN: echo '.globl _start; _start: call group' | llvm-mc -filetype=obj -triple=x86_64 - -o %t.o
 # RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t1.o
-# RUN: ld.lld --gc-sections %t.o %t1.o %t1.o -o %t
+# RUN: ld.lld --emit-relocs --gc-sections %t.o %t1.o %t1.o -o %t
 # RUN: llvm-objdump -s %t | FileCheck %s
+# RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=REL
 
 # CHECK:      Contents of section .debug_loc:
 # CHECK-NEXT:  0000 01000000 00000000 01000000 00000000
-# CHECK-NEXT: Contents of section .debug_ranges:
+# CHECK:      Contents of section .debug_ranges:
 # CHECK-NEXT:  0000 01000000 00000000 01000000 00000000
-# CHECK-NEXT: Contents of section .debug_addr:
+# CHECK:      Contents of section .debug_addr:
 # CHECK-NEXT:  0000 {{.*}}000 00000000 {{.*}}000 00000000
 # CHECK-NEXT:  0010 00000000  00000000 {{.*}}000 00000000
-# CHECK-NEXT: Contents of section .debug_foo:
+# CHECK:      Contents of section .debug_foo:
 # CHECK-NEXT:  0000 00000000 00000000 08000000 00000000
 # CHECK-NEXT:  0010 00000000 00000000 08000000 00000000
 
+# REL:      Relocations [
+# REL-NEXT:   .rela.text {
+# REL-NEXT:     0x201121 R_X86_64_PLT32 group 0xFFFFFFFFFFFFFFFC
+# REL-NEXT:   }
+# REL-NEXT:   .rela.debug_loc {
+# REL-NEXT:     0x0 R_X86_64_NONE - 0x8
+# REL-NEXT:     0x8 R_X86_64_NONE - 0x8
+# REL-NEXT:   }
+# REL-NEXT:   .rela.debug_ranges {
+# REL-NEXT:     0x0 R_X86_64_NONE - 0x10
+# REL-NEXT:     0x8 R_X86_64_NONE - 0x10
+# REL-NEXT:   }
+# REL-NEXT:   .rela.debug_addr {
+# REL-NEXT:     0x0 R_X86_64_64 .text 0x1D
+# REL-NEXT:     0x8 R_X86_64_64 group 0x20
+# REL-NEXT:     0x10 R_X86_64_NONE - 0x18
+# REL-NEXT:     0x18 R_X86_64_64 group 0x20
+# REL-NEXT:   }
+# REL-NEXT:   .rela.debug_foo {
+# REL-NEXT:     0x0 R_X86_64_NONE - 0x8
+# REL-NEXT:     0x8 R_X86_64_NONE - 0x8
+# REL-NEXT:     0x10 R_X86_64_NONE - 0x8
+# REL-NEXT:     0x18 R_X86_64_NONE - 0x8
+# REL-NEXT:   }
+# REL-NEXT: ]
+
 ## -z dead-reloc-in-nonalloc= can override the tombstone value.
 # RUN: ld.lld --gc-sections -z dead-reloc-in-nonalloc=.debug_loc=42 %t.o %t1.o %t1.o -o %t42
 # RUN: llvm-objdump -s %t42 | FileCheck %s --check-prefix=OVERRIDE


        


More information about the llvm-commits mailing list