Debian Codegraph @

llvm/test/tools/llvm-objcopy/ELF/strip-symbol-and-relocation.test

raw
1 # RUN: yaml2obj %s -o %t
2
3 ## Check we are able to strip all symbols and relocatable information at the same time.
4
5 # RUN: llvm-objcopy -S %t %t2
6 # RUN: llvm-objdump --section-headers %t2 | FileCheck %s
7
8 # RUN: llvm-objcopy --strip-all-gnu %t %t2
9 # RUN: llvm-objdump --section-headers %t2 | FileCheck %s
10
11 # CHECK-NOT: .symtab
12 # CHECK-NOT: .rela.text
13
14 ## Check we are able to strip the particular symbol if we
15 ## strip the corresponding relocation section at the same time.
16
17 # RUN: llvm-objcopy --strip-symbol=bar -R .rela.text %t %t2
18 # RUN: llvm-readelf -s -S %t2 | FileCheck %s --check-prefix=STRIPSYM
19
20 # STRIPSYM-NOT: bar
21 # STRIPSYM-NOT: .rela.text
22
23 # RUN: not llvm-objcopy --strip-symbol=bar %t %t2 2>&1 | FileCheck %s --check-prefix=ERR -DINPUT=%t
24 # ERR: error: '[[INPUT]]': not stripping symbol 'bar' because it is named in a relocation
25
26 --- !ELF
27 FileHeader:
28 Class: ELFCLASS64
29 Data: ELFDATA2LSB
30 Type: ET_REL
31 Machine: EM_X86_64
32 Sections:
33 - Name: .text
34 Type: SHT_PROGBITS
35 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
36 Content: 00000000
37 - Name: .rela.text
38 Type: SHT_RELA
39 Link: .symtab
40 Info: .text
41 Relocations:
42 - Offset: 0x0000000000000000
43 Symbol: bar
44 Type: R_X86_64_32S
45 Symbols:
46 - Name: bar
47 Section: .text
48 Binding: STB_GLOBAL