mips: branches to external labels are broken

cgd@broadcom.com cgd@broadcom.com
Tue Nov 26 10:19:00 GMT 2002


At Tue, 26 Nov 2002 12:40:23 +0000 (UTC), "Thiemo Seufer" wrote:
> > Which specs?  There's no spec I'm aware of that introduces any
> > relocation type that could be used for branch targets.  R_MIPS_PC16 is
> > certainly not it,
> 
> R_MIPS_PC16 is defined in the ELF ABI as relocation against an external
> symbol, and branches are the only PC-relative MIPS insns.

[just thought about this a little] 

could you just as well use R_MIPS_PC16 to calculate PC-relative
offsets for something like:

fn:
	# assume address of fn is in reg2 on call)
	lw	reg, textdata-fn(reg2)

textdata:
	...

(of course, most of the time that'll just be a constant, but i dunno,
it might be useful if you want to worry about, say, code that changes
size (e.g. linker relaxation of branches or something).


(I don't see how branches being PC-relative is relevant.)

(not suggesting that the code above is something we should try to
support.  Just that there's another plausable alternative which would
use that relocation type, and would probably work as specified in the
ABI spec, i.e. w/o any shift.)



cgd



More information about the Binutils mailing list