[commit: ghc] master: Systools: read ELF section without calling readelf (109d7ce)
git at git.haskell.org
git at git.haskell.org
Wed Nov 11 12:04:27 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/109d7ce85aadbd9fb7a322a0a83548e5d4e83926/ghc
>---------------------------------------------------------------
commit 109d7ce85aadbd9fb7a322a0a83548e5d4e83926
Author: Sylvain HENRY <hsyl20 at gmail.com>
Date: Wed Nov 11 12:31:31 2015 +0100
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
>---------------------------------------------------------------
109d7ce85aadbd9fb7a322a0a83548e5d4e83926
compiler/ghc.cabal.in | 2 +
compiler/main/DriverPipeline.hs | 61 ++-
compiler/main/Elf.hs | 471 +++++++++++++++++++++
compiler/main/SysTools.hs | 29 +-
testsuite/tests/driver/recomp015/Generate.hs | 7 +
testsuite/tests/driver/recomp015/Makefile | 39 ++
testsuite/tests/driver/recomp015/all.T | 7 +
.../tests/driver/recomp015/recomp015.stderr | 0
testsuite/tests/driver/recomp015/recomp015.stdout | 6 +
9 files changed, 560 insertions(+), 62 deletions(-)
Diff suppressed because of size. To see it, use:
git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 109d7ce85aadbd9fb7a322a0a83548e5d4e83926
More information about the ghc-commits
mailing list