tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: m68k build failure for 68040

On Mon, May 11, 2015 at 05:09:57PM +0100, Robert Swindells wrote:
> Martin Husemann wrote:
> >On Mon, May 11, 2015 at 04:43:18PM +0100, Robert Swindells wrote:
> >> 
> >> Doing a build of current for mac68k with -m68040 defined in mk.conf I
> >> get the following error. It used to be possible to do an 040 build.
> >
> >What exactly are you doing? Accidently dropped all optimizations?
> I had got this in mk.conf:
> .if ${MACHINE_ARCH} == m68k
> COPTS+= -m68040
> LDFLAGS+= -m68040
> .endif

with those options turned on, the linker is putting the objects together in
a different order for some reason, with the effect that the branch target
of "PICJUMP $_exception_handler" is no longer within range of the 16-bit
branch displacement which that that macro produces.

curiously, the comment in that macro implies that someone expected that
the "bra" instruction would be assembled into an instruction with 32-bit

	.macro PICJUMP addr
	/* ISA C has no bra.l instruction, and since this assembly file
	   gets assembled into multiple object files, we avoid the
	   bra instruction entirely.  */
#if defined (__mcoldfire__) && !defined (__mcfisab__)
	lea	\addr-.-8,a0
	jmp	pc@(a0)
	bra	\addr

but the assembler actually produces the 16-bit displacement branch.
forcing 32-bit displacement (ie. changing the "bra" to "bral")
fixes the build (though I haven't tried running the resulting binaries).

accord to the as info docs, the assembler really should be generating
a 32-bit displacement:

9.23.1 M680x0 Options


     You can use the `-l' option to shorten the size of references to
     undefined symbols.  If you do not use the `-l' option, references
     to undefined symbols are wide enough for a full `long' (32 bits).
     (Since `as' cannot know where these symbols end up, `as' can only
     allocate space for the linker to fill in later.  Since `as' does
     not know how far away these symbols are, it allocates as much
     space as it can.)  If you use this option, the references are only
     one word wide (16 bits).  This may be useful if you want the
     object file to be as small as possible, and you know that the
     relevant symbols are always less than 17 bits away.


`--disp-size-default-16  --disp-size-default-32'
     If you use an addressing mode with a displacement, and the value
     of the displacement is not known, `as' will normally assume that
     the value is 32 bits.  For example, if the symbol `disp' has not
     been defined, `as' will assemble the addressing mode
     `%a0@(disp,%d0)' as though `disp' is a 32 bit value.  You may use
     the `--disp-size-default-16' option to tell `as' to instead assume
     that the displacement is 16 bits.  In this case, `as' will
     assemble `%a0@(disp,%d0)' as though `disp' is a 16 bit value.  You
     may use the `--disp-size-default-32' option to restore the default

we do not use "-l" or "--disp-size-default-16".
even specifying "--disp-size-default-32" does not produce the 32-bit
displacement version of the instruction.  perhaps that option is not
supposed to affect branch displacements?

I looked at the gas sources a bit but didn't get very far yet.


Home | Main Index | Thread Index | Old Index