compat: Fix ABI issues

Several constructor shims are implemented incorrectly because
they completely ignore the fact that constructors have 'this-call'
calling convention and should pass 'this ptr' as the first argument [1]
as well as its return value, at least according ARM ABI [2].

Additionally android::SurfaceComposerClient::Transaction::apply(bool)
shim has void return value instead of status_t so the caller retrieves
random value.

[1] https://review.lineageos.org/c/LineageOS/android_device_xiaomi_sdm710-common/+/360011/comments/eb6600df_3e2fb434
[2] 617079d8a0/cppabi32/cppabi32.rst (L576)

Change-Id: I7b14b5d3ca6008c1e4b3f5fcbaece5021b3cbb82
Signed-off-by: Ivan Vecera <ivan@cera.cz>
This commit is contained in:
Ivan Vecera 2023-06-26 13:10:07 +02:00 committed by Bruno Martins
parent e386376f9c
commit d67ae54f8e
4 changed files with 32 additions and 25 deletions

View file

@ -1,12 +1,12 @@
#include <android-base/logging.h>
extern "C" void _ZN7android4base10LogMessageC1EPKcjNS0_5LogIdENS0_11LogSeverityES3_i(
const char* file, unsigned int line, android::base::LogId id,
extern "C" void* _ZN7android4base10LogMessageC1EPKcjNS0_5LogIdENS0_11LogSeverityES3_i(
void* thisptr, const char* file, unsigned int line, android::base::LogId id,
android::base::LogSeverity severity, const char* tag, int error);
extern "C" void _ZN7android4base10LogMessageC1EPKcjNS0_5LogIdENS0_11LogSeverityEi(
const char* file, unsigned int line, android::base::LogId id,
extern "C" void* _ZN7android4base10LogMessageC1EPKcjNS0_5LogIdENS0_11LogSeverityEi(
void* thisptr, const char* file, unsigned int line, android::base::LogId id,
android::base::LogSeverity severity, int error) {
_ZN7android4base10LogMessageC1EPKcjNS0_5LogIdENS0_11LogSeverityES3_i(file, line, id, severity,
nullptr, error);
return _ZN7android4base10LogMessageC1EPKcjNS0_5LogIdENS0_11LogSeverityES3_i(
thisptr, file, line, id, severity, nullptr, error);
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2022 The LineageOS Project
* Copyright (C) 2022-2023 The LineageOS Project
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -11,12 +11,13 @@ using android::IBinder;
using android::IGraphicBufferProducer;
using android::sp;
extern "C" void _ZN7android7SurfaceC1ERKNS_2spINS_22IGraphicBufferProducerEEEbRKNS1_INS_7IBinderEEE(
const sp<IGraphicBufferProducer>& bufferProducer, bool controlledByApp,
extern "C" void*
_ZN7android7SurfaceC1ERKNS_2spINS_22IGraphicBufferProducerEEEbRKNS1_INS_7IBinderEEE(
void* thisptr, const sp<IGraphicBufferProducer>& bufferProducer, bool controlledByApp,
const sp<IBinder>& surfaceControlHandle);
extern "C" void _ZN7android7SurfaceC1ERKNS_2spINS_22IGraphicBufferProducerEEEb(
const sp<IGraphicBufferProducer>& bufferProducer, bool controlledByApp) {
_ZN7android7SurfaceC1ERKNS_2spINS_22IGraphicBufferProducerEEEbRKNS1_INS_7IBinderEEE(
bufferProducer, controlledByApp, NULL);
extern "C" void* _ZN7android7SurfaceC1ERKNS_2spINS_22IGraphicBufferProducerEEEb(
void* thisptr, const sp<IGraphicBufferProducer>& bufferProducer, bool controlledByApp) {
return _ZN7android7SurfaceC1ERKNS_2spINS_22IGraphicBufferProducerEEEbRKNS1_INS_7IBinderEEE(
thisptr, bufferProducer, controlledByApp, nullptr);
}

View file

@ -1,12 +1,18 @@
/*
* Copyright (C) 2022 The LineageOS Project
* Copyright (C) 2022-2023 The LineageOS Project
*
* SPDX-License-Identifier: Apache-2.0
*/
extern "C" void _ZN7android21SurfaceComposerClient11Transaction5applyEbb(bool synchronous,
bool oneWay);
#include <utils/Errors.h>
extern "C" void _ZN7android21SurfaceComposerClient11Transaction5applyEb(bool synchronous) {
_ZN7android21SurfaceComposerClient11Transaction5applyEbb(synchronous, false);
using android::status_t;
extern "C" status_t _ZN7android21SurfaceComposerClient11Transaction5applyEbb(void* thisptr,
bool synchronous,
bool oneWay);
extern "C" status_t _ZN7android21SurfaceComposerClient11Transaction5applyEb(void* thisptr,
bool synchronous) {
return _ZN7android21SurfaceComposerClient11Transaction5applyEbb(thisptr, synchronous, false);
}

View file

@ -1,16 +1,16 @@
/*
* Copyright (C) 2022 The LineageOS Project
* Copyright (C) 2022-2023 The LineageOS Project
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdint.h>
extern "C" void _ZN7android13GraphicBuffer4lockEjPPvPiS3_(void* thisptr, uint32_t inUsage,
void** vaddr, int32_t* outBytesPerPixel,
int32_t* outBytesPerStride);
extern "C" void* _ZN7android13GraphicBuffer4lockEjPPvPiS3_(void* thisptr, uint32_t inUsage,
void** vaddr, int32_t* outBytesPerPixel,
int32_t* outBytesPerStride);
extern "C" void _ZN7android13GraphicBuffer4lockEjPPv(void* thisptr, uint32_t inUsage,
void** vaddr) {
_ZN7android13GraphicBuffer4lockEjPPvPiS3_(thisptr, inUsage, vaddr, nullptr, nullptr);
extern "C" void* _ZN7android13GraphicBuffer4lockEjPPv(void* thisptr, uint32_t inUsage,
void** vaddr) {
return _ZN7android13GraphicBuffer4lockEjPPvPiS3_(thisptr, inUsage, vaddr, nullptr, nullptr);
}