This patch fixes the undefined behavior that reported by ubsan.
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/44524/
getDWARFEmitterByName(StringRef SecName);
Expected<StringMap<std::unique_ptr<MemoryBuffer>>>
emitDebugSections(StringRef YAMLString,
- bool IsLittleEndian = sys::IsLittleEndianHost);
+ bool IsLittleEndian = sys::IsLittleEndianHost,
+ bool Is64BitAddrSize = true);
} // end namespace DWARFYAML
} // end namespace llvm
}
Expected<StringMap<std::unique_ptr<MemoryBuffer>>>
-DWARFYAML::emitDebugSections(StringRef YAMLString, bool IsLittleEndian) {
+DWARFYAML::emitDebugSections(StringRef YAMLString, bool IsLittleEndian,
+ bool Is64BitAddrSize) {
auto CollectDiagnostic = [](const SMDiagnostic &Diag, void *DiagContext) {
*static_cast<SMDiagnostic *>(DiagContext) = Diag;
};
DWARFYAML::Data DI;
DI.IsLittleEndian = IsLittleEndian;
+ DI.Is64BitAddrSize = Is64BitAddrSize;
+
YIn >> DI;
if (YIn.error())
return createStringError(YIn.error(), GeneratedDiag.getMessage());
)";
Expected<StringMap<std::unique_ptr<MemoryBuffer>>> Sections =
DWARFYAML::emitDebugSections(StringRef(yamldata),
- /*IsLittleEndian=*/true);
+ /*IsLittleEndian=*/true,
+ /*Is64BitAddrSize=*/false);
ASSERT_THAT_EXPECTED(Sections, Succeeded());
std::unique_ptr<DWARFContext> Ctx =
DWARFContext::create(*Sections, 4, /*isLittleEndian=*/true);