Skip to content
Snippets Groups Projects
Commit ad519f81 authored by Nguyen Anh Quynh's avatar Nguyen Anh Quynh
Browse files

x86: fix the testcase 9, 10, 11 (JMP short with non-zero offset) of #issue 9

parent 1838aece
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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");
......
......@@ -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()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment