| 1 |
# RUN: yaml2obj %s -o %t |
| 2 |
|
| 3 |
## Check we cannot remove the .dynsym symbol table because dynamic |
| 4 |
## relocation section .rela.dyn still references it via sh_link field. |
| 5 |
# RUN: not llvm-objcopy -R .dynsym %t %t2 2>&1 >/dev/null | FileCheck %s --check-prefix=ERR -DINPUT=%t |
| 6 |
# ERR: error: '[[INPUT]]': symbol table '.dynsym' cannot be removed because it is referenced by the relocation section '.rela.dyn' |
| 7 |
|
| 8 |
## Check we can remove .dynsym after removing the reference. |
| 9 |
# RUN: llvm-objcopy -R .dynsym -R .rela.dyn %t %t2 |
| 10 |
# RUN: llvm-readelf --sections %t2 | FileCheck %s --implicit-check-not=".dynsym" |
| 11 |
|
| 12 |
## Check we zero out sh_link field and allow producing output with the --allow-broken-links switch. |
| 13 |
# RUN: llvm-objcopy -R .dynsym --allow-broken-links %t %t2 |
| 14 |
# RUN: llvm-readelf --sections %t2 | FileCheck %s --check-prefix=DROP-LINK |
| 15 |
# DROP-LINK: [Nr] Name Type Address Off Size ES Flg L |
| 16 |
# DROP-LINK: [ 1] .rela.dyn RELA 0000000000000270 000040 000000 18 A 0 |
| 17 |
# DROP-LINK-NOT: .dynsym |
| 18 |
|
| 19 |
!ELF |
| 20 |
FileHeader: |
| 21 |
Class: ELFCLASS64 |
| 22 |
Data: ELFDATA2LSB |
| 23 |
Type: ET_DYN |
| 24 |
Machine: EM_X86_64 |
| 25 |
Sections: |
| 26 |
- Name: .rela.dyn |
| 27 |
Type: SHT_RELA |
| 28 |
Flags: [ SHF_ALLOC ] |
| 29 |
Address: 0x0000000000000270 |
| 30 |
Link: .dynsym |
| 31 |
EntSize: 0x0000000000000018 |
| 32 |
DynamicSymbols: |
| 33 |
- Name: bar |
| 34 |
Binding: STB_GLOBAL |