Follow up to d0858bffa11, add missing REQUIRES x86
[llvm-project.git] / llvm / test / tools / llvm-objcopy / ELF / redefine-symbol.test
blob75f6f8d773224b4de7562215603cc3cfe5d71db7
1 # RUN: yaml2obj %s -o %t
2 # RUN: llvm-objcopy --redefine-sym foo=oof --redefine-sym =wasempty --redefine-sym empty= %t %t2
3 # RUN: llvm-readobj --symbols %t2 | FileCheck %s
4 # RUN: echo "  bar   rab #rename bar  " > %t.rename1.txt
5 # RUN: echo "foo oof #rename foo  " > %t.rename2.txt
6 # RUN: echo "  empty   ytpme #rename empty  " >> %t.rename2.txt
7 # RUN: llvm-objcopy --redefine-syms %t.rename1.txt --redefine-syms %t.rename2.txt %t %t4
8 # RUN: llvm-readobj --symbols %t4 | FileCheck %s --check-prefix=MULTIPLE-FILES
10 !ELF
11 FileHeader:
12   Class:           ELFCLASS64
13   Data:            ELFDATA2LSB
14   Type:            ET_EXEC
15   Machine:         EM_X86_64
16 Sections:
17   - Name:            .text
18     Type:            SHT_PROGBITS
19     Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
20     Address:         0x1000
21     AddressAlign:    0x0000000000000010
22     Content:         "0000000000000000"
23   - Name:            .data
24     Type:            SHT_PROGBITS
25     Flags:           [ SHF_ALLOC ]
26     Address:         0x2000
27     AddressAlign:    0x0000000000000010
28     Content:         "0000000000000000"
29 Symbols:
30   - Name:     foo
31     Type:     STT_FUNC
32     Section:  .text
33     Value:    0x1004
34     Binding:  STB_GLOBAL
35   - Name:     bar
36     Type:     STT_OBJECT
37     Section:  .data
38     Value:    0x2000
39     Size:     4
40     Binding:  STB_GLOBAL
41   - Name:     empty
42     Type:     STT_FUNC
43     Section:  .text
44     Value:    0x1008
45     Binding:  STB_GLOBAL
46   - Type:     STT_OBJECT
47     Section:  .data
48     Value:    0x2008
49     Binding:  STB_GLOBAL
51 #CHECK: Symbols [
52 #CHECK-NEXT:  Symbol {
53 #CHECK-NEXT:    Name:
54 #CHECK-NEXT:    Value: 0x0
55 #CHECK-NEXT:    Size: 0
56 #CHECK-NEXT:    Binding: Local
57 #CHECK-NEXT:    Type: None
58 #CHECK-NEXT:    Other: 0
59 #CHECK-NEXT:    Section: Undefined
60 #CHECK-NEXT:  }
61 #CHECK-NEXT:  Symbol {
62 #CHECK-NEXT:    Name: oof
63 #CHECK-NEXT:    Value: 0x1004
64 #CHECK-NEXT:    Size: 0
65 #CHECK-NEXT:    Binding: Global
66 #CHECK-NEXT:    Type: Function
67 #CHECK-NEXT:    Other: 0
68 #CHECK-NEXT:    Section: .text
69 #CHECK-NEXT:  }
70 #CHECK-NEXT:  Symbol {
71 #CHECK-NEXT:    Name: bar
72 #CHECK-NEXT:    Value: 0x2000
73 #CHECK-NEXT:    Size: 4
74 #CHECK-NEXT:    Binding: Global
75 #CHECK-NEXT:    Type: Object
76 #CHECK-NEXT:    Other: 0
77 #CHECK-NEXT:    Section: .data
78 #CHECK-NEXT:  }
79 #CHECK-NEXT:  Symbol {
80 #CHECK-NEXT:    Name: (0)
81 #CHECK-NEXT:    Value: 0x1008
82 #CHECK-NEXT:    Size: 0
83 #CHECK-NEXT:    Binding: Global
84 #CHECK-NEXT:    Type: Function
85 #CHECK-NEXT:    Other: 0
86 #CHECK-NEXT:    Section: .text
87 #CHECK-NEXT:  }
88 #CHECK-NEXT:  Symbol {
89 #CHECK-NEXT:    Name: wasempty
90 #CHECK-NEXT:    Value: 0x2008
91 #CHECK-NEXT:    Size: 0
92 #CHECK-NEXT:    Binding: Global
93 #CHECK-NEXT:    Type: Object
94 #CHECK-NEXT:    Other: 0
95 #CHECK-NEXT:    Section: .data
96 #CHECK-NEXT:  }
98 #MULTIPLE-FILES:        Name: oof
99 #MULTIPLE-FILES-NEXT:   Value: 0x1004
100 #MULTIPLE-FILES:        Name: rab
101 #MULTIPLE-FILES-NEXT:   Value: 0x2000
102 #MULTIPLE-FILES:        Name: ytpme
103 #MULTIPLE-FILES-NEXT:   Value: 0x1008
105 ## Show that it is not an error if a specified symbol is not present.
106 # RUN: llvm-objcopy %t2 %t5 --redefine-sym missing=blah
107 # RUN: cmp %t2 %t5
109 ## Show that --redefine-sym doesn't chain together.
110 # RUN: llvm-objcopy %t2 %t6 --redefine-sym oof=bob --redefine-sym bob=baz
111 # RUN: llvm-readobj %t6 --syms | FileCheck %s --check-prefix=CHAIN --implicit-check-not="Name: baz"
113 # CHAIN: Name: bob