Position independent CODE with position dependent DATA ?

John Reiser jreiser@bitwagon.com
Thu Jul 8 14:35:00 GMT 2010


> Just tried, but as I thought, declaring the symbol address as ABSOLUTE
> doesn't changed the addressing style :
> 
> $ avr32-nm test.elf | grep _GLOBAL_
> 00004000 A _GLOBAL_OFFSET_TABLE_
> 
> Dissasembly:
> ...
> 80018098:	4b 16       	lddpc	r6,8001815c    <-- R6 = 0x8001409A
> 8001809a:	1e 26       	rsub	r6,pc              <--- GOT = R6 = PC - R6 = 0x4000
> ... do something with GOT...
> 8001815c: .word        0x8001409A
> 
> The GOT symbol IS at 0x4000, BUT due to PIC behaviour, it's still
> considered to be relative to PC, so whatever offset we'll give to
> CODE, the same will apply to the GOT symbol.
> We need GOTs to be unrelative to CODE.. Should I have to patch GCC ? ;)

If the generated code is that stylized, then another option is a utility
program which takes a .o, finds those two-instruction sequences, then
re-writes the code in-place to become:
-----
> 80018098:	4b 16       	lddpc	r6,8001815c    <-- R6 = 0x4000
> 8001809a:	XX XX       	<<two-byte NOP>>
> ... do something with GOT...
> 8001815c: .word        0x4000
-----

-- 



More information about the Binutils mailing list