add-symbol-new-symtab.test
1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
## Show that llvm-objcopy can replace the symbol table with a new one.
# RUN: yaml2obj %s -o %t
# RUN: llvm-objcopy -R .symtab --add-symbol newsym=1234 %t %t2
# RUN: llvm-readelf -S -s %t2 | FileCheck %s --match-full-lines
# CHECK: There are 5 section headers, starting at offset {{.+}}:
# CHECK: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
# CHECK-NEXT: [ 0] NULL 0000000000000000 {{.+}} 000000 00 0 0 0
# CHECK-NEXT: [ 1] .text PROGBITS 0000000000001000 {{.+}} 000040 00 AX 0 0 16
# CHECK-NEXT: [ 2] .strtab STRTAB 0000000000000000 {{.+}} 000001 00 0 0 1
# CHECK-NEXT: [ 3] .shstrtab STRTAB 0000000000000000 {{.+}} 000028 00 0 0 1
# CHECK-NEXT: [ 4] .symtab SYMTAB 0000000000000000 {{.+}} 000030 18 3 1 8
# CHECK: Symbol table '.symtab' contains 2 entries:
# CHECK-NEXT: Num: Value Size Type Bind Vis Ndx Name
# CHECK-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
# CHECK-NEXT: 1: 00000000000004d2 0 NOTYPE GLOBAL DEFAULT ABS newsym
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0x1000
AddressAlign: 0x0000000000000010
Size: 64
Symbols:
- Name: foo
Type: STT_FUNC
Section: .text
Value: 0x1000
Size: 8
- Name: bar
Type: STT_FUNC
Section: .text
Value: 0x1008
Size: 8
- Name: baz
Type: STT_FUNC
Section: .text
Value: 0x1010
Size: 8