From ad519f81427ce22588cb8e7afe7f5ed6d696a7ff Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh <aquynh@gmail.com> Date: Wed, 25 May 2016 11:54:00 +0800 Subject: [PATCH] x86: fix the testcase 9, 10, 11 (JMP short with non-zero offset) of #issue 9 --- llvm/lib/MC/MCAssembler.cpp | 9 +++++---- llvm/lib/MC/MCObjectStreamer.cpp | 3 ++- suite/regress/x86_issue9.py | 3 +++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index 8db52e0..0b2c90e 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -207,14 +207,13 @@ bool MCAssembler::evaluateFixup(const MCAsmLayout &Layout, Value -= Layout.getSymbolOffset(Sym); } - bool ShouldAlignPC = Backend.getFixupKindInfo(Fixup.getKind()).Flags & MCFixupKindInfo::FKF_IsAlignedDownTo32Bits; assert((ShouldAlignPC ? IsPCRel : true) && "FKF_IsAlignedDownTo32Bits is only allowed on PC-relative fixups!"); if (IsPCRel) { - uint32_t Offset = Layout.getFragmentOffset(DF) + Fixup.getOffset(); + uint64_t Offset = Layout.getFragmentOffset(DF) + Fixup.getOffset(); // A number of ARM fixups in Thumb mode require that the effective PC // address be determined as the 32-bit aligned version of the actual offset. @@ -773,7 +772,8 @@ bool MCAssembler::relaxDwarfCallFrameFragment(MCAsmLayout &Layout, return false; } -bool MCAssembler::layoutSectionOnce(MCAsmLayout &Layout, MCSection &Sec) { +bool MCAssembler::layoutSectionOnce(MCAsmLayout &Layout, MCSection &Sec) +{ // Holds the first fragment which needed relaxing during this layout. It will // remain NULL if none were relaxed. // When a fragment is relaxed, all the fragments following it should get @@ -815,7 +815,8 @@ bool MCAssembler::layoutSectionOnce(MCAsmLayout &Layout, MCSection &Sec) { return false; } -bool MCAssembler::layoutOnce(MCAsmLayout &Layout) { +bool MCAssembler::layoutOnce(MCAsmLayout &Layout) +{ bool WasRelaxed = false; for (iterator it = begin(), ie = end(); it != ie; ++it) { MCSection &Sec = *it; diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index 6fe19f2..b2d6e1b 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -278,7 +278,8 @@ void MCObjectStreamer::EmitInstruction(MCInst &Inst, } void MCObjectStreamer::EmitInstToFragment(MCInst &Inst, - const MCSubtargetInfo &STI) { + const MCSubtargetInfo &STI) +{ if (getAssembler().getRelaxAll() && getAssembler().isBundlingEnabled()) llvm_unreachable("All instructions should have already been relaxed"); diff --git a/suite/regress/x86_issue9.py b/suite/regress/x86_issue9.py index 85399a3..8c09ca6 100755 --- a/suite/regress/x86_issue9.py +++ b/suite/regress/x86_issue9.py @@ -26,6 +26,9 @@ class TestX86(regress.RegressTest): encoding, _ = ks.asm(b"MOV DWORD PTR [ESP-0x218],0x2080000") self.assertEqual(encoding, [ 0xC7, 0x84, 0x24, 0xE8, 0xFD, 0xFF, 0xFF, 0x00, 0x00, 0x08, 0x02 ]) + encoding, _ = ks.asm(b"JMP 0x7FFCAA022104", 0x7FFCAA022104) + self.assertEqual(encoding, [ 0xeb, 0xfe ]) + if __name__ == '__main__': regress.main() -- GitLab