[GHC] #13849: Remove Binutils<2.17 hack in X86 codegen

GHC ghc-devs at haskell.org
Tue Jun 20 09:03:27 UTC 2017


#13849: Remove Binutils<2.17 hack in X86 codegen
-------------------------------------+-------------------------------------
           Reporter:  hsyl20         |             Owner:  (none)
               Type:  task           |            Status:  new
           Priority:  low            |         Milestone:
          Component:  Compiler       |           Version:  8.0.1
  (CodeGen)                          |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:  x86_64         |   Type of failure:  None/Unknown
  (amd64)                            |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 The purpose of this ticket is to keep track of an hack that the X86 code
 generator uses to support binutils<2.17:

 nativeGen/X86/CodeGen.hs:
 > 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.

 nativeGen/X86/Ppr.hs:
 > 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

 includes/rts/storage/InfoTables.h
 >   Note [x86-64-relative]
 >   There is a complication on the x86_64 platform, where pointeres 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.

 As binutils 2.17 is out since 2011, maybe we could remove this hack now.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13849>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list