Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Aug 2015 21:55:19 -0400
From:      Serge Voilokov <serge0x76@gmail.com>
To:        freebsd-arm@freebsd.org
Subject:   cross-compiling on OSX for RPI
Message-ID:  <CAMbZYjWHWmpmEzo-BLRW10WO2oLLHi9nQ8odA6Njq-pRt0c74g@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Hi,

I have built some hello world app on OSX for Raspberry PI
using clang and GNU binutils.

Resulting a.out fails on RPI with the error:
Invalid PT_INTERP
./a.out: Exec format error. Binary file not executable.

Loading of a.out fails in the kernel on imgact_elf.c:780 when it
verifies offsets and page size for INTERP section.

When comparing readelfs for native (6k) and osx a.out(38k) variants I
found that sizes differs and INTERP sections have different positions:

--- a.out.cross
+++ a.out.native
   Start of program headers:          52 (bytes into file)
-  Start of section headers:          35076 (bytes into file)
-  Flags:                             0x5000002, has entry point, Version5 EABI
+  Start of section headers:          2652 (bytes into file)
+  Flags:                             0x5000202, has entry point,
Version5 EABI, soft-float ABI
   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
-  INTERP         0x008000 0x00008000 0x00008000 0x00015 0x00015 R   0x1
+  INTERP         0x000134 0x00008134 0x00008134 0x00015 0x00015 R   0x1

How can I fix this? I see following options:

- fix binutils-2.24/ld somehow to put valid section offsets.
- try to compile freebsd/contrib/binutils on OSX and use it.
- static linking (less preferred).
- as a last resort install FreeBSD x86 VM and compile there.

Please advice.
-serge

P.S.

Compiler command line:
clang-mp-3.7 --sysroot=/sd_sysroot --target=armv6--freebsd11.0-eabi -o
test.o -c test.c

Ld command line:
arm-eabi-freebsd11.0-ld -dynamic-linker /libexec/ld-elf.so.1 test.o -o
a.out [other crt files and libs].

(Linker is from binutils-2.24 configured with sysroot and
target=arm-eabi-freebsd11.0)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAMbZYjWHWmpmEzo-BLRW10WO2oLLHi9nQ8odA6Njq-pRt0c74g>