[GHC] #15847: GHCi cannot load .o built from c with -fPIC on i386 linux

GHC ghc-devs at haskell.org
Fri Nov 2 18:06:55 UTC 2018


#15847: GHCi cannot load .o built from c with -fPIC on i386 linux
-------------------------------------+-------------------------------------
           Reporter:  watashi        |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Runtime        |           Version:  8.7
  System (Linker)                    |
           Keywords:                 |  Operating System:  Linux
       Architecture:  x86            |   Type of failure:  None/Unknown
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 GHCi cannot load .o built from c with -fPIC on i386 linux. On i386 linux,
 the PIC object code looks like:

 {{{
 000001ac <hs_remWord64>:
  1ac:   53                      push   %ebx
  1ad:   83 ec 08                sub    $0x8,%esp
  1b0:   e8 fc ff ff ff          call   1b1 <hs_remWord64+0x5>
                         1b1: R_386_PC32 __x86.get_pc_thunk.bx
  1b5:   81 c3 02 00 00 00       add    $0x2,%ebx
                         1b7: R_386_GOTPC        _GLOBAL_OFFSET_TABLE_
  1bb:   ff 74 24 1c             pushl  0x1c(%esp)
  1bf:   ff 74 24 1c             pushl  0x1c(%esp)
  1c3:   ff 74 24 1c             pushl  0x1c(%esp)
  1c7:   ff 74 24 1c             pushl  0x1c(%esp)
  1cb:   e8 fc ff ff ff          call   1cc <hs_remWord64+0x20>
                         1cc: R_386_PLT32        __umoddi3
  1d0:   83 c4 18                add    $0x18,%esp
  1d3:   5b                      pop    %ebx
  1d4:   c3                      ret
 }}}

 1. the GOT symbol `_GLOBAL_OFFSET_TABLE_` may be undefined
 2. the runtime linker doesn't support PIC-related i386 relocations like
 `R_386_GOTPC` or `R_386_PLT32`

 As a result, we will see errors like
 `unknown symbol '_GLOBAL_OFFSET_TABLE_'` or `unhandled ELF relocation`.

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


More information about the ghc-tickets mailing list