This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Position independent CODE with position dependent DATA ?


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 ? ;)

On Wed, Jul 7, 2010 at 8:58 PM, John Reiser <jreiser@bitwagon.com> wrote:
>> Implement a new loader option which would be specified to gcc as
>>
>> ? ? -Wl,-z,fixedGOT=0x4000
>>
>
> At least some parts of a similar idea work already, just by assigning to
> _GLOBAL_OFFSET_TABLE_ in a linker script:
>
> ? ? ? ?ld --other_flags_here --verbose ?> my.lds
>
> then edit my.lds to remove the header and trailer lines (marked with
> "==========") and add the assignment (spaces matter):
> ----- my.lds
> ? ? . . .
> _GLOBAL_OFFSET_TABLE_ = 0x4000 ;
>
> SECTIONS
> {
> ? ? . . .
> -----
>
> $ gcc -fPIC -o hello -Wl,--script=my.lds hello.c
> $ nm hello | grep _GLOBAL_OFFSET_TABLE_
> 00004000 a _GLOBAL_OFFSET_TABLE_
>
> --
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]