Skip to content

Commit 8bded6c

Browse files
authored
Fixed a few bugs of lld (#4)
1 parent df0dade commit 8bded6c

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lld/ELF/Driver.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,9 @@ void LinkerDriver::addFile(StringRef path, bool withLOption) {
315315

316316
// Add a given library by searching it from input search paths.
317317
void LinkerDriver::addLibrary(StringRef name) {
318-
if (std::optional<std::string> path = searchLibrary(name))
318+
if (name.size() > 0 && name[0] == '/')
319+
addFile(saver().save(name), /*withLOption=*/true);
320+
else if (std::optional<std::string> path = searchLibrary(name))
319321
addFile(saver().save(*path), /*withLOption=*/true);
320322
else
321323
error("unable to find library -l" + name, ErrorTag::LibNotFound, {name});
@@ -2252,8 +2254,13 @@ static std::vector<WrappedSymbol> addWrappedSymbols(opt::InputArgList &args) {
22522254
if (!sym)
22532255
continue;
22542256

2255-
Symbol *wrap =
2256-
addUnusedUndefined(saver().save("__wrap_" + name), sym->binding);
2257+
// If __wrap_ is lazy force load it - its sym->binding might be
2258+
// weak, in which case the wrapped symbol will not get loaded.
2259+
StringRef wrapName = saver().save("__wrap_" + name);
2260+
Symbol *existingWrap = symtab.find(wrapName);
2261+
if (existingWrap && existingWrap->isLazy())
2262+
existingWrap->extract();
2263+
Symbol *wrap = addUnusedUndefined(wrapName, sym->binding);
22572264

22582265
// If __real_ is referenced, pull in the symbol if it is lazy. Do this after
22592266
// processing __wrap_ as that may have referenced __real_.

lld/ELF/Options.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,8 @@ def: F<"stats">;
714714
def: F<"warn-execstack">;
715715
def: F<"warn-once">;
716716
def: F<"warn-shared-textrel">;
717+
def: F<"no-keep-files-mapped">;
718+
def: F<"no-warn-search-mismatch">;
717719
def: JoinedOrSeparate<["-"], "G">;
718720

719721
// Hidden option used for testing MIPS multi-GOT implementation.

0 commit comments

Comments
 (0)