C++ Logo

std-proposals

Advanced search

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

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 25 Jan 2024 16:00:06 -0800
On Thursday, 25 January 2024 14:51:20 PST Frederick Virchanza Gotham via Std-
Proposals wrote:
> I am unable to fathom how that 128-Bit number would end up in the
> ".ro.data.rel" section of an ELF file -- other than by me
> strategically placing it there.

Because this number now has a meaning, so if someone were trying to implement
the purpose of this meaning (i.e., read the typeinfos and find a link to the
vtable), they'd use this number. So it may end up in the file.

struct VTableSearcher
{
    const std::type_info *ti = &typeid(abi::__vmi_class_type_info);
    unsigned char id[16] = {
        0x3c,0x1f,0xed,0x6f,0x74,0xbb,0x6c,0x81,0x41,0x73,0xc5,0x40,0x9c,
0xb7,0xd0,0xaa
    };
};
https://gcc.godbolt.org/z/EozoarToh

So if for some reason the linker placed an older typeinfo object after this
struct, it would false-positively match.

The problem of making this an ABI requirement is that now everyone can write
(ABI-dependent) code that tries to find it. And there will be people not as
skilled doing so.

Anyway, please note you have yet to explain why we need this.

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

Received on 2024-01-26 00:00:10