From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id CD7753858D32 for ; Mon, 22 Jan 2024 16:50:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CD7753858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CD7753858D32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705942236; cv=none; b=oquzr/hi70aZBg3qlk0JnjwbW8PnqD4Da/B7iR4ktm3KLOcA4L3Tqwpc9nGHIRGHnr4+e5llLqMxI9qtinVhklpyoFGcgWYXTKrMJS6TsEI33LcIOGBZtH2UhiHnuHYO22FLnHqnesnHZrHbpCEK5432Jqp4oCRkcQm+EVFAHQA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705942236; c=relaxed/simple; bh=hJBAPYeWl6jgRT3tRMqsw3JgDSSJ5W4lJC9m3793PDc=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:Message-ID:MIME-Version; b=RMCIxeJPyF70C+1VWCHxQfsXuawXO50qN5BrSV7Qrss/9KaFH6GQN9nrEIag9dkt6Mwk1Vv6X+qrMh9L1sKt8tPxXF1IwCFUE1b+yenQ72wsUi54YgPTJHMZqXrDD/G8Icyabiw9KBpIupoqdUBJKBalHq0d3bFB86qluQOt1d8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from knuth.suse.de (unknown [10.168.5.16]) by smtp-out1.suse.de (Postfix) with ESMTP id DE22921FF2; Mon, 22 Jan 2024 16:50:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705942233; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2gAE4e5e8uXEB7gtIGU1+HqxMUlG7oD1Q/kAUJ6jTsA=; b=LYr2w4hHxH3bizX0sfE+omMpoDzho/8d0WDDQ/BfGc6ZVRMmd8lmcO9kwm+BQ4xBcNnFp3 u4FtscQKE+KFEXqAoSkPKJDCiHbpQdQWQIJOj9KnEO9I0xJyJ1oDbEHKvnLomzBqAhNDkm jmrMSsVTJWA1viih2dZxgvABCx+zrfo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705942233; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2gAE4e5e8uXEB7gtIGU1+HqxMUlG7oD1Q/kAUJ6jTsA=; b=tpj6qFCoyCAvVwU28/AdnVrCTOvfFIgeWAzeM+zZUB8RH/BkF6QQJ0qr+RJjTizXDNQRXM q8hN6uMnbFuT3DDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705942233; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2gAE4e5e8uXEB7gtIGU1+HqxMUlG7oD1Q/kAUJ6jTsA=; b=LYr2w4hHxH3bizX0sfE+omMpoDzho/8d0WDDQ/BfGc6ZVRMmd8lmcO9kwm+BQ4xBcNnFp3 u4FtscQKE+KFEXqAoSkPKJDCiHbpQdQWQIJOj9KnEO9I0xJyJ1oDbEHKvnLomzBqAhNDkm jmrMSsVTJWA1viih2dZxgvABCx+zrfo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705942233; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2gAE4e5e8uXEB7gtIGU1+HqxMUlG7oD1Q/kAUJ6jTsA=; b=tpj6qFCoyCAvVwU28/AdnVrCTOvfFIgeWAzeM+zZUB8RH/BkF6QQJ0qr+RJjTizXDNQRXM q8hN6uMnbFuT3DDw== Received: by knuth.suse.de (Postfix, from userid 10510) id D4A59255160; Mon, 22 Jan 2024 17:50:33 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by knuth.suse.de (Postfix) with ESMTP id D312025515F; Mon, 22 Jan 2024 17:50:33 +0100 (CET) Date: Mon, 22 Jan 2024 17:50:33 +0100 (CET) From: Michael Matz To: Frederick Virchanza Gotham cc: binutils@sourceware.org Subject: Re: Linker : Make a map of typeinfo to vtable In-Reply-To: Message-ID: <51e942dd-dbe0-f644-e9bb-0e12fc69f076@suse.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Authentication-Results: smtp-out1.suse.de; none X-Spamd-Result: default: False [-0.00 / 50.00]; ARC_NA(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_TWO(0.00)[2]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; MID_RHS_MATCH_FROM(0.00)[]; BAYES_HAM(-0.00)[42.57%] X-Spam-Level: X-Spam-Score: -0.00 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 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.