Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2009-11

ARM Illegal instruction debugging howto

8 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

ik

Hello,

I'm working (when I have time) to find a way to create an OpenMoko FPC version.
It uses ARM EABI version. My latest attempt provides me the following executable:
ELF 32-bit LSB executable, ARM, version 1, statically linked, not stripped

While on "regular" Linux the same file identifier is: hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, for GNU/Linux 2.4.0, stripped

A normal executable in OM is:
ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.24, dynamically linked (uses shared libs), stripped

So how can I look for the proper build of ppcrossarm and normal ppcarm ?

Thanks,
Ido

http://ik.homelinux.org/

Reply by email

Jonas Maebe
to ik
ik wrote 13 lines
It uses ARM EABI version. My latest attempt provides me the following executable: ELF 32-bit LSB executable, ARM, version 1, statically linked, not stripped While on "regular" Linux the same file identifier is: hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, for GNU/Linux 2.4.0, stripped A normal executable in OM is: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.24, dynamically linked (uses shared libs), stripped So how can I look for the proper build of ppcrossarm and normal ppcarm ?

Static or dynamic is unlikely to be related to your problems with illegal instructions. The backtrace you previously posted (with the illegal opcode in sysinitfpu suggests that you are not compiling an EABI compiler, because that one defaults to softfloat. There's another thing I just noticed in your previous mail:

make OPT='dFPC_ARMEL -dFPC_ABI_EABI -Xd' OS=TARGET=linux CPU_TARGET=arm

That first parameter is missing a dash (-), it should read -dFPC_ARMEL. Without that dash, you will not get an EABI compiler.

You should also not define -dFPC_ABI_EABI yourself. The compiler will define that symbol when the current target is EABI. Defining that symbol while you are not compiling for an EABI platform will only result in an RTL with invalid code.

Jonas

Reply by email

ik
to Jonas Maebe

‎Thanks Jonas,

I'll try it this evening and see if it works.

Ido

http://ik.homelinux.org/

Jonas Maebe wrote 39 lines
On 30 Nov 2009, at 22:22, ik wrote: > It uses ARM EABI version. My latest attempt provides me the following > executable: > ELF 32-bit LSB executable, ARM, version 1, statically linked, not stripped > > While on "regular" Linux the same file identifier is: > hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically > linked, for GNU/Linux 2.4.0, stripped > > A normal executable in OM is: > ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.24, > dynamically linked (uses shared libs), stripped > > So how can I look for the proper build of ppcrossarm and normal ppcarm ? Static or dynamic is unlikely to be related to your problems with illegal instructions. The backtrace you previously posted (with the illegal opcode in sysinitfpu suggests that you are not compiling an EABI compiler, because that one defaults to softfloat. There's another thing I just noticed in your previous mail: > make OPT='dFPC_ARMEL -dFPC_ABI_EABI -Xd' OS=TARGET=linux CPU_TARGET=arm That first parameter is missing a dash (-), it should read -dFPC_ARMEL. Without that dash, you will not get an EABI compiler. You should also not define -dFPC_ABI_EABI yourself. The compiler will define that symbol when the current target is EABI. Defining that symbol while you are not compiling for an EABI platform will only result in an RTL with invalid code. Jonas_______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

ik
to ik

The program now execute but does not do anything:

program hello;
begin
  writeln('Hello World');
end.

it does not print anything on the screen.

strace only uses execv as the single executing line.

What am I missing here ?

Ido

http://ik.homelinux.org/

ik wrote 53 lines
‎Thanks Jonas, I'll try it this evening and see if it works. Ido http://ik.homelinux.org/ On Tue, Dec 1, 2009 at 12:09 AM, Jonas Maebe wrote: > > On 30 Nov 2009, at 22:22, ik wrote: > > > It uses ARM EABI version. My latest attempt provides me the following > > executable: > > ELF 32-bit LSB executable, ARM, version 1, statically linked, not > stripped > > > > While on "regular" Linux the same file identifier is: > > hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically > > linked, for GNU/Linux 2.4.0, stripped > > > > A normal executable in OM is: > > ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.24, > > dynamically linked (uses shared libs), stripped > > > > So how can I look for the proper build of ppcrossarm and normal ppcarm ? > > Static or dynamic is unlikely to be related to your problems with illegal > instructions. The backtrace you previously posted (with the illegal opcode > in sysinitfpu suggests that you are not compiling an EABI compiler, because > that one defaults to softfloat. There's another thing I just noticed in your > previous mail: > > > make OPT='dFPC_ARMEL -dFPC_ABI_EABI -Xd' OS=TARGET=linux CPU_TARGET=arm > > That first parameter is missing a dash (-), it should read -dFPC_ARMEL. > Without that dash, you will not get an EABI compiler. > > You should also not define -dFPC_ABI_EABI yourself. The compiler will > define that symbol when the current target is EABI. Defining that symbol > while you are not compiling for an EABI platform will only result in an RTL > with invalid code. > > > Jonas_______________________________________________ > fpc-devel maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-devel >

Reply by email

Jonas Maebe
to ik
ik wrote 13 lines
The program now execute but does not do anything: program hello; begin writeln('Hello World'); end. it does not print anything on the screen. strace only uses execv as the single executing line. What am I missing here ?

A debugger and single stepping from the start of the program to see what fails where.

Jonas

Reply by email

ik
to Jonas Maebe

gdb ./hello
GNU gdb (GDB) 7.0
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html

This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details.
This GDB was configured as "arm-oe-linux-gnueabi". For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /var/volatile/tmp/hello...done. (gdb) break 1
Breakpoint 1 at 0x807c: file ../../../../../tmp/hello.pp, line 1. (gdb) break 4
Note: breakpoint 1 also set at pc 0x807c.
Breakpoint 2 at 0x807c: file ../../../../../tmp/hello.pp, line 4. (gdb) r
Starting program: /var/volatile/tmp/hello

Program received signal SIGILL, Illegal instruction. 0x00008abc in SYSTEM_FPC_CPUCODEINIT ()
(gdb) bt
#0 0x00008abc in SYSTEM_FPC_CPUCODEINIT ()
#1 0x0000fbbc in SYSTEM_init ()
#2 0x0000b268 in fpc_initializeunits ()
#3 0x0000807c in $main () at ../../../../../tmp/hello.pp:3 (gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault. 0x00000000 in ?? ()
(gdb) bt
#0 0x00000000 in ?? ()
#1 0x0000f670 in SYSTEM_REENABLE_SIGNAL$LONGINT$$BOOLEAN () #2 0x00000000 in ?? ()
(gdb) c
Continuing.

Program exited with code 0330.

Thanks,

Ido
http://ik.homelinux.org/

Jonas Maebe wrote 25 lines
On 01 Dec 2009, at 19:09, ik wrote: > The program now execute but does not do anything: > > program hello; > > begin > writeln('Hello World'); > end. > > it does not print anything on the screen. > > strace only uses execv as the single executing line. > > What am I missing here ? A debugger and single stepping from the start of the program to see what fails where. Jonas_______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Jonas Maebe
to ik
ik wrote 40 lines
gdb ./hello GNU gdb (GDB) 7.0 Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html > This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "arm-oe-linux-gnueabi". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /var/volatile/tmp/hello...done. (gdb) break 1 Breakpoint 1 at 0x807c: file ../../../../../tmp/hello.pp, line 1. (gdb) break 4 Note: breakpoint 1 also set at pc 0x807c. Breakpoint 2 at 0x807c: file ../../../../../tmp/hello.pp, line 4. (gdb) r Starting program: /var/volatile/tmp/hello Program received signal SIGILL, Illegal instruction. 0x00008abc in SYSTEM_FPC_CPUCODEINIT () (gdb) bt #0 0x00008abc in SYSTEM_FPC_CPUCODEINIT () #1 0x0000fbbc in SYSTEM_init () #2 0x0000b268 in fpc_initializeunits () #3 0x0000807c in $main () at ../../../../../tmp/hello.pp:3 (gdb) c Continuing. Program received signal SIGSEGV, Segmentation fault. 0x00000000 in ?? () (gdb) bt #0 0x00000000 in ?? () #1 0x0000f670 in SYSTEM_REENABLE_SIGNAL$LONGINT$$BOOLEAN () #2 0x00000000 in ?? () (gdb) c Continuing. Program exited with code 0330.

This does not appear to correspond to what you previously said about strace, since strace normally also show signals. I would guess (but these are really just wild guesses) that the problem is one or more of the following: a) the sigprocmask system call on your device has a different interface than the one expected by the rtl, or its sigset has a different number of elements b) the definition of the signal handler context in the rtl does not correspond to whatever the kernel on your device uses. You can compare the definitions in rtl/linux/arm/sighndh.inc with similar ones referred to from ucontext_t or a similar type in your C headers; it doesn't matter if those structs contain more fields *after* the ones defined in the Pascal include file, but if they use a different order or other fields are defined in between, then that is a problem.

I'm not really interested in digging further in this though (I have too many things on my plate as it is), so I hope that someone else can continue helping you to debug and fix your problem.

Jonas

Reply by email

ik
to Jonas Maebe

OK, thank you for your help.

For now I did not find anything that is different on the function that is causing the termination of the program.

Does anyone here knows what/where else I should be looking for, or how to better debug the problem ?

Thanks,
Ido

http://ik.homelinux.org/

Jonas Maebe wrote 70 lines
On 01 Dec 2009, at 19:36, ik wrote: > gdb ./hello > GNU gdb (GDB) 7.0 > Copyright (C) 2009 Free Software Foundation, Inc. > License GPLv3+: GNU GPL version 3 or later < http://gnu.org/licenses/gpl.html >> > This is free software: you are free to change and redistribute it. > There is NO WARRANTY, to the extent permitted by law. Type "show copying" > and "show warranty" for details. > This GDB was configured as "arm-oe-linux-gnueabi". > For bug reporting instructions, please see: > <http://www.gnu.org/software/gdb/bugs/>... > Reading symbols from /var/volatile/tmp/hello...done. > (gdb) break 1 > Breakpoint 1 at 0x807c: file ../../../../../tmp/hello.pp, line 1. > (gdb) break 4 > Note: breakpoint 1 also set at pc 0x807c. > Breakpoint 2 at 0x807c: file ../../../../../tmp/hello.pp, line 4. > (gdb) r > Starting program: /var/volatile/tmp/hello > > Program received signal SIGILL, Illegal instruction. > 0x00008abc in SYSTEM_FPC_CPUCODEINIT () > (gdb) bt > #0 0x00008abc in SYSTEM_FPC_CPUCODEINIT () > #1 0x0000fbbc in SYSTEM_init () > #2 0x0000b268 in fpc_initializeunits () > #3 0x0000807c in $main () at ../../../../../tmp/hello.pp:3 > (gdb) c > Continuing. > > Program received signal SIGSEGV, Segmentation fault. > 0x00000000 in ?? () > (gdb) bt > #0 0x00000000 in ?? () > #1 0x0000f670 in SYSTEM_REENABLE_SIGNAL$LONGINT$$BOOLEAN () > #2 0x00000000 in ?? () > (gdb) c > Continuing. > > Program exited with code 0330. This does not appear to correspond to what you previously said about strace, since strace normally also show signals. I would guess (but these are really just wild guesses) that the problem is one or more of the following: a) the sigprocmask system call on your device has a different interface than the one expected by the rtl, or its sigset has a different number of elements b) the definition of the signal handler context in the rtl does not correspond to whatever the kernel on your device uses. You can compare the definitions in rtl/linux/arm/sighndh.inc with similar ones referred to from ucontext_t or a similar type in your C headers; it doesn't matter if those structs contain more fields *after* the ones defined in the Pascal include file, but if they use a different order or other fields are defined in between, then that is a problem. I'm not really interested in digging further in this though (I have too many things on my plate as it is), so I hope that someone else can continue helping you to debug and fix your problem. Jonas_______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email