• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1## Here we want to check that llvm-objcopy removes an undefined symbol
2## if all references to it have been stripped.
3
4# RUN: yaml2obj --docnum=1 %s -o %t.o
5# RUN: llvm-objcopy -j .other.section %t.o %t2.o
6# RUN: llvm-readobj --symbols %t2.o | FileCheck %s
7
8# RUN: llvm-objcopy -j .text -j .rela.text1 %t.o %t2.o
9# RUN: llvm-readobj --symbols %t2.o | FileCheck %s --check-prefix=BAR
10
11# CHECK-NOT: Name: bar
12# BAR: Name: bar
13
14--- !ELF
15FileHeader:
16  Class:   ELFCLASS64
17  Data:    ELFDATA2LSB
18  Type:    ET_REL
19  Machine: EM_X86_64
20Sections:
21  - Name:        .text
22    Type:        SHT_PROGBITS
23  - Name:        .rela.text1
24    Type:        SHT_RELA
25    Relocations:
26      - Offset:  0x0000000000000001
27        Symbol:  bar
28        Type:    R_X86_64_32
29  - Name:        .rela.text2
30    Type:        SHT_RELA
31    Relocations:
32      - Offset:  0x0000000000000001
33        Symbol:  bar
34        Type:    R_X86_64_32
35  - Name:        .other.section
36    Type:        SHT_PROGBITS
37Symbols:
38  - Name:    bar
39    Binding: STB_GLOBAL
40...
41
42## Check we remove unreferenced undefined symbols, even if
43## they weren't previously referenced. This follows GNU.
44
45# RUN: yaml2obj --docnum=2 %s -o %t.o
46# RUN: llvm-objcopy -j .keep_me %t.o %t2.o
47# RUN: llvm-readobj --symbols %t2.o | FileCheck %s
48
49--- !ELF
50FileHeader:
51  Class:   ELFCLASS64
52  Data:    ELFDATA2LSB
53  Type:    ET_REL
54  Machine: EM_X86_64
55Sections:
56  - Name: .keep_me
57    Type: SHT_PROGBITS
58Symbols:
59  - Name:    bar
60    Binding: STB_GLOBAL
61...
62