[PATCH] D149268: [LLD][COFF] Fix PDB relocation on big-endian hosts
Ulrich Weigand via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 26 10:03:16 PDT 2023
uweigand created this revision.
uweigand added reviewers: rnk, hans, aganea.
Herald added subscribers: wlei, wenlei.
Herald added a project: All.
uweigand requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
When running the LLD test suite on a big-endian host, the COFF/pdb-framedata.yaml test case currently fails.
As it turns out, this is because code in DebugSHandler::finish intended to relocate RvaStart entries of FDO records does not work correctly when compiled for a big-endian host.
Fixed by always reading file data in little-endian mode.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D149268
Files:
lld/COFF/PDB.cpp
Index: lld/COFF/PDB.cpp
===================================================================
--- lld/COFF/PDB.cpp
+++ lld/COFF/PDB.cpp
@@ -950,7 +950,7 @@
// must also be rewritten to use the PDB string table.
for (const UnrelocatedFpoData &subsec : frameDataSubsecs) {
// Relocate the first four bytes of the subection and reinterpret them as a
- // 32 bit integer.
+ // 32 bit little-endian integer.
SectionChunk *debugChunk = subsec.debugChunk;
ArrayRef<uint8_t> subsecData = subsec.subsecData;
uint32_t relocIndex = subsec.relocIndex;
@@ -959,8 +959,8 @@
debugChunk->writeAndRelocateSubsection(debugChunk->getContents(),
unrelocatedRvaStart, relocIndex,
&relocatedRvaStart[0]);
- uint32_t rvaStart;
- memcpy(&rvaStart, &relocatedRvaStart[0], sizeof(uint32_t));
+ support::ulittle32_t rvaStart;
+ memcpy(&rvaStart, &relocatedRvaStart[0], sizeof(support::ulittle32_t));
// Copy each frame data record, add in rvaStart, translate string table
// indices, and add the record to the PDB.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149268.517217.patch
Type: text/x-patch
Size: 1135 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230426/f7bf8ddc/attachment.bin>
More information about the llvm-commits
mailing list