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

via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 14 03:51:48 PDT 2025


================
@@ -32,14 +32,21 @@ struct BuildAttributeItem {
   unsigned Tag;
   unsigned IntValue;
   std::string StringValue;
+  BuildAttributeItem() {};
   BuildAttributeItem(Types Ty, unsigned Tg, unsigned IV, std::string SV)
       : Type(Ty), Tag(Tg), IntValue(IV), StringValue(std::move(SV)) {}
 };
+
 struct BuildAttributeSubSection {
-  StringRef Name;
+  std::string Name;
----------------
sivan-shani wrote:

The worry is that in some cases the memory holding the string being referenced might go out of scope.
In paeticualr, in: `llvm/lib/Support/ELFAttrParserExtended.cpp` the lines:
`StringRef VendorName = De.getCStrRef(Cursor);`
...
`  BuildAttributeSubSection BASubSection;`

While the first `StringRef VendorName` is safe, since `Section` is in scope inside the current function (`parse`) 
`BASubSection` scope is not restricted to `parse`, there fore it can not rely on the memory to be available and has to own it's own copy.

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


More information about the llvm-commits mailing list