diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2021-06-10 22:07:16 +0000 |
---|---|---|
committer | Ben Gamari <ben@well-typed.com> | 2021-07-28 15:30:43 +0000 |
commit | aa21d4bcf3b8460006110ef0c948a55a0738264a (patch) | |
tree | 6fbe18055a2b6cb4c6af7950dce1749afee71c39 | |
parent | 10678945c1d3261273a1d7a389d14a69f4e28567 (diff) | |
download | haskell-wip/drop-old-bintools-hack.tar.gz |
Revert "Revert "codeGen: Remove binutils<2.17 hack, fixes T11758""wip/drop-old-bintools-hack
This reverts commit b2c5e4ce5c44a7be7c2b81c2600cae40c5b225ad.
Fixes #2725
Per the issue discussion, this sounds safe to try again.
-rw-r--r-- | compiler/GHC/CmmToAsm/X86/CodeGen.hs | 17 | ||||
-rw-r--r-- | compiler/GHC/CmmToAsm/X86/Ppr.hs | 23 | ||||
-rw-r--r-- | includes/rts/storage/InfoTables.h | 11 |
3 files changed, 3 insertions, 48 deletions
diff --git a/compiler/GHC/CmmToAsm/X86/CodeGen.hs b/compiler/GHC/CmmToAsm/X86/CodeGen.hs index 5e7c261cbb..c8881fe5f3 100644 --- a/compiler/GHC/CmmToAsm/X86/CodeGen.hs +++ b/compiler/GHC/CmmToAsm/X86/CodeGen.hs @@ -3506,25 +3506,10 @@ genSwitch expr targets = do let op = OpAddr (AddrBaseIndex (EABaseReg tableReg) (EAIndex reg (platformWordSizeInBytes platform)) (ImmInt 0)) - offsetReg <- getNewRegNat (intFormat (platformWordWidth platform)) - return $ if is32bit || os == OSDarwin - then e_code `appOL` t_code `appOL` toOL [ + return $ e_code `appOL` t_code `appOL` toOL [ ADD (intFormat (platformWordWidth platform)) op (OpReg tableReg), JMP_TBL (OpReg tableReg) ids rosection lbl ] - else -- HACK: On x86_64 binutils<2.17 is only able to generate - -- PC32 relocations, hence we only get 32-bit offsets in - -- the jump table. As these offsets are always negative - -- we need to properly sign extend them to 64-bit. This - -- hack should be removed in conjunction with the hack in - -- PprMach.hs/pprDataItem once binutils 2.17 is standard. - e_code `appOL` t_code `appOL` toOL [ - MOVSxL II32 op (OpReg offsetReg), - ADD (intFormat (platformWordWidth platform)) - (OpReg offsetReg) - (OpReg tableReg), - JMP_TBL (OpReg tableReg) ids rosection lbl - ] else do (reg,e_code) <- getSomeReg indexExpr lbl <- getNewLabelNat diff --git a/compiler/GHC/CmmToAsm/X86/Ppr.hs b/compiler/GHC/CmmToAsm/X86/Ppr.hs index 5f030b8d58..bba727522d 100644 --- a/compiler/GHC/CmmToAsm/X86/Ppr.hs +++ b/compiler/GHC/CmmToAsm/X86/Ppr.hs @@ -543,27 +543,8 @@ pprDataItem config lit _ -> panic "X86.Ppr.ppr_item: no match for II64" | otherwise -> [text "\t.quad\t" <> pprImm platform imm] - _ - | target32Bit platform -> - [text "\t.quad\t" <> pprImm platform imm] - | otherwise -> - -- x86_64: binutils can't handle the R_X86_64_PC64 - -- relocation type, which means we can't do - -- pc-relative 64-bit addresses. Fortunately we're - -- assuming the small memory model, in which all such - -- offsets will fit into 32 bits, so we have to stick - -- to 32-bit offset fields and modify the RTS - -- appropriately - -- - -- See Note [x86-64-relative] in includes/rts/storage/InfoTables.h - -- - case lit of - -- A relative relocation: - CmmLabelDiffOff _ _ _ _ -> - [text "\t.long\t" <> pprImm platform imm, - text "\t.long\t0"] - _ -> - [text "\t.quad\t" <> pprImm platform imm] + + _ -> [text "\t.quad\t" <> pprImm platform imm] asmComment :: SDoc -> SDoc diff --git a/includes/rts/storage/InfoTables.h b/includes/rts/storage/InfoTables.h index b97e12982b..b37d7294f6 100644 --- a/includes/rts/storage/InfoTables.h +++ b/includes/rts/storage/InfoTables.h @@ -14,17 +14,6 @@ Several pointer fields in info tables are expressed as offsets relative to the info pointer, so that we can generate position-independent code. - - Note [x86-64-relative] - There is a complication on the x86_64 platform, where pointers are - 64 bits, but the tools don't support 64-bit relative relocations. - However, the default memory model (small) ensures that all symbols - have values in the lower 2Gb of the address space, so offsets all - fit in 32 bits. Hence we can use 32-bit offset fields. - - Somewhere between binutils-2.16.1 and binutils-2.16.91.0.6, - support for 64-bit PC-relative relocations was added, so maybe this - hackery can go away sometime. ------------------------------------------------------------------------- */ #if defined(x86_64_HOST_ARCH) |