[PATCH] D153335: [ELFAttributeParser] Skip unknown vendor subsections.
Simon Tatham via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 20 08:06:40 PDT 2023
simon_tatham updated this revision to Diff 532943.
simon_tatham added a comment.
Deleted unnecessary parts from the YAML input file (and, while I'm there, added a comment naming the test it's used by).
> I think on the general principle that the ABI doesn't require compatibility checks for this section then it isn't worth checking that the vendor be part of the registered list.
Not to mention that it would require constant LLVM updates whenever the registered list changes!
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153335/new/
https://reviews.llvm.org/D153335
Files:
lld/test/ELF/Inputs/arm-vfp-arg-vfp-vendor.yaml
lld/test/ELF/arm-tag-vfp-args-errs.s
llvm/lib/Support/ELFAttributeParser.cpp
Index: llvm/lib/Support/ELFAttributeParser.cpp
===================================================================
--- llvm/lib/Support/ELFAttributeParser.cpp
+++ 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
Index: lld/test/ELF/arm-tag-vfp-args-errs.s
===================================================================
--- lld/test/ELF/arm-tag-vfp-args-errs.s
+++ 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
Index: lld/test/ELF/Inputs/arm-vfp-arg-vfp-vendor.yaml
===================================================================
--- /dev/null
+++ 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
+...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153335.532943.patch
Type: text/x-patch
Size: 3681 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230620/eb85c9de/attachment.bin>
More information about the llvm-commits
mailing list