Add -print-map and -M options.

llvm-svn: 292046
This commit is contained in:
Rui Ueyama 2017-01-15 02:52:34 +00:00
parent 9c6cdc2022
commit 1705f99c77
3 changed files with 10 additions and 2 deletions

View File

@ -543,6 +543,9 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
Config->Target2 = getTarget2Option(Args);
Config->UnresolvedSymbols = getUnresolvedSymbolOption(Args);
if (Args.hasArg(OPT_print_map))
Config->MapFile = "-";
// --omagic is an option to create old-fashioned executables in which
// .text segments are writable. Today, the option is still in use to
// create special-purpose programs such as boot loaders. It doesn't

View File

@ -174,6 +174,9 @@ def pie: F<"pie">, HelpText<"Create a position independent executable">;
def print_gc_sections: F<"print-gc-sections">,
HelpText<"List removed unused sections">;
def print_map: F<"print-map">,
HelpText<"Print a link map to the standard output">;
def reproduce: S<"reproduce">,
HelpText<"Dump linker invocation and input files for debugging">;
@ -276,6 +279,7 @@ def alias_omagic: Flag<["-"], "N">, Alias<omagic>;
def alias_o_output: Joined<["--"], "output=">, Alias<o>;
def alias_o_output2 : Separate<["--"], "output">, Alias<o>;
def alias_pie_pic_executable: F<"pic-executable">, Alias<pie>;
def alias_print_map_M: Flag<["-"], "M">, Alias<print_map>;
def alias_relocatable_r: Flag<["-"], "r">, Alias<relocatable>;
def alias_retain_symbols_file: S<"retain-symbols-file">, Alias<retain_symbols_file>;
def alias_rpath_R: JoinedOrSeparate<["-"], "R">, Alias<rpath>;
@ -327,7 +331,6 @@ def define_common: F<"define-common">;
def demangle: F<"demangle">;
def detect_odr_violations: F<"detect-odr-violations">;
def g: Flag<["-"], "g">;
def M: Flag<["-"], "M">;
def no_add_needed: F<"no-add-needed">;
def no_allow_shlib_undefined: F<"no-allow-shlib-undefined">;
def no_copy_dt_needed_entries: F<"no-copy-dt-needed-entries">,

View File

@ -6,7 +6,9 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/map-file4.s -o %t4.o
// RUN: rm -f %t4.a
// RUN: llvm-ar rc %t4.a %t4.o
// RUN: ld.lld %t1.o %t2.o %t3.o %t4.a -o %t -Map=%t.map
// RUN: ld.lld %t1.o %t2.o %t3.o %t4.a -o %t -M | FileCheck %s
// RUN: ld.lld %t1.o %t2.o %t3.o %t4.a -o %t -print-map | FileCheck %s
// RUN: ld.lld %t1.o %t2.o %t3.o %t4.a -o %t -Map=%t.map
// RUN: FileCheck %s < %t.map
.global _start