Re: ppc32: Building tiny executable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 4, 2018 at 2:40 PM, Segher Boessenkool
<segher@xxxxxxxxxxxxxxxxxxx> wrote:
> On Fri, May 04, 2018 at 02:23:02PM +0200, Mathieu Malaterre wrote:
>> 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
>
> So
>
> $ gdb ./tiny
> (gdb) run
> (gdb) disas
>
> and look what line the "=>" mark is on.

(gdb) r
Starting program: /tmp/tiny

Program received signal SIGSEGV, Segmentation fault.
0x10000180 in ?? ()
(gdb) disas
No function contains program counter for selected frame.
(gdb)

Just in case:

$ strace ./tiny
execve("./tiny", ["./tiny"], 0xbfd3e610 /* 17 vars */) = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0xffff8fd0} ---
+++ killed by SIGSEGV +++
Segmentation fault


-- 
Mathieu



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux