@@ -281,7 +281,7 @@ bool LinkerDriver::tryAddFatLTOFile(MemoryBufferRef mb, StringRef archiveName,
281281void LinkerDriver::addFile (StringRef path, bool withLOption) {
282282 using namespace sys ::fs;
283283
284- std::optional<MemoryBufferRef> buffer = readFile (path);
284+ std::optional<MemoryBufferRef> buffer = readFile (ctx, path);
285285 if (!buffer)
286286 return ;
287287 MemoryBufferRef mbref = *buffer;
@@ -352,7 +352,7 @@ void LinkerDriver::addFile(StringRef path, bool withLOption) {
352352 // cannot be stored into SharedFile::soName.
353353 path = mbref.getBufferIdentifier ();
354354 auto *f =
355- make<SharedFile>(mbref, withLOption ? path::filename (path) : path);
355+ make<SharedFile>(ctx, mbref, withLOption ? path::filename (path) : path);
356356 f->init ();
357357 files.push_back (f);
358358 return ;
@@ -371,7 +371,7 @@ void LinkerDriver::addFile(StringRef path, bool withLOption) {
371371
372372// Add a given library by searching it from input search paths.
373373void LinkerDriver::addLibrary (StringRef name) {
374- if (std::optional<std::string> path = searchLibrary (name))
374+ if (std::optional<std::string> path = searchLibrary (ctx, name))
375375 addFile (saver ().save (*path), /* withLOption=*/ true );
376376 else
377377 error (" unable to find library -l" + name, ErrorTag::LibNotFound, {name});
@@ -665,7 +665,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
665665 ctx.tar ->append (" version.txt" , getLLDVersion () + " \n " );
666666 StringRef ltoSampleProfile = args.getLastArgValue (OPT_lto_sample_profile);
667667 if (!ltoSampleProfile.empty ())
668- readFile (ltoSampleProfile);
668+ readFile (ctx, ltoSampleProfile);
669669 } else {
670670 error (" --reproduce: " + toString (errOrWriter.takeError ()));
671671 }
@@ -1542,7 +1542,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
15421542 }
15431543 for (opt::Arg *arg : args.filtered (OPT_remap_inputs_file)) {
15441544 StringRef filename (arg->getValue ());
1545- std::optional<MemoryBufferRef> buffer = readFile (filename);
1545+ std::optional<MemoryBufferRef> buffer = readFile (ctx, filename);
15461546 if (!buffer)
15471547 continue ;
15481548 // Parse 'from-glob=to-file' lines, ignoring #-led comments.
@@ -1761,7 +1761,8 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
17611761 if (args.hasArg (OPT_call_graph_ordering_file))
17621762 error (" --symbol-ordering-file and --call-graph-order-file "
17631763 " may not be used together" );
1764- if (std::optional<MemoryBufferRef> buffer = readFile (arg->getValue ())) {
1764+ if (std::optional<MemoryBufferRef> buffer =
1765+ readFile (ctx, arg->getValue ())) {
17651766 ctx.arg .symbolOrderingFile = getSymbolOrderingFile (ctx, *buffer);
17661767 // Also need to disable CallGraphProfileSort to prevent
17671768 // LLD order symbols with CGProfile
@@ -1780,7 +1781,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
17801781 if (auto *arg = args.getLastArg (OPT_retain_symbols_file)) {
17811782 ctx.arg .versionDefinitions [VER_NDX_LOCAL].nonLocalPatterns .push_back (
17821783 {" *" , /* isExternCpp=*/ false , /* hasWildcard=*/ true });
1783- if (std::optional<MemoryBufferRef> buffer = readFile (arg->getValue ()))
1784+ if (std::optional<MemoryBufferRef> buffer = readFile (ctx, arg->getValue ()))
17841785 for (StringRef s : args::getLines (*buffer))
17851786 ctx.arg .versionDefinitions [VER_NDX_GLOBAL].nonLocalPatterns .push_back (
17861787 {s, /* isExternCpp=*/ false , /* hasWildcard=*/ false });
@@ -1812,12 +1813,12 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
18121813 ctx.arg .bsymbolic == BsymbolicKind::All || args.hasArg (OPT_dynamic_list);
18131814 for (auto *arg :
18141815 args.filtered (OPT_dynamic_list, OPT_export_dynamic_symbol_list))
1815- if (std::optional<MemoryBufferRef> buffer = readFile (arg->getValue ()))
1816+ if (std::optional<MemoryBufferRef> buffer = readFile (ctx, arg->getValue ()))
18161817 readDynamicList (ctx, *buffer);
18171818
18181819 for (auto *arg : args.filtered (OPT_version_script))
1819- if (std::optional<std::string> path = searchScript (arg->getValue ())) {
1820- if (std::optional<MemoryBufferRef> buffer = readFile (*path))
1820+ if (std::optional<std::string> path = searchScript (ctx, arg->getValue ())) {
1821+ if (std::optional<MemoryBufferRef> buffer = readFile (ctx, *path))
18211822 readVersionScript (ctx, *buffer);
18221823 } else {
18231824 error (Twine (" cannot find version script " ) + arg->getValue ());
@@ -1951,8 +1952,9 @@ void LinkerDriver::createFiles(opt::InputArgList &args) {
19511952 }
19521953 case OPT_script:
19531954 case OPT_default_script:
1954- if (std::optional<std::string> path = searchScript (arg->getValue ())) {
1955- if (std::optional<MemoryBufferRef> mb = readFile (*path)) {
1955+ if (std::optional<std::string> path =
1956+ searchScript (ctx, arg->getValue ())) {
1957+ if (std::optional<MemoryBufferRef> mb = readFile (ctx, *path)) {
19561958 if (arg->getOption ().matches (OPT_default_script)) {
19571959 defaultScript = mb;
19581960 } else {
@@ -1989,15 +1991,16 @@ void LinkerDriver::createFiles(opt::InputArgList &args) {
19891991 inWholeArchive = false ;
19901992 break ;
19911993 case OPT_just_symbols:
1992- if (std::optional<MemoryBufferRef> mb = readFile (arg->getValue ())) {
1994+ if (std::optional<MemoryBufferRef> mb = readFile (ctx, arg->getValue ())) {
19931995 files.push_back (createObjFile (*mb));
19941996 files.back ()->justSymbols = true ;
19951997 }
19961998 break ;
19971999 case OPT_in_implib:
19982000 if (armCmseImpLib)
19992001 error (" multiple CMSE import libraries not supported" );
2000- else if (std::optional<MemoryBufferRef> mb = readFile (arg->getValue ()))
2002+ else if (std::optional<MemoryBufferRef> mb =
2003+ readFile (ctx, arg->getValue ()))
20012004 armCmseImpLib = createObjFile (*mb);
20022005 break ;
20032006 case OPT_start_group:
@@ -3208,7 +3211,8 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
32083211 // Read the callgraph now that we know what was gced or icfed
32093212 if (ctx.arg .callGraphProfileSort != CGProfileSortKind::None) {
32103213 if (auto *arg = args.getLastArg (OPT_call_graph_ordering_file))
3211- if (std::optional<MemoryBufferRef> buffer = readFile (arg->getValue ()))
3214+ if (std::optional<MemoryBufferRef> buffer =
3215+ readFile (ctx, arg->getValue ()))
32123216 readCallGraph (ctx, *buffer);
32133217 readCallGraphsFromObjectFiles<ELFT>(ctx);
32143218 }
0 commit comments