xref: /llvm-project/lld/test/ELF/debug-dead-reloc-32.s (revision 26ddf4eee2a009147faa3000c55d7822c2087dce)
1# REQUIRES: x86
2## Test we resolve symbolic relocations in .debug_* sections to a tombstone
3## value if the referenced symbol is discarded (--gc-sections, non-prevailing
4## section group, SHF_EXCLUDE, /DISCARD/, etc).
5
6# RUN: llvm-mc -filetype=obj -triple=i386 %s -o %t.o
7# RUN: ld.lld %t.o -o %t
8# RUN: llvm-objdump -s %t | FileCheck %s
9
10# CHECK:      Contents of section .debug_loc:
11# CHECK-NEXT:  0000 01000000
12# CHECK-NEXT: Contents of section .debug_ranges:
13# CHECK-NEXT:  0000 01000000
14# CHECK-NEXT: Contents of section .debug_addr:
15# CHECK-NEXT:  0000 00000000
16# CHECK-NEXT: Contents of section .debug_names:
17# CHECK-NEXT:  0000 ffffffff
18
19## -z dead-reloc-in-nonalloc= can override the tombstone value.
20# RUN: ld.lld -z dead-reloc-in-nonalloc=.debug_loc=42 -z dead-reloc-in-nonalloc=.debug_addr=0xfffffffffffffffe %t.o -o %t1
21# RUN: llvm-objdump -s %t1 | FileCheck %s --check-prefix=OVERRIDE
22
23# OVERRIDE:      Contents of section .debug_loc:
24# OVERRIDE-NEXT:  0000 2a000000                             *...
25# OVERRIDE-NEXT: Contents of section .debug_ranges:
26# OVERRIDE-NEXT:  0000 01000000                             ....
27# OVERRIDE-NEXT: Contents of section .debug_addr:
28# OVERRIDE-NEXT:  0000 feffffff                             ....
29
30.section .text.1,"axe"
31  .byte 0
32
33## Resolved to UINT32_C(-2), with the addend ignored.
34## UINT32_C(-1) is a reserved value (base address selection entry) which can't be used.
35.section .debug_loc
36  .long .text.1+8
37.section .debug_ranges
38  .long .text.1+16
39
40## Resolved to UINT32_C(0), with the addend ignored.
41.section .debug_addr
42  .long .text.1+8
43
44.section  .debug_info,"eG",@progbits,5657452045627120676,comdat
45.Ltu_begin0:
46
47.section .debug_names
48## .debug_names may reference a local type unit defined in a COMDAT .debug_info
49## section (-g -gpubnames -fdebug-types-section). If the referenced section is
50## non-prevailing, resolve to UINT32_MAX.
51.long .Ltu_begin0
52