On Fri, May 4, 2018 at 2:16 PM, Segher Boessenkool <segher@xxxxxxxxxxxxxxxxxxx> wrote: > On Fri, May 04, 2018 at 01:45:35PM +0200, Mathieu Malaterre wrote: >> $ gcc -static -ffreestanding -nostartfiles -s -o tiny tiny.c >> $ ./tiny >> Segmentation fault >> >> What do I need to pay attention to on ppc to build tiny executable >> using the _start function ? > > You need to set up r13. This is powerpc64? (32-bit works fine for me, > but you may be using a different ABI, you didn't tell. I'm on Linux). Nope, ppc32. $ objdump -f tiny tiny: file format elf32-powerpc architecture: powerpc:common, flags 0x00000102: EXEC_P, D_PAGED start address 0x10000120 dmesg states: [ 1552.267961] tiny[2127]: unhandled signal 11 at ffff8fd0 nip 10000180 lr 10000150 code 1 > You also should align r1 and set up a terminating stack frame, and set > LR to 0. Look what glibc does :-) Alright, let me stare at that code until it surrender :) -- Mathieu