Skip to content

Commit fdd6ed8

Browse files
committed
[LLD] Rename lld port driver entry function to a consistent name
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
1 parent 93fd523 commit fdd6ed8

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

lld/COFF/Driver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ bool link(ArrayRef<const char *> args, bool canExitEarly, raw_ostream &stdoutOS,
9191
symtab = make<SymbolTable>();
9292
driver = make<LinkerDriver>();
9393

94-
driver->link(args);
94+
driver->linkerMain(args);
9595

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

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

12031203
// Needed for LTO.

lld/COFF/Driver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class ArgParser {
7878

7979
class LinkerDriver {
8080
public:
81-
void link(llvm::ArrayRef<const char *> args);
81+
void linkerMain(llvm::ArrayRef<const char *> args);
8282

8383
// Used by the resolver to parse .drectve section contents.
8484
void parseDirectives(InputFile *file);

lld/ELF/Driver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ bool elf::link(ArrayRef<const char *> args, bool canExitEarly,
119119

120120
config->progName = args[0];
121121

122-
driver->main(args);
122+
driver->linkerMain(args);
123123

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

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

lld/ELF/Driver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ extern class LinkerDriver *driver;
2626

2727
class LinkerDriver {
2828
public:
29-
void main(ArrayRef<const char *> args);
29+
void linkerMain(ArrayRef<const char *> args);
3030
void addFile(StringRef path, bool withLOption);
3131
void addLibrary(StringRef name);
3232

lld/wasm/Driver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static void initLLVM() {
6767

6868
class LinkerDriver {
6969
public:
70-
void link(ArrayRef<const char *> argsArr);
70+
void linkerMain(ArrayRef<const char *> argsArr);
7171

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

100100
initLLVM();
101-
LinkerDriver().link(args);
101+
LinkerDriver().linkerMain(args);
102102

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

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

0 commit comments

Comments
 (0)