140 lines · plain
1// REQUIRES: x862// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o3 4// RUN: ld.lld %t.o -o %t5// RUN: llvm-readobj --file-headers -S --section-data -l --symbols %t \6// RUN: | FileCheck %s --check-prefix=NOHDR7 8// RUN: ld.lld -eh-frame-hdr -no-eh-frame-hdr %t.o -o %t9// RUN: llvm-readobj --file-headers -S --section-data -l --symbols %t \10// RUN: | FileCheck %s --check-prefix=NOHDR11 12// RUN: ld.lld --eh-frame-hdr %t.o -o %t13// RUN: llvm-readobj --file-headers -S --section-data -l --symbols %t \14// RUN: | FileCheck %s --check-prefix=HDR15// RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=HDRDISASM16 17.section foo,"ax",@progbits18.cfi_startproc19 nop20.cfi_endproc21 22.section bar,"ax",@progbits23.cfi_startproc24 nop25.cfi_endproc26 27.section dah,"ax",@progbits28.cfi_startproc29 nop30.cfi_endproc31 32.text33.globl _start34_start:35 36// NOHDR: Sections [37// NOHDR-NOT: Name: .eh_frame_hdr38// NOHDR: ProgramHeaders [39// NOHDR-NOT: PT_GNU_EH_FRAME40 41// HDRDISASM: Disassembly of section foo:42// HDRDISASM-EMPTY:43// HDRDISASM-NEXT: <foo>:44// HDRDISASM-NEXT: 2011dc: 90 nop45// HDRDISASM-EMPTY:46// HDRDISASM-NEXT: Disassembly of section bar:47// HDRDISASM-EMPTY:48// HDRDISASM-NEXT: <bar>:49// HDRDISASM-NEXT: 2011dd: 90 nop50// HDRDISASM-EMPTY:51// HDRDISASM-NEXT: Disassembly of section dah:52// HDRDISASM-EMPTY:53// HDRDISASM-NEXT: <dah>:54// HDRDISASM-NEXT: 2011de: 90 nop55 56// HDR: Section {57// HDR: Index:58// HDR: Name: .eh_frame_hdr59// HDR-NEXT: Type: SHT_PROGBITS60// HDR-NEXT: Flags [61// HDR-NEXT: SHF_ALLOC62// HDR-NEXT: ]63// HDR-NEXT: Address: 0x20015864// HDR-NEXT: Offset: 0x15865// HDR-NEXT: Size: 3666// HDR-NEXT: Link: 067// HDR-NEXT: Info: 068// HDR-NEXT: AddressAlignment: 469// HDR-NEXT: EntrySize: 070// HDR-NEXT: SectionData (71// HDR-NEXT: 0000: 011B033B 24000000 03000000 8410000072// HDR-NEXT: 0010: 40000000 85100000 54000000 8610000073// HDR-NEXT: 0020: 6800000074// HDR-NEXT: )75// Header (always 4 bytes): 0x011B033B76// 24000000 = .eh_frame(0x200180) - .eh_frame_hdr(0x200158) - 477// 03000000 = 3 = the number of FDE pointers in the table.78// Entry(1): 8C100000 4000000079// 480E0000 = 0x2011e4 - .eh_frame_hdr(0x200158) = 0x108C80// 40000000 = address of FDE(1) - .eh_frame_hdr(0x200158) =81// = .eh_frame(0x200180) + 24 - 0x200158 = 0x4082// Entry(2): 8D100000 5800000083// A90E0000 = 0x2011e5 - .eh_frame_hdr(0x200158) = 0x108D84// 58000000 = address of FDE(2) - .eh_frame_hdr(0x200158) =85// = .eh_frame(0x200180) + 24 + 24 - 0x200158 = 0x5886// Entry(3): 8E100000 7000000087// AA0E0000 = 0x2011e6 - .eh_frame_hdr(0x200158) = 0x108E88// 70000000 = address of FDE(3) - .eh_frame_hdr(0x200158) =89// = .eh_frame(0x200180) + 24 + 24 + 24 - 0x200158 = 0x7090// HDR-NEXT: }91// HDR-NEXT: Section {92// HDR-NEXT: Index:93// HDR-NEXT: Name: .eh_frame94// HDR-NEXT: Type: SHT_PROGBITS95// HDR-NEXT: Flags [96// HDR-NEXT: SHF_ALLOC97// HDR-NEXT: ]98// HDR-NEXT: Address: 0x20018099// HDR-NEXT: Offset: 0x180100// HDR-NEXT: Size: 92101// HDR-NEXT: Link: 0102// HDR-NEXT: Info: 0103// HDR-NEXT: AddressAlignment: 8104// HDR-NEXT: EntrySize: 0105// HDR-NEXT: SectionData (106// HDR-NEXT: 0000: 14000000 00000000 017A5200 01781001107// HDR-NEXT: 0010: 1B0C0708 90010000 10000000 1C000000108// HDR-NEXT: 0020: 3C100000 01000000 00000000 10000000109// HDR-NEXT: 0030: 30000000 29100000 01000000 00000000110// HDR-NEXT: 0040: 14000000 44000000 16100000 01000000111// HDR-NEXT: 0050: 00000000 00000000 00000000112// HDR-NEXT: )113// CIE: 14000000 00000000 017A5200 01781001 1B0C0708 90010000114// FDE(1): 14000000 1C000000 600E0000 01000000 00000000 00000000115// address of data (starts with 0x600E0000) = 0x200180 + 0x0020 = 0x2001A0116// The starting address to which this FDE applies = 0xE60 + 0x2001A0 = 0x201000117// The number of bytes after the start address to which this FDE applies = 0x01000000 = 1118// FDE(2): 14000000 34000000 490E0000 01000000 00000000 00000000119// address of data (starts with 0x490E0000) = 0x200180 + 0x0038 = 0x2001B8120// The starting address to which this FDE applies = 0xE49 + 0x2001B8 = 0x201001121// The number of bytes after the start address to which this FDE applies = 0x01000000 = 1122// FDE(3): 14000000 4C000000 320E0000 01000000 00000000 00000000123// address of data (starts with 0x320E0000) = 0x200180 + 0x0050 = 0x2001D0124// The starting address to which this FDE applies = 0xE5A + 0x2001D0 = 0x201002125// The number of bytes after the start address to which this FDE applies = 0x01000000 = 1126// HDR-NEXT: }127// HDR: ProgramHeaders [128// HDR: ProgramHeader {129// HDR: Type: PT_GNU_EH_FRAME130// HDR-NEXT: Offset: 0x158131// HDR-NEXT: VirtualAddress: 0x200158132// HDR-NEXT: PhysicalAddress: 0x200158133// HDR-NEXT: FileSize: 36134// HDR-NEXT: MemSize: 36135// HDR-NEXT: Flags [136// HDR-NEXT: PF_R137// HDR-NEXT: ]138// HDR-NEXT: Alignment: 4139// HDR-NEXT: }140