mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* aarch64 binaries using nolibc segfault before reaching the entry point
@ 2023-09-13 18:44 Sebastian Ott
  2023-09-13 19:17 ` Mark Brown
  2023-09-13 20:19 ` Thomas Weißschuh
  0 siblings, 2 replies; 7+ messages in thread
From: Sebastian Ott @ 2023-09-13 18:44 UTC (permalink / raw)
  To: Mark Brown, Willy Tarreau, Thomas Weißschuh; +Cc: linux-kernel

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-09-13 23:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-13 18:44 aarch64 binaries using nolibc segfault before reaching the entry point Sebastian Ott
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

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®