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