Skip to content

Commit e916868

Browse files
committed
[MinGW] Implement support for the --image-base option
Differential Revision: https://reviews.llvm.org/D40018 llvm-svn: 318282
1 parent 094d8c0 commit e916868

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

lld/MinGW/Driver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ bool mingw::link(ArrayRef<const char *> ArgsArr, raw_ostream &Diag) {
138138
Add("-stack:" + StringRef(A->getValue()));
139139
if (auto *A = Args.getLastArg(OPT_output_def))
140140
Add("-output-def:" + StringRef(A->getValue()));
141+
if (auto *A = Args.getLastArg(OPT_image_base))
142+
Add("-base:" + StringRef(A->getValue()));
141143

142144
if (auto *A = Args.getLastArg(OPT_o))
143145
Add("-out:" + StringRef(A->getValue()));

lld/MinGW/Options.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def entry: S<"entry">, MetaVarName<"<entry>">,
1111
HelpText<"Name of entry point symbol">;
1212
def export_all_symbols: F<"export-all-symbols">,
1313
HelpText<"Export all symbols even if a def file or dllexport attributes are used">;
14+
def image_base: S<"image-base">, HelpText<"Base address of the program">;
1415
def l: JoinedOrSeparate<["-"], "l">, MetaVarName<"<libName>">,
1516
HelpText<"Root name of library to use">;
1617
def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;

lld/test/MinGW/driver.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,7 @@ DEFAULT-DISABLE-FLAGS: -dynamicbase:no
101101
RUN: ld.lld -### -m i386pep foo.o --dynamicbase | FileCheck -check-prefix DYNAMICBASE %s
102102
RUN: ld.lld -### -m i386pep foo.o -dynamicbase | FileCheck -check-prefix DYNAMICBASE %s
103103
DYNAMICBASE: -dynamicbase -
104+
105+
RUN: ld.lld -### -m i386pep foo.o --image-base 0x1230000 | FileCheck -check-prefix IMAGE-BASE %s
106+
RUN: ld.lld -### -m i386pep foo.o -image-base 0x1230000 | FileCheck -check-prefix IMAGE-BASE %s
107+
IMAGE-BASE: -base:0x1230000

0 commit comments

Comments
 (0)