Common areas and as

Nick Burrett nick at
Sun Oct 26 11:28:15 PST 2003

See the attached file.

The code is correct as compiled by GCC 3.3.1, but if you build an 
executable and examime the pointers in |L..20|, then you'll see 
something weird as happened.

Code compiled with -O2 and -mlibscl.

         KEEP |init_xy|
         ; args = 0, pretend = 0, frame = 0, alloca = 0
         ; frame_needed = 0, uses_anonymous_args = 0
         ; nonlocal_label = 0, nonlocal_goto = 0, leaf = 1
         ; link register save eliminated.
         ldr     __a4, |L..20|
         mov     __a3, #3
         str     __a3, [__a4, #0]
         mov     __a2, #2
         ; __lr needed for prologue
         ldr     __a4, |L..20|+4
         str     __a2, [__a4, #0]
         mov     __pc, __lr
         DCD     |x|
         DCD     |y|

If I disassemble the resultant code, I get this:

00008100 e59f3014 ldr   r3, &0000811c
00008104 e3a02003 mov   r2, #3
00008108 e5832000 str   r2, [r3]
0000810c e3a01002 mov   r1, #2
00008110 e59f3008 ldr   r3, &00008120
00008114 e5831000 str   r1, [r3]
00008118 e1a0f00e mov   pc, lr
0000811c 0000819c muleq r0, ip, r1           ; DCD |x|
00008120 0000827c andeq r8, r0, ip, ror r2   ; DCD |y|

Rather than pointing at the common definitions of |x| and |y|, I find 
that 'y' points to 'main' and 'x' points to 'test5'.

I'm in a maze of twisty passages here and getting very confused with the 
code in 'as'.  Does anybody have a clue about the code in 'as' or are we 
all secretly hoping that it is bug free ?



-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20000715-1.c
Type: text/x-csrc
Size: 1148 bytes
Desc: not available
URL: <>

More information about the gcc mailing list