1 # This test is checking to ensure that if a section is removed in the presence
2 # of a segment that the segment maintains its shape and properties and that any
3 # section inside that segment maintains the relative positioning it had in the
4 # segment. Note worthy is that .text3 keeps its offset despite it being
5 # possible to place it after .text when .text2 is removed.
7 # RUN: yaml2obj %s -o %t
8 # RUN: llvm-objcopy -R .text2 %t %t2
9 # RUN: llvm-readobj --file-headers --program-headers --sections %t2 | FileCheck %s
10 # RUN: od -t x1 -j 8192 -N 4 %t2 | FileCheck %s --check-prefix=DATA
21 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
27 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
34 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
45 ## TODO (grimar): without the following line (i.e. without an empty symbol table),
46 ## llvm-objcopy adds an empty .strtab section. It doesn't look correct.
49 # Make sure that when we remove a section we overwrite it with zeros
50 # DATA: {{^[^[:blank:]]+}} 00 00 00 00
52 #CHECK: SectionHeaderCount: 4
56 # CHECK-NEXT: Index: 0
57 # CHECK-NEXT: Name: (0)
58 # CHECK-NEXT: Type: SHT_NULL (0x0)
59 # CHECK-NEXT: Flags [ (0x0)
61 # CHECK-NEXT: Address: 0x0
66 # CHECK-NEXT: AddressAlignment: 0
67 # CHECK-NEXT: EntrySize: 0
69 # CHECK-NEXT: Section {
70 # CHECK-NEXT: Index: 1
71 # CHECK-NEXT: Name: .text
72 # CHECK-NEXT: Type: SHT_PROGBITS
74 # CHECK-NEXT: SHF_ALLOC
75 # CHECK-NEXT: SHF_EXECINSTR
77 # CHECK-NEXT: Address: 0x1000
78 # CHECK-NEXT: Offset: 0x1000
82 # CHECK-NEXT: AddressAlignment: 4096
83 # CHECK-NEXT: EntrySize: 0
85 # CHECK-NEXT: Section {
86 # CHECK-NEXT: Index: 2
87 # CHECK-NEXT: Name: .text3
88 # CHECK-NEXT: Type: SHT_PROGBITS (0x1)
90 # CHECK-NEXT: SHF_ALLOC
91 # CHECK-NEXT: SHF_EXECINSTR
93 # CHECK-NEXT: Address: 0x3000
94 # CHECK-NEXT: Offset: 0x3000
98 # CHECK-NEXT: AddressAlignment: 4096
99 # CHECK-NEXT: EntrySize: 0
101 # CHECK-NEXT: Section {
102 # CHECK-NEXT: Index: 3
103 # CHECK-NEXT: Name: .shstrtab
104 # CHECK-NEXT: Type: SHT_STRTAB (0x3)
105 # CHECK-NEXT: Flags [ (0x0)
107 # CHECK-NEXT: Address: 0x0
108 # CHECK-NEXT: Offset:
110 # CHECK-NEXT: Link: 0
111 # CHECK-NEXT: Info: 0
112 # CHECK-NEXT: AddressAlignment: 1
113 # CHECK-NEXT: EntrySize: 0
117 #CHECK: ProgramHeaders [
118 #CHECK-NEXT: ProgramHeader {
119 #CHECK-NEXT: Type: PT_LOAD (0x1)
120 #CHECK-NEXT: Offset: 0x1000
121 #CHECK-NEXT: VirtualAddress: 0x0
122 #CHECK-NEXT: PhysicalAddress: 0x0
123 #CHECK-NEXT: FileSize: 12288
124 #CHECK-NEXT: MemSize: 12288
125 #CHECK-NEXT: Flags [ (0x5)
126 #CHECK-NEXT: PF_R (0x4)
127 #CHECK-NEXT: PF_X (0x1)
129 #CHECK-NEXT: Alignment: 4096