summaryrefslogtreecommitdiff
path: root/bolt
diff options
context:
space:
mode:
authorJob Noorman <jnoorman@igalia.com>2023-04-13 16:38:45 +0200
committerJob Noorman <jnoorman@igalia.com>2023-04-13 16:39:22 +0200
commit8bbfac7be1b1be94a7a95aaf602cc224f6e504e7 (patch)
treee53626850d2834a96c8231dd053d41ca0a0fd1e1 /bolt
parent934373886e08492e70245c56468c91d4f59595b8 (diff)
downloadllvm-8bbfac7be1b1be94a7a95aaf602cc224f6e504e7.tar.gz
[BOLT][NFC] Fix UB due to unaligned load in DebugStrOffsetsWriter
The following tests fail when enabling UBSan due to an unaligned memory load: > runtime error: load of misaligned address 0x620000000643 for type > 'const uint32_t' (aka 'const unsigned int'), which requires 4 byte > alignment BOLT :: AArch64/asm-func-debug.test BOLT :: AArch64/update-debug-reloc.test BOLT :: X86/asm-func-debug.test BOLT :: X86/dwarf5-df-dualcu.test BOLT :: X86/dwarf5-df-mono-dualcu.test BOLT :: X86/dwarf5-ftypes-dwp-input-dwo-output.test BOLT :: X86/dwarf5-locaddrx.test BOLT :: X86/dwarf5-split-dwarf4-monolithic.test BOLT :: X86/inlined-function-mixed.test BOLT :: non-empty-debug-line.test This patch fixes this by using read32le for the load. Reviewed By: ayermolo Differential Revision: https://reviews.llvm.org/D148217
Diffstat (limited to 'bolt')
-rw-r--r--bolt/lib/Core/DebugData.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/bolt/lib/Core/DebugData.cpp b/bolt/lib/Core/DebugData.cpp
index 41289fbcbcad..2b56357df9c0 100644
--- a/bolt/lib/Core/DebugData.cpp
+++ b/bolt/lib/Core/DebugData.cpp
@@ -1166,7 +1166,7 @@ void DebugStrOffsetsWriter::initialize(
"Dwarf String Offsets Byte Size is not supported.");
uint32_t Index = 0;
for (uint64_t Offset = 0; Offset < Contr->Size; Offset += DwarfOffsetByteSize)
- IndexToAddressMap[Index++] = *reinterpret_cast<const uint32_t *>(
+ IndexToAddressMap[Index++] = support::endian::read32le(
StrOffsetsSection.Data.data() + Contr->Base + Offset);
}