C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Allow conversion of memfunc pointers to func pointers

From: Thiago Macieira <thiago_at_[hidden]>
Date: Fri, 19 Jan 2024 17:28:39 -0800
On Friday, 19 January 2024 14:47:22 PST Frederick Virchanza Gotham via Std-
Proposals wrote:
> Actually, just after having sent that post, I realise that it's not the
> linker but rather the C++ compiler that generates the vtables and
> typeinfo's and puts them inside the object files. So the linker will load
> in all the object files and see a list of typeinfo's and vtables. So then,
> inside the linker, I need to create my array which will map typeinfo hash
> codes to vtables, and then I need to define the symbol
> '__map_typeinfohash_vtable' and let the normal linker code take it from
> there.

Just put them in a specific section name, like the compiler does with
.init_array and .fini_array. The linker will then merge everything for the
output.

It's all unsorted, of course.

Then you just need to add code to the module initialisation and termination to
register and unregister that array.

> Even if this feature turns out to be useless, it will be good practise for
> me to get into editing compilers/linkers. I reckon it will be useful though.


-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2024-01-20 01:28:41