[GHC] #11022: Invalid ELF "note" section format

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


#11022: Invalid ELF "note" section format
---------------------------+----------------------------------------
        Reporter:  hsyl20  |                Owner:
            Type:  bug     |               Status:  closed
        Priority:  normal  |            Milestone:  8.0.1
       Component:  Driver  |              Version:  7.10.2
      Resolution:  fixed   |             Keywords:
Operating System:  POSIX   |         Architecture:  Unknown/Multiple
 Type of failure:  Other   |            Test Case:
      Blocked By:          |             Blocking:
 Related Tickets:          |  Differential Rev(s):  Phab:D1375
       Wiki Page:          |
---------------------------+----------------------------------------

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/11022#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list