* dynamic vtables in c-program's on ia64
@ 2002-06-05 3:36 W.Stuehlmeyer
0 siblings, 0 replies; 2+ messages in thread
From: W.Stuehlmeyer @ 2002-06-05 3:36 UTC (permalink / raw)
To: gcc-help
Hello,
i have dynamically created c-programs with vtable structures.
Example:
typedef struct IMallocVtbl
{
HRESULT ( *QueryInterface) (IMalloc * pThis, const IID & riid, void
** ppvObject);
ULONG ( *AddRef) (IMalloc * pThis);
ULONG ( *Release) (IMalloc * pThis);
void * ( *Alloc) (IMalloc * pThis, ULONG cb);
...
} IMallocVtbl;
typedef struct CMalloc
{
IMallocVtbl *lpVtbl;
} CMalloc;
IMallocVtbl * g_lpVtblMalloc = 0;
CMalloc g_CMalloc;
IMalloc * g_pMalloc = (IMalloc *) &g_CMalloc;
IMallocVtbl CRetailMallocVtbl =
{
CMalloc_QueryInterface,
CMalloc_AddRef,
CMalloc_Release,
CRetailMalloc_Alloc,
...
};
HRESULT MallocInitialize(BOOL fForceLocalAlloc)
{
...
g_lpVtblMalloc = &CRetailMallocVtbl;
g_CMalloc.lpVtbl = g_lpVtblMalloc;
return hr;
}
extern "C" LPVOID CoTaskMemAlloc(ULONG ulcb)
{
if (g_CMalloc.lpVtbl == 0) {
MallocInitialize(0);
}
//
// SEGMENTATION VIOLATION
//
return g_pMalloc->Alloc(ulcb);
}
I create a function address pointer in CRetailMallocVtbl.
With gcc 3.0.x it works fine, but gcc 3.1 has a new ABI and
g_pMalloc->Alloc(ulcb) needs a <function address; GP address pointer>
pair on a itanium machine.
I have no idea how could create a GP adress pointer or a function
address/GP address pair from a C. I found no information on
www.codesourcecery.org how
could i create these address pairs.
How can i solve this problem?
Only IMallocVtbl could be modified ( typedef struct IMallocVtbl ... and
IMallocVtbl CRetailMallocVtbl = ..) via macros in a header file.
^ permalink raw reply [flat|nested] 2+ messages in thread
* dynamic vtables in c-program's on ia64
@ 2002-06-05 3:36 W.Stuehlmeyer
0 siblings, 0 replies; 2+ messages in thread
From: W.Stuehlmeyer @ 2002-06-05 3:36 UTC (permalink / raw)
To: gcc-help
Hello,
i have dynamically created c-programs with vtable structures.
Example:
typedef struct IMallocVtbl
{
HRESULT ( *QueryInterface) (IMalloc * pThis, const IID & riid, void
** ppvObject);
ULONG ( *AddRef) (IMalloc * pThis);
ULONG ( *Release) (IMalloc * pThis);
void * ( *Alloc) (IMalloc * pThis, ULONG cb);
...
} IMallocVtbl;
typedef struct CMalloc
{
IMallocVtbl *lpVtbl;
} CMalloc;
IMallocVtbl * g_lpVtblMalloc = 0;
CMalloc g_CMalloc;
IMalloc * g_pMalloc = (IMalloc *) &g_CMalloc;
IMallocVtbl CRetailMallocVtbl =
{
CMalloc_QueryInterface,
CMalloc_AddRef,
CMalloc_Release,
CRetailMalloc_Alloc,
...
};
HRESULT MallocInitialize(BOOL fForceLocalAlloc)
{
...
g_lpVtblMalloc = &CRetailMallocVtbl;
g_CMalloc.lpVtbl = g_lpVtblMalloc;
return hr;
}
extern "C" LPVOID CoTaskMemAlloc(ULONG ulcb)
{
if (g_CMalloc.lpVtbl == 0) {
MallocInitialize(0);
}
//
// SEGMENTATION VIOLATION
//
return g_pMalloc->Alloc(ulcb);
}
I create a function address pointer in CRetailMallocVtbl.
With gcc 3.0.x it works fine, but gcc 3.1 has a new ABI and
g_pMalloc->Alloc(ulcb) needs a <function address; GP address pointer>
pair on a itanium machine.
I have no idea how could create a GP adress pointer or a function
address/GP address pair from a C. I found no information on
www.codesourcecery.org how
could i create these address pairs.
How can i solve this problem?
Only IMallocVtbl could be modified ( typedef struct IMallocVtbl ... and
IMallocVtbl CRetailMallocVtbl = ..) via macros in a header file.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-06-05 10:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-05 3:36 dynamic vtables in c-program's on ia64 W.Stuehlmeyer
2002-06-05 3:36 W.Stuehlmeyer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).