• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1## Show that llvm-objcopy correctly updates the elf header and program header
2## table when they are within a segment.
3
4# RUN: yaml2obj %s -o %t.in
5## Validate that the properties are different before the removal.
6# RUN: llvm-readobj --file-headers --program-headers %t.in | FileCheck %s --check-prefix=BEFORE
7# RUN: llvm-objcopy %t.in %t.out -R .remove_me
8# RUN: llvm-readobj --file-headers --program-headers %t.out | FileCheck %s --check-prefix=AFTER
9
10# BEFORE: SectionHeaderCount: 6
11# BEFORE:      Type: PT_LOAD
12# BEFORE-NEXT: Offset: 0x0
13# BEFORE:      Type: PT_LOAD
14# BEFORE-NEXT: Offset: 0xC0
15
16# AFTER:      SectionHeaderCount: 3
17# AFTER:      Type: PT_LOAD
18# AFTER-NEXT: Offset: 0x0
19# AFTER:      Type: PT_LOAD
20# AFTER-NEXT: Offset: 0xB0
21
22--- !ELF
23FileHeader:
24  Class:   ELFCLASS64
25  Data:    ELFDATA2LSB
26  Type:    ET_EXEC
27  Machine: EM_X86_64
28Sections:
29  - Name: .remove_me
30    Type: SHT_PROGBITS
31    Size: 0x10
32  - Name: .keep_me
33    Type: SHT_PROGBITS
34    Size: 0x10
35ProgramHeaders:
36  - Type:     PT_LOAD
37    Offset:   0
38    FileSize: 176 # sizeof(Elf64_Ehdr) + 2 * sizeof(Elf64_Phdr)
39  - Type:     PT_LOAD
40    FirstSec: .keep_me
41    LastSec:  .keep_me
42Symbols: []
43