| 1 |
# RUN: yaml2obj %s -o %t |
| 2 |
## No-op copy. |
| 3 |
# RUN: llvm-objcopy %t %t2 |
| 4 |
# RUN: llvm-readobj --sections %t2 | FileCheck %s |
| 5 |
## No-op strip. |
| 6 |
# RUN: cp %t %t3 |
| 7 |
# RUN: llvm-strip --no-strip-all %t3 |
| 8 |
# RUN: llvm-readobj --sections %t3 | FileCheck %s |
| 9 |
## Add symbol. |
| 10 |
# RUN: llvm-objcopy --add-symbol=another=.text:0,function %t %t4 |
| 11 |
# RUN: llvm-readobj --sections %t4 | FileCheck %s |
| 12 |
|
| 13 |
## A section with sh_link referencing SHT_SYMTAB indicates that its content may |
| 14 |
## use the old symbol indices. If the symbol indices change, reset sh_link to 0 |
| 15 |
## to inform tools like linkers that the sh_link has been invalidated. |
| 16 |
|
| 17 |
## Strip first symbol. |
| 18 |
# RUN: llvm-objcopy --strip-symbol bar %t %t5 |
| 19 |
# RUN: llvm-readobj --sections %t5 | FileCheck %s --check-prefix=LINK-0 |
| 20 |
## Strip last symbol. |
| 21 |
# RUN: llvm-objcopy --strip-symbol baz %t %t6 |
| 22 |
# RUN: llvm-readobj --sections %t6 | FileCheck %s --check-prefix=LINK-0 |
| 23 |
## Re-order symbols. |
| 24 |
# RUN: llvm-objcopy --localize-symbol baz %t %t7 |
| 25 |
# RUN: llvm-readobj --sections %t7 | FileCheck %s --check-prefix=LINK-0 |
| 26 |
## Remove .text section. |
| 27 |
# RUN: llvm-objcopy --remove-section=.text %t %t8 |
| 28 |
# RUN: llvm-readobj --sections %t8 | FileCheck %s --check-prefix=LINK-0 |
| 29 |
|
| 30 |
!ELF |
| 31 |
FileHeader: |
| 32 |
Class: ELFCLASS64 |
| 33 |
Data: ELFDATA2LSB |
| 34 |
Type: ET_REL |
| 35 |
Machine: EM_X86_64 |
| 36 |
Sections: |
| 37 |
- Name: .text |
| 38 |
Type: SHT_PROGBITS |
| 39 |
Flags: [ SHF_ALLOC, SHF_EXECINSTR ] |
| 40 |
Address: 0x1000 |
| 41 |
AddressAlign: 0x0000000000000010 |
| 42 |
Size: 32 |
| 43 |
- Name: .foo |
| 44 |
Link: .symtab |
| 45 |
Type: SHT_PROGBITS |
| 46 |
Flags: [ ] |
| 47 |
Symbols: |
| 48 |
- Name: bar |
| 49 |
Type: STT_FUNC |
| 50 |
Size: 8 |
| 51 |
Section: .text |
| 52 |
Value: 0x1000 |
| 53 |
Binding: STB_GLOBAL |
| 54 |
- Name: baz |
| 55 |
Type: STT_FUNC |
| 56 |
Size: 8 |
| 57 |
Section: .text |
| 58 |
Value: 0x1010 |
| 59 |
Binding: STB_GLOBAL |
| 60 |
|
| 61 |
# CHECK: Name: .foo |
| 62 |
# CHECK-NEXT: Type: |
| 63 |
# CHECK-NEXT: Flags [ (0x0) |
| 64 |
# CHECK-NEXT: ] |
| 65 |
# CHECK-NEXT: Address: |
| 66 |
# CHECK-NEXT: Offset: |
| 67 |
# CHECK-NEXT: Size: |
| 68 |
# CHECK-NEXT: Link: [[#SYMTABIDX:]] |
| 69 |
|
| 70 |
# CHECK: Index: [[#SYMTABIDX]] |
| 71 |
# CHECK-NEXT: Name: .symtab |
| 72 |
# CHECK-NEXT: Type: SHT_SYMTAB |
| 73 |
|
| 74 |
# LINK-0: Name: .foo |
| 75 |
# LINK-0-NEXT: Type: |
| 76 |
# LINK-0-NEXT: Flags [ (0x0) |
| 77 |
# LINK-0-NEXT: ] |
| 78 |
# LINK-0-NEXT: Address: |
| 79 |
# LINK-0-NEXT: Offset: |
| 80 |
# LINK-0-NEXT: Size: |
| 81 |
# LINK-0-NEXT: Link: 0 |