xref: /llvm-project/llvm/test/tools/llvm-objcopy/ELF/prefix-symbols.test (revision f8be7f29ede5369b96056d3879c57de54781c9cf)
1# RUN: yaml2obj %s -o %t
2# RUN: llvm-objcopy --prefix-symbols prefix %t %t2
3# RUN: llvm-readelf --symbols %t2 | FileCheck %s --check-prefixes=COMMON,BASIC
4# RUN: llvm-objcopy --redefine-sym bar=baz --prefix-symbols prefix %t %t3
5# RUN: llvm-readelf --symbols %t3 | FileCheck %s --check-prefixes=COMMON,REDEF
6
7## Show that an empty string is permitted as the argument to
8## --prefix-symbols.
9# RUN: llvm-objcopy --prefix-symbols= %t2 %t4
10# RUN: cmp %t2 %t4
11
12## Show that the last prefix wins.
13# RUN: llvm-objcopy --prefix-symbols foo --prefix-symbols prefix %t %t5
14# RUN: cmp %t2 %t5
15
16!ELF
17FileHeader:
18  Class:           ELFCLASS64
19  Data:            ELFDATA2LSB
20  Type:            ET_REL
21  Machine:         EM_X86_64
22Sections:
23  - Name:            .text
24    Type:            SHT_PROGBITS
25    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
26    Address:         0x1000
27    AddressAlign:    0x0000000000000010
28    Size:            64
29Symbols:
30  - Name:     foo
31    Type:     STT_SECTION
32    Section:  .text
33  - Name:     bar
34    Type:     STT_FILE
35    Section:  .text
36  - Name:     foobar
37    Type:     STT_FUNC
38    Section:  .text
39    Binding:  STB_GLOBAL
40  - Name:     undef
41    Binding:  STB_GLOBAL
42
43# COMMON:      Symbol table '.symtab' contains 5 entries:
44# COMMON-NEXT:  Num: Value Size Type Bind Vis Ndx Name
45# COMMON-NEXT:   0: [[#]] 0 NOTYPE  LOCAL  {{.*}}
46# COMMON-NEXT:   1: [[#]] 0 SECTION LOCAL  {{.*}} foo
47# BASIC-NEXT:    2: [[#]] 0 FILE    LOCAL  {{.*}} prefixbar
48# REDEF-NEXT:    2: [[#]] 0 FILE    LOCAL  {{.*}} prefixbaz
49# COMMON-NEXT:   3: [[#]] 0 FUNC    GLOBAL {{.*}} prefixfoobar
50# COMMON-NEXT:   4: [[#]] 0 NOTYPE  GLOBAL {{.*}} prefixundef
51