blob: 036c9541f3003d6e7e4cff1c098d2f04e6379661 [file] [log] [blame]
James Hendersonb5de5e22019-03-14 11:47:41 +00001# Show that --remove-section removes sections in segments.
2
3# RUN: yaml2obj %s -o %t
4
5# Validate the offsets for the later parts of the test.
6# RUN: llvm-objcopy %t %t.copy
7# Skip to the start of the sections, which should be immediately after the
8# program header table (i.e. sizeof(Elf64_Ehdr) + sizeof(Elf64_Phdr) == 120).
9# RUN: od -t x1 -N 16 -j 120 %t.copy | FileCheck %s --check-prefix=COPY
10
11# COPY: 11 22 33 44 55 66 77 88
12
13# RUN: llvm-objcopy --remove-section non_alloc %t %t.nonalloc
14# RUN: llvm-readelf --sections %t.nonalloc | FileCheck %s --check-prefix=NONALLOC-SHDRS
15# RUN: od -t x1 -N 16 -j 120 %t.nonalloc | FileCheck %s --check-prefix=NONALLOC-BYTES
16
17# NONALLOC-SHDRS-NOT: non_alloc
18# NONALLOC-BYTES: 11 22 33 44 00 00 00 00
19
20# RUN: llvm-objcopy --remove-section shf_alloc %t %t.alloc
21# RUN: llvm-readelf --sections %t.alloc | FileCheck %s --check-prefix=ALLOC-SHDRS
22# RUN: od -t x1 -N 16 -j 120 %t.alloc | FileCheck %s --check-prefix=ALLOC-BYTES
23
24# ALLOC-SHDRS-NOT: shf_alloc
25# ALLOC-BYTES: 00 00 00 00 55 66 77 88
26
27--- !ELF
28FileHeader:
29 Class: ELFCLASS64
30 Data: ELFDATA2LSB
31 Type: ET_EXEC
32 Machine: EM_X86_64
33Sections:
34 - Name: shf_alloc
35 Type: SHT_PROGBITS
36 Flags: [SHF_ALLOC]
37 Content: '11223344'
38 - Name: non_alloc
39 Type: SHT_PROGBITS
40 Flags: []
41 Content: '55667788'
42ProgramHeaders:
43 # Use an arbitrary segment type to show that the segment type is unimportant.
44 - Type: 0x61234567
45 Sections:
46 - Section: shf_alloc
47 - Section: non_alloc