Skip to content

Commit 25cf784

Browse files
committed
Fixed a few bugs of lld (#4)
1 parent 5c412d7 commit 25cf784

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lld/ELF/Driver.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,9 @@ void LinkerDriver::addFile(StringRef path, bool withLOption) {
355355

356356
// Add a given library by searching it from input search paths.
357357
void LinkerDriver::addLibrary(StringRef name) {
358-
if (std::optional<std::string> path = searchLibrary(name))
358+
if (name.size() > 0 && name[0] == '/')
359+
addFile(saver().save(name), /*withLOption=*/true);
360+
else if (std::optional<std::string> path = searchLibrary(name))
359361
addFile(saver().save(*path), /*withLOption=*/true);
360362
else
361363
error("unable to find library -l" + name, ErrorTag::LibNotFound, {name});
@@ -2555,8 +2557,13 @@ static std::vector<WrappedSymbol> addWrappedSymbols(opt::InputArgList &args) {
25552557
if (!sym)
25562558
continue;
25572559

2558-
Symbol *wrap =
2559-
symtab.addUnusedUndefined(saver().save("__wrap_" + name), sym->binding);
2560+
// If __wrap_ is lazy force load it - its sym->binding might be
2561+
// weak, in which case the wrapped symbol will not get loaded.
2562+
StringRef wrapName = saver().save("__wrap_" + name);
2563+
Symbol *existingWrap = symtab.find(wrapName);
2564+
if (existingWrap && existingWrap->isLazy())
2565+
existingWrap->extract();
2566+
Symbol *wrap = symtab.addUnusedUndefined(wrapName, sym->binding);
25602567

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

lld/ELF/Options.td

+2
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,8 @@ def: F<"stats">;
782782
def: F<"warn-execstack">;
783783
def: F<"warn-once">;
784784
def: F<"warn-shared-textrel">;
785+
def: F<"no-keep-files-mapped">;
786+
def: F<"no-warn-search-mismatch">;
785787
def: JoinedOrSeparate<["-"], "G">;
786788

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

0 commit comments

Comments
 (0)