Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c9c527f8 authored by Jiyong Park's avatar Jiyong Park
Browse files

resolve merge conflicts of fbe94272 to oc-dev-plus-aosp

Test: I solemnly swear I tested this conflict resolution.
Merged-In: I137c17d55940b783eab6d0125bc4d26b96bcc2f2
Change-Id: I90c3ff7c82a9b53ce00057fd87cf227d5faf0975
parents 1475ef28 fbe94272
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
subdirs = ["tests"]

cc_library_shared {
    name: "libvndksupport",
    srcs: ["linker.c"],
    local_include_dirs: ["include/vndksupport"],
    export_include_dirs: ["include"],
    shared_libs: ["liblog"],
}

llndk_library {
    name: "libvndksupport",
    symbol_file: "libvndksupport.map.txt",
    export_include_dirs: ["include"],
}
+31 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef VNDKSUPPORT_LINKER_H_
#define VNDKSUPPORT_LINKER_H_

#ifdef __cplusplus
extern "C" {
#endif

void* android_load_sphal_library(const char* name, int flag);

int android_unload_sphal_library(void* handle);

#ifdef __cplusplus
}
#endif

#endif  // VNDKSUPPORT_LINKER_H_
+7 −0
Original line number Diff line number Diff line
LIBVNDKSUPPORT {
  global:
    android_load_sphal_library; # vndk
    android_unload_sphal_library; # vndk
  local:
    *;
};
+50 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include "linker.h"

#include <android/dlext.h>
#include <dlfcn.h>

#define LOG_TAG "vndksupport"
#include <log/log.h>

extern struct android_namespace_t* android_get_exported_namespace(const char*);

void* android_load_sphal_library(const char* name, int flag) {
    struct android_namespace_t* sphal_namespace = android_get_exported_namespace("sphal");
    if (sphal_namespace != NULL) {
        const android_dlextinfo dlextinfo = {
            .flags = ANDROID_DLEXT_USE_NAMESPACE, .library_namespace = sphal_namespace,
        };
        void* handle = android_dlopen_ext(name, flag, &dlextinfo);
        if (handle) {
            return handle;
        } else {
            ALOGW(
                "Could not load %s from sphal namespace: %s. "
                "Falling back to loading it from the current namespace,",
                name, dlerror());
        }
    } else {
        ALOGI(
            "sphal namespace is not configured for this process. "
            "Loading %s from the current namespace instead.",
            name);
    }
    return dlopen(name, flag);
}

int android_unload_sphal_library(void* handle) { return dlclose(handle); }
+26 −0
Original line number Diff line number Diff line
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

cc_test {
    name: "libvndksupport-tests",
    srcs: [
        "linker_test.cpp",
    ],

    host_supported: false,
    shared_libs: [
        "libvndksupport",
        "libbase",
    ]
}
Loading