controlling code generation more precisely?

Josh Fryman fryman@cc.gatech.edu
Thu Sep 20 20:54:00 GMT 2001


hi,

i've got an ARM target, and am using a cross-hosted little-endian 
gcc (v. 2.95.2) ... and i want to change the behavior of the code
generation system.

hopefully, there's some obscure flag combination i can use to do
it for me, or maybe someone can give me a pointer on how to get
started hacking gcc.

here's the problem.  gcc generates (very annoyingly) code with
"data" values interspersed in the text segment.  that is, it
might generate something like this:


in C
----
void foo( void )
{
   int c=42;
   printf("c=%d\n",c);
}

in ARM-ASM  (edited to make shorter)
----------
.section        .rodata
.LC0:
        .ascii  "c=%d\012\000"
.text
foo:
   .....
        ldr     r0, .L4
        ldr     r1, [fp, #-16]
        bl      printf
        b       .L3
.L4:
        .word   .LC0
.L3:
        ldmea   fp, {fp, sp, pc}

note how gcc has "stuck" into the middle of the instruction
stream some data values at .L4! there's absolutely no reason 
to do this that i can see.  it would make my life much easier 
(for research purposes) if i could move these little random 
scattered data segments into the *main* data segment.  

(note that gcc doesn't generate a .data segment, it just 
generates a .rodata segment, which is another error AFAICS.  
but these little chunks *should* go into a .data segment, 
not .text!)

more complicated examples just do this with bigger "insert"'s
of data, and more little data blocks everywhere - even within
the same function.

anyone have any ideas?  any solutions i can try?  any reasons
why this is a wrong-thing-to-do?

thanks,

josh fryman



More information about the Gcc-help mailing list