libphobos on ARM
Alex Rønne Petersen
alex at lycus.org
Fri Jun 1 15:24:16 PDT 2012
On 01-06-2012 23:05, Matthew Caron wrote:
> Hey folks,
>
> So, I've used the instructions and code here:
>
> https://bitbucket.org/goshawk/gdc/wiki/crosstool-ng
>
> to build a gdc for ARM.
>
> I've written up a simple "Hello world" and I get an Illegal Instruction
> when executing on my ARM Linux EABI system.
>
> GDB says (edited to remove standard stuff):
>
> ==
> (gdb) run
> Starting program: /hello
>
> Program received signal SIGILL, Illegal instruction.
> 0x0002f5c4 in _D2gc3gcx2GC6mallocMFkkPkZPv (this=@0x96018, size=88, bits=1,
> alloc_size=0x0)
> at
> /home/mattc/workspace/d/buildder/.build/src/gcc-4.6.2/libphobos/gc/gcx.d:1224
>
> 1224
> /home/mattc/workspace/d/buildder/.build/src/gcc-4.6.2/libphobos/gc/gcx.d: No
> such file or directory.
> in /home/mattc/workspace/d/buildder/.build/src/gcc-4.6.2/libphobos/gc/gcx.d
> Current language: auto; currently minimal
> (gdb) bt full
> #0 0x0002f5c4 in _D2gc3gcx2GC6mallocMFkkPkZPv (this=@0x96018, size=88,
> bits=1, alloc_size=0x0)
> at
> /home/mattc/workspace/d/buildder/.build/src/gcc-4.6.2/libphobos/gc/gcx.d:1224
>
> No locals.
> #1 0x0002692c in gc.gc.gc_malloc (sz=<value optimized out>,
> ba=<value optimized out>)
> at
> /home/mattc/workspace/d/buildder/.build/src/gcc-4.6.2/libphobos/gc/gc.d:201
> No locals.
> #2 0x00019ad0 in _d_newclass (ci=@0x8e8bc)
> at
> /home/mattc/workspace/d/buildder/.build/src/gcc-4.6.2/libphobos/rt/lifetime.d:123
>
> p = Unhandled dwarf expression opcode 0x9f
> ==
>
> So, the error is at line 1224 of gcx.d, which is:
>
> ==
> /**
> * add range to scan for roots
> */
> void addRange(void *p, size_t sz)
> {
> if (!p || !sz) // 1224
> {
> return;
> }
> ==
>
> The full backtrace is less than useful here, because of optimizations in
> libphobos, so I've recompiled libphobos with -O0. Recompiling my program
> and re-running it gives me:
>
> ==
> (gdb) run
> Starting program: /hello
> Hello gents
>
> Program received signal SIGILL, Illegal instruction.
> 0x0004535c in _D2gc3gcx3Gcx16fullcollectshellMFZk (this=Cannot access
> memory at address 0x1
> )
> at
> /home/mattc/workspace/d/buildder/.build/src/gcc-4.6.2/libphobos/gc/gcx.d:245
>
> 245
> /home/mattc/workspace/d/buildder/.build/src/gcc-4.6.2/libphobos/gc/gcx.d: No
> such file or directory.
> in /home/mattc/workspace/d/buildder/.build/src/gcc-4.6.2/libphobos/gc/gcx.d
> Current language: auto; currently minimal
> (gdb) bt full
> #0 0x0004535c in _D2gc3gcx3Gcx16fullcollectshellMFZk (this=Cannot access
> memory at address 0x1
> )
> at
> /home/mattc/workspace/d/buildder/.build/src/gcc-4.6.2/libphobos/gc/gcx.d:245
>
> No locals.
> #1 0x000418ec in _D2gc3gcx2GC18fullCollectNoStackMFZv (this=@0xe4018)
> at
> /home/mattc/workspace/d/buildder/.build/src/gcc-4.6.2/libphobos/gc/gcx.d:245
>
> __sync33 = (struct TypeInfo_Class &) @0xdce4c: {init = {length = 8,
> ptr = 0xbc81c "4�v"}, name = {length = 13,
> ptr = 0xbc824 "gc.gcx.GCLock"}, vtbl = {length = 6, ptr = 0xbc834},
> interfaces = {length = 0, ptr = 0x0}, base = @0xda804, destructor = 0x0,
> classInvariant = 0, m_flags = 54, deallocator = 0x0, m_offTi = {length = 0,
> ptr = 0x0}, defaultConstructor = 0x0, xgetMembers = 0}
> #2 0x0003ca34 in gc_term ()
> at
> /home/mattc/workspace/d/buildder/.build/src/gcc-4.6.2/libphobos/gc/gc.d:133
> No locals.
> #3 0x00022e2c in rt.dmain2.main.runAll (this=0xbe9e7cd8)
> at
> /home/mattc/workspace/d/buildder/.build/src/gcc-4.6.2/libphobos/rt/dmain2.d:67
>
> No locals.
> #4 0x000227c4 in rt.dmain2.main.tryExec (this=0xbe9e7cd8, dg=
> {object = 0xbe9e7cd8, func = 0x22d94 <rt.dmain2.main.runAll>})
> ---Type <return> to continue, or q <return> to quit---
> at
> /home/mattc/workspace/d/buildder/.build/src/gcc-4.6.2/libphobos/rt/dmain2.d:67
>
> No locals.
> #5 0x000225ac in main (argc=1, argv=0xbe9e7e64)
> at
> /home/mattc/workspace/d/buildder/.build/src/gcc-4.6.2/libphobos/rt/dmain2.d:67
>
> trapExceptions = true
> am = (struct char[] *) 0xe4008
> result = 0
> args = {length = 1, ptr = 0xe4008}
> ==
>
> This actually does print the "Hello gents" that it is supposed to, but
> then dies after (likely when exiting and collecting all its memory).
>
> The line referenced is in the following:
> ==
> {{{
> void initialize() // 245
> {
> gcLock = GCLock.classinfo;
> gcx = cast(Gcx*)cstdlib.calloc(1, Gcx.sizeof);
> if (!gcx)
> onOutOfMemoryError();
> gcx.initialize();
> setStackBottom(rt_stackBottom());
> }
> }}}
>
> I should note that I tested the gcc which was built along with gdc and
> it does produce a "Hello world" application which appears to work
> correctly.
>
> Does anyone have any ideas/pointers/hey there, do it this way, dummy/etc?
Please try building libphobos and libdruntime with -fno-section-anchors.
--
Alex Rønne Petersen
alex at lycus.org
http://lycus.org
More information about the D.gnu
mailing list