Skip to content

Commit

Permalink
[ELF][test] --emit-relocs: test ALLOC sections discarded by --gc-sect…
Browse files Browse the repository at this point in the history
…ions and referenced by non-ALLOC

bbf7b9d accidentally caused a regression that
is fixed by #69425. Add test to prevent regression.
  • Loading branch information
MaskRay committed Oct 19, 2023
1 parent 8ff3e4f commit ab301d8
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions lld/test/ELF/debug-dead-reloc.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ab301d8

Please sign in to comment.