public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Michael Matz <matz@suse.de>
To: Frederick Virchanza Gotham <cauldwell.thomas@gmail.com>
Cc: binutils@sourceware.org
Subject: Re: Linker : Make a map of typeinfo to vtable
Date: Mon, 22 Jan 2024 17:50:33 +0100 (CET)	[thread overview]
Message-ID: <51e942dd-dbe0-f644-e9bb-0e12fc69f076@suse.de> (raw)
In-Reply-To: <CALtZhhMUxmUzWrHLB8xDA_0z0yjgZDLp8DqaofJvVk6rZznQ=g@mail.gmail.com>

Hello,

On Fri, 19 Jan 2024, Frederick Virchanza Gotham wrote:

> So I want to edit the source code for the GNU linker in order to add two
> new symbols to every binary:
> 
>     (1) __map_typeinfohash_vtable
>     (2) __map_typeinfohash_vtable_size
> 
> The first one is an array mapping the hashes of type_info's to vtable
> pointers. The second one is the number of elements in the array. The array
> would look something like the following in C++:
> 
>     pair<size_t, void const*> const g_vtables[] = {
>          { typeid(MyClass).hash_code(), &_ZTI7MyClass },
>          { typeid(YourClass).hash_code(), &_ZTI9YourClass },
>     };

When you want to get from typeinfo to vtable pointer, why not just add 
that pointer directly into the typeinfo?  A hashtable is quite a 
roundabout way to implement 'typeid(Type).vtable()' .

As you're proposing your general idea on a mailing list for new features 
of C++, that seems like a more sensible design than hacking the linker.


Ciao,
Michael.

  parent reply	other threads:[~2024-01-22 16:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-19 22:29 Frederick Virchanza Gotham
2024-01-19 22:52 ` Frederick Virchanza Gotham
2024-01-20 19:44   ` Frederick Virchanza Gotham
2024-01-21  3:27     ` Frederick Virchanza Gotham
2024-01-21 22:35       ` Frederick Virchanza Gotham
2024-01-22 16:50 ` Michael Matz [this message]
2024-01-25 10:17   ` Frederick Virchanza Gotham
2024-01-25 23:02     ` Frederick Virchanza Gotham
2024-01-27 10:56       ` Frederick Virchanza Gotham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51e942dd-dbe0-f644-e9bb-0e12fc69f076@suse.de \
    --to=matz@suse.de \
    --cc=binutils@sourceware.org \
    --cc=cauldwell.thomas@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).