Debian Codegraph @

llvm/test/tools/llvm-objcopy/ELF/strip-section-err.test

raw
1 ## Check we cannot remove a section containing symbols
2 ## referenced by relocations contained in the object.
3
4 # RUN: yaml2obj %s -o %t1
5 # RUN: not llvm-objcopy -R .data %t1 2>&1 | FileCheck %s -DINPUT=%t1
6 # CHECK: error: '[[INPUT]]': section '.data' cannot be removed: (.text+0x1) has relocation against symbol 'foo'
7
8 ## Check the behavior when we also remove the relocation section.
9 ## We have no reference in this case and hence no error should be emitted.
10
11 # RUN: yaml2obj %s -o %t2
12 # RUN: llvm-objcopy -R .data -R .rela.text %t2 %t3
13 # RUN: llvm-objdump --section-headers %t3 | FileCheck %s --check-prefix=NOSEC
14 # NOSEC-NOT: .data
15 # NOSEC-NOT: .rela.text
16
17 --- !ELF
18 FileHeader:
19 Class: ELFCLASS64
20 Data: ELFDATA2LSB
21 Type: ET_REL
22 Machine: EM_X86_64
23 Sections:
24 - Name: .text
25 Type: SHT_PROGBITS
26 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
27 AddressAlign: 0x0000000000000004
28 Content: E800000000
29 - Name: .rela.text
30 Type: SHT_RELA
31 Link: .symtab
32 AddressAlign: 0x0000000000000008
33 EntSize: 0x0000000000000018
34 Info: .text
35 Relocations:
36 - Offset: 0x0000000000000001
37 Symbol: foo
38 Type: R_X86_64_GOTPCREL
39 Addend: -4
40 - Name: .data
41 Type: SHT_PROGBITS
42 Flags: [ SHF_WRITE, SHF_ALLOC ]
43 AddressAlign: 0x0000000000000001
44 Content: '0102'
45 Symbols:
46 - Name: foo
47 Section: .data
48 Value: 0x0000000000000001
49 ...