[lld] [llvm] [lld][AArch64][Build Attributes] Add support for converting AArch64 Build Attributes to GNU Properties (PR #131990)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 9 09:41:56 PDT 2025


================
@@ -554,6 +697,33 @@ template <class ELFT> void ObjFile<ELFT>::parse(bool ignoreComdats) {
   StringRef shstrtab = CHECK2(obj.getSectionStringTable(objSections), this);
   uint64_t size = objSections.size();
   sections.resize(size);
+
+  // Check whether GNU properties section present and store it's data.
----------------
smithp35 wrote:

May I suggest an alternative design that I think should simplify the code and avoid another loop through the input sections, which could take non-negligble time for a large object file with tens of thousands of sections produced from LTO.

Both BuildAttributes and GNU properties want to update `InputFile::andFeatures` and `InputFile::aarch64PauthCoreInfo` and the consensus seems to be that we want to sanity check that if both are present then they are consistent.

given that InputFile::andFeatures are common to at least x86_64 and AArch64. I suggest that we keep the existing code to read GNU properties in place. Then when we see a AArch64 BuildAttributes section we just call extractBuildAttributesSubsections. Instead of trying to update `InputFile::andFeatures` and `InputFile::aarch64PauthABICoreInfo` in place, we delay until after the loop through all the sections on line 727 has completed.

At this stage we will either:
* Have neither build attributes or GNU properties. Nothing to do.
* Have GNU properties but no Build Attributes. Nothing to do.
* Have BuildAttributes but no GNU properties. Translate the KnownAArch64BuildAttrSubSections we extracted into andFeatures and aarch64PauthABI.
* Have both BuildAttributes and GNU properties. Check that they match, if they don't error, otherwise there is nothing to do as we've already set the fields with GNU properties.

https://github.com/llvm/llvm-project/pull/131990


More information about the llvm-commits mailing list