Path: utzoo!censor!geac!jtsv16!uunet!ginosko!uakari.primate.wisc.edu!polyslo!decwrl!sgi!davea@quasar.wpd.sgi.com From: davea@quasar.wpd.sgi.com (David B. Anderson) Newsgroups: comp.sys.sgi Subject: Re: "Relocation out-of-range" errors Summary: call from text to data rejected by the linker Message-ID: <42681@sgi.sgi.com> Date: 7 Oct 89 23:48:21 GMT References: <14188@shamash.cdc.com> <28025@mips.mips.COM> Reply-To: davea@sgi.com (David B. Anderson) Distribution: usa Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 40 In article <14188@shamash.cdc.com> pwp@shamash.UUCP (Pete Poorman) writes: >A few weeks back Steve Maurer asked what caused "jump relocation out of range" >errors, and someone explained it. > >Now, it's happening to me and the response has aged-away on my system. > >Can someone please explain again? (I promise to save it this time!) The question was answered by: len@synthesis.Synthesis.COM (Len Lattanzi) in <28025@mips.mips.COM> ;;Typically this is caused by one importing module referencing a symbol as text ;;and trying to jump to it. And the exporting module defining the symbol ;;to be data. Text and Data are normally too far apart to jump between. ;;You could use -Wl,-yerror,-yasm on the link command to indicate all ;;modules referencing error and asm and make sure the uses are consistent. Len was exactly right. Some further information: A call to a named function is generated as a JAL instruction. In the MIPS R2/3000 a JAL gets 26 bits for the address. It is a word address by definition, so the 2 least significant bits are implicit. Shifting the 26 bits from the instruction left two bits and making the top 4 bits identical to the address of the jump instruction itself gives a target address. (Wouldn't a picture be better than words? :-) In the ZMAGIC format (the format used for executables in IRIX) code starts at 0x400000 and data starts at 0x10000000. When one does a call (JAL) and the name is resolved to a _data address_ one gets ``jump relocation out of range'' since the linker can see that the top 4 bits are not the same in the JAL instruction address and the target address. Regards, [ David B. Anderson Silicon Graphics (415)335-1548 davea@sgi.com ]