This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: vtbl layout
- To: bob at werken dot com, egcs at egcs dot cygnus dot com
- Subject: Re: vtbl layout
- From: mrs at wrs dot com (Mike Stump)
- Date: Wed, 6 Jan 1999 19:09:48 -0800
> Date: Wed, 6 Jan 1999 20:18:06 -0500 (EST)
> From: Bob McWhirter <bob@werken.com>
> actually, I'm laying out bytes in memory, and blessing them into
> being by writing a valid vptr value into them.
:-) Ok.
> Is there some way to find the address of the vtbl without just
> inspecting the bytes of an object?
The vtable has a predictable name, and if you extern char buf[8]
asm("__vtable_name"); and use &bufp[0], you can get the address of it,
this is, if you can do this at compile time. If not, maybe I am
missing something...
> `nm` shows the Foo Virtual Table in my objects, but dlsym() does
> not seem to work (even if I pre-mangle the symbol name as shown by `nm`).
? I don't see this can fail to work. Maybe you got confused with the
leading _ (or lack of one)? I'm thinking this should work. Try a
user defined name (int foo, dlsym("foo")), make sure it works, then
tweak it one character at a time until it matches the vtable name and
let us know your results.