From: Jacob Kroon <jacob.kroon@gmail.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: Jacob Kroon via Gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: Reserving specified size of RUNPATH entry in the dynamic section during linking
Date: Sun, 28 Nov 2021 16:54:05 +0100 [thread overview]
Message-ID: <fb80319d-82d7-2ff4-3834-df3c327fe5a1@gmail.com> (raw)
In-Reply-To: <87k0gsgvhg.fsf@oldenburg.str.redhat.com>
On 11/28/21 16:17, Florian Weimer wrote:
> * Jacob Kroon:
>
>>> The RUNPATH strings are in the string table, so it's necessary to
>>> allocate space there, and be able to find it during patching.
>>>
>>> Solaris offers this mechanism:
>>>
>>> | DT_SUNW_STRPAD
>>> |
>>> | The total size, in bytes, of the unused reserved space at the end of
>>> | the dynamic string table. If DT_SUNW_STRPAD is not present in an
>>> | object, no reserved space is available.
>>>
>>> Would that help in your case as well?
>>>
>>
>> The problem is that for two different build I pass two different
>> -Wl,--rpath=<path>, and they are of different length. So I'd like to
>> reserve a maximum size, at link-time, which becomes the same in both
>> builds, so that when I later remove the rpath's, the binaries become
>> identical.
>
> In the file, there is no array of some number of characters that
> contains the null-terminated RUNPATH string, an array to which just more
> null bytes could be added at the end. DT_RUNPATH contains an offset
> into the string table. The null-terminated string could be used for
> something else. For example, if the RUNPATH is
> "/usr/lib64/sys/library.so.3", and the link edit needs the string
> "library.so.3" for something else, it can point into the RUNPATH string
> to get that. So it's not valid in general to patch the string in-place,
> let alone change its length.
>
> That's why I think something like the Solaris approach is needed: The
> new RUNPATH value would come from the reservation, the offset in
> DT_RUNPATH points to it, and the original string table is not modified
> at all.
>
Aha, thank you for explaining.
I suppose gnu ld doesn't try to optimize for usage of substrings in
RUNPATH, thus making if fairly easy to change it post linking.
But can I then specify during link time that RUNTIME should go in a
"reserved" area, whose size I can also control ? I hope I understood you
correctly.
Jacob
next prev parent reply other threads:[~2021-11-28 15:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-27 22:05 Jacob Kroon
2021-11-27 22:27 ` Tom Kacvinsky
2021-11-28 14:24 ` Jacob Kroon
2021-11-28 11:44 ` Florian Weimer
2021-11-28 14:31 ` Jacob Kroon
2021-11-28 15:09 ` Dan Kegel
2021-11-28 15:17 ` Florian Weimer
2021-11-28 15:54 ` Jacob Kroon [this message]
2021-11-28 17:06 ` Florian Weimer
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=fb80319d-82d7-2ff4-3834-df3c327fe5a1@gmail.com \
--to=jacob.kroon@gmail.com \
--cc=fweimer@redhat.com \
--cc=gcc-help@gcc.gnu.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).