Subject: New Toolchain's gas lossage on m68k
To: None <tech-toolchain@netbsd.org>
From: Steve Woodford <steve@mctavish.co.uk>
List: tech-toolchain
Date: 11/07/2001 22:36:27
Hi,

In one of my earlier emails I alluded to a problem with new Gas when
compiling m68k's FPSP assembly source.

Specifically, the following code test case will fail to assemble:

oor-wullie% cat > foo.s
	.text
	.globl	foo

	.space	200

baz:	bras	foo
	nop
foo:	rts

oor-wullie% as -o foo.o foo.s
foo.s:6: Error: Value of -202 too large for field of 1 bytes at 201

Changing the `bras' to simply `bra' works around the problem (but is not
the correct fix IMO). Removing the `.globl foo' also fixes the problem,
and herein lies the root of the issue.

According to comments in the source (eg. gas/config/tc-m68k.h:170),
externally visible symbols may be overridden by shared libraries, so the
assembler cannot do the relocation at assembly time. This bites m68k's
relative branches because the offsets can be 8, 16 or 32-bits in size.

Presumably the assembler is doing TRT as per ELF's requirements, but there
must be a better way to do this other than hacking our in-tree assembly
source.

What does gas do on other cpus with variable branch offset sizes?

Cheers, Steve