C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Ensure ABI compatibility at runtime -- std::layout_of

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 07 Nov 2024 10:20:56 -0800
On Thursday 7 November 2024 06:59:40 Pacific Standard Time Robin Savonen
Söderholm via Std-Proposals wrote:
> What worse, this type of construct may falsely make users think that they
> can use such a construct to "query" whether a library is ABI compatible
> with the current context or not. Which, as others here have already pointed
> out, would not reliable.

It's usually too late too. If you've loaded an ABI-incompatible plugin into
memory, you're already in dangerous territory. This plugin may have load-time
initialisation content that will cause crashes or data corruption.

You need to determine whether the plugin should be loaded before it's loaded.
That's metadata information that cannot be obtained from C++ and cannot be
created by C++ alone.

QPluginLoader does something like this. The QPlugin side of it creates a
special section in your binary with some metadata that tells the loader some
things about the ABI (for us, what matters are simply the Qt versions). But
the QLibrary/QPluginLoader side has a parser that can find this metadata and
decide for itself whether to attempt to load or not. We also have a few
techniques that would cause a plugin that is incompatible to fail to load in
the first place.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel DCAI Platform & System Engineering

Received on 2024-11-07 18:21:00