Created attachment 29548 [details] Script of the compile/link I compiled and linked on Ubuntu x86_64 for the Raspberry Pi. The compiler/linker completed with no errors. int main() { return 0;} When hello is executed on Raspberry Pi, I got a Segmentation fault. If I compile on Ubuntu with -nostdlib and explicitly list the Raspberry Pi crtxxx.o files and the Raspberry Pi libs, the resultant executable completes without error on Raspberry Pi. I attached a script of the compile actions on Ubuntu. I believe this to be a problem with the crtxxxx.o files and the libs distributed with arm-linux-gnueabihf-gcc-4.6 package. The same package on Raspberry Pi works Ok. On Ubuntu > uname -a Linux P9X79 3.2.0-38-generic #60-Ubuntu SMP Wed Feb 13 13:22:43 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux On Raspberry Pi > uname -a Linux raspberrypi 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l GNU/Linux
If these files come form an Ubuntu package then it should be reported to Ubuntu
Have you tried running gdb on it to see why it is segfaulting? It sounds like you are using maybe an incompatible ABI.
On Ubuntu, I recompiled with -g On RaspberryPi, I ran gdb on the resulting executable tomdean@raspberrypi:~/p9x79/bug$ gdb hello GNU gdb (GDB) 7.4.1-debian <snip> Reading symbols from /home/tomdean/p9x79/bug/hello...done. (gdb) b main Breakpoint 1 at 0x8364: file hello.c, line 3. (gdb) r Starting program: /home/tomdean/p9x79/bug/hello Program received signal SIGSEGV, Segmentation fault. 0x000573a6 in ?? () (gdb) bt #0 0x000573a6 in ?? () #1 0x000082ee in _start () I think the ubuntu crtxxx.o files and the unbunt arm-linux-gnueabihf-gcc-4.6 libs were not built correctly. diff says they are not the same as the RaspberryPi files. If I compile on ubuntu and link on RaspberryPi, all is well. If I compile on ubuntu and link, using the crtxxx.o and libs from RaspberryPi, all is well.
Looking again at gdb, _start from ubuntu is not the same as _start on RaspberryPi, although both compiler versions are the same. ################### ## build on ubuntu ## gdb on raspi tomdean@raspberrypi:~/p9x79/bug$ gdb hello GNU gdb (GDB) 7.4.1-debian <snip> Reading symbols from /home/tomdean/p9x79/bug/hello...done. (gdb) b main Breakpoint 1 at 0x8364: file hello.c, line 3. (gdb) r Starting program: /home/tomdean/p9x79/bug/hello Program received signal SIGSEGV, Segmentation fault. 0x000573a6 in ?? () (gdb) bt #0 0x000573a6 in ?? () #1 0x000082ee in _start () (gdb) disassemble/r _start Dump of assembler code for function _start: 0x000082e4 <+0>: 4f f0 00 0b mov.w r11, #0 0x000082e8 <+4>: 4f f0 00 0e mov.w lr, #0 0x000082ec <+8>: 5d f8 04 1b ldr.w r1, [sp], #4 0x000082f0 <+12>: 6a 46 mov r2, sp 0x000082f2 <+14>: 4d f8 04 2d str.w r2, [sp, #-4]! 0x000082f6 <+18>: 4d f8 04 0d str.w r0, [sp, #-4]! 0x000082fa <+22>: df f8 14 c0 ldr.w r12, [pc, #20] ; 0x8310 <_start+44> 0x000082fe <+26>: 4d f8 04 cd str.w r12, [sp, #-4]! 0x00008302 <+30>: 04 48 ldr r0, [pc, #16] ; (0x8314 <_start+48>) 0x00008304 <+32>: 04 4b ldr r3, [pc, #16] ; (0x8318 <_start+52>) 0x00008306 <+34>: ff f7 da ef blx 0x82bc <__libc_start_main> 0x0000830a <+38>: ff f7 e6 ef blx 0x82d8 <abort> 0x0000830e <+42>: 00 00 bd 83 ; <UNDEFINED> instruction: 0x83bd0000 0x00008312 <+46>: 00 00 5c 83 cmphi r12, #0 0x00008316 <+50>: 00 00 79 83 cmnhi r9, #0 0x0000831a <+54>: 00 00 03 4b blmi 0xc8322 End of assembler dump. ################### ## compile on ubuntu ## link on raspi ## gdb on raspi ubuntu> arm-linux-gnueabihf-gcc-4.6 -g -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -marm hello.c -Wl,-t -c -o hello.o tomdean@raspberrypi:~/p9x79/bug$ arm-linux-gnueabihf-gcc-4.6 -g -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -marm hello.o -Wl,-t -o ~/work/hello tomdean@raspberrypi:~/p9x79/bug$ gdb ~/work/hello GNU gdb (GDB) 7.4.1-debian <snip> Reading symbols from /home/tomdean/work/hello...done. (gdb) b main Breakpoint 1 at 0x8398: file hello.c, line 3. (gdb) r Starting program: /home/tomdean/work/hello Breakpoint 1, main () at hello.c:3 3 return 0; (gdb) disassemble/r _start Dump of assembler code for function _start: 0x000082e4 <+0>: 00 b0 a0 e3 mov r11, #0 0x000082e8 <+4>: 00 e0 a0 e3 mov lr, #0 0x000082ec <+8>: 04 10 9d e4 pop {r1} ; (ldr r1, [sp], #4) 0x000082f0 <+12>: 0d 20 a0 e1 mov r2, sp 0x000082f4 <+16>: 04 20 2d e5 push {r2} ; (str r2, [sp, #-4]!) 0x000082f8 <+20>: 04 00 2d e5 push {r0} ; (str r0, [sp, #-4]!) 0x000082fc <+24>: 10 c0 9f e5 ldr r12, [pc, #16] ; 0x8314 <_start+48> 0x00008300 <+28>: 04 c0 2d e5 push {r12} ; (str r12, [sp, #-4]!) 0x00008304 <+32>: 0c 00 9f e5 ldr r0, [pc, #12] ; 0x8318 <_start+52> 0x00008308 <+36>: 0c 30 9f e5 ldr r3, [pc, #12] ; 0x831c <_start+56> 0x0000830c <+40>: eb ff ff eb bl 0x82c0 <__libc_start_main> 0x00008310 <+44>: f0 ff ff eb bl 0x82d8 <abort> 0x00008314 <+48>: 0c 84 00 00 andeq r8, r0, r12, lsl #8 0x00008318 <+52>: 90 83 00 00 muleq r0, r0, r3 0x0000831c <+56>: ac 83 00 00 andeq r8, r0, r12, lsr #7 End of assembler dump.