[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 03:59:58 PST 2016
hans updated this revision to Diff 80839.
hans marked an inline comment as done.
hans added a comment.
Addressing comments.
https://reviews.llvm.org/D27595
Files:
COFF/Driver.cpp
COFF/Options.td
test/COFF/lldmap.test
Index: test/COFF/lldmap.test
===================================================================
--- test/COFF/lldmap.test
+++ 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: COFF/Options.td
===================================================================
--- COFF/Options.td
+++ 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.
Index: COFF/Driver.cpp
===================================================================
--- COFF/Driver.cpp
+++ 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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27595.80839.patch
Type: text/x-patch
Size: 2473 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161209/48b042df/attachment.bin>
More information about the llvm-commits
mailing list