Subject: m68k gas optimisation
To: None <>
From: Gregory McGarry <>
List: tech-toolchain
Date: 02/06/2002 11:27:48
Sometime between about 2001/12/15 and 2002/01/15 a flag
was enabled in binutils to permit gas to optimise memory
access into pc-relative addressing on m68k.  This
breaks on the NetBSD/hp300 kernel when it is running
without the MMU on and we are manually relocating

Obviously we don't have to manually relocate addresses
if they are pc-relative.  I don't want to change the code
to assume pc-relative addressing, since it will break with
older binutils.  So is there an assembler directive
to tell gas I don't want it to do this?

MMU trampoline loading from sys/arch/hp300/hp300/locore.s:

#define _RELOC(var, ar)         \
        lea     var,ar;         \
        addl    %a5,ar
#define ASRELOC(var, ar)        _RELOC(_ASM_LABEL(var), ar)

        lea     MAXADDR,%a2             | PA of last RAM page
        ASRELOC(Lhighcode, %a1)         | addr of high code
        ASRELOC(Lehighcode, %a3)        | end addr
        movw    %a1@+,%a2@+             | copy a word
        cmpl    %a3,%a1                 | done yet?
        jcs     Lcodecopy               | no, keep going
        jmp     MAXADDR                 | go for it!

         * BEGIN MMU TRAMPOLINE.  This section of code is not
         * executed in-place.  It's copied to the last page
         * of RAM (mapped va == pa) and executed there.


Used to generate (about mid December):

0000176e <Lstploaddone>:
    176e:       45f8 f000       lea fffff000 <_end+0xfff245b8>,%a2
    1772:       43f9 0000 178c  lea 178c <Lhighcode>,%a1
    1778:       d3cd            addal %a5,%a1
    177a:       47f9 0000 1826  lea 1826 <Lehighcode>,%a3
    1780:       d7cd            addal %a5,%a3

00001782 <Lcodecopy>:
    1782:       34d9            movew %a1@+,%a2@+
    1784:       b3cb            cmpal %a3,%a1
    1786:       65fa            bcss 1782 <Lcodecopy>
    1788:       4ef8 f000       jmp fffff000 <_end+0xfff245b8>

Now generates: 

0000176e <Lstploaddone>:
    176e:       45f8 f000       lea fffff000 <_end+0xfff24568>,%a2
    1772:       43fa 0014       lea %pc@(1788 <Lhighcode>),%a1
    1776:       d3cd            addal %a5,%a1
    1778:       47fa 00a2       lea %pc@(181c <Lehighcode>),%a3
    177c:       d7cd            addal %a5,%a3

0000177e <Lcodecopy>:
    177e:       34d9            movew %a1@+,%a2@+
    1780:       b3cb            cmpal %a3,%a1
    1782:       65fa            bcss 177e <Lcodecopy>
    1784:       4ef8 f000       jmp fffff000 <_end+0xfff24568>

	-- Gregory McGarry <>