[GHC] #11022: Invalid ELF "note" section format
#11022: Invalid ELF "note" section format ----------------------------------------+--------------------------- Reporter: hsyl20 | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Driver | Version: 7.10.2 Keywords: | Operating System: POSIX Architecture: Unknown/Multiple | Type of failure: Other Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: ----------------------------------------+--------------------------- GHC adds a section called ".debug-ghc-link-info" to ELF binaries (see compiler/main/DriverPipeline.hs:1660). The section type is "note" (SHT_NOTE) but the format is not compliant with the ELF specification (see http://refspecs.linuxbase.org/elf/elf.pdf section 2 "Note section"). It makes tools reading sections with "note" type fail. I think we should change the section type to "progbits". Is there any problem with that? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11022> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11022: Invalid ELF "note" section format ---------------------------+---------------------------------------- Reporter: hsyl20 | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Driver | Version: 7.10.2 Resolution: | Keywords: Operating System: POSIX | Architecture: Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------+---------------------------------------- Changes (by bgamari): * milestone: => 8.0.1 Comment: Sounds like the right thing to do. Are you offering a patch? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11022#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11022: Invalid ELF "note" section format ---------------------------+---------------------------------------- Reporter: hsyl20 | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Driver | Version: 7.10.2 Resolution: | Keywords: Operating System: POSIX | Architecture: Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------+---------------------------------------- Changes (by hsyl20): * Attachment "0001-driver-use-PROGBITS-type-for-.debug-ghc-link-info- se.patch" added. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11022> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11022: Invalid ELF "note" section format ---------------------------+---------------------------------------- Reporter: hsyl20 | Owner: Type: bug | Status: patch Priority: normal | Milestone: 8.0.1 Component: Driver | Version: 7.10.2 Resolution: | Keywords: Operating System: POSIX | Architecture: Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------+---------------------------------------- Changes (by hsyl20): * status: new => patch -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11022#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11022: Invalid ELF "note" section format ---------------------------+---------------------------------------- Reporter: hsyl20 | Owner: Type: bug | Status: patch Priority: normal | Milestone: 8.0.1 Component: Driver | Version: 7.10.2 Resolution: | 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: | ---------------------------+---------------------------------------- Changes (by bgamari): * differential: => Phab:D1375 Comment: I've pushed this patch up to Phabricator as Phab:D1375 and written a bit more descriptive commit message. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11022#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11022: Invalid ELF "note" section format ---------------------------+---------------------------------------- Reporter: hsyl20 | Owner: Type: bug | Status: patch Priority: normal | Milestone: 8.0.1 Component: Driver | Version: 7.10.2 Resolution: | 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:"f78b477bd0ba1f85089c515259c9e3145abd1f7b/ghc" f78b477b/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="f78b477bd0ba1f85089c515259c9e3145abd1f7b" driver: use PROGBITS type for .debug-ghc-link-info section Previously the `.debug-ghc-link-info` section was of type `SHT_NOTE` but this is not compliant with the ELF specification, which requires that `NOTE` sections are in a particular record-based format. We mark this section as `PROGBITS` instead, which is defined as implying no particular format. Fixes #11022. Reviewers: bgamari, austin Reviewed By: bgamari, austin Subscribers: thomie, hsyl20 Differential Revision: https://phabricator.haskell.org/D1375 GHC Trac Issues: #11022 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11022#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#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: | ---------------------------+---------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed Comment: Fixed. Thanks hsyl20! -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11022#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#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
#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:"ceaf0f4683a3e0ba85ae420956cfc394824e9a38/ghc" ceaf0f46/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="ceaf0f4683a3e0ba85ae420956cfc394824e9a38" testsuite: Only run recomp015 on ELF-based platforms It fails on OS X with hundreds of messages of the form, ``` ManySections.s:196576:10: error: error: mach-o section specifier uses an unknown section type .section s65525,"",@progbits ^ ManySections.s:196579:10: error: error: mach-o section specifier uses an unknown section type .section s65526,"",@progbits ``` It fails on Windows with messages of the form, ``` ManySections.s:196579:10: error: Error: junk at the end of line, first unrecognized character is ',' ``` Test Plan: Validate Reviewers: hsyl20, thomie, austin Reviewed By: thomie, austin Differential Revision: https://phabricator.haskell.org/D1601 GHC Trac Issues: #11022 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11022#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#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 bgamari): I've also had to disable this test on ARM due to differences in the assembly syntax. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11022#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#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:"e2e24f2808561e5e6e1086e2ee15bf320d879e46/ghc" e2e24f2/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="e2e24f2808561e5e6e1086e2ee15bf320d879e46" Disable recomp015 on ARM Due to differences in assembly syntax. See #11022. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11022#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC