On Sunday, 5 April 2015 at 10:16:10 UTC, Johannes Pfau wrote:
I'll push support for the section attribute in 1~2 hours. (waiting for the testsuite ;-)

[1] https://github.com/D-Programming-GDC/GDC/blob/master/libphobos/libdruntime/gcc/attribute.d

I've made a couple of tests and it all works as expected...
The snippet below builds without problems (except for the expected error; confirming that I have gotten the immutable part right). In addition, I've checked the disassembly and it all checks out fine.

import gcc.attribute;

//alias extern(C) void function() VectorFunc;
//@attribute("section",(".isr_vector")) immutable VectorFunc [100] functions = [ cast(VectorFunc) 0x10001000, &Reset_Handler, cast(VectorFunc)0xfadeface ]; /* works */ //@attribute("section",".isr_vector") immutable VectorFunc [100] functions = [ cast(VectorFunc) 0x10001000, &Reset_Handler, cast(VectorFunc)0xfeedface ]; /* works */

alias extern(C) immutable void function() VectorFunc;
@attribute("section",".isr_vector") VectorFunc [100] g_pfnVectors = [ cast(VectorFunc) 0x10001000, &Reset_Handler, cast(VectorFunc)0xfeedfeed ]; /* works */


extern(C) void Reset_Handler()
{
// g_pfnVectors[4] = cast(VectorFunc)0x1000; /* error: cannot modify immutable expression g_pfnVectors[4] (correct behaviour) */

        while(1){}
}

...

08000000 <_D5start12g_pfnVectorsyG100PUZv>:
 8000000:       10001000        andne   r1, r0, r0
 8000004:       08000235        stmdaeq r0, {r0, r2, r4, r5, r9}
 8000008:       feedface        cdp2    10, 14, cr15, cr13, cr14, {6}

[snipped some frame_dummy, tm_clones and dtors junk]

08000234 <Reset_Handler>:
 8000234:       e7fe            b.n     8000234 <Reset_Handler>

Reply via email to