Index: llvm/trunk/include/llvm/Support/ARMWinEH.h =================================================================== --- llvm/trunk/include/llvm/Support/ARMWinEH.h +++ llvm/trunk/include/llvm/Support/ARMWinEH.h @@ -339,7 +339,7 @@ return ((ES & 0xff000000) >> 24); } - uint8_t EpilogueStartIndexAArch64() const { + uint16_t EpilogueStartIndexAArch64() const { return ((ES & 0xffc00000) >> 22); } }; @@ -428,7 +428,7 @@ inline size_t HeaderWords(const ExceptionDataRecord &XR) { if (XR.isAArch64) - return (XR.Data[0] & 0xffc0000) ? 1 : 2; + return (XR.Data[0] & 0xffc00000) ? 1 : 2; return (XR.Data[0] & 0xff800000) ? 1 : 2; } } Index: llvm/trunk/test/tools/llvm-readobj/arm64-win-error1.s =================================================================== --- llvm/trunk/test/tools/llvm-readobj/arm64-win-error1.s +++ llvm/trunk/test/tools/llvm-readobj/arm64-win-error1.s @@ -7,6 +7,7 @@ // CHECK: Prologue [ // CHECK: 0xdf ; Bad opcode! +// CHECK: 0xff ; Bad opcode! // CHECK: 0xd600 ; stp x19, lr, [sp, #0] // CHECK: 0x01 ; sub sp, #16 // CHECK: 0xe4 ; end @@ -48,6 +49,6 @@ .long 0x10800012 .long 0x8 .long 0xe - .long 0x100d6df - .long 0xe3e3e3e4 + .long 0x00d6ffdf + .long 0xe3e3e401 Index: llvm/trunk/tools/llvm-readobj/ARMWinEHPrinter.cpp =================================================================== --- llvm/trunk/tools/llvm-readobj/ARMWinEHPrinter.cpp +++ llvm/trunk/tools/llvm-readobj/ARMWinEHPrinter.cpp @@ -788,7 +788,7 @@ if ((isAArch64 && (DI >= array_lengthof(Ring64))) || (!isAArch64 && (DI >= array_lengthof(Ring)))) { SW.startLine() << format("0x%02x ; Bad opcode!\n", - Opcodes.data()[Offset]); + Opcodes.data()[OI]); ++OI; break; } @@ -871,6 +871,8 @@ SW.printNumber("EpilogueStartIndex", isAArch64 ? ES.EpilogueStartIndexAArch64() : ES.EpilogueStartIndexARM()); + if (ES.ES & ~0xffc3ffff) + SW.printNumber("ReservedBits", (ES.ES >> 18) & 0xF); ListScope Opcodes(SW, "Opcodes"); decodeOpcodes(XData.UnwindByteCode(), @@ -887,10 +889,15 @@ + (XData.E() ? 0 : XData.EpilogueCount()) + XData.CodeWords(); - ErrorOr Symbol = - getRelocatedSymbol(COFF, Section, HandlerOffset * sizeof(uint32_t)); + ErrorOr Symbol = getRelocatedSymbol( + COFF, Section, Offset + HandlerOffset * sizeof(uint32_t)); if (!Symbol) Symbol = getSymbol(COFF, Address, /*FunctionOnly=*/true); + if (!Symbol) { + ListScope EHS(SW, "ExceptionHandler"); + SW.printString("Routine", "(null)"); + return true; + } Expected Name = Symbol->getName(); if (!Name) { @@ -950,10 +957,7 @@ } FunctionAddress = *FunctionAddressOrErr; } else { - const pe32_header *PEHeader; - if (COFF.getPE32Header(PEHeader)) - return false; - FunctionAddress = PEHeader->ImageBase + RF.BeginAddress; + FunctionAddress = COFF.getImageBase() + RF.BeginAddress; } SW.printString("Function", formatSymbol(FunctionName, FunctionAddress)); @@ -988,22 +992,18 @@ } section_iterator SI = *SIOrErr; - return dumpXDataRecord(COFF, *SI, FunctionAddress, Address); + // FIXME: Do we need to add an offset from the relocation? + return dumpXDataRecord(COFF, *SI, FunctionAddress, + RF.ExceptionInformationRVA()); } else { - const pe32_header *PEHeader; - if (COFF.getPE32Header(PEHeader)) - return false; - - uint64_t Address = PEHeader->ImageBase + RF.ExceptionInformationRVA(); + uint64_t Address = COFF.getImageBase() + RF.ExceptionInformationRVA(); SW.printString("ExceptionRecord", formatSymbol("", Address)); - ErrorOr Section = - getSectionContaining(COFF, RF.ExceptionInformationRVA()); + ErrorOr Section = getSectionContaining(COFF, Address); if (!Section) return false; - return dumpXDataRecord(COFF, *Section, FunctionAddress, - RF.ExceptionInformationRVA()); + return dumpXDataRecord(COFF, *Section, FunctionAddress, Address); } } @@ -1073,8 +1073,8 @@ if (Entry.Flag() == RuntimeFunctionFlag::RFF_Unpacked) return dumpUnpackedEntry(COFF, Section, Offset, Index, Entry); if (isAArch64) { - llvm::errs() << "Packed unwind data not yet supported for ARM64\n"; - return false; + SW.startLine() << "Packed unwind data not yet supported for ARM64\n"; + return true; } return dumpPackedEntry(COFF, Section, Offset, Index, Entry); }