1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00
llvm-mirror/test/tools/llvm-readobj/unwind.test
Fangrui Song c21ea7e2f4 [yaml2obj] Write the section header table after section contents
Linkers (ld.bfd/gold/lld) place the section header table at the very
end. This allows tools to strip it, which is optional in executable/shared objects.
In addition, if we add or section, the size of the section header table
will change. Placing the section header table in the end keeps section
offsets unchanged.

yaml2obj currently places the section header table immediately after the
program header. Follow what linkers do to make offset updating easier.

Reviewed By: grimar

Differential Revision: https://reviews.llvm.org/D67221

llvm-svn: 371074
2019-09-05 14:25:57 +00:00

218 lines
7.6 KiB
Plaintext

# RUN: yaml2obj %s > %t.exe
# RUN: llvm-readobj --unwind %t.exe | FileCheck %s
# CHECK: EH_FRAME Header [
# CHECK-NEXT: Address: 0x4013c0
# CHECK-NEXT: Offset: 0xbc
# CHECK-NEXT: Size: 0x3c
# CHECK-NEXT: Corresponding Section: .eh_frame_hdr
# CHECK-NEXT: Header {
# CHECK-NEXT: version: 1
# CHECK-NEXT: eh_frame_ptr_enc: 0x1b
# CHECK-NEXT: fde_count_enc: 0x3
# CHECK-NEXT: table_enc: 0x3b
# CHECK-NEXT: eh_frame_ptr: 0x401400
# CHECK-NEXT: fde_count: 6
# CHECK-NEXT: entry 0 {
# CHECK-NEXT: initial_location: 0x4004a0
# CHECK-NEXT: address: 0x401448
# CHECK-NEXT: }
# CHECK-NEXT: entry 1 {
# CHECK-NEXT: initial_location: 0x4004d0
# CHECK-NEXT: address: 0x401418
# CHECK-NEXT: }
# CHECK-NEXT: entry 2 {
# CHECK-NEXT: initial_location: 0x4005b6
# CHECK-NEXT: address: 0x401470
# CHECK-NEXT: }
# CHECK-NEXT: entry 3 {
# CHECK-NEXT: initial_location: 0x4005d0
# CHECK-NEXT: address: 0x401490
# CHECK-NEXT: }
# CHECK-NEXT: entry 4 {
# CHECK-NEXT: initial_location: 0x401250
# CHECK-NEXT: address: 0x4014c0
# CHECK-NEXT: }
# CHECK-NEXT: entry 5 {
# CHECK-NEXT: initial_location: 0x4012c0
# CHECK-NEXT: address: 0x4014f0
# CHECK-NEXT: }
# CHECK-NEXT: }
# CHECK-NEXT:]
# CHECK: .eh_frame section at offset 0xf8 address 0x401400:
# CHECK-NEXT: [0x401400] CIE length=20
# CHECK-NEXT: version: 1
# CHECK-NEXT: augmentation: zR
# CHECK-NEXT: code_alignment_factor: 1
# CHECK-NEXT: data_alignment_factor: -8
# CHECK-NEXT: return_address_register: 16
# CHECK: Program:
# CHECK-NEXT: DW_CFA_def_cfa: reg7 +8
# CHECK-NEXT: DW_CFA_offset: reg16 -8
# CHECK-NEXT: DW_CFA_undefined: reg16
# CHECK: [0x401418] FDE length=20 cie=[0x401400]
# CHECK-NEXT: initial_location: 0x4004d0
# CHECK-NEXT: address_range: 0x2a (end : 0x4004fa)
# CHECK: Program:
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK: [0x401430] CIE length=20
# CHECK-NEXT: version: 1
# CHECK-NEXT: augmentation: zR
# CHECK-NEXT: code_alignment_factor: 1
# CHECK-NEXT: data_alignment_factor: -8
# CHECK-NEXT: return_address_register: 16
# CHECK: Program:
# CHECK-NEXT: DW_CFA_def_cfa: reg7 +8
# CHECK-NEXT: DW_CFA_offset: reg16 -8
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK: [0x401448] FDE length=36 cie=[0x401430]
# CHECK-NEXT: initial_location: 0x4004a0
# CHECK-NEXT: address_range: 0x20 (end : 0x4004c0)
# CHECK: Program:
# CHECK-NEXT: DW_CFA_def_cfa_offset: +16
# CHECK-NEXT: DW_CFA_advance_loc: 6
# CHECK-NEXT: DW_CFA_def_cfa_offset: +24
# CHECK-NEXT: DW_CFA_advance_loc: 10
# CHECK-NEXT: DW_CFA_def_cfa_expression: DW_OP_breg7 +8, DW_OP_breg16 +0, DW_OP_lit15, DW_OP_and, DW_OP_lit11, DW_OP_ge, DW_OP_lit3, DW_OP_shl, DW_OP_plus
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK: [0x401470] FDE length=28 cie=[0x401430]
# CHECK-NEXT: initial_location: 0x4005b6
# CHECK-NEXT: address_range: 0x10 (end : 0x4005c6)
# CHECK: Program:
# CHECK-NEXT: DW_CFA_advance_loc: 1
# CHECK-NEXT: DW_CFA_def_cfa_offset: +16
# CHECK-NEXT: DW_CFA_offset: reg6 -16
# CHECK-NEXT: DW_CFA_advance_loc: 3
# CHECK-NEXT: DW_CFA_def_cfa_register: reg6
# CHECK-NEXT: DW_CFA_advance_loc: 11
# CHECK-NEXT: DW_CFA_def_cfa: reg7 +8
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK: [0x401490] FDE length=44 cie=[0x401430]
# CHECK-NEXT: initial_location: 0x4005d0
# CHECK-NEXT: address_range: 0xc7f (end : 0x40124f)
# CHECK: Program:
# CHECK-NEXT: DW_CFA_advance_loc: 5
# CHECK-NEXT: DW_CFA_def_cfa: reg10 +0
# CHECK-NEXT: DW_CFA_advance_loc: 9
# CHECK-NEXT: DW_CFA_expression: reg6 DW_OP_breg6 +0
# CHECK-NEXT: DW_CFA_advance_loc: 5
# CHECK-NEXT: DW_CFA_def_cfa_expression: DW_OP_breg6 -8, DW_OP_deref
# CHECK-NEXT: DW_CFA_advance_loc2: 3174
# CHECK-NEXT: DW_CFA_def_cfa: reg10 +0
# CHECK-NEXT: DW_CFA_advance_loc: 5
# CHECK-NEXT: DW_CFA_def_cfa: reg7 +8
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK: [0x4014c0] FDE length=44 cie=[0x401430]
# CHECK-NEXT: initial_location: 0x401250
# CHECK-NEXT: address_range: 0x66 (end : 0x4012b6)
# CHECK: Program:
# CHECK-NEXT: DW_CFA_advance_loc: 1
# CHECK-NEXT: DW_CFA_def_cfa_offset: +16
# CHECK-NEXT: DW_CFA_offset: reg6 -16
# CHECK-NEXT: DW_CFA_advance_loc: 3
# CHECK-NEXT: DW_CFA_def_cfa_register: reg6
# CHECK-NEXT: DW_CFA_advance_loc: 2
# CHECK-NEXT: DW_CFA_offset: reg15 -24
# CHECK-NEXT: DW_CFA_advance_loc: 5
# CHECK-NEXT: DW_CFA_offset: reg14 -32
# CHECK-NEXT: DW_CFA_advance_loc: 7
# CHECK-NEXT: DW_CFA_offset: reg13 -40
# CHECK-NEXT: DW_CFA_offset: reg12 -48
# CHECK-NEXT: DW_CFA_advance_loc: 8
# CHECK-NEXT: DW_CFA_offset: reg3 -56
# CHECK-NEXT: DW_CFA_advance_loc1: 75
# CHECK-NEXT: DW_CFA_def_cfa: reg7 +8
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK: [0x4014f0] FDE length=20 cie=[0x401430]
# CHECK-NEXT: initial_location: 0x4012c0
# CHECK-NEXT: address_range: 0x1 (end : 0x4012c1)
# CHECK: Program:
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
# CHECK-NEXT: DW_CFA_nop:
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Entry: 0x0000000000400000
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0x0000000000400000
AddressAlign: 16
Content: 50C704240020400031C05AC3
- Name: .eh_frame_hdr
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x00000000004013c0
AddressAlign: 4
Content: 011B033B3C00000006000000E0F0FFFF8800000010F1FFFF58000000F6F1FFFFB000000010F2FFFFD000000090FEFFFF0001000000FFFFFF30010000
- Name: .eh_frame
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x0000000000401400
AddressAlign: 8
Content: 1400000000000000017A5200017810011B0C070890010710140000001C000000B0F0FFFF2A00000000000000000000001400000000000000017A5200017810011B0C070890010000240000001C00000050F0FFFF20000000000E10460E184A0F0B770880003F1A3B2A332422000000001C000000440000003EF1FFFF1000000000410E108602430D064B0C07080000002C0000006400000038F1FFFF7F0C000000450C0A00491006027600450F0376780603660C0C0A00450C070800000000002C0000009400000088FDFFFF6600000000410E108602430D06428F03458E04478D058C06488307024B0C07080000000014000000C4000000C8FDFFFF01000000000000000000000000000000
Symbols:
- Name: myfunc
Type: STT_FUNC
Section: .text
Value: 0x0000000000400000
Binding: STB_GLOBAL
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
VAddr: 0x00400000
PAddr: 0x00400000
Sections:
- Section: .text
- Type: PT_GNU_EH_FRAME
Flags: [ PF_X, PF_R ]
VAddr: 0x004013C0
PAddr: 0x004013C0
Sections:
- Section: .eh_frame_hdr
...