|
From: stephen c. <ste...@st...> - 2003-05-15 16:43:34
|
ben...@su... wrote: > > hi, Hi Ben, > i am currently porting modutils-2.4.2 to sh64 Linux and have a question > concerning the handling of relocations of instructions that are the > destination of an shmedia branch. > > the problem i am having is how to determine when the relocation is to be > included in an instruction that is an shmedia branch destination. if one > looks at the code in dl-machine.h it calculates the value of the > variable lsb, to be 1 or 0, by anding STO_SH5_ISA32 with the field > st_other in the symbol structure (Elf32_Sym) being relocated and this > result is then ored into the resulting value during the calculation the > of relocation. > > --- it is a little strange that we are using the st_other field as this > seems to be for symbol visibility! Only bits 0 and 1 of st_other are used for visibility, STO_SH5_ISA32 is bit 2. STO_SH5_ISA32 indicates that the symbol marks SHmedia code, so if you want to branch to that symbol, you must make sure to set bit 0 of the target address. > unfortunately unlike binutils and bfd the modutils does not use the bfd > library, instead choosing to implement its own symbol structure > (obj_symbol in obj.h) which does not contain a mapping to the symbol > visibility. > > does any one have any ideas of what might be the best approach to > solving this problem? I don't know what modutils does so I can't help much. If you are trying to resolve relocations, then somehow you need to know the ISA at the symbol that marks the branch destination, i.e. is the branch destination SHmedia code or SHcompact code. The only place this information exists in ELF objects is in the st_other field. The same problem occurs with arm/thumb and mips/mips16 (mips also uses the st_other field to represent the ISA of a symbol, but arm uses a different field). Maybe you could look at what is done for those targets? (BTW, you also need to worry about the destination of SHcompact branches, if you have SHcompact code branching to SHmedia code.) Steve. |