From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5659 invoked by alias); 10 Apr 2012 19:28:05 -0000 Received: (qmail 5645 invoked by uid 22791); 10 Apr 2012 19:28:04 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,MIME_QP_LONG_LINE,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,SUBJ_OBFU_PUNCT_FEW,SUBJ_OBFU_PUNCT_MANY X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 10 Apr 2012 19:27:51 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1SHgjG-0003FT-6Y from Maxim_Kuvyrkov@mentor.com ; Tue, 10 Apr 2012 12:27:50 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 10 Apr 2012 12:27:35 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.1.289.1; Tue, 10 Apr 2012 20:27:48 +0100 From: Maxim Kuvyrkov Content-Type: multipart/mixed; boundary="Apple-Mail=_E47D8EC7-1A7A-494C-970E-44265534DBC6" Subject: [PATCH, cross prelink] 0001-Pull-ld.so-s-name-from-PT_INTERP-to-avoid-the-runtim.patch Date: Tue, 10 Apr 2012 19:28:00 -0000 Message-ID: <78E2B6DA-6156-43B6-B788-C8501057C234@codesourcery.com> CC: To: Mark Hatle MIME-Version: 1.0 (Apple Message framework v1257) Mailing-List: contact prelink-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: prelink-owner@sourceware.org X-SW-Source: 2012-q2/txt/msg00000.txt.bz2 --Apple-Mail=_E47D8EC7-1A7A-494C-970E-44265534DBC6 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="us-ascii" Content-length: 859 Mark, This patch makes rtld emulator in cross prelink use ld.so's name as it is e= ncoded in PT_INTERP header. Currently, rtld emulator returns "lib/ld.so.1" for runtime linker's name, b= ut the linker actually expects "/lib/ld.so.1" -- that one slash at the begi= nning causes prelink checks done by the runtime linker to fail and not use = prelink information. The runtime linker sets up a map for itself under the name stored in PT_INT= ERP header of the executable, and this patch makes rtld emulator follow the= suit. I have tested this patch using a different version of rtld emulator (the on= e that CodeSourcery / Mentor maintains), but the function in question is th= e same in both, so this patch is also relevant for Yocto's prelink. Any comments? Please merge at your leisure. Thank you, -- Maxim Kuvyrkov CodeSourcery / Mentor Graphics --Apple-Mail=_E47D8EC7-1A7A-494C-970E-44265534DBC6 Content-Disposition: attachment; filename="0001-Pull-ld.so-s-name-from-PT_INTERP-to-avoid-the-runtim.patch" Content-Type: application/octet-stream; name="0001-Pull-ld.so-s-name-from-PT_INTERP-to-avoid-the-runtim.patch" Content-Transfer-Encoding: quoted-printable Content-length: 2591 >From 0065267a94585689628087dbd656ad1b2b20c952 Mon Sep 17 00:00:00 2001=0A= From: Maxim Kuvyrkov =0A= Date: Tue, 10 Apr 2012 12:15:02 -0700=0A= Subject: [PATCH] Pull ld.so's name from PT_INTERP to avoid the runtime link= er failing to use=0A= prelink information due to name mismatch.=0A= =0A= * src/rtld/rtld.c (find_lib_by_soname): Follow ld.so's behavior of=0A= pulling its name from PT_INTERP.=0A= =0A= Signed-off-by: Maxim Kuvyrkov =0A= ---=0A= trunk/ChangeLog.cross | 4 ++++=0A= trunk/src/rtld/rtld.c | 28 ++++++++++++++++++++++++++++=0A= 2 files changed, 32 insertions(+), 0 deletions(-)=0A= =0A= diff --git a/trunk/ChangeLog.cross b/trunk/ChangeLog.cross=0A= index d802a60..24b5d5c 100644=0A= --- a/trunk/ChangeLog.cross=0A= +++ b/trunk/ChangeLog.cross=0A= @@ -1,3 +1,7 @@=0A= +2012-04-10 Maxim Kuvyrkov =0A= + * src/rtld/rtld.c (find_lib_by_soname): Follow ld.so's behavior of=0A= + pulling its name from PT_INTERP.=0A= +=0A= 2012-04-04 Mark Hatle =0A= * testsuite/ifunc1.sh, ifunc2.sh, ifunc3.sh: Add cross compilation=0A= checks to a few of the test cases.=0A= diff --git a/trunk/src/rtld/rtld.c b/trunk/src/rtld/rtld.c=0A= index 8121493..b6bcef3 100644=0A= --- a/trunk/src/rtld/rtld.c=0A= +++ b/trunk/src/rtld/rtld.c=0A= @@ -497,6 +497,34 @@ find_lib_by_soname (const char *soname, struct dso_lis= t *loader,=0A= if (strchr (soname, '/'))=0A= return strdup (soname);=0A= =20=0A= + if (is_ldso_soname (soname))=0A= + /* For dynamic linker, pull the path out of PT_INTERP header.=0A= + When loading an executable the dynamic linker creates an entry for= =0A= + itself under the name stored in PT_INTERP, and the name that we=0A= + record in .gnu.liblist should match that exactly. */=0A= + {=0A= + struct dso_list *loader_p =3D loader;=0A= +=0A= + while (loader_p)=0A= + {=0A= + if (loader_p->dso->ehdr.e_type =3D=3D ET_EXEC)=0A= + {=0A= + int i;=0A= +=0A= + for (i =3D 0; i < loader_p->dso->ehdr.e_phnum; ++i)=0A= + if (loader_p->dso->phdr[i].p_type =3D=3D PT_INTERP)=0A= + {=0A= + const char *interp;=0A= + interp =3D get_data (loader_p->dso,=0A= + loader_p->dso->phdr[i].p_vaddr,=0A= + NULL, NULL);=0A= + return strdup (interp);=0A= + }=0A= + }=0A= + loader_p =3D loader_p->loader;=0A= + }=0A= + }=0A= +=0A= if (loader->dso->info[DT_RUNPATH] =3D=3D 0)=0A= {=0A= /* Search DT_RPATH all the way up. */=0A= --=20=0A= 1.7.0.4=0A= =0A= --Apple-Mail=_E47D8EC7-1A7A-494C-970E-44265534DBC6 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii" Content-length: 1 --Apple-Mail=_E47D8EC7-1A7A-494C-970E-44265534DBC6--