From: Thorsten Glaser <tg@mirbsd.de>
To: musl@lists.openwall.com
Cc: 1068350@bugs.debian.org, debian-glibc@lists.debian.org, doko@debian.org
Subject: [musl] Re: Bug#1068350: musl: miscompiles (runtime problems) on riscv64 and s390x with static-pie → seems to be a toolchain bug after all, it does too hit glibc
Date: Thu, 4 Apr 2024 21:18:26 +0000 (UTC) [thread overview]
Message-ID: <Pine.BSM.4.64L.2404042102310.18654@herc.mirbsd.org> (raw)
In-Reply-To: <Pine.BSM.4.64L.2404042035130.18654@herc.mirbsd.org>
Dixi quod…
>Hmm, actually… I could… test whether that one fixes static-pie
>on zelenka. Or at least the same approach. I’ll get back with
>report from that.
Having looked at the spec file, the only extra things the stock
specs do that the overriding specs don’t is:
*link:
[…] %{!static|static-pie:--eh-frame-hdr} […] %{static-pie:-static -pie --no-dynamic-linker -z text} […]
instead of:
[…] %{static-pie:-static -pie --no-dynamic-linker} […]
The -Wl,-z,text makes TEXTRELs an error. Granted.
The -Wl,--eh-frame-hdr is added for anything that’s not a normal
static executable, however adding that to a musl build doesn’t
fix the problem either.
A bit of gdb-ing shows the problem, though: the source code has…
#define Ttypeset "typeset"
#define Tdr "-r"
//… (a variant of this is used for string sharing on ancient Unix)
static const char *initcoms[] = {
Ttypeset, Tdr, initvsn, NULL,
Ttypeset, Tdx, "HOME", TPATH, TSHELL, NULL,
[…]
};
It then iterates over these commands with:
for (wp = initcoms; *wp != NULL; wp++) {
c_builtin(wp);
while (*wp != NULL)
wp++;
}
This is where the extra output happens:
(gdb) print initcoms
$3 = {0x3fff7fc14a4 "typeset", 0x0, 0x0, 0x0, 0x3fff7fc14a4 "typeset", 0x0, 0x3fff7fc0478 "HOME",
[…]
Notice the nullptrs there where string pointers are expected.
It shows the same output when just loading the executable, i.e. this
isn’t a runtime issue.
Linking the exact same .o files with the exact same command minus
-static-pie gives:
(gdb) print initcoms
$1 = {0x103cb34 "typeset", 0x103e368 <u_ops+128> "-r",
0x103e73c <initvsn> "KSH_VERSION=@(#)MIRBSD KSH R59 2024/02/01 +Debian", 0x0, 0x103cb34 "typeset",
But this does seem to be a toolchain bug: adding -static-pie to the
glibc dynamic-pie link command and…
(gdb) print initcoms
$1 = {0xda494 "typeset", 0x0, 0x0, 0x0, 0xda494 "typeset", 0x0, 0xd942c "HOME", 0xda7d8 "PATH",
Now I (or someone) is going to have to reduce that to a testcase, so
we can detect static-pie viability before it’s committed to being used…
bye,
//mirabilos
--
Solange man keine schmutzigen Tricks macht, und ich meine *wirklich*
schmutzige Tricks, wie bei einer doppelt verketteten Liste beide
Pointer XORen und in nur einem Word speichern, funktioniert Boehm ganz
hervorragend. -- Andreas Bogk über boehm-gc in d.a.s.r
next prev parent reply other threads:[~2024-04-04 21:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <171218457890.157989.17235252523998125898.reportbug@zelenka.debian.org>
2024-04-03 23:57 ` [musl] Re: Bug#1068350: musl: miscompiles (runtime problems) on s390x with static-pie Thorsten Glaser
2024-04-04 10:44 ` Szabolcs Nagy
2024-04-04 10:54 ` Szabolcs Nagy
2024-04-04 19:50 ` [musl] Re: Bug#1068350: musl: miscompiles (runtime problems) on riscv64 and " Thorsten Glaser
2024-04-04 20:26 ` Rich Felker
2024-04-04 20:40 ` Thorsten Glaser
2024-04-04 21:18 ` Thorsten Glaser [this message]
2024-04-05 0:26 ` [musl] Re: Bug#1068350: musl: miscompiles (runtime problems) on riscv64 and s390x with static-pie → seems to be a toolchain bug after all, it does too hit glibc Thorsten Glaser
2024-04-05 4:11 ` Markus Wichmann
2024-04-05 5:04 ` Thorsten Glaser
2024-04-05 5:31 ` Markus Wichmann
2024-04-05 5:58 ` Thorsten Glaser
2024-04-05 6:42 ` Markus Wichmann
2024-04-05 6:48 ` Szabolcs Nagy
2024-04-06 3:00 ` Rich Felker
2024-04-06 15:18 ` Thorsten Glaser
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=Pine.BSM.4.64L.2404042102310.18654@herc.mirbsd.org \
--to=tg@mirbsd.de \
--cc=1068350@bugs.debian.org \
--cc=debian-glibc@lists.debian.org \
--cc=doko@debian.org \
--cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).