Skip to content

Commit

Permalink
[LLD] [MinGW] Implement the --file-alignment and --section-alignment …
Browse files Browse the repository at this point in the history
…options

Differential Revision: https://reviews.llvm.org/D83720
  • Loading branch information
mstorsjo committed Jul 15, 2020
1 parent 4f763b2 commit 92f7bd3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lld/MinGW/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ bool mingw::link(ArrayRef<const char *> argsArr, bool canExitEarly,
add("-reproduce:" + StringRef(a->getValue()));
if (auto *a = args.getLastArg(OPT_thinlto_cache_dir))
add("-lldltocache:" + StringRef(a->getValue()));
if (auto *a = args.getLastArg(OPT_file_alignment))
add("-filealign:" + StringRef(a->getValue()));
if (auto *a = args.getLastArg(OPT_section_alignment))
add("-align:" + StringRef(a->getValue()));

if (auto *a = args.getLastArg(OPT_o))
add("-out:" + StringRef(a->getValue()));
Expand Down
2 changes: 2 additions & 0 deletions lld/MinGW/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def exclude_all_symbols: F<"exclude-all-symbols">,
HelpText<"Don't automatically export any symbols">;
def export_all_symbols: F<"export-all-symbols">,
HelpText<"Export all symbols even if a def file or dllexport attributes are used">;
defm file_alignment: Eq<"file-alignment", "Set file alignment">;
def gc_sections: F<"gc-sections">, HelpText<"Remove unused sections">;
def help: F<"help">, HelpText<"Print option help">;
def icf: J<"icf=">, HelpText<"Identical code folding">;
Expand Down Expand Up @@ -64,6 +65,7 @@ def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,
HelpText<"Path to file to write output">;
defm out_implib: Eq<"out-implib", "Import library name">;
defm output_def: Eq<"output-def", "Output def file">;
defm section_alignment: Eq<"section-alignment", "Set section alignment">;
def shared: F<"shared">, HelpText<"Build a shared object">;
defm subs: Eq<"subsystem", "Specify subsystem">;
def stack: S<"stack">;
Expand Down
12 changes: 12 additions & 0 deletions lld/test/MinGW/driver.test
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,15 @@ DISABLE_RUNTIME_PSEUDO_RELOC: -runtime-pseudo-reloc:no

RUN: ld.lld -### foo.o -m i386pe --thinlto-cache-dir=_foo | FileCheck -check-prefix=THINLTO_CACHEDIR %s
THINLTO_CACHEDIR: -lldltocache:_foo

RUN: ld.lld -### -m i386pep foo.o --file-alignment 0x1000 | FileCheck -check-prefix FILEALIGN %s
RUN: ld.lld -### -m i386pep foo.o -file-alignment 0x1000 | FileCheck -check-prefix FILEALIGN %s
RUN: ld.lld -### -m i386pep foo.o --file-alignment=0x1000 | FileCheck -check-prefix FILEALIGN %s
RUN: ld.lld -### -m i386pep foo.o -file-alignment=0x1000 | FileCheck -check-prefix FILEALIGN %s
FILEALIGN: -filealign:0x1000

RUN: ld.lld -### -m i386pep foo.o --section-alignment 0x2000 | FileCheck -check-prefix ALIGN %s
RUN: ld.lld -### -m i386pep foo.o -section-alignment 0x2000 | FileCheck -check-prefix ALIGN %s
RUN: ld.lld -### -m i386pep foo.o --section-alignment=0x2000 | FileCheck -check-prefix ALIGN %s
RUN: ld.lld -### -m i386pep foo.o -section-alignment=0x2000 | FileCheck -check-prefix ALIGN %s
ALIGN: -align:0x2000

0 comments on commit 92f7bd3

Please sign in to comment.