Skip to content

Commit

Permalink
[LLD] Rename lld port driver entry function to a consistent name
Browse files Browse the repository at this point in the history
Libraries linked to the lld elf library exposes a function named main.
When debugging code linked to such libraries and intending to set a
breakpoint at main, the debugger also sets breakpoint at the main
function at lld elf driver. The possible choice was to rename it to
link but that would again clash with lld::*::link. This patch tries
to consistently rename them to linkerMain.

Differential Revision: https://reviews.llvm.org/D91418
  • Loading branch information
rksharma-yymd committed Dec 18, 2020
1 parent 93fd523 commit fdd6ed8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lld/COFF/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ bool link(ArrayRef<const char *> args, bool canExitEarly, raw_ostream &stdoutOS,
symtab = make<SymbolTable>();
driver = make<LinkerDriver>();

driver->link(args);
driver->linkerMain(args);

// Call exit() if we can to avoid calling destructors.
if (canExitEarly)
Expand Down Expand Up @@ -1197,7 +1197,7 @@ Optional<std::string> getReproduceFile(const opt::InputArgList &args) {
return None;
}

void LinkerDriver::link(ArrayRef<const char *> argsArr) {
void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
ScopedTimer rootTimer(Timer::root());

// Needed for LTO.
Expand Down
2 changes: 1 addition & 1 deletion lld/COFF/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class ArgParser {

class LinkerDriver {
public:
void link(llvm::ArrayRef<const char *> args);
void linkerMain(llvm::ArrayRef<const char *> args);

// Used by the resolver to parse .drectve section contents.
void parseDirectives(InputFile *file);
Expand Down
4 changes: 2 additions & 2 deletions lld/ELF/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ bool elf::link(ArrayRef<const char *> args, bool canExitEarly,

config->progName = args[0];

driver->main(args);
driver->linkerMain(args);

// Exit immediately if we don't need to return to the caller.
// This saves time because the overhead of calling destructors
Expand Down Expand Up @@ -470,7 +470,7 @@ static void checkZOptions(opt::InputArgList &args) {
error("unknown -z value: " + StringRef(arg->getValue()));
}

void LinkerDriver::main(ArrayRef<const char *> argsArr) {
void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
ELFOptTable parser;
opt::InputArgList args = parser.parse(argsArr.slice(1));

Expand Down
2 changes: 1 addition & 1 deletion lld/ELF/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extern class LinkerDriver *driver;

class LinkerDriver {
public:
void main(ArrayRef<const char *> args);
void linkerMain(ArrayRef<const char *> args);
void addFile(StringRef path, bool withLOption);
void addLibrary(StringRef name);

Expand Down
6 changes: 3 additions & 3 deletions lld/wasm/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static void initLLVM() {

class LinkerDriver {
public:
void link(ArrayRef<const char *> argsArr);
void linkerMain(ArrayRef<const char *> argsArr);

private:
void createFiles(opt::InputArgList &args);
Expand Down Expand Up @@ -98,7 +98,7 @@ bool link(ArrayRef<const char *> args, bool canExitEarly, raw_ostream &stdoutOS,
symtab = make<SymbolTable>();

initLLVM();
LinkerDriver().link(args);
LinkerDriver().linkerMain(args);

// Exit immediately if we don't need to return to the caller.
// This saves time because the overhead of calling destructors
Expand Down Expand Up @@ -787,7 +787,7 @@ static void wrapSymbols(ArrayRef<WrappedSymbol> wrapped) {
symtab->wrap(w.sym, w.real, w.wrap);
}

void LinkerDriver::link(ArrayRef<const char *> argsArr) {
void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
WasmOptTable parser;
opt::InputArgList args = parser.parse(argsArr.slice(1));

Expand Down

0 comments on commit fdd6ed8

Please sign in to comment.