Upgrade cxx (#2780)

This commit is contained in:
LoveSy 2023-10-05 01:06:57 +08:00 committed by GitHub
parent cc31605423
commit 888a7dbeb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 71 additions and 65 deletions

6
.gitmodules vendored
View File

@ -1,6 +1,3 @@
[submodule "external/cxx"]
path = external/cxx
url = https://github.com/LSPosed/libcxx.git
[submodule "external/lsplant"] [submodule "external/lsplant"]
path = external/lsplant path = external/lsplant
url = https://github.com/LSPosed/LSPlant.git url = https://github.com/LSPosed/LSPlant.git
@ -10,3 +7,6 @@
[submodule "external/fmt"] [submodule "external/fmt"]
path = external/fmt path = external/fmt
url = https://github.com/fmtlib/fmt.git url = https://github.com/fmtlib/fmt.git
[submodule "external/cxx"]
path = external/cxx
url = https://github.com/topjohnwu/libcxx.git

View File

@ -16,18 +16,15 @@
* *
* Copyright (C) 2022 LSPosed Contributors * Copyright (C) 2022 LSPosed Contributors
*/ */
#pragma once
//
// Created by Kotori0 on 2022/4/14.
//
#ifndef LSPOSED_CONFIGBRIDGE_H
#define LSPOSED_CONFIGBRIDGE_H
#include <map> #include <map>
using obfuscation_map_t = std::map<std::string, std::string>; namespace lspd {
class ConfigBridge { using obfuscation_map_t = std::map<std::string, std::string>;
public:
class ConfigBridge {
public:
inline static ConfigBridge *GetInstance() { inline static ConfigBridge *GetInstance() {
return instance_.get(); return instance_.get();
} }
@ -36,12 +33,13 @@ public:
return std::move(instance_); return std::move(instance_);
} }
virtual obfuscation_map_t& obfuscation_map() = 0; virtual obfuscation_map_t &obfuscation_map() = 0;
virtual void obfuscation_map(obfuscation_map_t) = 0; virtual void obfuscation_map(obfuscation_map_t) = 0;
virtual ~ConfigBridge() = default; virtual ~ConfigBridge() = default;
protected:
inline static std::unique_ptr<ConfigBridge> instance_ = nullptr;
};
#endif //LSPOSED_CONFIGBRIDGE_H protected:
static std::unique_ptr<ConfigBridge> instance_;
};
}

View File

@ -52,7 +52,7 @@ namespace lspd {
virtual ~Context() = default; virtual ~Context() = default;
protected: protected:
inline static std::unique_ptr<Context> instance_; static std::unique_ptr<Context> instance_;
jobject inject_class_loader_ = nullptr; jobject inject_class_loader_ = nullptr;
jclass entry_class_ = nullptr; jclass entry_class_ = nullptr;

View File

@ -31,7 +31,11 @@
using namespace lsplant; using namespace lsplant;
namespace lspd { namespace lspd {
std::unique_ptr<lspd::Context> lspd::Context::instance_;
std::unique_ptr<ConfigBridge> ConfigBridge::instance_;
Context::PreloadedDex::PreloadedDex(int fd, std::size_t size) { Context::PreloadedDex::PreloadedDex(int fd, std::size_t size) {
LOGD("Context::PreloadedDex::PreloadedDex: fd={}, size={}", fd, size); LOGD("Context::PreloadedDex::PreloadedDex: fd={}, size={}", fd, size);
auto *addr = mmap(nullptr, size, PROT_READ, MAP_SHARED, fd, 0); auto *addr = mmap(nullptr, size, PROT_READ, MAP_SHARED, fd, 0);

View File

@ -23,6 +23,7 @@
#include <sys/mount.h> #include <sys/mount.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
#include <sched.h>
#include "logging.h" #include "logging.h"

View File

@ -8,6 +8,7 @@
#include <cinttypes> #include <cinttypes>
#include <chrono> #include <chrono>
#include <thread> #include <thread>
#include <functional>
#include <sys/system_properties.h> #include <sys/system_properties.h>
using namespace std::string_view_literals; using namespace std::string_view_literals;

View File

@ -22,6 +22,7 @@
#define _LOGGING_H #define _LOGGING_H
#include <android/log.h> #include <android/log.h>
#include <errno.h>
#ifndef LOG_TAG #ifndef LOG_TAG
#define LOG_TAG "LSPosed" #define LOG_TAG "LSPosed"

View File

@ -9,37 +9,40 @@ SET_OPTION(Plugin.SymbolResolver OFF)
set(LIBCXX_SOURCES set(LIBCXX_SOURCES
algorithm.cpp algorithm.cpp
any.cpp # any.cpp
atomic.cpp atomic.cpp
barrier.cpp barrier.cpp
bind.cpp # bind.cpp
charconv.cpp charconv.cpp
chrono.cpp chrono.cpp
condition_variable.cpp condition_variable.cpp
condition_variable_destructor.cpp condition_variable_destructor.cpp
debug.cpp # debug.cpp
exception.cpp exception.cpp
filesystem/directory_iterator.cpp # filesystem/directory_iterator.cpp
filesystem/int128_builtins.cpp # filesystem/int128_builtins.cpp
filesystem/operations.cpp # filesystem/operations.cpp
functional.cpp functional.cpp
future.cpp future.cpp
# use absl instead # use absl instead
# hash.cpp # hash.cpp
ios.cpp # ios.cpp
iostream.cpp # iostream.cpp
locale.cpp # locale.cpp
memory.cpp memory.cpp
mutex.cpp mutex.cpp
mutex_destructor.cpp mutex_destructor.cpp
new.cpp new.cpp
optional.cpp optional.cpp
random.cpp random.cpp
regex.cpp # regex.cpp
# ryu/d2fixed.cpp
# ryu/d2s.cpp
# ryu/f2s.cpp
shared_mutex.cpp shared_mutex.cpp
stdexcept.cpp stdexcept.cpp
string.cpp string.cpp
strstream.cpp # strstream.cpp
system_error.cpp system_error.cpp
thread.cpp thread.cpp
# typeinfo.cpp # typeinfo.cpp
@ -51,17 +54,18 @@ set(LIBCXX_SOURCES
list(TRANSFORM LIBCXX_SOURCES PREPEND cxx/src/) list(TRANSFORM LIBCXX_SOURCES PREPEND cxx/src/)
set(LIBCXX_EXPORT_FLAGS) set(LIBCXX_EXPORT_FLAGS
set(LIBCXX_FLAGS
-fvisibility-global-new-delete-hidden
-fvisibility=hidden
-fvisibility-inlines-hidden
-DLIBCXX_BUILDING_LIBCXXABI -DLIBCXX_BUILDING_LIBCXXABI
-D_LIBCPP_NO_EXCEPTIONS -D_LIBCPP_NO_EXCEPTIONS
-D_LIBCPP_NO_RTTI -D_LIBCPP_NO_RTTI
-D_LIBCPP_BUILDING_LIBRARY -D_LIBCPP_BUILDING_LIBRARY
-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
-D__STDC_FORMAT_MACROS -D_LIBCXXABI_NO_EXCEPTIONS
)
set(LIBCXX_FLAGS
-fvisibility-global-new-delete-hidden
-fvisibility=hidden
-fvisibility-inlines-hidden
) )
set(LIBCXX_EXPORT_INCLUDES cxx/include) set(LIBCXX_EXPORT_INCLUDES cxx/include)
set(LIBCXX_INCLUDES cxx/src) set(LIBCXX_INCLUDES cxx/src)
@ -84,7 +88,6 @@ set(LIBCXXABI_SOURCES
) )
list(TRANSFORM LIBCXXABI_SOURCES PREPEND cxx/src/abi/) list(TRANSFORM LIBCXXABI_SOURCES PREPEND cxx/src/abi/)
set(LIBCXXABI_FLAGS set(LIBCXXABI_FLAGS
-D_LIBCXXABI_NO_EXCEPTIONS
-Wno-macro-redefined -Wno-macro-redefined
-Wno-unknown-attributes -Wno-unknown-attributes
-DHAS_THREAD_LOCAL) -DHAS_THREAD_LOCAL)

2
external/cxx vendored

@ -1 +1 @@
Subproject commit 82090ae75f7d284f2647a67f3f80f28f54eaddfc Subproject commit 12c8f4e93f196a700137e983dcceeac43cf807f2

2
external/lsplant vendored

@ -1 +1 @@
Subproject commit 9c33903c87a240ae38dbf7fdf49c0748addd073d Subproject commit bbabd25043f4fd8056cf5df55e2839de824467a1

View File

@ -17,28 +17,24 @@
* Copyright (C) 2022 LSPosed Contributors * Copyright (C) 2022 LSPosed Contributors
*/ */
// #pragma once
// Created by Kotori0 on 2022/4/14.
//
#ifndef LSPOSED_CONFIGIMPL_H
#define LSPOSED_CONFIGIMPL_H
#include "config_bridge.h" #include "config_bridge.h"
#include "service.h" #include "service.h"
class ConfigImpl: public ConfigBridge { namespace lspd {
public: class ConfigImpl : public ConfigBridge {
public:
inline static void Init() { inline static void Init() {
instance_ = std::make_unique<ConfigImpl>(); instance_ = std::make_unique<ConfigImpl>();
} }
virtual obfuscation_map_t& obfuscation_map() override { return obfuscation_map_; } virtual obfuscation_map_t &obfuscation_map() override { return obfuscation_map_; }
virtual void obfuscation_map(obfuscation_map_t m) override { obfuscation_map_ = std::move(m); }
private: virtual void
obfuscation_map(obfuscation_map_t m) override { obfuscation_map_ = std::move(m); }
private:
inline static std::map<std::string, std::string> obfuscation_map_; inline static std::map<std::string, std::string> obfuscation_map_;
}; };
}
#endif //LSPOSED_CONFIGIMPL_H

View File

@ -33,6 +33,8 @@
using namespace lsplant; using namespace lsplant;
namespace lspd { namespace lspd {
std::unique_ptr<Service> Service::instance_;
jboolean jboolean
Service::exec_transact_replace(jboolean *res, JNIEnv *env, [[maybe_unused]] jobject obj, Service::exec_transact_replace(jboolean *res, JNIEnv *env, [[maybe_unused]] jobject obj,
va_list args) { va_list args) {

View File

@ -89,7 +89,7 @@ namespace lspd {
std::map<std::string, std::string> RequestObfuscationMap(JNIEnv *env, const lsplant::ScopedLocalRef<jobject> &binder); std::map<std::string, std::string> RequestObfuscationMap(JNIEnv *env, const lsplant::ScopedLocalRef<jobject> &binder);
private: private:
inline static std::unique_ptr<Service> instance_ = std::make_unique<Service>(); static std::unique_ptr<Service> instance_;
bool initialized_ = false; bool initialized_ = false;
Service() = default; Service() = default;