This is the mail archive of the binutils@sources.redhat.com 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: ld relocation problem on ARM (PIC related)


On Wed, Nov 06, 2002 at 05:24:38PM +0100, jeroen dobbelaere wrote:
> 000083d4 <main>:
>     83d4:	e92d4400 	stmdb	sp!, {sl, lr}
>     83d8:	e59fa018 	ldr	sl, [pc, #24]	; 83f8 <main+0x24>
>     83dc:	e59f1018 	ldr	r1, [pc, #24]	; 83fc <main+0x28>
>     83e0:	e59f3018 	ldr	r3, [pc, #24]	; 8400 <main+0x2c>
>     83e4:	e08fa00a 	add	sl, pc, sl
>     83e8:	e79a0001 	ldr	r0, [sl, r1]
>     83ec:	e79a1003 	ldr	r1, [sl, r3]
>     83f0:	e8bd4400 	ldmia	sp!, {sl, lr}
>     83f4:	eaffffb1 	b	82c0 <_init+0x44>
> 
>     83f8:	0000815c 	andeq	r8, r0, ip, asr r1
> -> global offset table
>     83fc:	0000001c 	andeq	r0, r0, ip, lsl r0
> -> offset for '"%p\n"'
>     8400:	00000020 	andeq	r0, r0, r0, lsr #32
> -> offset for &var
> 
> 00010548 <_GLOBAL_OFFSET_TABLE_>:
>    10548:	0001046c 	andeq	r0, r1, ip, ror #8
>    1054c:	00000000 	andeq	r0, r0, r0
>    10550:	00000000 	andeq	r0, r0, r0
>    10554:	00008290 	muleq	r0, r0, r2
>    10558:	00008290 	muleq	r0, r0, r2
>    1055c:	00008290 	muleq	r0, r0, r2
>    10560:	00000000 	andeq	r0, r0, r0
>    10564:	00008458 	andeq	r8, r0, r8, asr r4
>    10568:	00000000 	andeq	r0, r0, r0
> 
> 
> At 0x83e4, 'sl' becomes : 0x815c + (0x83e4+8) = 0x10548
> Which is the global offset table.
> 
> r1, becomes 0x1c
> r3, becomes 0x20
> 
> 
> Afterwards, [sl, r1] is loaded :
>   sl+r1 = 0x10564, which contains a (valid) pointer to the string '%p\n"
> 
> Than, [sl, r3] is loaded, sl+r3 = 0x10568, which contains a NULL pointer.
> (Thus, &var == NULL !!)

Does it contain a NULL pointer at run time?

You didn't show the dynamic relocations in this binary.  The content of
the GOT in the binary can be NULL if there is an appropriate relocation
against var to fill it in.


-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


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