xref: /llvm-project/llvm/test/tools/llvm-objcopy/ELF/reloc-error-remove-symtab.test (revision 9bb4cd5977f8a0d6f1d6cc00cb707ed2db27f1c0)
1# RUN: yaml2obj %s -o %t
2# RUN: not llvm-objcopy -R .symtab %t %t2 2>&1 >/dev/null | FileCheck %s --check-prefix=ERR1 -DINPUT=%t
3# RUN: cp %t %t3
4# RUN: not llvm-strip --no-strip-all -R .symtab %t3 2>&1 >/dev/null | FileCheck %s --check-prefix=ERR2 -DINPUT=%t3
5
6# RUN: yaml2obj -DTYPE=SHT_CREL %s -o %t.crel
7# RUN: not llvm-objcopy -R .symtab %t.crel %t2.crel 2>&1 >/dev/null | FileCheck %s --check-prefix=ERR1 -DINPUT=%t.crel
8
9!ELF
10FileHeader:
11  Class:           ELFCLASS64
12  Data:            ELFDATA2LSB
13  Type:            ET_REL
14  Machine:         EM_X86_64
15Sections:
16  - Name:            .text
17    Type:            SHT_PROGBITS
18    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
19    Address:         0x1000
20    AddressAlign:    0x0000000000000010
21    Content:         "0000000000000000"
22  - Name:            .rel.text
23    Type:            [[TYPE=SHT_REL]]
24    Link:            .symtab
25    Info:            .text
26    Relocations:
27      - Offset: 0x1000
28        Symbol: foo
29        Type:   R_X86_64_PC32
30
31Symbols:
32  - Name:     foo
33    Type:     STT_FUNC
34    Size:     4
35    Binding:  STB_GLOBAL
36
37# ERR1: error: '[[INPUT]]': symbol table '.symtab' cannot be removed because it is referenced by the relocation section '.rel.text'
38# ERR2: error: '[[INPUT]]': symbol table '.symtab' cannot be removed because it is referenced by the relocation section '.rel.text'
39
40# RUN: llvm-objcopy --allow-broken-links -R .symtab %t %t4
41# RUN: llvm-readobj --sections %t4 | FileCheck %s --check-prefix=SECTIONS --implicit-check-not=.symtab
42# RUN: cp %t %t5
43# RUN: llvm-strip --no-strip-all --allow-broken-links -R .symtab %t5
44# RUN: llvm-readobj --sections %t5 | FileCheck %s --check-prefix=SECTIONS --implicit-check-not=.symtab
45
46# RUN: llvm-objcopy --allow-broken-links -R .symtab %t.crel %t4.crel
47# RUN: llvm-readobj --sections %t4.crel | FileCheck %s --check-prefix=SECTIONS --implicit-check-not=.symtab
48# RUN: cp %t.crel %t5.crel
49# RUN: llvm-strip --no-strip-all --allow-broken-links -R .symtab %t5.crel
50# RUN: llvm-readobj --sections %t5.crel | FileCheck %s --check-prefix=SECTIONS --implicit-check-not=.symtab
51
52# SECTIONS:        Name: .rel.text
53# SECTIONS:        Link
54# SECTIONS-SAME: : 0
55