Summary: | =sys-devel/gcc-6.4.0[pie] (17.0 profile) generates broken binaries on 32-bit powerpc ABI | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Sergei Trofimovich (RETIRED) <slyfox> |
Component: | Current packages | Assignee: | Gentoo Toolchain Maintainers <toolchain> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | max, ppc, slyfox, stszap |
Priority: | Normal | Keywords: | PATCH |
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
URL: | https://sourceware.org/bugzilla/show_bug.cgi?id=22626 | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Bug Depends on: | |||
Bug Blocks: | 640184, 642232 | ||
Attachments: |
gcc-6.4.0-0001-RS6000-linux-startfile-endfile.patch
gcc-6.4.0-0001-PR-driver-81523-Make-static-override-pie.patch |
Description
Sergei Trofimovich (RETIRED)
2017-12-17 15:03:09 UTC
binutils-2.26.1 generates working binary, binutils-2.29.1 does not work. Tried more binutils targets to see what immediately breaks 'int main(){}' example: [1] powerpc-unknown-linux-gnu-2.25.1 OK [2] powerpc-unknown-linux-gnu-2.26.1 OK [3] powerpc-unknown-linux-gnu-2.27 BROKEN [4] powerpc-unknown-linux-gnu-2.28.1 BROKEN [5] powerpc-unknown-linux-gnu-2.29.1 BROKEN Looks like regression was introduced around 2.26.1 - 2.27 times. Compared readelf output for 'int main(){}' linked with binutils-2.26.1 and 2.27. The main difference is 2 relocation in '.rela.dyn' (dynamic symbols) section: Good (2.26.1): 0000050a 00000806 R_PPC_ADDR16_HA 00020024 _end + 20020 00000512 00000804 R_PPC_ADDR16_LO 00020024 _end + 20020 0000053e 00000806 R_PPC_ADDR16_HA 00020024 _end + 20020 00000546 00000804 R_PPC_ADDR16_LO 00020024 _end + 20020 Bad (2.27): 000004aa 00000806 R_PPC_ADDR16_HA 000004b2 00000804 R_PPC_ADDR16_LO 000004de 00000806 R_PPC_ADDR16_HA 000004e6 00000804 R_PPC_ADDR16_LO (for 2.27 readelf can't recognize relocation type and complains about the symbol type) Bisected it down to 6b3b0ab89663306d17927d630304dbbd36e84570 is the first bad commit commit 6b3b0ab89663306d17927d630304dbbd36e84570 Author: H.J. Lu <hjl.tools@gmail.com> Date: Tue Feb 23 05:18:43 2016 -0800 Make linker assigned symbol dynamic only for shared object Linker assigned symbols should be made dynamic by default only when creating shared object or relocatable executable. bfd/ * elflink.c (bfd_elf_record_link_assignment): Check for shared library, instead of PIC, and don't check PDE when making linker assigned symbol dynamic. ld/ * testsuite/ld-frv/fdpic-pie-6.d: Updated. * testsuite/ld-mips-elf/pie-n32.d: Likewise. * testsuite/ld-mips-elf/pie-n64.d: Likewise. * testsuite/ld-mips-elf/pie-o32.d: Likewise. :040000 040000 1815fe304ea13706d5a945a28068683414c3d5c4 e59fd268e5bdad0d4c58784298ebae1c3e4bb8f9 M bfd :040000 040000 09b9e50f4624715c59b2dc42ed6078e0a1b7edaf 7efb992565b9f49a4c6c4197e1274d611792883e M ld Reported upstream: https://sourceware.org/bugzilla/show_bug.cgi?id=22626 In https://sourceware.org/bugzilla/show_bug.cgi?id=22626#c5 Alan pointed at gcc fixes already present in -6, -7 and -HEAD branches to use proper startup files. We will need to pull those to unbreak powerpc. Created attachment 510578 [details]
gcc-6.4.0-0001-RS6000-linux-startfile-endfile.patch
(In reply to Sergei Trofimovich from comment #7) > Created attachment 510578 [details] > gcc-6.4.0-0001-RS6000-linux-startfile-endfile.patch xgcc: fatal error: braced spec 'shared:; pg|p|profile:gcrt1.o%s; static:crt1.o%s; no-pie|static|r|shared:;:Scrt1.o%s; :crt1.o%s} %{mnewlib:ecrti.o%s;:crti.o%s} %{sta tic:crtbeginT.o%s; shared|no-pie|static|r|shared:;:crtbeginS.o%s; :crtbegin.o%s} %{fvtable-verify=none:%s; fvtable-verify=preinit:vtv_start_preinit.o%s; fvtable-verify= std:vtv_start.o%s} ' is invalid at ' ' compilation terminated. make[3]: *** [Makefile:950: libgcc_s.so] Error 1 Does not work as-is. Will need more fixes. Created attachment 510580 [details, diff]
gcc-6.4.0-0001-PR-driver-81523-Make-static-override-pie.patch
With both patches applied powerpc generates working PIE files. Queued both patches for gcc/6.4.0 and gcc/7.2.0 as: """ gcc/6.4.0, gcc/7.2.0: fix --default-pie to use proper startup files, bug #641474 The change adds two patches to patchset: - gentoo/95_all_static_override_pie.patch - gentoo/96_all_powerpc_pie.patch First fixes -static handling for --default-pie compiler. Second fixes to use proper startup files for --default-pie on powerpc. Otherwise binutils-2.27 and upper generates invalid ELF files. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22626 Bug: https://bugs.gentoo.org/641474 """ Please test it a bit before we cut new gcc patchset off them. commit 4207f3a916969991e9c19a6e27ba504d9e42da6e Author: Alan Modra <amodra@gmail.com> Date: Mon Dec 18 22:27:08 2017 +1030 PR22626, invalid dynindx used for dynamic relocs against section syms ^ queued for binutils-2.29.1 patchset The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ecb2d0bf2d0195efe753abb3f32e7ee1599c12ce commit ecb2d0bf2d0195efe753abb3f32e7ee1599c12ce Author: Sergei Trofimovich <slyfox@gentoo.org> AuthorDate: 2018-01-06 19:54:31 +0000 Commit: Sergei Trofimovich <slyfox@gentoo.org> CommitDate: 2018-01-06 19:55:00 +0000 sys-devel/gcc: bump 6.4.0 and 7.2.0 patchsets, bug #641474 Two new patches for a single issue: - 95_all_static_override_pie.patch - 96_all_powerpc_pie.patch First fixes -static handling for --default-pie compiler. Second fixes to use proper startup files for --default-pie on powerpc. This should unbreak 17.0 profiles at least for powerpc. Dropped keywords until minimal testing is done for other arches. Bug: https://bugs.gentoo.org/641474 Package-Manager: Portage-2.3.19, Repoman-2.3.6 sys-devel/gcc/Manifest | 2 ++ sys-devel/gcc/gcc-6.4.0-r1.ebuild | 25 +++++++++++++++++++++++++ sys-devel/gcc/gcc-7.2.0-r1.ebuild | 25 +++++++++++++++++++++++++ 3 files changed, 52 insertions(+)} The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fe331fe6a6ce98f906685c43576b81e398ef6dbc commit fe331fe6a6ce98f906685c43576b81e398ef6dbc Author: Sergei Trofimovich <slyfox@gentoo.org> AuthorDate: 2018-01-12 08:02:25 +0000 Commit: Sergei Trofimovich <slyfox@gentoo.org> CommitDate: 2018-01-12 08:04:11 +0000 sys-devel/gcc: restore ~arch keywords for static+pie fixes, bug #641474 Bug: https://bugs.gentoo.org/641474 Package-Manager: Portage-2.3.19, Repoman-2.3.6 sys-devel/gcc/gcc-6.4.0-r1.ebuild | 3 +-- sys-devel/gcc/gcc-7.2.0-r1.ebuild | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)} (In reply to Larry the Git Cow from comment #14) > The bug has been referenced in the following commit(s): > > https://gitweb.gentoo.org/repo/gentoo.git/commit/ > ?id=fe331fe6a6ce98f906685c43576b81e398ef6dbc > > commit fe331fe6a6ce98f906685c43576b81e398ef6dbc > Author: Sergei Trofimovich <slyfox@gentoo.org> > AuthorDate: 2018-01-12 08:02:25 +0000 > Commit: Sergei Trofimovich <slyfox@gentoo.org> > CommitDate: 2018-01-12 08:04:11 +0000 > > sys-devel/gcc: restore ~arch keywords for static+pie fixes, bug #641474 > > Bug: https://bugs.gentoo.org/641474 > Package-Manager: Portage-2.3.19, Repoman-2.3.6 > > sys-devel/gcc/gcc-6.4.0-r1.ebuild | 3 +-- in https://github.com/gentoo/gentoo/commit/fe331fe6a6ce98f906685c43576b81e398ef6dbc#commitcomment-26813297 hydrapolic pointed out i've restored then from KEYWORDS="" straight to stable. That was not intended but should not be harmful (especially on 17.0 profile). I'll revert back to ~arch if we get any reports of regression. But otherwise accidentally RESOLVED it. The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a48596f11cd6b5ecfeb994b9ea9678f3499955f6 commit a48596f11cd6b5ecfeb994b9ea9678f3499955f6 Author: Sergei Trofimovich <slyfox@gentoo.org> AuthorDate: 2018-02-28 23:03:59 +0000 Commit: Sergei Trofimovich <slyfox@gentoo.org> CommitDate: 2018-02-28 23:04:09 +0000 sys-devel/gcc: stable 6.4.0-r1 for arm, bug #641474 Bug: https://bugs.gentoo.org/641474 Package-Manager: Portage-2.3.24, Repoman-2.3.6 sys-devel/gcc/gcc-6.4.0-r1.ebuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)} |