diff --git a/llvm/test/tools/llvm-objcopy/ELF/strip-preserve-arm-attributes.test b/llvm/test/tools/llvm-objcopy/ELF/strip-preserve-arm-attributes.test new file mode 100644 --- /dev/null +++ b/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 diff --git a/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp b/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp --- a/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp +++ b/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;