Bad profiling code from gcc-3.2 for m68k-linux

Peter Barada
Tue Aug 27 08:00:00 GMT 2002

>> I'm trying to build a m68k-linux gcc compiler for coldfire, and its
>> producing the follwoing code sequence for profiling:
>> tanMp:
>> 	link.w %a6,#-332
>> 	move.l %d2,-(%sp)
>> 	.data
>> 	.align	2
>> .LP1:
>> 	.long	0
>> 	.text
>> 	lea (.LP1,%pc),%a1
>> 	jbsr _mcount
>> The lea doesn't look right.  I'm assuming its trying to put the
>> address of .LP1 into %a1 before calling _mcount.  If so, that syntax
>> looks like its placing the *sum* of .LP1 and %pc into %a1.
>That's correct.  The assembler makes .LP1 a pc-relative reference.

Well, in my case it won't work since the ColdFire only supports 16 bit
offset in the lea for pc-relative addressing mode(7.2).  It requires 32 bits
since .LP1 is in the .data section.  Once I changed it use absolute
addressing mode(7.1) to:

 	lea .LP1,%a1

it works fine.  Why would one do this type of addressing is beyond me
since it requires 4 words(on 68020) to encode that addressing mode
where an lea of the absolute symbol address directly only requires three:

00000000 <.text>:
   0:	43fb 0170 0000 	lea %pc@(0x2),%a1  ; lea (.LP0,%pc),%a1
   6:	0000 
   8:	61ff 0000 0000 	bsrl 0xa           ; jbsr _mcount

00000000 <.text>:
   0:	43f9 0000 0000 	lea 0x0,%a1        ; lea .LP0,%a1
   6:	61ff 0000 0000 	bsrl 0x8           ; jbsr _mcount

Peter Barada                         
Wizard                                         781-852-2768 (direct)
WaveMark Solutions(wholly owned by Motorola)   781-270-0193 (fax)

More information about the Binutils mailing list