* [PATCH, cross prelink] 0001-Pull-ld.so-s-name-from-PT_INTERP-to-avoid-the-runtim.patch
@ 2012-04-10 19:28 Maxim Kuvyrkov
2012-04-10 19:46 ` Mark Hatle
0 siblings, 1 reply; 8+ messages in thread
From: Maxim Kuvyrkov @ 2012-04-10 19:28 UTC (permalink / raw)
To: Mark Hatle; +Cc: prelink
[-- 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 --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH, cross prelink] 0001-Pull-ld.so-s-name-from-PT_INTERP-to-avoid-the-runtim.patch
2012-04-10 19:28 [PATCH, cross prelink] 0001-Pull-ld.so-s-name-from-PT_INTERP-to-avoid-the-runtim.patch Maxim Kuvyrkov
@ 2012-04-10 19:46 ` Mark Hatle
2012-04-10 19:57 ` Maxim Kuvyrkov
0 siblings, 1 reply; 8+ messages in thread
From: Mark Hatle @ 2012-04-10 19:46 UTC (permalink / raw)
To: Maxim Kuvyrkov; +Cc: prelink
On 4/10/12 2:27 PM, Maxim Kuvyrkov wrote:
> 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.
prelinker currently checks that the ld.so name matches what it's expecting for
any given arch in the PL_ARCH structure. Does this change any of that behavior?
Or does it simply change the internal prelink-rtld behavior so that it the
prelink-rtld acts as if it's name is the PT_INTERP element?
--Mark
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH, cross prelink] 0001-Pull-ld.so-s-name-from-PT_INTERP-to-avoid-the-runtim.patch
2012-04-10 19:46 ` Mark Hatle
@ 2012-04-10 19:57 ` Maxim Kuvyrkov
2012-04-10 20:23 ` Mark Hatle
0 siblings, 1 reply; 8+ messages in thread
From: Maxim Kuvyrkov @ 2012-04-10 19:57 UTC (permalink / raw)
To: Mark Hatle; +Cc: prelink
On 11/04/2012, at 7:46 AM, Mark Hatle wrote:
> On 4/10/12 2:27 PM, Maxim Kuvyrkov wrote:
>> 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.
>
> prelinker currently checks that the ld.so name matches what it's expecting for any given arch in the PL_ARCH structure. Does this change any of that behavior? Or does it simply change the internal prelink-rtld behavior so that it the prelink-rtld acts as if it's name is the PT_INTERP element?
It is the latter. Only behavior of prelink-rtld is change to the effect that it outputs "/lib/ld.so.1 -> /lib/ld.so.1 ..." as executable's dependency.
Forgot to mention: the dependency on ld.so.1 [usually] comes from libdl.so, which is, probably, why this bug wasn't noticed before.
--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH, cross prelink] 0001-Pull-ld.so-s-name-from-PT_INTERP-to-avoid-the-runtim.patch
2012-04-10 19:57 ` Maxim Kuvyrkov
@ 2012-04-10 20:23 ` Mark Hatle
2012-05-26 3:42 ` Maxim Kuvyrkov
0 siblings, 1 reply; 8+ messages in thread
From: Mark Hatle @ 2012-04-10 20:23 UTC (permalink / raw)
To: Maxim Kuvyrkov; +Cc: prelink
On 4/10/12 2:56 PM, Maxim Kuvyrkov wrote:
> On 11/04/2012, at 7:46 AM, Mark Hatle wrote:
>
>> On 4/10/12 2:27 PM, Maxim Kuvyrkov wrote:
>>> 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.
>>
>> prelinker currently checks that the ld.so name matches what it's expecting for any given arch in the PL_ARCH structure. Does this change any of that behavior? Or does it simply change the internal prelink-rtld behavior so that it the prelink-rtld acts as if it's name is the PT_INTERP element?
>
> It is the latter. Only behavior of prelink-rtld is change to the effect that it outputs "/lib/ld.so.1 -> /lib/ld.so.1 ..." as executable's dependency.
>
> Forgot to mention: the dependency on ld.so.1 [usually] comes from libdl.so, which is, probably, why this bug wasn't noticed before.
Thanks, I think I understand what is going on now. I'll look into getting this
merged into the cross prelinker later today or tomorrow.
--Mark
> --
> Maxim Kuvyrkov
> CodeSourcery / Mentor Graphics
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH, cross prelink] 0001-Pull-ld.so-s-name-from-PT_INTERP-to-avoid-the-runtim.patch
2012-04-10 20:23 ` Mark Hatle
@ 2012-05-26 3:42 ` Maxim Kuvyrkov
2012-05-29 15:17 ` Mark Hatle
0 siblings, 1 reply; 8+ messages in thread
From: Maxim Kuvyrkov @ 2012-05-26 3:42 UTC (permalink / raw)
To: Mark Hatle; +Cc: prelink
On 11/04/2012, at 8:23 AM, Mark Hatle wrote:
> On 4/10/12 2:56 PM, Maxim Kuvyrkov wrote:
>> On 11/04/2012, at 7:46 AM, Mark Hatle wrote:
>>
>>> On 4/10/12 2:27 PM, Maxim Kuvyrkov wrote:
>>>> 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.
>>>
>>> prelinker currently checks that the ld.so name matches what it's expecting for any given arch in the PL_ARCH structure. Does this change any of that behavior? Or does it simply change the internal prelink-rtld behavior so that it the prelink-rtld acts as if it's name is the PT_INTERP element?
>>
>> It is the latter. Only behavior of prelink-rtld is change to the effect that it outputs "/lib/ld.so.1 -> /lib/ld.so.1 ..." as executable's dependency.
>>
>> Forgot to mention: the dependency on ld.so.1 [usually] comes from libdl.so, which is, probably, why this bug wasn't noticed before.
>
> Thanks, I think I understand what is going on now. I'll look into getting this merged into the cross prelinker later today or tomorrow.
Mark,
This patch is still not merged to cross-prelink, did you encounter a problem with it?
Thank you,
--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH, cross prelink] 0001-Pull-ld.so-s-name-from-PT_INTERP-to-avoid-the-runtim.patch
2012-05-26 3:42 ` Maxim Kuvyrkov
@ 2012-05-29 15:17 ` Mark Hatle
2012-06-27 22:34 ` Maxim Kuvyrkov
0 siblings, 1 reply; 8+ messages in thread
From: Mark Hatle @ 2012-05-29 15:17 UTC (permalink / raw)
To: Maxim Kuvyrkov; +Cc: prelink
This was just an oversight it appears. I'm working on a number of merges into
the cross prelinker today. Hopefully in a few days it will be tested and
pushed. If you don't see anything, feel free to keep reminding me.
--Mark
On 5/25/12 10:42 PM, Maxim Kuvyrkov wrote:
> On 11/04/2012, at 8:23 AM, Mark Hatle wrote:
>
>> On 4/10/12 2:56 PM, Maxim Kuvyrkov wrote:
>>> On 11/04/2012, at 7:46 AM, Mark Hatle wrote:
>>>
>>>> On 4/10/12 2:27 PM, Maxim Kuvyrkov wrote:
>>>>> 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.
>>>>
>>>> prelinker currently checks that the ld.so name matches what it's expecting for any given arch in the PL_ARCH structure. Does this change any of that behavior? Or does it simply change the internal prelink-rtld behavior so that it the prelink-rtld acts as if it's name is the PT_INTERP element?
>>>
>>> It is the latter. Only behavior of prelink-rtld is change to the effect that it outputs "/lib/ld.so.1 -> /lib/ld.so.1 ..." as executable's dependency.
>>>
>>> Forgot to mention: the dependency on ld.so.1 [usually] comes from libdl.so, which is, probably, why this bug wasn't noticed before.
>>
>> Thanks, I think I understand what is going on now. I'll look into getting this merged into the cross prelinker later today or tomorrow.
>
> Mark,
>
> This patch is still not merged to cross-prelink, did you encounter a problem with it?
>
> Thank you,
>
> --
> Maxim Kuvyrkov
> CodeSourcery / Mentor Graphics
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH, cross prelink] 0001-Pull-ld.so-s-name-from-PT_INTERP-to-avoid-the-runtim.patch
2012-05-29 15:17 ` Mark Hatle
@ 2012-06-27 22:34 ` Maxim Kuvyrkov
2012-06-28 2:29 ` Mark Hatle
0 siblings, 1 reply; 8+ messages in thread
From: Maxim Kuvyrkov @ 2012-06-27 22:34 UTC (permalink / raw)
To: Mark Hatle; +Cc: prelink
Ping.
--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics
On 30/05/2012, at 3:17 AM, Mark Hatle wrote:
> This was just an oversight it appears. I'm working on a number of merges into the cross prelinker today. Hopefully in a few days it will be tested and pushed. If you don't see anything, feel free to keep reminding me.
>
> --Mark
>
> On 5/25/12 10:42 PM, Maxim Kuvyrkov wrote:
>> On 11/04/2012, at 8:23 AM, Mark Hatle wrote:
>>
>>> On 4/10/12 2:56 PM, Maxim Kuvyrkov wrote:
>>>> On 11/04/2012, at 7:46 AM, Mark Hatle wrote:
>>>>
>>>>> On 4/10/12 2:27 PM, Maxim Kuvyrkov wrote:
>>>>>> 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.
>>>>>
>>>>> prelinker currently checks that the ld.so name matches what it's expecting for any given arch in the PL_ARCH structure. Does this change any of that behavior? Or does it simply change the internal prelink-rtld behavior so that it the prelink-rtld acts as if it's name is the PT_INTERP element?
>>>>
>>>> It is the latter. Only behavior of prelink-rtld is change to the effect that it outputs "/lib/ld.so.1 -> /lib/ld.so.1 ..." as executable's dependency.
>>>>
>>>> Forgot to mention: the dependency on ld.so.1 [usually] comes from libdl.so, which is, probably, why this bug wasn't noticed before.
>>>
>>> Thanks, I think I understand what is going on now. I'll look into getting this merged into the cross prelinker later today or tomorrow.
>>
>> Mark,
>>
>> This patch is still not merged to cross-prelink, did you encounter a problem with it?
>>
>> Thank you,
>>
>> --
>> Maxim Kuvyrkov
>> CodeSourcery / Mentor Graphics
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH, cross prelink] 0001-Pull-ld.so-s-name-from-PT_INTERP-to-avoid-the-runtim.patch
2012-06-27 22:34 ` Maxim Kuvyrkov
@ 2012-06-28 2:29 ` Mark Hatle
0 siblings, 0 replies; 8+ messages in thread
From: Mark Hatle @ 2012-06-28 2:29 UTC (permalink / raw)
To: Maxim Kuvyrkov; +Cc: prelink
On 6/27/12 5:34 PM, Maxim Kuvyrkov wrote:
> Ping.
Hmm, I thought I replied sorry. The patch is in the cross prelinker.
http://git.yoctoproject.org/cgit/cgit.cgi/prelink-cross/commit/?h=cross_prelink&id=104e49c827b1b452910e0415acf72b8008990141
--Mark
> --
> Maxim Kuvyrkov
> CodeSourcery / Mentor Graphics
>
>
> On 30/05/2012, at 3:17 AM, Mark Hatle wrote:
>
>> This was just an oversight it appears. I'm working on a number of merges into the cross prelinker today. Hopefully in a few days it will be tested and pushed. If you don't see anything, feel free to keep reminding me.
>>
>> --Mark
>>
>> On 5/25/12 10:42 PM, Maxim Kuvyrkov wrote:
>>> On 11/04/2012, at 8:23 AM, Mark Hatle wrote:
>>>
>>>> On 4/10/12 2:56 PM, Maxim Kuvyrkov wrote:
>>>>> On 11/04/2012, at 7:46 AM, Mark Hatle wrote:
>>>>>
>>>>>> On 4/10/12 2:27 PM, Maxim Kuvyrkov wrote:
>>>>>>> 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.
>>>>>>
>>>>>> prelinker currently checks that the ld.so name matches what it's expecting for any given arch in the PL_ARCH structure. Does this change any of that behavior? Or does it simply change the internal prelink-rtld behavior so that it the prelink-rtld acts as if it's name is the PT_INTERP element?
>>>>>
>>>>> It is the latter. Only behavior of prelink-rtld is change to the effect that it outputs "/lib/ld.so.1 -> /lib/ld.so.1 ..." as executable's dependency.
>>>>>
>>>>> Forgot to mention: the dependency on ld.so.1 [usually] comes from libdl.so, which is, probably, why this bug wasn't noticed before.
>>>>
>>>> Thanks, I think I understand what is going on now. I'll look into getting this merged into the cross prelinker later today or tomorrow.
>>>
>>> Mark,
>>>
>>> This patch is still not merged to cross-prelink, did you encounter a problem with it?
>>>
>>> Thank you,
>>>
>>> --
>>> Maxim Kuvyrkov
>>> CodeSourcery / Mentor Graphics
>>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-06-28 2:29 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-10 19:28 [PATCH, cross prelink] 0001-Pull-ld.so-s-name-from-PT_INTERP-to-avoid-the-runtim.patch Maxim Kuvyrkov
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
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).