ralocation entries and relaxation questions.

ddiky ddiky@alarity.com
Thu Aug 11 10:30:00 GMT 2005


Fellows,

I got a question concerning relocation of symbols defined as 'section start
plus some value'.

So, for the code given

	br .l1
	...		; more 16 bytes
.l1:
	...

I got relocation recorded as:
	00000000	R_PC_16	.text+0x00000010

The long instruction 'br abs_addr' can be relaxed to short 'jmp disp'.
I do not want to relax this on assembly stage cause there may be some
branches between 'br .l1' and '.l1:'.

On linking stage I compute the value of disp. Then I have to delete 2 bytes
and recompute values of all symbols and relocations.
For all relocations I do
	/* Get the new reloc address.  */
    	if ((irel->r_offset > addr && irel->r_offset < toaddr))	/* addr is
and address of 'br .l1' */
      	irel->r_offset -= count;	/* count == 2 */

Then I adjust values of all local and global symbols.
However, the relocation I need recorded as .text+0x10 which neither listed
in locals nor in globals.
Therefore, the value of 'disp' is computed incorrectly.

If I recompute values of r_addend of all relocs as
	{
		int sidx = ELF32_R_SYM(irel->r_info);
		lsym = isym + sidx;
		/* Adjust symbols referenced by .sec+0xXX */
		if(irel->r_addend > addr && irel->r_addend < toaddr 
			&& lsym->st_shndx == sec_shndx)
		  irel->r_addend -= count;
	}
Then I got what I want.
However, this looks suspicious, cause relaxation code for other targets does
not perform anything similar.

So, the question is: is it possible to handle '.sect + 0xXX' symbols the way
expressed above ?

Thanks,
Dmitry.




More information about the Binutils mailing list