From: Maxim Kuvyrkov <maxim@codesourcery.com>
To: Mark Hatle <mark.hatle@windriver.com>
Cc: <prelink@sourceware.org>
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 [thread overview]
Message-ID: <78E2B6DA-6156-43B6-B788-C8501057C234@codesourcery.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 861 bytes --]
Mark,
This patch makes rtld emulator in cross prelink use ld.so's name as it is encoded in PT_INTERP header.
Currently, rtld emulator returns "lib/ld.so.1" for runtime linker's name, but the linker actually expects "/lib/ld.so.1" -- that one slash at the beginning 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_INTERP 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 one that CodeSourcery / Mentor maintains), but the function in question is the 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
[-- Attachment #2: 0001-Pull-ld.so-s-name-from-PT_INTERP-to-avoid-the-runtim.patch --]
[-- Type: application/octet-stream, Size: 2354 bytes --]
From 0065267a94585689628087dbd656ad1b2b20c952 Mon Sep 17 00:00:00 2001
From: Maxim Kuvyrkov <maxim@codesourcery.com>
Date: Tue, 10 Apr 2012 12:15:02 -0700
Subject: [PATCH] Pull ld.so's name from PT_INTERP to avoid the runtime linker failing to use
prelink information due to name mismatch.
* src/rtld/rtld.c (find_lib_by_soname): Follow ld.so's behavior of
pulling its name from PT_INTERP.
Signed-off-by: Maxim Kuvyrkov <maxim@codesourcery.com>
---
trunk/ChangeLog.cross | 4 ++++
trunk/src/rtld/rtld.c | 28 ++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/trunk/ChangeLog.cross b/trunk/ChangeLog.cross
index d802a60..24b5d5c 100644
--- a/trunk/ChangeLog.cross
+++ b/trunk/ChangeLog.cross
@@ -1,3 +1,7 @@
+2012-04-10 Maxim Kuvyrkov <maxim@codesourcery.com>
+ * src/rtld/rtld.c (find_lib_by_soname): Follow ld.so's behavior of
+ pulling its name from PT_INTERP.
+
2012-04-04 Mark Hatle <mark.hatle@windriver.com>
* testsuite/ifunc1.sh, ifunc2.sh, ifunc3.sh: Add cross compilation
checks to a few of the test cases.
diff --git a/trunk/src/rtld/rtld.c b/trunk/src/rtld/rtld.c
index 8121493..b6bcef3 100644
--- a/trunk/src/rtld/rtld.c
+++ b/trunk/src/rtld/rtld.c
@@ -497,6 +497,34 @@ find_lib_by_soname (const char *soname, struct dso_list *loader,
if (strchr (soname, '/'))
return strdup (soname);
+ if (is_ldso_soname (soname))
+ /* For dynamic linker, pull the path out of PT_INTERP header.
+ When loading an executable the dynamic linker creates an entry for
+ itself under the name stored in PT_INTERP, and the name that we
+ record in .gnu.liblist should match that exactly. */
+ {
+ struct dso_list *loader_p = loader;
+
+ while (loader_p)
+ {
+ if (loader_p->dso->ehdr.e_type == ET_EXEC)
+ {
+ int i;
+
+ for (i = 0; i < loader_p->dso->ehdr.e_phnum; ++i)
+ if (loader_p->dso->phdr[i].p_type == PT_INTERP)
+ {
+ const char *interp;
+ interp = get_data (loader_p->dso,
+ loader_p->dso->phdr[i].p_vaddr,
+ NULL, NULL);
+ return strdup (interp);
+ }
+ }
+ loader_p = loader_p->loader;
+ }
+ }
+
if (loader->dso->info[DT_RUNPATH] == 0)
{
/* Search DT_RPATH all the way up. */
--
1.7.0.4
[-- Attachment #3: Type: text/plain, Size: 1 bytes --]
next reply other threads:[~2012-04-10 19:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-10 19:28 Maxim Kuvyrkov [this message]
2012-04-10 19:46 ` Mark Hatle
2012-04-10 19:57 ` Maxim Kuvyrkov
2012-04-10 20:23 ` Mark Hatle
2012-05-26 3:42 ` Maxim Kuvyrkov
2012-05-29 15:17 ` Mark Hatle
2012-06-27 22:34 ` Maxim Kuvyrkov
2012-06-28 2:29 ` Mark Hatle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=78E2B6DA-6156-43B6-B788-C8501057C234@codesourcery.com \
--to=maxim@codesourcery.com \
--cc=mark.hatle@windriver.com \
--cc=prelink@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).