From: Florian Weimer <fweimer@redhat.com>
To: Jacob Kroon <jacob.kroon@gmail.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 18:06:38 +0100 [thread overview]
Message-ID: <87fsrggqg1.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <fb80319d-82d7-2ff4-3834-df3c327fe5a1@gmail.com> (Jacob Kroon's message of "Sun, 28 Nov 2021 16:54:05 +0100")
* Jacob Kroon:
> 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.
I think it does, it's just that RUNPATH with an overlapping tail is just
rare in practice because of its contents.
Try this:
$ gcc -nostartfiles -shared -Wl,-rpath,one-long-string,-soname,one-long-string
$ readelf -dW a.out
Dynamic section at offset 0x1f20 contains 9 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000e (SONAME) Library soname: [one-long-string]
0x000000000000001d (RUNPATH) Library runpath: [one-long-string]
0x000000006ffffef5 (GNU_HASH) 0x180
0x0000000000000005 (STRTAB) 0x1b8
0x0000000000000006 (SYMTAB) 0x1a0
0x000000000000000a (STRSZ) 27 (bytes)
0x000000000000000b (SYMENT) 24 (bytes)
0x0000000000000000 (NULL) 0x0
But if you look at the file with a hex editor, you'll notice that the
string is only there once:
000001b0: 0000 0000 0000 0000 006c 6962 632e 736f .........libc.so
000001c0: 2e36 006f 6e65 2d6c 6f6e 672d 7374 7269 .6.one-long-stri
000001d0: 6e67 0000 0000 0000 0000 0000 0000 0000 ng..............
> 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.
I think GNU ld doesn't have this feature today.
Thanks,
Florian
prev parent reply other threads:[~2021-11-28 17:06 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
2021-11-28 17:06 ` Florian Weimer [this message]
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=87fsrggqg1.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=gcc-help@gcc.gnu.org \
--cc=jacob.kroon@gmail.com \
/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).