[lld] [lld][COFF] Fix: Merge `.drectve` sections in ObjFile::readSections (PR #86380)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 25 13:55:55 PDT 2024


================
@@ -89,16 +89,16 @@ class InputFile {
   // An archive file name if this file is created from an archive.
   StringRef parentName;
 
-  // Returns .drectve section contents if exist.
-  StringRef getDirectives() { return directives; }
+  // Returns .drectve section(s) content if exist.
+  llvm::SmallVector<StringRef, 0>  getDrectves() { return directives; }
 
   COFFLinkerContext &ctx;
 
 protected:
   InputFile(COFFLinkerContext &c, Kind k, MemoryBufferRef m, bool lazy = false)
       : mb(m), ctx(c), fileKind(k), lazy(lazy) {}
 
-  StringRef directives;
+  llvm::SmallVector<StringRef, 0> directives;
----------------
mstorsjo wrote:

I admit this is nitpicky and I'm not entirely sure, but I think 1 would be a more ideal default allocation size here. Depending on what kind of build it is, it's not uncommon to have directives in almost every single object file.

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


More information about the llvm-commits mailing list