[dsymutil] fix accidental 32bit truncation in patchFrameInfoForObject
authorAlessandro Arzilli <alessandro.arzilli@gmail.com>
Sat, 17 Dec 2022 12:22:05 +0000 (13:22 +0100)
committerAlexey Lapshin <a.v.lapshin@mail.ru>
Sat, 17 Dec 2022 14:26:32 +0000 (15:26 +0100)
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
llvm/include/llvm/DWARFLinker/DWARFStreamer.h
llvm/lib/DWARFLinker/DWARFLinker.cpp
llvm/lib/DWARFLinker/DWARFStreamer.cpp

index 8125add..6b0f457 100644 (file)
@@ -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
index 3bc3f45..3ff5fda 100644 (file)
@@ -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.
index 0261b8f..ee70690 100644 (file)
@@ -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
index 2a11d31..9d66c84 100644 (file)
@@ -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);