#1068302 musl: static-pie support questionable: segfault on m68k, no ASLR on sh4

Package:
musl
Source:
musl
Description:
standard C library
Submitter:
Thorsten Glaser
Date:
2024-04-05 01:21:02 UTC
Severity:
normal
Tags:
#1068302#5
Date:
2024-04-03 10:30:55 UTC
From:
To:
On m68k (ARAnyM Atari TT/Falcon VM):

root@aranym:~ # cat t.c
#include <stdio.h>
int main(void) {
printf("main = 0x%lX\n", (unsigned long)main);
return (0);
}
root@aranym:~ # musl-gcc -fPIE -static -static-pie -fno-lto -o t t.c
root@aranym:~ # file t
t: ELF 32-bit MSB pie executable, Motorola m68k, 68020, version 1 (SYSV), static-pie linked, with debug_info, not stripped
root@aranym:~ # ./t
Segmentation fault
139|root@aranym:~ # musl-gcc -fPIE -static-pie -fno-lto -o t t.c
root@aranym:~ # file t
t: ELF 32-bit MSB pie executable, Motorola m68k, 68020, version 1 (SYSV), static-pie linked, with debug_info, not stripped
root@aranym:~ # ./t
Segmentation fault


The same test program in a qemu-user-based sh4 buildd:

main = 0x400006A4
main = 0x400006A4
main = 0x400006A4


On amd64, arm64, armel, armhf, i386, loong64, mips64el¹, ppc64el,
riscv64 and s390x, it DTRT.

① with a manual hack due to the still-existing musl-gcc wrapper bug:

	muslspec=$topdir/xmusl.spec
	case $DEB_HOST_ARCH in
	(mipsel)   cat /usr/lib/mipsel-linux-musl/musl-gcc.specs ;;
	(mips64el) cat /usr/lib/mips64el-linux-musl/musl-gcc.specs ;;
	esac >"$muslspec" || exit 255
	printf '%s\n' 1a '%rename cc1 old_cc1' . \
	    '/^[*]cc1:/+1s/^/%(old_cc1) /' w q | \
	    ed -s "$muslspec" || exit 255
	test -s "$muslspec" || exit 255
	muslgcc="$CC -specs $muslspec"