Skip to content

Commit a7517e1

Browse files
[BOLT] Fix the initialization of DWARFDataExtractor
Without this patch, we pass Endian as one of the parameters to the constructor of DWARFDataExtractor. The problem is that Endian is of: enum endianness {big, little, native}; whereas the constructor is expecting "bool IsLittleEndian". That is, we are relying on an implicit conversion to convert big and little to false and true, respectively. When we migrate llvm::support::endianness to std::endian in future, we can no longer rely on an implicit conversion because std::endian is declared with "enum class". Even if we could, the conversion would not be guaranteed to work because, for example, libcxx defines: enum class endian { little = 0xDEAD, big = 0xFACE, : where big and little are not boolean values. This patch fixes the problem by properly converting Endian to a boolean value.
1 parent 8de2ecc commit a7517e1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

bolt/lib/Core/DebugData.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,8 @@ void DebugAddrWriterDwarf5::update(DIEBuilder &DIEBlder, DWARFUnit &CU) {
495495
const endianness Endian =
496496
BC->DwCtx->isLittleEndian() ? support::little : support::big;
497497
const DWARFSection &AddrSec = BC->DwCtx->getDWARFObj().getAddrSection();
498-
DWARFDataExtractor AddrData(BC->DwCtx->getDWARFObj(), AddrSec, Endian, 0);
498+
DWARFDataExtractor AddrData(BC->DwCtx->getDWARFObj(), AddrSec,
499+
Endian == support::little, 0);
499500
DWARFDebugAddrTable AddrTable;
500501
DIDumpOptions DumpOpts;
501502
constexpr uint32_t HeaderSize = 8;

0 commit comments

Comments
 (0)