Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / eh-frame-hdr.s
blobdd78925ac537ef2752ac3152c33fb42e47239cbc
1 // REQUIRES: x86
2 // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
4 // RUN: ld.lld %t.o -o %t
5 // RUN: llvm-readobj --file-headers -S --section-data -l --symbols %t \
6 // RUN: | FileCheck %s --check-prefix=NOHDR
8 // RUN: ld.lld -eh-frame-hdr -no-eh-frame-hdr %t.o -o %t
9 // RUN: llvm-readobj --file-headers -S --section-data -l --symbols %t \
10 // RUN: | FileCheck %s --check-prefix=NOHDR
12 // RUN: ld.lld --eh-frame-hdr %t.o -o %t
13 // RUN: llvm-readobj --file-headers -S --section-data -l --symbols %t \
14 // RUN: | FileCheck %s --check-prefix=HDR
15 // RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=HDRDISASM
17 .section foo,"ax",@progbits
18 .cfi_startproc
19 nop
20 .cfi_endproc
22 .section bar,"ax",@progbits
23 .cfi_startproc
24 nop
25 .cfi_endproc
27 .section dah,"ax",@progbits
28 .cfi_startproc
29 nop
30 .cfi_endproc
32 .text
33 .globl _start
34 _start:
36 // NOHDR: Sections [
37 // NOHDR-NOT: Name: .eh_frame_hdr
38 // NOHDR: ProgramHeaders [
39 // NOHDR-NOT: PT_GNU_EH_FRAME
41 // HDRDISASM: Disassembly of section foo:
42 // HDRDISASM-EMPTY:
43 // HDRDISASM-NEXT: <foo>:
44 // HDRDISASM-NEXT: 2011dc: 90 nop
45 // HDRDISASM-EMPTY:
46 // HDRDISASM-NEXT: Disassembly of section bar:
47 // HDRDISASM-EMPTY:
48 // HDRDISASM-NEXT: <bar>:
49 // HDRDISASM-NEXT: 2011dd: 90 nop
50 // HDRDISASM-EMPTY:
51 // HDRDISASM-NEXT: Disassembly of section dah:
52 // HDRDISASM-EMPTY:
53 // HDRDISASM-NEXT: <dah>:
54 // HDRDISASM-NEXT: 2011de: 90 nop
56 // HDR: Section {
57 // HDR: Index:
58 // HDR: Name: .eh_frame_hdr
59 // HDR-NEXT: Type: SHT_PROGBITS
60 // HDR-NEXT: Flags [
61 // HDR-NEXT: SHF_ALLOC
62 // HDR-NEXT: ]
63 // HDR-NEXT: Address: 0x200158
64 // HDR-NEXT: Offset: 0x158
65 // HDR-NEXT: Size: 36
66 // HDR-NEXT: Link: 0
67 // HDR-NEXT: Info: 0
68 // HDR-NEXT: AddressAlignment: 4
69 // HDR-NEXT: EntrySize: 0
70 // HDR-NEXT: SectionData (
71 // HDR-NEXT: 0000: 011B033B 24000000 03000000 84100000
72 // HDR-NEXT: 0010: 40000000 85100000 54000000 86100000
73 // HDR-NEXT: 0020: 68000000
74 // HDR-NEXT: )
75 // Header (always 4 bytes): 0x011B033B
76 // 24000000 = .eh_frame(0x200180) - .eh_frame_hdr(0x200158) - 4
77 // 03000000 = 3 = the number of FDE pointers in the table.
78 // Entry(1): 8C100000 40000000
79 // 480E0000 = 0x2011e4 - .eh_frame_hdr(0x200158) = 0x108C
80 // 40000000 = address of FDE(1) - .eh_frame_hdr(0x200158) =
81 // = .eh_frame(0x200180) + 24 - 0x200158 = 0x40
82 // Entry(2): 8D100000 58000000
83 // A90E0000 = 0x2011e5 - .eh_frame_hdr(0x200158) = 0x108D
84 // 58000000 = address of FDE(2) - .eh_frame_hdr(0x200158) =
85 // = .eh_frame(0x200180) + 24 + 24 - 0x200158 = 0x58
86 // Entry(3): 8E100000 70000000
87 // AA0E0000 = 0x2011e6 - .eh_frame_hdr(0x200158) = 0x108E
88 // 70000000 = address of FDE(3) - .eh_frame_hdr(0x200158) =
89 // = .eh_frame(0x200180) + 24 + 24 + 24 - 0x200158 = 0x70
90 // HDR-NEXT: }
91 // HDR-NEXT: Section {
92 // HDR-NEXT: Index:
93 // HDR-NEXT: Name: .eh_frame
94 // HDR-NEXT: Type: SHT_PROGBITS
95 // HDR-NEXT: Flags [
96 // HDR-NEXT: SHF_ALLOC
97 // HDR-NEXT: ]
98 // HDR-NEXT: Address: 0x200180
99 // HDR-NEXT: Offset: 0x180
100 // HDR-NEXT: Size: 92
101 // HDR-NEXT: Link: 0
102 // HDR-NEXT: Info: 0
103 // HDR-NEXT: AddressAlignment: 8
104 // HDR-NEXT: EntrySize: 0
105 // HDR-NEXT: SectionData (
106 // HDR-NEXT: 0000: 14000000 00000000 017A5200 01781001
107 // HDR-NEXT: 0010: 1B0C0708 90010000 10000000 1C000000
108 // HDR-NEXT: 0020: 3C100000 01000000 00000000 10000000
109 // HDR-NEXT: 0030: 30000000 29100000 01000000 00000000
110 // HDR-NEXT: 0040: 14000000 44000000 16100000 01000000
111 // HDR-NEXT: 0050: 00000000 00000000 00000000
112 // HDR-NEXT: )
113 // CIE: 14000000 00000000 017A5200 01781001 1B0C0708 90010000
114 // FDE(1): 14000000 1C000000 600E0000 01000000 00000000 00000000
115 // address of data (starts with 0x600E0000) = 0x200180 + 0x0020 = 0x2001A0
116 // The starting address to which this FDE applies = 0xE60 + 0x2001A0 = 0x201000
117 // The number of bytes after the start address to which this FDE applies = 0x01000000 = 1
118 // FDE(2): 14000000 34000000 490E0000 01000000 00000000 00000000
119 // address of data (starts with 0x490E0000) = 0x200180 + 0x0038 = 0x2001B8
120 // The starting address to which this FDE applies = 0xE49 + 0x2001B8 = 0x201001
121 // The number of bytes after the start address to which this FDE applies = 0x01000000 = 1
122 // FDE(3): 14000000 4C000000 320E0000 01000000 00000000 00000000
123 // address of data (starts with 0x320E0000) = 0x200180 + 0x0050 = 0x2001D0
124 // The starting address to which this FDE applies = 0xE5A + 0x2001D0 = 0x201002
125 // The number of bytes after the start address to which this FDE applies = 0x01000000 = 1
126 // HDR-NEXT: }
127 // HDR: ProgramHeaders [
128 // HDR: ProgramHeader {
129 // HDR: Type: PT_GNU_EH_FRAME
130 // HDR-NEXT: Offset: 0x158
131 // HDR-NEXT: VirtualAddress: 0x200158
132 // HDR-NEXT: PhysicalAddress: 0x200158
133 // HDR-NEXT: FileSize: 36
134 // HDR-NEXT: MemSize: 36
135 // HDR-NEXT: Flags [
136 // HDR-NEXT: PF_R
137 // HDR-NEXT: ]
138 // HDR-NEXT: Alignment: 4
139 // HDR-NEXT: }