diff options
author | Jordan Rupprecht <rupprecht@google.com> | 2019-07-10 23:32:44 +0000 |
---|---|---|
committer | Jordan Rupprecht <rupprecht@google.com> | 2019-07-10 23:32:44 +0000 |
commit | 77d3590a87ba4a2ef621a1aab6a378639e1cd926 (patch) | |
tree | ec38548229e9feefcf6c35fae39154dcc619d6e8 /llvm/tools/llvm-objcopy/ELF/Object.cpp | |
parent | 138328e45cdfaff58fdbf643580563f9775e5d25 (diff) | |
download | llvm-77d3590a87ba4a2ef621a1aab6a378639e1cd926.zip llvm-77d3590a87ba4a2ef621a1aab6a378639e1cd926.tar.gz llvm-77d3590a87ba4a2ef621a1aab6a378639e1cd926.tar.bz2 |
Revert [llvm-objcopy] Allow strip symtab from executables and DSOs
This reverts r365193 (git commit 194f16b3548bcb23a7f0fd638778ed72edd18d37)
This patch doesn't work with binaries built w/ `--emit-relocs`, e.g.
```
$ echo 'int main() { return 0; }' | clang -Wl,--emit-relocs -x c - -o foo && llvm-objcopy --strip-unneeded foo
llvm-objcopy: error: 'foo': not stripping symbol '__gmon_start__' because it is named in a relocation
```
llvm-svn: 365712
Diffstat (limited to 'llvm/tools/llvm-objcopy/ELF/Object.cpp')
-rw-r--r-- | llvm/tools/llvm-objcopy/ELF/Object.cpp | 21 |
1 files changed, 0 insertions, 21 deletions
diff --git a/llvm/tools/llvm-objcopy/ELF/Object.cpp b/llvm/tools/llvm-objcopy/ELF/Object.cpp index 2d85b3a..fa69638 100644 --- a/llvm/tools/llvm-objcopy/ELF/Object.cpp +++ b/llvm/tools/llvm-objcopy/ELF/Object.cpp @@ -1995,25 +1995,6 @@ template <class ELFT> Error ELFWriter<ELFT>::write() { return Buf.commit(); } -static Error removeUnneededSections(Object &Obj) { - // We can remove an empty symbol table from non-relocatable objects. - // Relocatable objects typically have relocation sections whose - // sh_link field points to .symtab, so we can't remove .symtab - // even if it is empty. - if (Obj.isRelocatable() || Obj.SymbolTable == nullptr || - !Obj.SymbolTable->empty()) - return Error::success(); - - // .strtab can be used for section names. In such a case we shouldn't - // remove it. - auto *StrTab = Obj.SymbolTable->getStrTab() == Obj.SectionNames - ? nullptr - : Obj.SymbolTable->getStrTab(); - return Obj.removeSections(false, [&](const SectionBase &Sec) { - return &Sec == Obj.SymbolTable || &Sec == StrTab; - }); -} - template <class ELFT> Error ELFWriter<ELFT>::finalize() { // It could happen that SectionNames has been removed and yet the user wants // a section header table output. We need to throw an error if a user tries @@ -2023,8 +2004,6 @@ template <class ELFT> Error ELFWriter<ELFT>::finalize() { "cannot write section header table because " "section header string table was removed"); - if (Error E = removeUnneededSections(Obj)) - return E; Obj.sortSections(); // We need to assign indexes before we perform layout because we need to know |