ld problem: resolve symbol from .o on arm/pe arm/wince/pe target

longchuan longchuan@koretide.com.cn
Mon Apr 21 04:12:00 GMT 2003


Hello all:
With Nick Clifton's patch, I found that for arm/pe target, relocation
information sounds correct, but for arm/wince/pe, still wrong.

Here i met a bigger problem: LD resolves symbol form .o wrong when
linking a dll. below is the details:
------------------------------------------------------------------------
--
source:
class _CCCounterICounter : public ICounter
{
public:
    STDMETHODIMP QueryInterface(REFIID riid, void ** ppv) {
        return _CCCounterICounterQI(this, riid, ppv);
// this call would be mis-resolved by ld
    }

};
------------------------------------------------------------------------
--
after cc1plus processes this file:
	.global	__ZN18_CCCounterICounter14QueryInterfaceERK8_tagGUIDPPv
__ZN18_CCCounterICounter14QueryInterfaceERK8_tagGUIDPPv:
.stabn
68,0,72,LM104-__ZN18_CCCounterICounter14QueryInterfaceERK8_tagGUIDPPv
LM104:
	@ args = 0, pretend = 0, frame = 12
	@ frame_needed = 1, uses_anonymous_args = 0
	mov	ip, sp
	stmfd	sp!, {fp, ip, lr, pc}
	sub	fp, ip, #4
	sub	sp, sp, #12
	str	r0, [fp, #-16]
	str	r1, [fp, #-20]
	str	r2, [fp, #-24]
LBB37:
.stabn
68,0,73,LM105-__ZN18_CCCounterICounter14QueryInterfaceERK8_tagGUIDPPv
LM105:
	ldr	r0, [fp, #-16]
	ldr	r1, [fp, #-20]
	ldr	r2, [fp, #-24]
	bl	__Z20_CCCounterICounterQIP8ICounterRK8_tagGUIDPPv
//call _CCCounterICounterQI(this, riid, ppv);	
	mov	r3, r0
LBE37:
.stabn
68,0,74,LM106-__ZN18_CCCounterICounter14QueryInterfaceERK8_tagGUIDPPv
LM106:
	mov	r0, r3
	ldmea	fp, {fp, sp, pc}^
Lscope22:
	.stabs
"",36,0,0,Lscope22-__ZN18_CCCounterICounter14QueryInterfaceERK8_tagGUIDP
Pv
	.section	.text$_ZN9_CCounterD2Ev,"x"
	.linkonce discard
------------------------------------------------------------------------
--
I think at this point, compiler is correct. after as processing:
Disassembly of section
.text$_ZN18_CCCounterICounter14QueryInterfaceERK8_tagGUIDPPv:
------------------------------------------------------------------------
--
00000000 <__ZN18_CCCounterICounter14QueryInterfaceERK8_tagGUIDPPv>:
   0:	e1a0c00d 	mov	ip, sp
   4:	e92dd800 	stmdb	sp!, {fp, ip, lr, pc}
   8:	e24cb004 	sub	fp, ip, #4	; 0x4
   c:	e24dd00c 	sub	sp, sp, #12	; 0xc
  10:	e50b0010 	str	r0, [fp, -#16]
  14:	e50b1014 	str	r1, [fp, -#20]
  18:	e50b2018 	str	r2, [fp, -#24]

0000001c <LM105>:
  1c:	e51b0010 	ldr	r0, [fp, -#16]
  20:	e51b1014 	ldr	r1, [fp, -#20]
  24:	e51b2018 	ldr	r2, [fp, -#24]
  28:	ebfffffe 	bl	28 <LM105+0xc>	//call
_CCCounterICounterQI(this, riid, ppv);
  2c:	e1a03000 	mov	r3, r0
------------------------------------------------------------------------
--
I think as is correct. then ld links this obj to a dll:
------------------------------------------------------------------------
--
class _CCCounterICounter : public ICounter
{
public:
    STDMETHODIMP QueryInterface(REFIID riid, void ** ppv) {	// a
virtual function
1000220c:	e1a0c00d 	mov	ip, sp
10002210:	e92dd800 	stmdb	sp!, {fp, ip, lr, pc}
10002214:	e24cb004 	sub	fp, ip, #4	; 0x4
10002218:	e24dd00c 	sub	sp, sp, #12	; 0xc
1000221c:	e50b0010 	str	r0, [fp, -#16]
10002220:	e50b1014 	str	r1, [fp, -#20]
10002224:	e50b2018 	str	r2, [fp, -#24]

10002228 <LM105>:
        return _CCCounterICounterQI(this, riid, ppv);
10002228:	e51b0010 	ldr	r0, [fp, -#16]
1000222c:	e51b1014 	ldr	r1, [fp, -#20]
10002230:	e51b2018 	ldr	r2, [fp, -#24]
10002234:	ebfffb71 	bl	10001000
<__EzComDllGetClassObject>
10002238:	e1a03000 	mov	r3, r0

1000223c <LM106>:
    }
------------------------------------------------------------------------
--
I have no idea why a call to
__ZN18_CCCounterICounter14QueryInterfaceERK8_tagGUIDPPv were resolved to
a call of __EzComDllGetClassObject?? how did ld calculates address
0x10001000. In fact address of CCCounterICounterQI is
0x10001348

BTW, i was wondering who is in charge of porting gcc to arm/pe
arm/wince/pe? or is this porting IN progress?

regards,
wreckor



More information about the Binutils mailing list