diff options
author | Fangrui Song <i@maskray.me> | 2022-08-12 12:52:36 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2022-08-12 12:52:36 -0700 |
commit | f62e60fb238146113f84e0efb1a2ebc52f05cc0a (patch) | |
tree | ad14b1e6226fc7eb101066935b52204390410c65 /llvm/lib/MC/MCDwarf.cpp | |
parent | 53113515cdaa19a86e4b807808b7b99dc1c91685 (diff) | |
download | llvm-f62e60fb238146113f84e0efb1a2ebc52f05cc0a.zip llvm-f62e60fb238146113f84e0efb1a2ebc52f05cc0a.tar.gz llvm-f62e60fb238146113f84e0efb1a2ebc52f05cc0a.tar.bz2 |
[MCDwarf] Respect -fdebug-prefix-map= for generated assembly debug info (DWARF v5)
For generated assembly debug info, MCDwarfLineTableHeader::CompilationDir is an
unmapped path set in MCContext::setGenDwarfRootFile. Remap it.
A relative destination path of -fdebug-prefix-map= exposes a llvm-dwarfdump bug
which joins relative DW_AT_comp_dir and directories[0].
Fix https://github.com/llvm/llvm-project/issues/56609
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D131749
Diffstat (limited to 'llvm/lib/MC/MCDwarf.cpp')
-rw-r--r-- | llvm/lib/MC/MCDwarf.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp index 91a636b..cc1a662 100644 --- a/llvm/lib/MC/MCDwarf.cpp +++ b/llvm/lib/MC/MCDwarf.cpp @@ -416,9 +416,15 @@ void MCDwarfLineTableHeader::emitV5FileDirTables( : dwarf::DW_FORM_string); MCOS->emitULEB128IntValue(MCDwarfDirs.size() + 1); // Try not to emit an empty compilation directory. - const StringRef CompDir = CompilationDir.empty() - ? MCOS->getContext().getCompilationDir() - : StringRef(CompilationDir); + SmallString<256> Dir; + StringRef CompDir = MCOS->getContext().getCompilationDir(); + if (!CompilationDir.empty()) { + Dir = CompilationDir; + MCOS->getContext().remapDebugPath(Dir); + CompDir = Dir.str(); + if (LineStr) + CompDir = LineStr->getSaver().save(CompDir); + } if (LineStr) { // Record path strings, emit references here. LineStr->emitRef(MCOS, CompDir); |