Fix segfault in AArch64 backend with -g and -mbig-endian

Fix a null pointer dereference when trying to swap the endianness of
fixups in the .eh_frame section in the AArch64 backend.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218311 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Oliver Stannard
2014-09-23 15:38:11 +00:00
parent a6c580e834
commit abe1cb7985
2 changed files with 24 additions and 2 deletions

View File

@@ -535,8 +535,8 @@ void ELFAArch64AsmBackend::applyFixup(const MCFixup &Fixup, char *Data,
// store fixups in .eh_frame section in big endian order
if (!IsLittleEndian && Fixup.getKind() == FK_Data_4) {
const MCSection *Sec = Fixup.getValue()->FindAssociatedSection();
const MCSectionELF *SecELF = static_cast<const MCSectionELF *>(Sec);
if (SecELF->getSectionName() == ".eh_frame")
const MCSectionELF *SecELF = dyn_cast_or_null<const MCSectionELF>(Sec);
if (SecELF && SecELF->getSectionName() == ".eh_frame")
Value = ByteSwap_32(unsigned(Value));
}
AArch64AsmBackend::applyFixup (Fixup, Data, DataSize, Value, IsPCRel);