diff options
author | Zequan Wu <zequanwu@google.com> | 2023-12-05 14:57:45 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-05 14:57:45 -0500 |
commit | aaf3a8ded47121c8ec8136f97a7a2c39112b3e59 (patch) | |
tree | aa4441035ee7d64410400ad94bb0593b7782ae48 /lld/MinGW/Driver.cpp | |
parent | af03e2928971bbed2901e096b446e1e1a078de43 (diff) | |
download | llvm-aaf3a8ded47121c8ec8136f97a7a2c39112b3e59.zip llvm-aaf3a8ded47121c8ec8136f97a7a2c39112b3e59.tar.gz llvm-aaf3a8ded47121c8ec8136f97a7a2c39112b3e59.tar.bz2 |
[LLD][COFF] Add -build-id flag to generate .buildid section. (#71433)
[RFC](https://discourse.llvm.org/t/rfc-add-build-id-flag-to-lld-link/74661)
Before, lld-link only generate the debug directory containing guid when
generating PDB with the hash of PDB content.
With this change, lld-link can generate the debug directory when only
`/build-id` is given:
1. If generating PDB, `/build-id` is ignored. Same behaviour as before.
2. Not generating PDB, using hash of the binary.
- Not under MinGW, the debug directory is still in `.rdata` section.
- Under MinGW, place the debug directory into new `.buildid` section.
Diffstat (limited to 'lld/MinGW/Driver.cpp')
-rw-r--r-- | lld/MinGW/Driver.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp index 19bf2d1..d22b617 100644 --- a/lld/MinGW/Driver.cpp +++ b/lld/MinGW/Driver.cpp @@ -302,6 +302,21 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS, } else if (!args.hasArg(OPT_strip_all)) { add("-debug:dwarf"); } + if (auto *a = args.getLastArg(OPT_build_id)) { + StringRef v = a->getValue(); + if (v == "none") + add("-build-id:no"); + else { + if (!v.empty()) + warn("unsupported build id hashing: " + v + ", using default hashing."); + add("-build-id"); + } + } else { + if (args.hasArg(OPT_strip_debug) || args.hasArg(OPT_strip_all)) + add("-build-id:no"); + else + add("-build-id"); + } if (args.hasFlag(OPT_fatal_warnings, OPT_no_fatal_warnings, false)) add("-WX"); |