[GHC] #10375: arm: ghci hits an illegal instruction

GHC ghc-devs at haskell.org
Wed Oct 14 23:09:57 UTC 2015


#10375: arm: ghci hits an illegal instruction
-------------------------------------+-------------------------------------
        Reporter:  erikd             |                Owner:
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  7.10.3
       Component:  Runtime System    |              Version:  7.10.1
  (Linker)                           |
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:  arm
 Type of failure:  GHCi crash        |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D1323
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Erik de Castro Lopo <erikd@…>):

 In [changeset:"933adc0f31164cb651d11ecfcfe612ac429f714f/ghc"
 933adc0f/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="933adc0f31164cb651d11ecfcfe612ac429f714f"
 Fix GHCi on Arm (#10375).

 Arm has two instruction sets, Arm and Thumb, and an execution mode for
 each.
 Executing Arm code in Thumb mode or vice-versa will likely result in an
 Illegal instruction exception.

 Furthermore, Haskell code compiled via LLVM was generating Arm
 instructions
 while C code compiled via GCC was generating Thumb code by default. When
 these two object code types were being linked by the system linker, all
 was
 fine, because the system linker knows how to jump and call from one
 instruction set to the other.

 The first problem was with GHCi's object code loader which did not know
 about Thumb vs Arm. When loading an object file `StgCRun` would jump
 into the loaded object which could change the mode causing a crash after
 it returned. This was fixed by forcing all C code to generate Arm
 instructions by passing `-marm` to GCC.

 The second problem was the `mkJumpToAddr` function which was generating
 Thumb instructions. Changing that to generate Arm instructions instead
 results in a working GHCi on Arm.

 Test Plan: validate on x86_64 and arm

 Reviewers: bgamari, austin, hvr

 Subscribers: thomie

 Differential Revision: https://phabricator.haskell.org/D1323

 GHC Trac Issues: #10375
 }}}

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


More information about the ghc-tickets mailing list