[PATCH] D69188: [llvm-objcopy] Preserve .ARM.attributes section when stripping files
James Henderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 31 04:58:58 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfb4a55010ee9: [llvm-objcopy] Preserve .ARM.attributes section when stripping files (authored by jhenderson).
Changed prior to commit:
https://reviews.llvm.org/D69188?vs=227056&id=227269#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69188/new/
https://reviews.llvm.org/D69188
Files:
llvm/docs/CommandGuide/llvm-objcopy.rst
llvm/docs/CommandGuide/llvm-strip.rst
llvm/test/tools/llvm-objcopy/ELF/strip-preserve-arm-attributes.test
llvm/tools/llvm-objcopy/CommonOpts.td
llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
Index: llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
===================================================================
--- llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
+++ llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
@@ -503,6 +503,12 @@
return false;
if (StringRef(Sec.Name).startswith(".gnu.warning"))
return false;
+ // We keep the .ARM.attribute section to maintain compatibility
+ // with Debian derived distributions. This is a bug in their
+ // patchset as documented here:
+ // https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=943798
+ if (Sec.Type == SHT_ARM_ATTRIBUTES)
+ return false;
if (Sec.ParentSegment != nullptr)
return false;
return (Sec.Flags & SHF_ALLOC) == 0;
Index: llvm/tools/llvm-objcopy/CommonOpts.td
===================================================================
--- llvm/tools/llvm-objcopy/CommonOpts.td
+++ llvm/tools/llvm-objcopy/CommonOpts.td
@@ -40,7 +40,8 @@
def strip_all : Flag<["--"], "strip-all">,
HelpText<"Remove non-allocated sections outside segments. "
- ".gnu.warning* sections are not removed">;
+ ".gnu.warning* and .ARM.attribute sections are not "
+ "removed">;
def strip_all_gnu
: Flag<["--"], "strip-all-gnu">,
Index: llvm/test/tools/llvm-objcopy/ELF/strip-preserve-arm-attributes.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-objcopy/ELF/strip-preserve-arm-attributes.test
@@ -0,0 +1,25 @@
+## This test makes sure that --strip-all and --strip-all-gnu preserve
+## .ARM.attributes sections in ELF files. This is needed to maintain
+## compatibility for Ubuntu/Debian distributions on ARM.
+
+# RUN: yaml2obj %s > %t
+# RUN: llvm-objcopy --strip-all %t %t2
+# RUN: llvm-readobj --sections %t2 | FileCheck %s
+# RUN: llvm-objcopy --strip-all-gnu %t %t3
+# RUN: llvm-readobj --sections %t3 | FileCheck %s
+# RUN: llvm-strip %t -o %t4
+# RUN: cmp %t4 %t2
+# RUN: llvm-strip --strip-all-gnu %t -o %t5
+# RUN: cmp %t5 %t3
+
+!ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_DYN
+ Machine: EM_ARM
+Sections:
+ - Name: .ARM.attributes
+ Type: SHT_ARM_ATTRIBUTES
+
+# CHECK: Name: .ARM.attributes
Index: llvm/docs/CommandGuide/llvm-strip.rst
===================================================================
--- llvm/docs/CommandGuide/llvm-strip.rst
+++ llvm/docs/CommandGuide/llvm-strip.rst
@@ -77,7 +77,8 @@
.. option:: --strip-all, -S
For ELF objects, remove from the output all symbols and non-alloc sections not
- within segments, except for .gnu.warning sections and the section name table.
+ within segments, except for .gnu.warning, .ARM.attribute sections and the
+ section name table.
For COFF objects, remove all symbols, debug sections, and relocations from the
output.
Index: llvm/docs/CommandGuide/llvm-objcopy.rst
===================================================================
--- llvm/docs/CommandGuide/llvm-objcopy.rst
+++ llvm/docs/CommandGuide/llvm-objcopy.rst
@@ -98,7 +98,8 @@
.. option:: --strip-all, -S
For ELF objects, remove from the output all symbols and non-alloc sections not
- within segments, except for .gnu.warning sections and the section name table.
+ within segments, except for .gnu.warning, .ARM.attribute sections and the
+ section name table.
For COFF and Mach-O objects, remove all symbols, debug sections, and
relocations from the output.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69188.227269.patch
Type: text/x-patch
Size: 3587 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191031/afe03015/attachment.bin>
More information about the llvm-commits
mailing list