summaryrefslogtreecommitdiff
path: root/tools/llvm-objcopy
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2018-07-27 22:51:36 +0000
committerFangrui Song <maskray@google.com>2018-07-27 22:51:36 +0000
commit2ccd4fbdb9c1417ba67e7494b6d50fe475c5ffea (patch)
tree4ca959f97b953ec357c8cd898e0ee3303e284bcc /tools/llvm-objcopy
parentb6a0f6b8e0026aab1978e9ee0e482a4d3fd7289b (diff)
[llvm-objcopy] Make --strip-debug strip .zdebug* (zlib-gnu) sections
This behavior matches GNU objcopy. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338173 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-objcopy')
-rw-r--r--tools/llvm-objcopy/llvm-objcopy.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/tools/llvm-objcopy/llvm-objcopy.cpp b/tools/llvm-objcopy/llvm-objcopy.cpp
index 4ccc67cc75d..e903e57ad5f 100644
--- a/tools/llvm-objcopy/llvm-objcopy.cpp
+++ b/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -185,6 +185,10 @@ LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, Error E) {
} // end namespace objcopy
} // end namespace llvm
+static bool IsDebugSection(const SectionBase &Sec) {
+ return Sec.Name.startswith(".debug") || Sec.Name.startswith(".zdebug");
+}
+
static bool IsDWOSection(const SectionBase &Sec) {
return Sec.Name.endswith(".dwo");
}
@@ -316,8 +320,7 @@ static void HandleArgs(const CopyConfig &Config, Object &Obj,
// Removes:
if (!Config.ToRemove.empty()) {
RemovePred = [&Config](const SectionBase &Sec) {
- return std::find(std::begin(Config.ToRemove), std::end(Config.ToRemove),
- Sec.Name) != std::end(Config.ToRemove);
+ return find(Config.ToRemove, Sec.Name) != Config.ToRemove.end();
};
}
@@ -346,7 +349,7 @@ static void HandleArgs(const CopyConfig &Config, Object &Obj,
case SHT_STRTAB:
return true;
}
- return Sec.Name.startswith(".debug");
+ return IsDebugSection(Sec);
};
if (Config.StripSections) {
@@ -357,7 +360,7 @@ static void HandleArgs(const CopyConfig &Config, Object &Obj,
if (Config.StripDebug) {
RemovePred = [RemovePred](const SectionBase &Sec) {
- return RemovePred(Sec) || Sec.Name.startswith(".debug");
+ return RemovePred(Sec) || IsDebugSection(Sec);
};
}
@@ -385,8 +388,7 @@ static void HandleArgs(const CopyConfig &Config, Object &Obj,
if (!Config.OnlyKeep.empty()) {
RemovePred = [&Config, RemovePred, &Obj](const SectionBase &Sec) {
// Explicitly keep these sections regardless of previous removes.
- if (std::find(std::begin(Config.OnlyKeep), std::end(Config.OnlyKeep),
- Sec.Name) != std::end(Config.OnlyKeep))
+ if (find(Config.OnlyKeep, Sec.Name) != Config.OnlyKeep.end())
return false;
// Allow all implicit removes.
@@ -408,8 +410,7 @@ static void HandleArgs(const CopyConfig &Config, Object &Obj,
if (!Config.Keep.empty()) {
RemovePred = [Config, RemovePred](const SectionBase &Sec) {
// Explicitly keep these sections regardless of previous removes.
- if (std::find(std::begin(Config.Keep), std::end(Config.Keep), Sec.Name) !=
- std::end(Config.Keep))
+ if (find(Config.Keep, Sec.Name) != Config.Keep.end())
return false;
// Otherwise defer to RemovePred.
return RemovePred(Sec);