|
1 |
| -# RUN: yaml2obj %s -o %t |
2 |
| -# RUN: llvm-objcopy %t %t2 |
3 |
| -# RUN: llvm-readobj --sections %t2 | FileCheck %s |
| 1 | +## .empty is not covered by a segment. Its offset is moved to 0x200 to fill the gap. |
| 2 | +# RUN: yaml2obj --docnum=1 %s -o %t1 |
| 3 | +# RUN: llvm-objcopy %t1 %t1.out |
| 4 | +# RUN: llvm-readelf -S %t1.out | FileCheck --check-prefix=CHECK1 %s |
4 | 5 |
|
5 |
| -!ELF |
| 6 | +# CHECK1: Name Type Address Off |
| 7 | +# CHECK1-NEXT: NULL 0000000000000000 000000 |
| 8 | +# CHECK1-NEXT: .foo PROGBITS 0000000000000000 000100 |
| 9 | +# CHECK1-NEXT: .empty PROGBITS 0000000000001000 000200 |
| 10 | +# CHECK1-NEXT: .baz PROGBITS 0000000000001000 001000 |
| 11 | + |
| 12 | +--- !ELF |
6 | 13 | FileHeader:
|
7 |
| - Class: ELFCLASS64 |
8 |
| - Data: ELFDATA2LSB |
9 |
| - Type: ET_EXEC |
10 |
| - Machine: EM_X86_64 |
| 14 | + Class: ELFCLASS64 |
| 15 | + Data: ELFDATA2LSB |
| 16 | + Type: ET_EXEC |
| 17 | + Machine: EM_X86_64 |
11 | 18 | Sections:
|
12 |
| - - Name: .text |
13 |
| - Type: SHT_PROGBITS |
14 |
| - Flags: [ SHF_ALLOC, SHF_EXECINSTR ] |
15 |
| - Address: 0x0 |
16 |
| - AddressAlign: 0x0000000000001000 |
17 |
| - Content: "00000000" |
18 |
| - - Name: .empty |
19 |
| - Type: SHT_PROGBITS |
20 |
| - Flags: [ SHF_ALLOC ] |
21 |
| - Address: 0x1000 |
22 |
| - AddressAlign: 0x0000000000001000 |
23 |
| - Content: "" |
24 |
| - - Name: .data |
25 |
| - Type: SHT_PROGBITS |
26 |
| - Flags: [ SHF_ALLOC ] |
27 |
| - Address: 0x1000 |
28 |
| - AddressAlign: 0x0000000000001000 |
29 |
| - Content: "00000000" |
| 19 | + - Name: gap |
| 20 | + Type: Fill |
| 21 | + Size: 0xE00 |
| 22 | + - Name: .foo |
| 23 | + Type: SHT_PROGBITS |
| 24 | + Flags: [ SHF_ALLOC ] |
| 25 | + AddressAlign: 0x100 |
| 26 | + Address: 0 |
| 27 | + Size: 0x100 |
| 28 | + - Name: .empty |
| 29 | + Type: SHT_PROGBITS |
| 30 | + Flags: [ SHF_ALLOC ] |
| 31 | + Address: 0x1000 |
| 32 | + - Name: .baz |
| 33 | + Type: SHT_PROGBITS |
| 34 | + Flags: [ SHF_ALLOC ] |
| 35 | + AddressAlign: 0x1000 |
| 36 | + Address: 0x1000 |
| 37 | + Size: 0x100 |
30 | 38 |
|
| 39 | +## Test that we attribute .empty to the second segment. Its offset is assigned according to |
| 40 | +## the p_offset of the second segment. |
| 41 | +# RUN: yaml2obj --docnum=2 %s -o %t2 |
| 42 | +# RUN: llvm-objcopy %t2 %t2.out |
| 43 | +# RUN: llvm-readelf -S -l %t2.out | FileCheck --check-prefix=CHECK2 %s |
31 | 44 |
|
32 |
| -# CHECK: Name: .text |
33 |
| -# CHECK-NEXT: Type: SHT_PROGBITS |
34 |
| -# CHECK-NEXT: Flags [ |
35 |
| -# CHECK-NEXT: SHF_ALLOC |
36 |
| -# CHECK-NEXT: SHF_EXECINSTR |
37 |
| -# CHECK-NEXT: ] |
| 45 | +# CHECK2: Name Type Address Off |
| 46 | +# CHECK2-NEXT: NULL 0000000000000000 000000 |
| 47 | +# CHECK2-NEXT: .foo PROGBITS 0000000000000000 000100 |
| 48 | +# CHECK2-NEXT: .empty PROGBITS 0000000000001000 001000 |
| 49 | +# CHECK2-NEXT: .baz PROGBITS 0000000000001000 001000 |
38 | 50 |
|
39 |
| -# CHECK: Name: .empty |
40 |
| -# CHECK-NEXT: Type: SHT_PROGBITS |
41 |
| -# CHECK-NEXT: Flags [ |
42 |
| -# CHECK-NEXT: SHF_ALLOC |
43 |
| -# CHECK-NEXT: ] |
44 |
| -# CHECK-NEXT: Address: 0x1000 |
45 |
| -# CHECK-NEXT: Offset: 0x2000 |
46 |
| -# CHECK-NEXT: Size: 0 |
| 51 | +# CHECK2: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align |
| 52 | +# CHECK2-NEXT: LOAD 0x000100 0x0000000000000000 0x0000000000000000 0x000100 0x000100 0x100 |
| 53 | +# CHECK2-NEXT: LOAD 0x001000 0x0000000000001000 0x0000000000001000 0x000100 0x000100 0x1000 |
47 | 54 |
|
48 |
| -# CHECK: Name: .data |
49 |
| -# CHECK-NEXT: Type: SHT_PROGBITS |
50 |
| -# CHECK-NEXT: Flags [ |
51 |
| -# CHECK-NEXT: SHF_ALLOC |
52 |
| -# CHECK-NEXT: ] |
53 |
| -# CHECK-NEXT: Address: 0x1000 |
54 |
| -# CHECK-NEXT: Offset: 0x2000 |
55 |
| -# CHECK-NEXT: Size: 4 |
| 55 | +--- !ELF |
| 56 | +FileHeader: |
| 57 | + Class: ELFCLASS64 |
| 58 | + Data: ELFDATA2LSB |
| 59 | + Type: ET_EXEC |
| 60 | + Machine: EM_X86_64 |
| 61 | +Sections: |
| 62 | + - Name: gap |
| 63 | + Type: Fill |
| 64 | + Size: 0xE00 |
| 65 | + - Name: .foo |
| 66 | + Type: SHT_PROGBITS |
| 67 | + Flags: [ SHF_ALLOC ] |
| 68 | + AddressAlign: 0x100 |
| 69 | + Address: 0 |
| 70 | + Size: 0x100 |
| 71 | + - Name: .empty |
| 72 | + Type: SHT_PROGBITS |
| 73 | + Flags: [ SHF_ALLOC ] |
| 74 | + Address: 0x1000 |
| 75 | + - Name: .baz |
| 76 | + Type: SHT_PROGBITS |
| 77 | + Flags: [ SHF_ALLOC ] |
| 78 | + AddressAlign: 0x1000 |
| 79 | + Address: 0x1000 |
| 80 | + Size: 0x100 |
| 81 | +ProgramHeaders: |
| 82 | + - Type: PT_LOAD |
| 83 | + VAddr: 0 |
| 84 | + PAddr: 0 |
| 85 | + Align: 0x100 |
| 86 | + Sections: |
| 87 | + - Section: .foo |
| 88 | + - Type: PT_LOAD |
| 89 | + VAddr: 0x1000 |
| 90 | + PAddr: 0x1000 |
| 91 | + Align: 0x1000 |
| 92 | + Sections: |
| 93 | + - Section: .empty |
| 94 | + - Section: .baz |
0 commit comments