[lld] r292046 - Add -print-map and -M options.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 14 18:52:34 PST 2017


Author: ruiu
Date: Sat Jan 14 20:52:34 2017
New Revision: 292046

URL: http://llvm.org/viewvc/llvm-project?rev=292046&view=rev
Log:
Add -print-map and -M options.

Modified:
    lld/trunk/ELF/Driver.cpp
    lld/trunk/ELF/Options.td
    lld/trunk/test/ELF/map-file.s

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=292046&r1=292045&r2=292046&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Sat Jan 14 20:52:34 2017
@@ -543,6 +543,9 @@ void LinkerDriver::readConfigs(opt::Inpu
   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

Modified: lld/trunk/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=292046&r1=292045&r2=292046&view=diff
==============================================================================
--- lld/trunk/ELF/Options.td (original)
+++ lld/trunk/ELF/Options.td Sat Jan 14 20:52:34 2017
@@ -174,6 +174,9 @@ def pie: F<"pie">, HelpText<"Create a po
 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">, Alia
 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">,

Modified: lld/trunk/test/ELF/map-file.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/map-file.s?rev=292046&r1=292045&r2=292046&view=diff
==============================================================================
--- lld/trunk/test/ELF/map-file.s (original)
+++ lld/trunk/test/ELF/map-file.s Sat Jan 14 20:52:34 2017
@@ -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




More information about the llvm-commits mailing list