summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy/COFF/COFFObjcopy.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-objcopy/COFF/COFFObjcopy.cpp')
-rw-r--r--llvm/tools/llvm-objcopy/COFF/COFFObjcopy.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/tools/llvm-objcopy/COFF/COFFObjcopy.cpp b/llvm/tools/llvm-objcopy/COFF/COFFObjcopy.cpp
index ea46b841bcf..6b386d29979 100644
--- a/llvm/tools/llvm-objcopy/COFF/COFFObjcopy.cpp
+++ b/llvm/tools/llvm-objcopy/COFF/COFFObjcopy.cpp
@@ -28,6 +28,11 @@ using namespace object;
using namespace COFF;
static Error handleArgs(const CopyConfig &Config, Object &Obj) {
+ // StripAll removes all symbols and thus also removes all relocations.
+ if (Config.StripAll || Config.StripAllGNU)
+ for (Section &Sec : Obj.Sections)
+ Sec.Relocs.clear();
+
// If we need to do per-symbol removals, initialize the Referenced field.
if (Config.StripUnneeded || Config.DiscardAll ||
!Config.SymbolsToRemove.empty())
@@ -36,6 +41,11 @@ static Error handleArgs(const CopyConfig &Config, Object &Obj) {
// Actually do removals of symbols.
Obj.removeSymbols([&](const Symbol &Sym) {
+ // For StripAll, all relocations have been stripped and we remove all
+ // symbols.
+ if (Config.StripAll || Config.StripAllGNU)
+ return true;
+
if (is_contained(Config.SymbolsToRemove, Sym.Name)) {
// Explicitly removing a referenced symbol is an error.
if (Sym.Referenced)
OpenPOWER on IntegriCloud