diff --git a/lld/test/ELF/Inputs/arm-vfp-arg-vfp-vendor.yaml b/lld/test/ELF/Inputs/arm-vfp-arg-vfp-vendor.yaml new file mode 100644 --- /dev/null +++ b/lld/test/ELF/Inputs/arm-vfp-arg-vfp-vendor.yaml @@ -0,0 +1,35 @@ +# Variant form of the object compiled from arm-vfp-arg-vfp.s which +# adds a vendor attribute subsection in front of the "aeabi" one. LLD +# ought to skip over it and still parse the "aeabi" subsection beyond +# it. +# +# Used by lld/test/ELF/arm-tag-vfp-args-errs.s . +# +# This file was generated by building arm-vfp-arg-vfp.s, running +# yaml2obj over it, deleting parts not needed by the test (the .text +# section and the symbols), and manually inserting the hex string +# 2000000053686F756C64426549676E6F72656400FFFFFFFFFFFFFFFFFFFFFFFF +# after the initial version byte of the attributes section, which +# unpacks as a 32-bit length word, the zero-terminated vendor name +# string "ShouldBeIgnored", and dummy data that's all FFs (since the +# interior of a vendor subsection is not required to adhere to any +# standard format). + +--- !ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_ARM + Flags: [ EF_ARM_EABI_VER5 ] + SectionHeaderStringTable: .strtab +Sections: + - Name: .ARM.attributes + Type: SHT_ARM_ATTRIBUTES + AddressAlign: 0x1 + Content: 412000000053686F756C64426549676E6F72656400FFFFFFFFFFFFFFFFFFFFFFFF30000000616561626900012600000005372D4100060A0741080109021204140115011703180119011A021C011E062201 + - Type: SectionHeaderTable + Sections: + - Name: .strtab + - Name: .ARM.attributes +... diff --git a/lld/test/ELF/arm-tag-vfp-args-errs.s b/lld/test/ELF/arm-tag-vfp-args-errs.s --- a/lld/test/ELF/arm-tag-vfp-args-errs.s +++ b/lld/test/ELF/arm-tag-vfp-args-errs.s @@ -1,9 +1,11 @@ // REQUIRES:arm // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %S/Inputs/arm-vfp-arg-base.s -o %tbase.o // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %S/Inputs/arm-vfp-arg-vfp.s -o %tvfp.o +// RUN: yaml2obj %S/Inputs/arm-vfp-arg-vfp-vendor.yaml -o %tvfpvendor.o // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %S/Inputs/arm-vfp-arg-toolchain.s -o %ttoolchain.o // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o // RUN: not ld.lld %t.o %tbase.o %tvfp.o -o%t 2>&1 | FileCheck %s +// RUN: not ld.lld %t.o %tbase.o %tvfpvendor.o -o%t 2>&1 | FileCheck %s // RUN: not ld.lld %t.o %tbase.o %ttoolchain.o -o%t 2>&1 | FileCheck %s // RUN: not ld.lld %t.o %tvfp.o %tbase.o -o%t 2>&1 | FileCheck %s // RUN: not ld.lld %t.o %tvfp.o %ttoolchain.o -o%t 2>&1 | FileCheck %s diff --git a/llvm/lib/Support/ELFAttributeParser.cpp b/llvm/lib/Support/ELFAttributeParser.cpp --- a/llvm/lib/Support/ELFAttributeParser.cpp +++ b/llvm/lib/Support/ELFAttributeParser.cpp @@ -127,10 +127,14 @@ sw->printString("Vendor", vendorName); } - // Ignore unrecognized vendor-name. - if (vendorName.lower() != vendor) - return createStringError(errc::invalid_argument, - "unrecognized vendor-name: " + vendorName); + // Handle a subsection with an unrecognized vendor-name by skipping + // over it to the next subsection. ADDENDA32 in the Arm ABI defines + // that vendor attribute sections must not affect compatibility, so + // this should always be safe. + if (vendorName.lower() != vendor) { + cursor.seek(end); + return Error::success(); + } while (cursor.tell() < end) { /// Tag_File | Tag_Section | Tag_Symbol uleb128:byte-size