commit:     cbd2a52033efd9a333508d5cd9bd35bd00a2c06b
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 28 18:23:57 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Dec 28 18:31:07 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cbd2a520

sys-libs/glibc: workaround ia64 early ldso crashes #503838

 .../2.19/glibc-2.19-ia64-gcc-4.8-reloc-hack.patch  | 32 ++++++++++++++++++++++
 sys-libs/glibc/glibc-2.19-r1.ebuild                |  5 +++-
 sys-libs/glibc/glibc-2.20-r2.ebuild                |  2 ++
 sys-libs/glibc/glibc-2.21-r1.ebuild                |  2 ++
 sys-libs/glibc/glibc-2.22-r1.ebuild                |  2 ++
 5 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/sys-libs/glibc/files/2.19/glibc-2.19-ia64-gcc-4.8-reloc-hack.patch 
b/sys-libs/glibc/files/2.19/glibc-2.19-ia64-gcc-4.8-reloc-hack.patch
new file mode 100644
index 0000000..72a616a
--- /dev/null
+++ b/sys-libs/glibc/files/2.19/glibc-2.19-ia64-gcc-4.8-reloc-hack.patch
@@ -0,0 +1,32 @@
+https://bugs.gentoo.org/503838
+http://gcc.gnu.org/PR60465
+https://sourceware.org/ml/libc-alpha/2015-12/msg00556.html
+https://trofi.github.io/posts/189-glibc-on-ia64-or-how-relocations-bootstrap.html
+
+newer versions of gcc generate relocations in the elf_get_dynamic_info func
+which glibc relies on to populate some info structs.  those structs are then
+used by ldso to process relocations in itself.  glibc requires that there are
+no relocations until that point (*after* elf_get_dynamic_info), so we end up
+crashing during elf_get_dynamic_info because the relocation has not yet been
+processed.
+
+this hack shuffles the code in a way that tricks gcc into not generating the
+relocation.  we need to figure out something better for upstream.
+
+--- a/elf/get-dynamic-info.h
++++ b/elf/get-dynamic-info.h
+@@ -66,8 +66,12 @@ elf_get_dynamic_info (struct link_map *l, ElfW(Dyn) *temp)
+       info[DT_VALTAGIDX (dyn->d_tag) + DT_NUM + DT_THISPROCNUM
+            + DT_VERSIONTAGNUM + DT_EXTRANUM] = dyn;
+       else if ((d_tag_utype) DT_ADDRTAGIDX (dyn->d_tag) < DT_ADDRNUM)
+-      info[DT_ADDRTAGIDX (dyn->d_tag) + DT_NUM + DT_THISPROCNUM
+-           + DT_VERSIONTAGNUM + DT_EXTRANUM + DT_VALNUM] = dyn;
++      {
++        d_tag_utype i =
++            DT_ADDRTAGIDX (dyn->d_tag) + DT_NUM + DT_THISPROCNUM
++            + DT_VERSIONTAGNUM + DT_EXTRANUM + DT_VALNUM;
++        info[i] = dyn;
++      }
+       ++dyn;
+     }
+ 

diff --git a/sys-libs/glibc/glibc-2.19-r1.ebuild 
b/sys-libs/glibc/glibc-2.19-r1.ebuild
index a683fa5..998b7fd 100644
--- a/sys-libs/glibc/glibc-2.19-r1.ebuild
+++ b/sys-libs/glibc/glibc-2.19-r1.ebuild
@@ -157,8 +157,11 @@ eblit-src_unpack-pre() {
 }
 
 eblit-src_unpack-post() {
+       cd "${S}"
+
+       epatch "${FILESDIR}"/2.19/${PN}-2.19-ia64-gcc-4.8-reloc-hack.patch 
#503838
+
        if use hardened ; then
-               cd "${S}"
                einfo "Patching to get working PIE binaries on PIE (hardened) 
platforms"
                gcc-specs-pie && epatch 
"${FILESDIR}"/2.17/glibc-2.17-hardened-pie.patch
                epatch 
"${FILESDIR}"/2.19/glibc-2.19-hardened-configure-picdefault.patch

diff --git a/sys-libs/glibc/glibc-2.20-r2.ebuild 
b/sys-libs/glibc/glibc-2.20-r2.ebuild
index 8280980..0ea96b2 100644
--- a/sys-libs/glibc/glibc-2.20-r2.ebuild
+++ b/sys-libs/glibc/glibc-2.20-r2.ebuild
@@ -160,6 +160,8 @@ eblit-src_unpack-pre() {
 eblit-src_prepare-post() {
        cd "${S}"
 
+       epatch "${FILESDIR}"/2.19/${PN}-2.19-ia64-gcc-4.8-reloc-hack.patch 
#503838
+
        if use hardened ; then
                einfo "Patching to get working PIE binaries on PIE (hardened) 
platforms"
                gcc-specs-pie && epatch 
"${FILESDIR}"/2.17/glibc-2.17-hardened-pie.patch

diff --git a/sys-libs/glibc/glibc-2.21-r1.ebuild 
b/sys-libs/glibc/glibc-2.21-r1.ebuild
index 9963ae3..3dcbb52 100644
--- a/sys-libs/glibc/glibc-2.21-r1.ebuild
+++ b/sys-libs/glibc/glibc-2.21-r1.ebuild
@@ -160,6 +160,8 @@ eblit-src_unpack-pre() {
 eblit-src_prepare-post() {
        cd "${S}"
 
+       epatch "${FILESDIR}"/2.19/${PN}-2.19-ia64-gcc-4.8-reloc-hack.patch 
#503838
+
        if use hardened ; then
                einfo "Patching to get working PIE binaries on PIE (hardened) 
platforms"
                gcc-specs-pie && epatch 
"${FILESDIR}"/2.17/glibc-2.17-hardened-pie.patch

diff --git a/sys-libs/glibc/glibc-2.22-r1.ebuild 
b/sys-libs/glibc/glibc-2.22-r1.ebuild
index d6f6033..6e41fa9 100644
--- a/sys-libs/glibc/glibc-2.22-r1.ebuild
+++ b/sys-libs/glibc/glibc-2.22-r1.ebuild
@@ -163,6 +163,8 @@ eblit-src_unpack-pre() {
 eblit-src_prepare-post() {
        cd "${S}"
 
+       epatch "${FILESDIR}"/2.19/${PN}-2.19-ia64-gcc-4.8-reloc-hack.patch 
#503838
+
        if use hardened ; then
                # We don't enable these for non-hardened as the output is very 
terse --
                # it only states that a crash happened.  The default upstream 
behavior

Reply via email to