[fpc-pascal] ARM Linux crosscompiler: compiles but... executable gives segmentation fault
Michael Ring
mail at michael-ring.org
Fri Jan 10 13:39:59 CET 2014
I think this is an ARMV6 specific Problem, I also realized while
debugging on embedded target that it does not work anymore, same code
compiled for ARMV7 debugs (and runs) just fine...
Until now I did not find the time to search for the revision that broke
armv6m.
Michael
Am 10.01.14 13:27, schrieb Reinier Olislagers:
> Hi all,
>
> For the Dutch among us: de dag die je wist dat zou komen...
>
> Thanks to earlier help I got to build an ARM Linux cross compiler module
> in fpcup which even compiles fpcup itself (both using trunk and stable
> starting compiler):
> opt="-fPIC -dFPC_ARMHF"
> crossopt="-CpARMV6 -CaEABIHF -CfVFPV2"
>
> fpc -g -gl -Tlinux -Parm simple.lpr
>
> Question: should I have compiled with -fPIC?
>
> Uploaded resulting executable
> http://ubuntuone.com/0y3yXGcU8fEXR6OTMyvfGN
>
> The program:
> program simple;
>
> begin
> writeln('hello');
> end.
>
> Relevant fpc.cfg snippet:
> #IFDEF CPUARM
> #IFDEF LINUX
> -CpARMV6
> -CaEABIHF
> -CfVFPV2
> -FDC:\development\cross\bin\arm-linux\
> -XParm-linux-
> -Xd
> -FlC:\development\cross\lib\arm-linux\
> -Xr/usr/lib
> #ENDIF
> #ENDIF
>
> However, running the resulting binary on my virtual Raspbian fails with
> a segmentation fault. Running under gdb gives
> (gdb) run
> Starting program: /root/simple
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x0002b6e4 in
> SYSTEM_$$_ARRAYSTRINGTOPPCHAR$array_of_ANSISTRING$LONGINT$$PPCHAR ()
> (gdb) bt
> #0 0x0002b6e4 in
> SYSTEM_$$_ARRAYSTRINGTOPPCHAR$array_of_ANSISTRING$LONGINT$$PPCHAR ()
> #1 0x00008124 in _start ()
>
>
> On the raspbian (which is built on hardfloat), file gives
> simple: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically
> linked, for GNU/Linux 2.0.0, not stripped
>
> Compare with system-provided binary:
> file /usr/bin/yes
> /usr/bin/yes: ELF 32-bit LSB executable, ARM, version 1 (SYSV),
> dynamically linked (uses shared libs), for GNU/Linux 2.6.26,
> BuildID[sha1]=0xf2df9a56df5c7b5490f7dba10f2163acb8971fce, stripped
>
> Question: should I be worried about the GNU/Linux 2.0.0 above?
>
> ldd simple
> not a dynamic executable
>
> I've run
> readelf -a simple
> uploaded to
> http://ubuntuone.com/1cAX24nbcPkGo05fFWDbOr
>
> readelf -a /usr/bin/yes
> uploaded to
> http://ubuntuone.com/6FD65xgakyE9eZOIme2z47
>
> Question: what steps should I take now?
>
> Thanks
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list