[PATCH] D69188: [llvm-objcopy] Preserve .ARM.attributes section when stripping files
Tobias Hieta via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 18 11:44:32 PDT 2019
thieta created this revision.
thieta added reviewers: rupprecht, MaskRay, grimar.
Herald added subscribers: llvm-commits, seiya, abrachet, jakehehrlich, kristof.beyls, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: alexshap.
Herald added a reviewer: jhenderson.
Herald added a project: LLVM.
While this section is not strictly needed for modern systems there are a lot of linux-arm devices out there with older glibc and eglibc which both require that this section is part of a shared object in order to dlopen it.
Peter Smith did a similar patch against lld a couple of years ago:
https://reviews.llvm.org/D27718
There is more context and discussion on llvm-dev: http://lists.llvm.org/pipermail/llvm-dev/2019-October/135993.html
This is my first contribution to LLVM - so please let me know if I did something wrong. I am mostly unsure about how I did the test for this bug. But I was able to confirm that it fails without my patch, and passes with it.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D69188
Files:
llvm/test/tools/llvm-objcopy/ELF/strip-preserve-arm-attributes.test
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,11 @@
return false;
if (StringRef(Sec.Name).startswith(".gnu.warning"))
return false;
+ // While keeping this section around shouldn't be needed
+ // there are older version of glibc and eglibc that requires
+ // it around in order for dlopen to work correctly.
+ if (Sec.Type == SHT_ARM_ATTRIBUTES)
+ return false;
if (Sec.ParentSegment != nullptr)
return false;
return (Sec.Flags & SHF_ALLOC) == 0;
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,16 @@
+# RUN: yaml2obj %s > %t
+# RUN: cp %t %t3
+# RUN: llvm-objcopy --strip-all %t %t2
+# RUN: llvm-readobj --file-headers --sections %t2 | FileCheck %s
+
+!ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_DYN
+ Machine: EM_ARM
+Sections:
+ - Name: .ARM.attributes
+ Type: SHT_ARM_ATTRIBUTES
+
+# CHECK: Name: .ARM.attributes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69188.225673.patch
Type: text/x-patch
Size: 1360 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191018/64137a4e/attachment.bin>
More information about the llvm-commits
mailing list