Skip to content

Commit

Permalink
[LLD][MinGW] Add support for --functionpadmin option (llvm#116511)
Browse files Browse the repository at this point in the history
This introduces the MinGW counterpart of `lld-link`'s `-functionpadmin`.
  • Loading branch information
cjacek authored Nov 18, 2024
1 parent 4c4a413 commit 696c108
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lld/MinGW/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,14 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
add("-build-id");
}

if (auto *a = args.getLastArg(OPT_functionpadmin)) {
StringRef v = a->getValue();
if (v.empty())
add("-functionpadmin");
else
add("-functionpadmin:" + v);
}

if (args.hasFlag(OPT_fatal_warnings, OPT_no_fatal_warnings, false))
add("-WX");
else
Expand Down
3 changes: 3 additions & 0 deletions lld/MinGW/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ defm error_limit:
def build_id: J<"build-id=">, HelpText<"Generate build ID note (pass none to disable)">,
MetaVarName<"<arg>">;
def : F<"build-id">, Alias<build_id>, HelpText<"Alias for --build-id=">;
def functionpadmin: J<"functionpadmin=">, HelpText<"Prepares an image for hotpatching">,
MetaVarName<"<arg>">;
def : F<"functionpadmin">, Alias<functionpadmin>, HelpText<"Alias for --functionpadmin=">;

// Alias
def alias_Bdynamic_call_shared: Flag<["-"], "call_shared">, Alias<Bdynamic>;
Expand Down
7 changes: 7 additions & 0 deletions lld/test/MinGW/driver.test
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,13 @@ RUN: ld.lld -### foo.o -m i386pep --build-id=fast 2>&1 | FileCheck -check-prefix
BUILD_ID_WARN: unsupported build id hashing: fast, using default hashing.
BUILD_ID_WARN: -build-id{{ }}

RUN: ld.lld -### foo.o -m i386pep --functionpadmin= 2>&1 | FileCheck -check-prefix=FUNCTIONPADMIN %s
RUN: ld.lld -### foo.o -m i386pep --functionpadmin 2>&1 | FileCheck -check-prefix=FUNCTIONPADMIN %s
FUNCTIONPADMIN: -functionpadmin{{ }}

RUN: ld.lld -### foo.o -m i386pep --functionpadmin=2 2>&1 | FileCheck -check-prefix=FUNCTIONPADMIN2 %s
FUNCTIONPADMIN2: -functionpadmin:2{{ }}

RUN: ld.lld -### foo.o -m i386pep --build-id=none 2>&1 | FileCheck -check-prefix=NO_BUILD_ID %s
RUN: ld.lld -### foo.o -m i386pep -s 2>&1 | FileCheck -check-prefix=NO_BUILD_ID %s
RUN: ld.lld -### foo.o -m i386pep -S 2>&1 | FileCheck -check-prefix=NO_BUILD_ID %s
Expand Down

0 comments on commit 696c108

Please sign in to comment.