[PATCH] D27595: COFF: Support both /lldmap and /lldmap:<file>
Hans Wennborg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 9 13:04:58 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289271: COFF: Support both /lldmap and /lldmap:<file> (authored by hans).
Changed prior to commit:
https://reviews.llvm.org/D27595?vs=80839&id=80943#toc
Repository:
rL LLVM
https://reviews.llvm.org/D27595
Files:
lld/trunk/COFF/Driver.cpp
lld/trunk/COFF/Options.td
lld/trunk/test/COFF/lldmap.test
Index: lld/trunk/test/COFF/lldmap.test
===================================================================
--- lld/trunk/test/COFF/lldmap.test
+++ lld/trunk/test/COFF/lldmap.test
@@ -1,6 +1,8 @@
# RUN: yaml2obj < %p/Inputs/ret42.yaml > %t.obj
-# RUN: lld-link /out:%t.exe /entry:main /lldmap:%t.map %t.obj
-# RUN: FileCheck %s < %t.map
+# RUN: lld-link /out:%t.exe /entry:main /lldmap:%T/foo.map %t.obj
+# RUN: FileCheck %s < %T/foo.map
+# RUN: lld-link /out:%T/bar.exe /entry:main /lldmap %t.obj
+# RUN: FileCheck %s < %T/bar.map
# CHECK: .obj:
# CHECK-NEXT: 140001000 .text$mn
Index: lld/trunk/COFF/Driver.cpp
===================================================================
--- lld/trunk/COFF/Driver.cpp
+++ lld/trunk/COFF/Driver.cpp
@@ -307,6 +307,18 @@
return DebugTypes;
}
+static std::string getMapFile(const opt::InputArgList &Args) {
+ auto *Arg = Args.getLastArg(OPT_lldmap, OPT_lldmap_file);
+ if (!Arg)
+ return "";
+ if (Arg->getOption().getID() == OPT_lldmap_file)
+ return Arg->getValue();
+
+ assert(Arg->getOption().getID() == OPT_lldmap);
+ StringRef OutFile = Config->OutputFile;
+ return (OutFile.substr(0, OutFile.rfind('.')) + ".map").str();
+}
+
void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
// If the first command line argument is "/lib", link.exe acts like lib.exe.
// We call our own implementation of lib.exe that understands bitcode files.
@@ -763,13 +775,15 @@
// Create a symbol map file containing symbol VAs and their names
// to help debugging.
- if (auto *Arg = Args.getLastArg(OPT_lldmap)) {
+ std::string MapFile = getMapFile(Args);
+ if (!MapFile.empty()) {
std::error_code EC;
- raw_fd_ostream Out(Arg->getValue(), EC, OpenFlags::F_Text);
+ raw_fd_ostream Out(MapFile, EC, OpenFlags::F_Text);
if (EC)
- fatal(EC, "could not create the symbol map");
+ fatal(EC, "could not create the symbol map " + MapFile);
Symtab.printMap(Out);
}
+
// Call exit to avoid calling destructors.
exit(0);
}
Index: lld/trunk/COFF/Options.td
===================================================================
--- lld/trunk/COFF/Options.td
+++ lld/trunk/COFF/Options.td
@@ -95,7 +95,8 @@
// Flags for debugging
def dumppdb : Joined<["/", "-"], "dumppdb">;
-def lldmap : Joined<["/", "-"], "lldmap:">;
+def lldmap : F<"lldmap">;
+def lldmap_file : Joined<["/", "-"], "lldmap:">;
//==============================================================================
// The flags below do nothing. They are defined only for link.exe compatibility.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27595.80943.patch
Type: text/x-patch
Size: 2563 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161209/d15792bf/attachment.bin>
More information about the llvm-commits
mailing list