Index: test/tools/llvm-objcopy/ELF/strip-relocations.test =================================================================== --- /dev/null +++ test/tools/llvm-objcopy/ELF/strip-relocations.test @@ -0,0 +1,35 @@ +# RUN: yaml2obj %s > %t + +## Check we are able to strip all symbols and relocatable information. + +# RUN: llvm-objcopy -S %t %t2 +# RUN: llvm-objdump --section-headers %t2 | FileCheck %s + +# RUN: llvm-objcopy --strip-all-gnu %t %t2 +# RUN: llvm-objdump --section-headers %t2 | FileCheck %s + +# CHECK-NOT: .symtab +# CHECK-NOT: .rela.text + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Content: 00000000 + - Name: .rela.text + Type: SHT_RELA + Link: .symtab + Info: .text + Relocations: + - Offset: 0x0000000000000000 + Symbol: bar + Type: R_X86_64_32S +Symbols: + Global: + - Name: bar Index: tools/llvm-objcopy/ELF/ELFObjcopy.cpp =================================================================== --- tools/llvm-objcopy/ELF/ELFObjcopy.cpp +++ tools/llvm-objcopy/ELF/ELFObjcopy.cpp @@ -542,10 +542,10 @@ Obj.OSABI = Config.OutputArch.getValue().OSABI; } - if (Error E = updateAndRemoveSymbols(Config, Obj)) + if (Error E = replaceAndRemoveSections(Config, Obj)) return E; - if (Error E = replaceAndRemoveSections(Config, Obj)) + if (Error E = updateAndRemoveSymbols(Config, Obj)) return E; if (!Config.SectionsToRename.empty()) {