[PATCH] D134559: [LLD][COFF] Generate map file even if no /out flag is present
Pengxuan Zheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 23 13:00:18 PDT 2022
pzheng created this revision.
pzheng added reviewers: rnk, thieta, thakis, hans, mstorsjo, ruiu.
Herald added a project: All.
pzheng requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Currently LLD does not generate a map file if no /out flag (e.g., /out:a.exe) is
present. This is because, in the case when no /out flag is present, the default
output file name has not been set by LLD yet when LLD sets the name of the map
file. This patch fixes this corner case by moving the logic handling map file
flags to a place after the default output file name is set.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D134559
Files:
lld/COFF/Driver.cpp
lld/test/COFF/map.test
Index: lld/test/COFF/map.test
===================================================================
--- lld/test/COFF/map.test
+++ lld/test/COFF/map.test
@@ -8,9 +8,10 @@
# RUN: lld-link /out:%t.exe /entry:main %t.obj %t-dll.lib /map /lldmap:%T/foo-lld.map
# RUN: FileCheck -check-prefix=MAP -strict-whitespace %s < %t.map
# RUN: FileCheck -check-prefix=LLDMAP -strict-whitespace %s < %T/foo-lld.map
-# RUN: lld-link /out:%t.dll /dll %t-dll.obj /export:exportfn1 \
-# RUN: /export:foo=exportfn2 /map /mapinfo:exports
-# RUN: FileCheck -check-prefix=MAPINFO -strict-whitespace %s < %t.map
+# RUN: rm -rf %t && mkdir -p %t && cd %t
+# RUN: cp %t-dll.obj bar.obj
+# RUN: lld-link /dll bar.obj /export:exportfn1 /export:foo=exportfn2 /map /mapinfo:exports
+# RUN: FileCheck -check-prefix=MAPINFO -strict-whitespace %s < bar.map
# MAP: {{.*}}
# MAP-EMPTY:
Index: lld/COFF/Driver.cpp
===================================================================
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -1919,25 +1919,6 @@
if (config->mingw || config->debugDwarf)
config->warnLongSectionNames = false;
- config->lldmapFile = getMapFile(args, OPT_lldmap, OPT_lldmap_file);
- config->mapFile = getMapFile(args, OPT_map, OPT_map_file);
-
- if (config->mapFile != "" && args.hasArg(OPT_map_info)) {
- for (auto *arg : args.filtered(OPT_map_info)) {
- std::string s = StringRef(arg->getValue()).lower();
- if (s == "exports")
- config->mapInfo = true;
- else
- error("unknown option: /mapinfo:" + s);
- }
- }
-
- if (config->lldmapFile != "" && config->lldmapFile == config->mapFile) {
- warn("/lldmap and /map have the same output file '" + config->mapFile +
- "'.\n>>> ignoring /lldmap");
- config->lldmapFile.clear();
- }
-
if (config->incremental && args.hasArg(OPT_profile)) {
warn("ignoring '/incremental' due to '/profile' specification");
config->incremental = false;
@@ -2143,6 +2124,25 @@
return;
}
+ config->lldmapFile = getMapFile(args, OPT_lldmap, OPT_lldmap_file);
+ config->mapFile = getMapFile(args, OPT_map, OPT_map_file);
+
+ if (config->mapFile != "" && args.hasArg(OPT_map_info)) {
+ for (auto *arg : args.filtered(OPT_map_info)) {
+ std::string s = StringRef(arg->getValue()).lower();
+ if (s == "exports")
+ config->mapInfo = true;
+ else
+ error("unknown option: /mapinfo:" + s);
+ }
+ }
+
+ if (config->lldmapFile != "" && config->lldmapFile == config->mapFile) {
+ warn("/lldmap and /map have the same output file '" + config->mapFile +
+ "'.\n>>> ignoring /lldmap");
+ config->lldmapFile.clear();
+ }
+
if (shouldCreatePDB) {
// Put the PDB next to the image if no /pdb flag was passed.
if (config->pdbPath.empty()) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134559.462573.patch
Type: text/x-patch
Size: 2796 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220923/5f8f363e/attachment.bin>
More information about the llvm-commits
mailing list