[PATCH] D83720: [LLD] [MinGW] Implement the --file-alignment and --section-alignment options
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 13 14:14:43 PDT 2020
mstorsjo created this revision.
mstorsjo added reviewers: ruiu, amccarth.
Herald added a subscriber: dang.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D83720
Files:
lld/MinGW/Driver.cpp
lld/MinGW/Options.td
lld/test/MinGW/driver.test
Index: lld/test/MinGW/driver.test
===================================================================
--- lld/test/MinGW/driver.test
+++ lld/test/MinGW/driver.test
@@ -244,3 +244,15 @@
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
Index: lld/MinGW/Options.td
===================================================================
--- lld/MinGW/Options.td
+++ lld/MinGW/Options.td
@@ -34,6 +34,7 @@
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">;
@@ -64,6 +65,7 @@
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">;
Index: lld/MinGW/Driver.cpp
===================================================================
--- lld/MinGW/Driver.cpp
+++ lld/MinGW/Driver.cpp
@@ -251,6 +251,10 @@
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()));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83720.277567.patch
Type: text/x-patch
Size: 2786 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200713/2a20c07e/attachment.bin>
More information about the llvm-commits
mailing list