From 10539ec2cf69fa8433840c9ddd6a56b8e2735e7a Mon Sep 17 00:00:00 2001 From: Alessandro Arzilli Date: Sat, 17 Dec 2022 13:22:05 +0100 Subject: [PATCH] [dsymutil] fix accidental 32bit truncation in patchFrameInfoForObject patchFrameInfoForObject accidentally truncates FDE addresses to the least significant 32bits, which causes the Go bug: https://github.com/golang/go/issues/25841. Patch by Alessandro Arzilli Differential Revision: https://reviews.llvm.org/D138763 --- llvm/include/llvm/DWARFLinker/DWARFLinker.h | 2 +- llvm/include/llvm/DWARFLinker/DWARFStreamer.h | 2 +- llvm/lib/DWARFLinker/DWARFLinker.cpp | 2 +- llvm/lib/DWARFLinker/DWARFStreamer.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/llvm/include/llvm/DWARFLinker/DWARFLinker.h b/llvm/include/llvm/DWARFLinker/DWARFLinker.h index 8125add..6b0f457 100644 --- a/llvm/include/llvm/DWARFLinker/DWARFLinker.h +++ b/llvm/include/llvm/DWARFLinker/DWARFLinker.h @@ -153,7 +153,7 @@ public: virtual void emitCIE(StringRef CIEBytes) = 0; /// Emit an FDE with data \p Bytes. - virtual void emitFDE(uint32_t CIEOffset, uint32_t AddreSize, uint32_t Address, + virtual void emitFDE(uint32_t CIEOffset, uint32_t AddreSize, uint64_t Address, StringRef Bytes) = 0; /// Emit the .debug_loc contribution for \p Unit by copying the entries from diff --git a/llvm/include/llvm/DWARFLinker/DWARFStreamer.h b/llvm/include/llvm/DWARFLinker/DWARFStreamer.h index 3bc3f45..3ff5fda 100644 --- a/llvm/include/llvm/DWARFLinker/DWARFStreamer.h +++ b/llvm/include/llvm/DWARFLinker/DWARFStreamer.h @@ -137,7 +137,7 @@ public: void emitCIE(StringRef CIEBytes) override; /// Emit an FDE with data \p Bytes. - void emitFDE(uint32_t CIEOffset, uint32_t AddreSize, uint32_t Address, + void emitFDE(uint32_t CIEOffset, uint32_t AddreSize, uint64_t Address, StringRef Bytes) override; /// Emit DWARF debug names. diff --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp b/llvm/lib/DWARFLinker/DWARFLinker.cpp index 0261b8f..ee70690 100644 --- a/llvm/lib/DWARFLinker/DWARFLinker.cpp +++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp @@ -1895,7 +1895,7 @@ void DWARFLinker::patchFrameInfoForObject(const DWARFFile &File, continue; } - uint32_t Loc = Data.getUnsigned(&InputOffset, AddrSize); + uint64_t Loc = Data.getUnsigned(&InputOffset, AddrSize); // Some compilers seem to emit frame info that doesn't start at // the function entry point, thus we can't just lookup the address diff --git a/llvm/lib/DWARFLinker/DWARFStreamer.cpp b/llvm/lib/DWARFLinker/DWARFStreamer.cpp index 2a11d311..9d66c84 100644 --- a/llvm/lib/DWARFLinker/DWARFStreamer.cpp +++ b/llvm/lib/DWARFLinker/DWARFStreamer.cpp @@ -796,7 +796,7 @@ void DwarfStreamer::emitCIE(StringRef CIEBytes) { /// contains the FDE data without the length, CIE offset and address /// which will be replaced with the parameter values. void DwarfStreamer::emitFDE(uint32_t CIEOffset, uint32_t AddrSize, - uint32_t Address, StringRef FDEBytes) { + uint64_t Address, StringRef FDEBytes) { MS->switchSection(MC->getObjectFileInfo()->getDwarfFrameSection()); MS->emitIntValue(FDEBytes.size() + 4 + AddrSize, 4); -- 2.7.4