llvm-for-llvmta/test/tools/llvm-objcopy/ELF/empty-section.test

92 lines
2.8 KiB
Plaintext
Raw Normal View History

2022-04-25 10:02:23 +02:00
## .empty is not covered by a segment. Its offset is moved to 0x200 to fill the gap.
# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-objcopy %t1 %t1.out
# RUN: llvm-readelf -S %t1.out | FileCheck --check-prefix=CHECK1 %s
# CHECK1: Name Type Address Off
# CHECK1-NEXT: NULL 0000000000000000 000000
# CHECK1-NEXT: .foo PROGBITS 0000000000000000 000100
# CHECK1-NEXT: .empty PROGBITS 0000000000001000 000200
# CHECK1-NEXT: .baz PROGBITS 0000000000001000 001000
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: gap
Type: Fill
Size: 0xE00
- Name: .foo
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
AddressAlign: 0x100
Address: 0
Size: 0x100
- Name: .empty
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x1000
- Name: .baz
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
AddressAlign: 0x1000
Address: 0x1000
Size: 0x100
## Test that we attribute .empty to the second segment. Its offset is assigned according to
## the p_offset of the second segment.
# RUN: yaml2obj --docnum=2 %s -o %t2
# RUN: llvm-objcopy %t2 %t2.out
# RUN: llvm-readelf -S -l %t2.out | FileCheck --check-prefix=CHECK2 %s
# CHECK2: Name Type Address Off
# CHECK2-NEXT: NULL 0000000000000000 000000
# CHECK2-NEXT: .foo PROGBITS 0000000000000000 000100
# CHECK2-NEXT: .empty PROGBITS 0000000000001000 001000
# CHECK2-NEXT: .baz PROGBITS 0000000000001000 001000
# CHECK2: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
# CHECK2-NEXT: LOAD 0x000100 0x0000000000000000 0x0000000000000000 0x000100 0x000100 0x100
# CHECK2-NEXT: LOAD 0x001000 0x0000000000001000 0x0000000000001000 0x000100 0x000100 0x1000
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: gap
Type: Fill
Size: 0xE00
- Name: .foo
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
AddressAlign: 0x100
Address: 0
Size: 0x100
- Name: .empty
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x1000
- Name: .baz
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
AddressAlign: 0x1000
Address: 0x1000
Size: 0x100
ProgramHeaders:
- Type: PT_LOAD
VAddr: 0
Align: 0x100
FirstSec: .foo
LastSec: .foo
- Type: PT_LOAD
VAddr: 0x1000
Align: 0x1000
FirstSec: .empty
LastSec: .baz