@@ -281,7 +281,7 @@ bool LinkerDriver::tryAddFatLTOFile(MemoryBufferRef mb, StringRef archiveName,
281
281
void LinkerDriver::addFile (StringRef path, bool withLOption) {
282
282
using namespace sys ::fs;
283
283
284
- std::optional<MemoryBufferRef> buffer = readFile (path);
284
+ std::optional<MemoryBufferRef> buffer = readFile (ctx, path);
285
285
if (!buffer)
286
286
return ;
287
287
MemoryBufferRef mbref = *buffer;
@@ -352,7 +352,7 @@ void LinkerDriver::addFile(StringRef path, bool withLOption) {
352
352
// cannot be stored into SharedFile::soName.
353
353
path = mbref.getBufferIdentifier ();
354
354
auto *f =
355
- make<SharedFile>(mbref, withLOption ? path::filename (path) : path);
355
+ make<SharedFile>(ctx, mbref, withLOption ? path::filename (path) : path);
356
356
f->init ();
357
357
files.push_back (f);
358
358
return ;
@@ -371,7 +371,7 @@ void LinkerDriver::addFile(StringRef path, bool withLOption) {
371
371
372
372
// Add a given library by searching it from input search paths.
373
373
void LinkerDriver::addLibrary (StringRef name) {
374
- if (std::optional<std::string> path = searchLibrary (name))
374
+ if (std::optional<std::string> path = searchLibrary (ctx, name))
375
375
addFile (saver ().save (*path), /* withLOption=*/ true );
376
376
else
377
377
error (" unable to find library -l" + name, ErrorTag::LibNotFound, {name});
@@ -665,7 +665,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
665
665
ctx.tar ->append (" version.txt" , getLLDVersion () + " \n " );
666
666
StringRef ltoSampleProfile = args.getLastArgValue (OPT_lto_sample_profile);
667
667
if (!ltoSampleProfile.empty ())
668
- readFile (ltoSampleProfile);
668
+ readFile (ctx, ltoSampleProfile);
669
669
} else {
670
670
error (" --reproduce: " + toString (errOrWriter.takeError ()));
671
671
}
@@ -1542,7 +1542,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
1542
1542
}
1543
1543
for (opt::Arg *arg : args.filtered (OPT_remap_inputs_file)) {
1544
1544
StringRef filename (arg->getValue ());
1545
- std::optional<MemoryBufferRef> buffer = readFile (filename);
1545
+ std::optional<MemoryBufferRef> buffer = readFile (ctx, filename);
1546
1546
if (!buffer)
1547
1547
continue ;
1548
1548
// Parse 'from-glob=to-file' lines, ignoring #-led comments.
@@ -1761,7 +1761,8 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
1761
1761
if (args.hasArg (OPT_call_graph_ordering_file))
1762
1762
error (" --symbol-ordering-file and --call-graph-order-file "
1763
1763
" 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 ())) {
1765
1766
ctx.arg .symbolOrderingFile = getSymbolOrderingFile (ctx, *buffer);
1766
1767
// Also need to disable CallGraphProfileSort to prevent
1767
1768
// LLD order symbols with CGProfile
@@ -1780,7 +1781,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
1780
1781
if (auto *arg = args.getLastArg (OPT_retain_symbols_file)) {
1781
1782
ctx.arg .versionDefinitions [VER_NDX_LOCAL].nonLocalPatterns .push_back (
1782
1783
{" *" , /* isExternCpp=*/ false , /* hasWildcard=*/ true });
1783
- if (std::optional<MemoryBufferRef> buffer = readFile (arg->getValue ()))
1784
+ if (std::optional<MemoryBufferRef> buffer = readFile (ctx, arg->getValue ()))
1784
1785
for (StringRef s : args::getLines (*buffer))
1785
1786
ctx.arg .versionDefinitions [VER_NDX_GLOBAL].nonLocalPatterns .push_back (
1786
1787
{s, /* isExternCpp=*/ false , /* hasWildcard=*/ false });
@@ -1812,12 +1813,12 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
1812
1813
ctx.arg .bsymbolic == BsymbolicKind::All || args.hasArg (OPT_dynamic_list);
1813
1814
for (auto *arg :
1814
1815
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 ()))
1816
1817
readDynamicList (ctx, *buffer);
1817
1818
1818
1819
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))
1821
1822
readVersionScript (ctx, *buffer);
1822
1823
} else {
1823
1824
error (Twine (" cannot find version script " ) + arg->getValue ());
@@ -1951,8 +1952,9 @@ void LinkerDriver::createFiles(opt::InputArgList &args) {
1951
1952
}
1952
1953
case OPT_script:
1953
1954
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)) {
1956
1958
if (arg->getOption ().matches (OPT_default_script)) {
1957
1959
defaultScript = mb;
1958
1960
} else {
@@ -1989,15 +1991,16 @@ void LinkerDriver::createFiles(opt::InputArgList &args) {
1989
1991
inWholeArchive = false ;
1990
1992
break ;
1991
1993
case OPT_just_symbols:
1992
- if (std::optional<MemoryBufferRef> mb = readFile (arg->getValue ())) {
1994
+ if (std::optional<MemoryBufferRef> mb = readFile (ctx, arg->getValue ())) {
1993
1995
files.push_back (createObjFile (*mb));
1994
1996
files.back ()->justSymbols = true ;
1995
1997
}
1996
1998
break ;
1997
1999
case OPT_in_implib:
1998
2000
if (armCmseImpLib)
1999
2001
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 ()))
2001
2004
armCmseImpLib = createObjFile (*mb);
2002
2005
break ;
2003
2006
case OPT_start_group:
@@ -3208,7 +3211,8 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
3208
3211
// Read the callgraph now that we know what was gced or icfed
3209
3212
if (ctx.arg .callGraphProfileSort != CGProfileSortKind::None) {
3210
3213
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 ()))
3212
3216
readCallGraph (ctx, *buffer);
3213
3217
readCallGraphsFromObjectFiles<ELFT>(ctx);
3214
3218
}
0 commit comments