179fb8580SGeorge Rimar## Check we cannot remove a section containing symbols 279fb8580SGeorge Rimar## referenced by relocations contained in the object. 379fb8580SGeorge Rimar 4*55c81d42SFangrui Song# RUN: yaml2obj %s -o %t1 5ada9d2d8SSeiya Nuta# RUN: not llvm-objcopy -R .data %t1 2>&1 | FileCheck %s -DINPUT=%t1 6ada9d2d8SSeiya Nuta# CHECK: error: '[[INPUT]]': section '.data' cannot be removed: (.text+0x1) has relocation against symbol 'foo' 779fb8580SGeorge Rimar 879fb8580SGeorge Rimar## Check the behavior when we also remove the relocation section. 979fb8580SGeorge Rimar## We have no reference in this case and hence no error should be emitted. 1079fb8580SGeorge Rimar 11*55c81d42SFangrui Song# RUN: yaml2obj %s -o %t2 1279fb8580SGeorge Rimar# RUN: llvm-objcopy -R .data -R .rela.text %t2 %t3 1379fb8580SGeorge Rimar# RUN: llvm-objdump --section-headers %t3 | FileCheck %s --check-prefix=NOSEC 1479fb8580SGeorge Rimar# NOSEC-NOT: .data 1579fb8580SGeorge Rimar# NOSEC-NOT: .rela.text 1679fb8580SGeorge Rimar 1779fb8580SGeorge Rimar--- !ELF 1879fb8580SGeorge RimarFileHeader: 1979fb8580SGeorge Rimar Class: ELFCLASS64 2079fb8580SGeorge Rimar Data: ELFDATA2LSB 2179fb8580SGeorge Rimar Type: ET_REL 2279fb8580SGeorge Rimar Machine: EM_X86_64 2379fb8580SGeorge RimarSections: 2479fb8580SGeorge Rimar - Name: .text 2579fb8580SGeorge Rimar Type: SHT_PROGBITS 2679fb8580SGeorge Rimar Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 2779fb8580SGeorge Rimar AddressAlign: 0x0000000000000004 2879fb8580SGeorge Rimar Content: E800000000 2979fb8580SGeorge Rimar - Name: .rela.text 3079fb8580SGeorge Rimar Type: SHT_RELA 3179fb8580SGeorge Rimar Link: .symtab 3279fb8580SGeorge Rimar AddressAlign: 0x0000000000000008 3379fb8580SGeorge Rimar EntSize: 0x0000000000000018 3479fb8580SGeorge Rimar Info: .text 3579fb8580SGeorge Rimar Relocations: 3679fb8580SGeorge Rimar - Offset: 0x0000000000000001 3779fb8580SGeorge Rimar Symbol: foo 3879fb8580SGeorge Rimar Type: R_X86_64_GOTPCREL 3979fb8580SGeorge Rimar Addend: -4 4079fb8580SGeorge Rimar - Name: .data 4179fb8580SGeorge Rimar Type: SHT_PROGBITS 4279fb8580SGeorge Rimar Flags: [ SHF_WRITE, SHF_ALLOC ] 4379fb8580SGeorge Rimar AddressAlign: 0x0000000000000001 4479fb8580SGeorge Rimar Content: '0102' 4579fb8580SGeorge RimarSymbols: 4679fb8580SGeorge Rimar - Name: foo 4779fb8580SGeorge Rimar Section: .data 4879fb8580SGeorge Rimar Value: 0x0000000000000001 4979fb8580SGeorge Rimar... 50