[PATCH] D149268: [LLD][COFF] Fix PDB relocation on big-endian hosts

Ulrich Weigand via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 27 05:00:01 PDT 2023


uweigand added inline comments.


================
Comment at: lld/COFF/PDB.cpp:958
     auto unrelocatedRvaStart = subsecData.take_front(sizeof(uint32_t));
     uint8_t relocatedRvaStart[sizeof(uint32_t)];
     debugChunk->writeAndRelocateSubsection(debugChunk->getContents(),
----------------
aganea wrote:
> Can't we just write `support::ulittle32_t rvaStart;` here and static cast to a uint8_t* it below in the function call?
I guess that would be safe (in particular w.r.t. aliasing rules) if `uint8_t` is implemented as an `unsigned char`.  This is probably always true in practice, but may not be absolutely guaranteed by the C++ standard.  Maybe this is why the original code used a memcpy here?

Let me know if you want me to make that change.   (The generated code should be identical with all modern compilers anyway.)



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149268/new/

https://reviews.llvm.org/D149268



More information about the llvm-commits mailing list