Skip to content

[PPC64] binaries segfault immediately #1498

@mhx

Description

@mhx

With #1497 fixed, I'm now running into the next issue on PPC64. The binaries emitted by mold will segfault immediately:

49b5351c1b64:~/build/cross/ppc64/gcc$ ppc64-alpine-linux-musl-gcc --sysroot=/opt/cross/O2 -fuse-ld=mold -static -static-libgcc CMakeFiles/sfxstub.dir/sfx/stub.c.o -o sfxstub
49b5351c1b64:~/build/cross/ppc64/gcc$ qemu-ppc64 sfxstub 
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault

I thought I'd look at the stack trace, but that wasn't very helpful:

Reading symbols from sfxstub...
(gdb) target remote localhost:1234
Remote debugging using localhost:1234
Reading /usr/lib/debug/.build-id/a3/46c839ad1004a330b536c22f017d4ecbbce4d1.debug from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
0x00000000002149c0 in ._start ()
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x00000000002149c8 in ._start ()
(gdb) bt
#0  0x00000000002149c8 in ._start ()
(gdb) q

Using lld instead of mold makes the binary work as expected:

49b5351c1b64:~/build/cross/ppc64/gcc$ ppc64-alpine-linux-musl-gcc --sysroot=/opt/cross/O2 -fuse-ld=lld -static -static-libgcc CMakeFiles/sfxstub.dir/sfx/stub.c.o -o sfxstub
49b5351c1b64:~/build/cross/ppc64/gcc$ qemu-ppc64 sfxstub 
wrapped: bad magic

This is with mold-2.40.3 with both d9b20a1 and 7e0b728 included.

Repro: sfxstub.repro.tar.gz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions