[lld] 7d13775 - [ELF] Pass ctx &

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 16 15:48:06 PST 2024


Author: Fangrui Song
Date: 2024-11-16T15:48:01-08:00
New Revision: 7d13775486b5e83959b0d96137176f366c41e13a

URL: https://github.com/llvm/llvm-project/commit/7d13775486b5e83959b0d96137176f366c41e13a
DIFF: https://github.com/llvm/llvm-project/commit/7d13775486b5e83959b0d96137176f366c41e13a.diff

LOG: [ELF] Pass ctx &

Added: 
    

Modified: 
    lld/ELF/DriverUtils.cpp
    lld/ELF/SyntheticSections.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp
index 2ea5210997d07e..8fbf7bf69c0896 100644
--- a/lld/ELF/DriverUtils.cpp
+++ b/lld/ELF/DriverUtils.cpp
@@ -89,7 +89,8 @@ static cl::TokenizerCallback getQuotingStyle(Ctx &ctx,
 // `--plugin-opt <foo>` is converted to `--plugin-opt=<foo>`. This is a
 // bit hacky, but looks like it is still better than handling --plugin-opt
 // options by hand.
-static void concatLTOPluginOptions(SmallVectorImpl<const char *> &args) {
+static void concatLTOPluginOptions(Ctx &ctx,
+                                   SmallVectorImpl<const char *> &args) {
   SmallVector<const char *, 256> v;
   for (size_t i = 0, e = args.size(); i != e; ++i) {
     StringRef s = args[i];
@@ -118,7 +119,7 @@ opt::InputArgList ELFOptTable::parse(Ctx &ctx, ArrayRef<const char *> argv) {
   // Expand response files (arguments in the form of @<filename>)
   // and then parse the argument again.
   cl::ExpandResponseFiles(saver(ctx), getQuotingStyle(ctx, args), vec);
-  concatLTOPluginOptions(vec);
+  concatLTOPluginOptions(ctx, vec);
   args = this->ParseArgs(vec, missingIndex, missingCount);
 
   handleColorDiagnostics(ctx, args);

diff  --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 814835449fdff1..8a5aa9502f0129 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -71,7 +71,7 @@ static void writeUint(Ctx &ctx, uint8_t *buf, uint64_t val) {
 }
 
 // Returns an LLD version string.
-static ArrayRef<uint8_t> getVersion() {
+static ArrayRef<uint8_t> getVersion(Ctx &ctx) {
   // Check LLD_VERSION first for ease of testing.
   // You can get consistent output by using the environment variable.
   // This is only for testing.
@@ -88,8 +88,9 @@ static ArrayRef<uint8_t> getVersion() {
 // by "readelf --string-dump .comment <file>".
 // The returned object is a mergeable string section.
 MergeInputSection *elf::createCommentSection(Ctx &ctx) {
-  auto *sec = make<MergeInputSection>(
-      ctx, SHF_MERGE | SHF_STRINGS, SHT_PROGBITS, 1, getVersion(), ".comment");
+  auto *sec =
+      make<MergeInputSection>(ctx, SHF_MERGE | SHF_STRINGS, SHT_PROGBITS, 1,
+                              getVersion(ctx), ".comment");
   sec->splitIntoPieces();
   return sec;
 }


        


More information about the llvm-commits mailing list