[LLD] [MinGW] Implement --disable-reloc-section, mapped to /fixed
Since binutils 2.36, GNU ld defaults to emitting base relocations, and that version added the new option --disable-reloc-section to disable it. Differential Revision: https://reviews.llvm.org/D127478
This commit is contained in:
parent
b209b9e11c
commit
aefa11166f
|
@ -323,6 +323,9 @@ bool mingw::link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
|
||||||
if (args.hasFlag(OPT_disable_tsaware, OPT_tsaware, false))
|
if (args.hasFlag(OPT_disable_tsaware, OPT_tsaware, false))
|
||||||
add("-tsaware:no");
|
add("-tsaware:no");
|
||||||
|
|
||||||
|
if (args.hasFlag(OPT_disable_reloc_section, OPT_enable_reloc_section, false))
|
||||||
|
add("-fixed");
|
||||||
|
|
||||||
if (args.hasFlag(OPT_no_insert_timestamp, OPT_insert_timestamp, false))
|
if (args.hasFlag(OPT_no_insert_timestamp, OPT_insert_timestamp, false))
|
||||||
add("-timestamp:0");
|
add("-timestamp:0");
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,11 @@ multiclass B_disable<string name, string help1, string help2> {
|
||||||
def disable_ # NAME: Flag<["--", "-"], "disable-" # name>, HelpText<help2>;
|
def disable_ # NAME: Flag<["--", "-"], "disable-" # name>, HelpText<help2>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
multiclass B_enable_disable<string name, string help1, string help2> {
|
||||||
|
def enable_ # NAME: Flag<["--", "-"], "enable-" # name>, HelpText<help1>;
|
||||||
|
def disable_ # NAME: Flag<["--", "-"], "disable-" # name>, HelpText<help2>;
|
||||||
|
}
|
||||||
|
|
||||||
def L: JoinedOrSeparate<["-"], "L">, MetaVarName<"<dir>">,
|
def L: JoinedOrSeparate<["-"], "L">, MetaVarName<"<dir>">,
|
||||||
HelpText<"Add a directory to the library search path">;
|
HelpText<"Add a directory to the library search path">;
|
||||||
defm allow_multiple_definition: B<"allow-multiple-definition",
|
defm allow_multiple_definition: B<"allow-multiple-definition",
|
||||||
|
@ -98,6 +103,8 @@ def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,
|
||||||
HelpText<"Path to file to write output">;
|
HelpText<"Path to file to write output">;
|
||||||
defm out_implib: Eq<"out-implib", "Import library name">;
|
defm out_implib: Eq<"out-implib", "Import library name">;
|
||||||
defm output_def: Eq<"output-def", "Output def file">;
|
defm output_def: Eq<"output-def", "Output def file">;
|
||||||
|
defm reloc_section: B_enable_disable<"reloc-section",
|
||||||
|
"Enable base relocations", "Disable base relocations">;
|
||||||
defm section_alignment: Eq<"section-alignment", "Set section alignment">;
|
defm section_alignment: Eq<"section-alignment", "Set section alignment">;
|
||||||
def shared: F<"shared">, HelpText<"Build a shared object">;
|
def shared: F<"shared">, HelpText<"Build a shared object">;
|
||||||
defm subs: Eq<"subsystem", "Specify subsystem">;
|
defm subs: Eq<"subsystem", "Specify subsystem">;
|
||||||
|
|
|
@ -181,6 +181,13 @@ RUN: ld.lld -### -m i386pe foo.o -disable-tsaware -tsaware 2>&1 | FileCheck -che
|
||||||
RUN: ld.lld -### -m i386pe foo.o --disable-tsaware --tsaware 2>&1 | FileCheck -check-prefix NO-DISABLE-TSAWARE %s
|
RUN: ld.lld -### -m i386pe foo.o --disable-tsaware --tsaware 2>&1 | FileCheck -check-prefix NO-DISABLE-TSAWARE %s
|
||||||
NO-DISABLE-TSAWARE-NOT: -tsaware:no
|
NO-DISABLE-TSAWARE-NOT: -tsaware:no
|
||||||
|
|
||||||
|
RUN: ld.lld -### -m i386pe foo.o -enable-reloc-section -disable-reloc-section 2>&1 | FileCheck -check-prefix DISABLE-RELOC-SECTION %s
|
||||||
|
RUN: ld.lld -### -m i386pe foo.o --enable-reloc-section --disable-reloc-section 2>&1 | FileCheck -check-prefix DISABLE-RELOC-SECTION %s
|
||||||
|
DISABLE-RELOC-SECTION: -fixed{{ }}
|
||||||
|
RUN: ld.lld -### -m i386pe foo.o -disable-reloc-section -enable-reloc-section 2>&1 | FileCheck -check-prefix NO-DISABLE-RELOC-SECTION %s
|
||||||
|
RUN: ld.lld -### -m i386pe foo.o --disable-reloc-section --enable-reloc-section 2>&1 | FileCheck -check-prefix NO-DISABLE-RELOC-SECTION %s
|
||||||
|
NO-DISABLE-RELOC-SECTION-NOT: -fixed
|
||||||
|
|
||||||
RUN: ld.lld -### -m i386pep foo.o --image-base 0x1230000 2>&1 | FileCheck -check-prefix IMAGE-BASE %s
|
RUN: ld.lld -### -m i386pep foo.o --image-base 0x1230000 2>&1 | FileCheck -check-prefix IMAGE-BASE %s
|
||||||
RUN: ld.lld -### -m i386pep foo.o -image-base 0x1230000 2>&1 | FileCheck -check-prefix IMAGE-BASE %s
|
RUN: ld.lld -### -m i386pep foo.o -image-base 0x1230000 2>&1 | FileCheck -check-prefix IMAGE-BASE %s
|
||||||
RUN: ld.lld -### -m i386pep foo.o --image-base=0x1230000 2>&1 | FileCheck -check-prefix IMAGE-BASE %s
|
RUN: ld.lld -### -m i386pep foo.o --image-base=0x1230000 2>&1 | FileCheck -check-prefix IMAGE-BASE %s
|
||||||
|
|
Loading…
Reference in New Issue