<div dir="ltr">Might want to check what binutils objcopy does with .gdb_index too - sort of debug info section without the ".debug_" prefix.</div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jul 27, 2018 at 3:51 PM Fangrui Song via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: maskray<br>
Date: Fri Jul 27 15:51:36 2018<br>
New Revision: 338173<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=338173&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=338173&view=rev</a><br>
Log:<br>
[llvm-objcopy] Make --strip-debug strip .zdebug* (zlib-gnu) sections<br>
<br>
This behavior matches GNU objcopy.<br>
<br>
Modified:<br>
llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp<br>
<br>
Modified: llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp?rev=338173&r1=338172&r2=338173&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp?rev=338173&r1=338172&r2=338173&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp (original)<br>
+++ llvm/trunk/tools/llvm-objcopy/llvm-objcopy.cpp Fri Jul 27 15:51:36 2018<br>
@@ -185,6 +185,10 @@ LLVM_ATTRIBUTE_NORETURN void reportError<br>
} // end namespace objcopy<br>
} // end namespace llvm<br>
<br>
+static bool IsDebugSection(const SectionBase &Sec) {<br>
+ return Sec.Name.startswith(".debug") || Sec.Name.startswith(".zdebug");<br>
+}<br>
+<br>
static bool IsDWOSection(const SectionBase &Sec) {<br>
return Sec.Name.endswith(".dwo");<br>
}<br>
@@ -316,8 +320,7 @@ static void HandleArgs(const CopyConfig<br>
// Removes:<br>
if (!Config.ToRemove.empty()) {<br>
RemovePred = [&Config](const SectionBase &Sec) {<br>
- return std::find(std::begin(Config.ToRemove), std::end(Config.ToRemove),<br>
- Sec.Name) != std::end(Config.ToRemove);<br>
+ return find(Config.ToRemove, Sec.Name) != Config.ToRemove.end();<br>
};<br>
}<br>
<br>
@@ -346,7 +349,7 @@ static void HandleArgs(const CopyConfig<br>
case SHT_STRTAB:<br>
return true;<br>
}<br>
- return Sec.Name.startswith(".debug");<br>
+ return IsDebugSection(Sec);<br>
};<br>
<br>
if (Config.StripSections) {<br>
@@ -357,7 +360,7 @@ static void HandleArgs(const CopyConfig<br>
<br>
if (Config.StripDebug) {<br>
RemovePred = [RemovePred](const SectionBase &Sec) {<br>
- return RemovePred(Sec) || Sec.Name.startswith(".debug");<br>
+ return RemovePred(Sec) || IsDebugSection(Sec);<br>
};<br>
}<br>
<br>
@@ -385,8 +388,7 @@ static void HandleArgs(const CopyConfig<br>
if (!Config.OnlyKeep.empty()) {<br>
RemovePred = [&Config, RemovePred, &Obj](const SectionBase &Sec) {<br>
// Explicitly keep these sections regardless of previous removes.<br>
- if (std::find(std::begin(Config.OnlyKeep), std::end(Config.OnlyKeep),<br>
- Sec.Name) != std::end(Config.OnlyKeep))<br>
+ if (find(Config.OnlyKeep, Sec.Name) != Config.OnlyKeep.end())<br>
return false;<br>
<br>
// Allow all implicit removes.<br>
@@ -408,8 +410,7 @@ static void HandleArgs(const CopyConfig<br>
if (!Config.Keep.empty()) {<br>
RemovePred = [Config, RemovePred](const SectionBase &Sec) {<br>
// Explicitly keep these sections regardless of previous removes.<br>
- if (std::find(std::begin(Config.Keep), std::end(Config.Keep), Sec.Name) !=<br>
- std::end(Config.Keep))<br>
+ if (find(Config.Keep, Sec.Name) != Config.Keep.end())<br>
return false;<br>
// Otherwise defer to RemovePred.<br>
return RemovePred(Sec);<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>