[GHC] #10974: Fix SysTools.readElfSection on platforms where "readelf" have different name

GHC ghc-devs at haskell.org
Wed Nov 11 12:04:22 UTC 2015


#10974: Fix SysTools.readElfSection on platforms where "readelf" have different
name
-------------------------------------+-------------------------------------
        Reporter:  ony               |                Owner:
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:  8.0.1
       Component:  Compiler          |              Version:  7.10.2
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  Other             |            Test Case:
                                     |  driver/recomp011
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D1326
       Wiki Page:                    |  Phab:D1335 Phab:D1381
-------------------------------------+-------------------------------------

Comment (by Ben Gamari <ben@…>):

 In [changeset:"109d7ce85aadbd9fb7a322a0a83548e5d4e83926/ghc" 109d7ce/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="109d7ce85aadbd9fb7a322a0a83548e5d4e83926"
 Systools: read ELF section without calling readelf

 This patch tackles two issues:

 1) GHC stores a "link info" string into a ELF section. Initially a
 section with type "note" was used but GHC didn't follow the ELF
 specification which specifies a record-based format for these sections.
 With D1375 we switched to a "progbits" section type for which there
 isn't any format constraint. This is an issue for D1242 which use GCC's
 --gc-sections which collects "unused" sections, such as our section
 containing link info... In this patch, we fall back to a section with
 type "note" but we respect the specified format.

 2) Reading back the ELF section was done by parsing the result of a
 call to "readelf". Calling readelf is problematic because the program
 may not be available or it may be renamed on some platforms (see
 D1326). Moreover we have no garanty that its output layout will stay
 the same in future releases of readelf. Finally we would need to fix
 the parsing to support  "note" sections because of 1. Instead, this
 patch proposes to use Data.Binary.Get to directly read the "link info"
 note into its section. ELF has a specification, hence it should work on
 every conforming platform.

 This patch "reverts" D1375, hence it supersedes D1432. It makes D1326
 not necessary anymore.

 Test Plan:
 - recomp011 should pass (test that relinking is avoided when both "link
 info" match)
 - we should add a test for ELF objects with more than 0xff00 sections
 => added test "recomp015"
 - we should check that GAS generates 32-bit words with .int on every
 supported platform using ELF (or find a place where this is
 documented). harbomaster and I (@hsyl20) only tested on x86-64. On
 platforms where it is not true, it should make recomp011 fail. =>
 tested to work on Linux/amd64, Solaris/i386 and OpenBSD/amd64

 Reviewers: olsner, ony, thomie, kgardas, austin, bgamari

 Reviewed By: thomie, bgamari

 Subscribers: kgardas, rwbarton, thomie

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

 GHC Trac Issues: #10974, #11022
 }}}

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


More information about the ghc-tickets mailing list