From bcbdbd25c0a2608299a4e97f12076be06a64d724 Mon Sep 17 00:00:00 2001 From: SivanShani-Arm Date: Mon, 14 Apr 2025 14:59:24 +0100 Subject: [PATCH] [llvm][ELF][build attributes] Change StringRef to std::string for BuildAttributeSubSection::Name (#135625) BuildAttributeSubSection::Name must be a std::string instead of StringRef because it may be assigned from non-persistent memory. StringRef is non-owning and unsafe in this context. This change ensures the subsection name owns its memory, preventing use-after-free or dangling references. Context: Work in progress in PR #131990. --- llvm/include/llvm/Support/ELFAttributes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/include/llvm/Support/ELFAttributes.h b/llvm/include/llvm/Support/ELFAttributes.h index 6782aec6050a..d652e2586e9e 100644 --- a/llvm/include/llvm/Support/ELFAttributes.h +++ b/llvm/include/llvm/Support/ELFAttributes.h @@ -36,7 +36,7 @@ struct BuildAttributeItem { : Type(Ty), Tag(Tg), IntValue(IV), StringValue(std::move(SV)) {} }; struct BuildAttributeSubSection { - StringRef Name; + std::string Name; unsigned IsOptional; unsigned ParameterType; SmallVector Content;