From: Sebastian Ott <sebott@redhat.com>
To: "Mark Brown" <broonie@kernel.org>, "Willy Tarreau" <w@1wt.eu>,
"Thomas Weißschuh" <linux@weissschuh.net>
Cc: linux-kernel@vger.kernel.org
Subject: aarch64 binaries using nolibc segfault before reaching the entry point
Date: Wed, 13 Sep 2023 20:44:59 +0200 (CEST) [thread overview]
Message-ID: <5d49767a-fbdc-fbe7-5fb2-d99ece3168cb@redhat.com> (raw)
Hi,
the tpidr2 selftest on an arm box segfaults before reaching the entry point.
I have no clue what is to blame for this or how to debug it but for a
statically linked binary there shouldn't be much stuff going on besides the
elf loader?
I can reproduce this with a program using an empty main function. Also checked
for other nolibc users - same result for init.c from rcutorture.
tools/testing/selftests/arm64/fp/za-fork is working though - the only
difference I could spot here is that it is linked together with another object
file. I also looked at the elf headers but didn't find anything obvious (but
I'm a bit out of my comfort zone here..)
After playing around with linker options I found that using -static-pie
lets the binaries run successful.
[root@arm abi]# cat test.c
int main(void)
{
return 1;
}
[root@arm abi]# gcc -Os -static -Wall -lgcc -nostdlib -ffreestanding -include ../../../../include/nolibc/nolibc.h test.c
[root@arm abi]# ./a.out
Segmentation fault
[root@arm abi]# gcc -Os -static -Wall -lgcc -nostdlib -ffreestanding -static-pie -include ../../../../include/nolibc/nolibc.h test.c
[root@arm abi]# ./a.out
[root@arm abi]#
All on aarch64 running fedora37 + upstream kernel. Any hints on what could
be borken here or how to actually fix it?
Sebastian
next reply other threads:[~2023-09-13 18:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-13 18:44 Sebastian Ott [this message]
2023-09-13 19:17 ` Mark Brown
2023-09-13 20:19 ` Thomas Weißschuh
2023-09-13 20:58 ` Willy Tarreau
2023-09-13 21:23 ` Thomas Weißschuh
2023-09-13 21:30 ` Sebastian Ott
2023-09-13 23:02 ` Thomas Weißschuh
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=5d49767a-fbdc-fbe7-5fb2-d99ece3168cb@redhat.com \
--to=sebott@redhat.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=w@1wt.eu \
/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
all inboxes | Powered by JetHome®