CN115016844A - A method to use chroot and gRPC to achieve program compatibility based on different runtime libraries - Google Patents
A method to use chroot and gRPC to achieve program compatibility based on different runtime libraries Download PDFInfo
- Publication number
- CN115016844A CN115016844A CN202210810983.XA CN202210810983A CN115016844A CN 115016844 A CN115016844 A CN 115016844A CN 202210810983 A CN202210810983 A CN 202210810983A CN 115016844 A CN115016844 A CN 115016844A
- Authority
- CN
- China
- Prior art keywords
- library
- runtime
- program
- grpc
- android
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/76—Adapting program code to run in a different environment; Porting
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/547—Remote procedure calls [RPC]; Web services
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
Description
技术领域technical field
本发明涉及一种方法,具体涉及一种使用chroot和gRPC来实现基于不同运行时库的程序兼容性运行的方法,属于多操作系统融合技术领域。The invention relates to a method, in particular to a method for realizing program compatibility operation based on different runtime libraries by using chroot and gRPC, and belongs to the technical field of multi-operating system fusion.
背景技术Background technique
目前市面的主流嵌入式操作系统是Android系统,绝大部分的嵌入式芯片厂商都为Android系统做了芯片适配,制作了很多基于Android运行时库的芯片驱动控制程序。例如基带处理器(BP,又称为Modem),一般该模块负责在移动设备上,负责提供基础语音业务和数据业务。芯片制造商会为BP芯片设计专门的基础服务程序,包括但不限于,启动BP的程序(或者代码库),对BP数据做加密检查的程序(或者代码库,这些程序都是基于Android系统的运行时来运行的。同时为了保护芯片制造商自己的权力和信息安全,一般以二进制的方式提供给客户,而非源代码的方式;该技术存在的问题在于,当离开了芯片制造商的支持后,开发者将只能拿到二进制的程序或者库,当目标操作系统有变化,如Android版本升级,或者需要更换上层操作系统(如保持Linux内核不变,但是将Android更换为OpenHarmony),该闭源程序/库就无法运行,因为该程序无法再正确的访问它原始设计中的依赖库(比如libc等等),而libd本身可能又依赖一个新的libe,libf等等,因此,迫切的需要一种新的方案解决上述技术问题。At present, the mainstream embedded operating system on the market is the Android system. Most of the embedded chip manufacturers have made chip adaptations for the Android system and produced many chip driver control programs based on the Android runtime library. For example, a baseband processor (BP, also known as Modem) is generally responsible for providing basic voice services and data services on a mobile device. The chip manufacturer will design a special basic service program for the BP chip, including but not limited to, the program (or code base) to start the BP, and the program (or code base) to encrypt and check the BP data. These programs are based on the operation of the Android system. It runs from time to time. At the same time, in order to protect the chip manufacturer's own power and information security, it is generally provided to customers in binary form rather than source code form; , developers can only get binary programs or libraries. When the target operating system changes, such as Android version upgrade, or the upper operating system needs to be replaced (such as keeping the Linux kernel unchanged, but replacing Android with OpenHarmony), the closure The source program/library cannot run, because the program can no longer correctly access the dependent libraries (such as libc, etc.) in its original design, and libd itself may depend on a new libe, libf, etc. Therefore, it is urgently needed. A new solution solves the above technical problems.
发明内容SUMMARY OF THE INVENTION
本发明正是针对现有技术中存在的问题,提供一种使用chroot和gRPC来实现基于不同运行时库的程序兼容性运行的方法,该技术方案主要针对闭源程序/库的移植兼容性问题,解决运行库依赖的问题,并且要进一步解决运行库本身的依赖,将可以实现的依赖转换到新操作系统/运行时环境中实现,从而让闭源的程序和库可以运行在新的操作系统/运行时环境上。The present invention is aimed at the problems existing in the prior art, and provides a method for realizing program compatibility operation based on different runtime libraries by using chroot and gRPC. The technical solution is mainly aimed at the transplantation compatibility problem of closed source programs/libraries. , to solve the problem of runtime dependencies, and to further solve the dependencies of the runtime itself, convert the achievable dependencies to the new operating system/runtime environment for implementation, so that closed-source programs and libraries can run on the new operating system /runtime environment.
为了实现上述目的,本发明的技术方案如下,一种使用chroot和gRPC来跨越不同用户空间和运行时库实现程序兼容性运行的方法,所述方法包括以下步骤:In order to achieve the above object, the technical solution of the present invention is as follows, a method for realizing program compatibility operation across different user spaces and runtime libraries by using chroot and gRPC, the method includes the following steps:
步骤1:准备基于Linux的操作系统Android的运行时环境;包括但不限于基础的libc运行时库等;Step 1: Prepare the runtime environment of the Linux-based operating system Android; including but not limited to the basic libc runtime library, etc.;
步骤2:将必要的基础库的API实现,用gRPC协议做接口转换,产生服务端程序和客户端的库程序;Step 2: Implement the API of the necessary basic library, use the gRPC protocol for interface conversion, and generate the server program and the client library program;
步骤3:基于Linux的操作系统OpenHarmony启动宿主运行时空间中基础库服务程序;Step 3: The Linux-based operating system OpenHarmony starts the basic library service program in the host runtime space;
步骤4:基于Linux的操作系统OpenHarmony使用系统调用chroot切换运行时环境;切换到步骤1准备的Android运行时环境中,执行Android中需要兼容的程序;Step 4: Linux-based operating system OpenHarmony uses system call chroot to switch the runtime environment; switch to the Android runtime environment prepared by
步骤5:在Android运行时环境中的程序,在访问其运行时库或者系统基础库的API时候,通过连接到宿主运行时空间中的基础库服务器程序,用OpenHarmony中的实现完成Android的运行时库或者系统基础库的API实现。Step 5: When the program in the Android runtime environment accesses the API of its runtime library or system basic library, it connects to the basic library server program in the host runtime space, and uses the implementation in OpenHarmony to complete the Android runtime. The API implementation of the library or system base library.
其中,步骤1具体实现过程如下:The specific implementation process of
(1)通过readelf或者直接运行检查等方法,确认Android操作系统中需要兼容的应用程序所需要的依赖库和基础库;(1) Confirm the dependent libraries and basic libraries required by compatible applications in the Android operating system by means of readelf or direct running check;
(2)将这些依赖库收集起来放入指定的路径。(2) Collect these dependent libraries and put them in the specified path.
其中,步骤2具体实现过程如下:The specific implementation process of step 2 is as follows:
(1)使用gRPC协议,将Android系统中必要的API调用转换为基于gRPC的服务端程序和客户端库程序;(1) Using the gRPC protocol, convert the necessary API calls in the Android system into gRPC-based server programs and client library programs;
(2)客户端库程序可以通过gRPC来访问服务端程序;(2) The client library program can access the server program through gRPC;
(3)服务器程序使用OpenHarmony中的实现,重新实现Android中的API功能;(3) The server program uses the implementation in OpenHarmony to re-implement the API function in Android;
(4)客户端库则需要在Android环境中编译运行;(4) The client library needs to be compiled and run in the Android environment;
(5)将步骤1收集的基础库和运行时库中需要重新实现的API,链接到本步骤中准备好的gRPC客户端库中。(5) Link the APIs that need to be reimplemented in the basic library and runtime library collected in
其中,步骤3具体实现过程如下:Wherein, the specific implementation process of step 3 is as follows:
(1)OpenHarmony系统中启动一个后台服务,该服务就是步骤2中定义的服务端程序(1) Start a background service in the OpenHarmony system, which is the server program defined in step 2
(2)该服务会打开一个Linux的本地Socket接口(2) The service will open a Linux local socket interface
(3)该服务等待客户端连接(3) The service waits for the client to connect
其中,步骤4具体实现过程如下:Wherein, the specific implementation process of
(1)OpenHarmony通过Linux的系统调用chroot,把根目录切换到步骤1中准备好的依赖库中,并且执行应该在Android操作系统中运行的程序。(1) OpenHarmony calls chroot through the Linux system, switches the root directory to the dependency library prepared in
其中,步骤5具体实现过程如下:Wherein, the specific implementation process of step 5 is as follows:
(1)Android操作系统运行的程序,会调用Android操作系统中的基础库或者运行时库的API来实现某些业务逻辑;(1) The program running on the Android operating system will call the basic library or the API of the runtime library in the Android operating system to implement some business logic;
(2)Android中的基础库和运行时库的已经被重新链接到gRPC客户端库的API,会去访问步骤3中的服务端API。(2) The APIs of the base library and runtime library in Android that have been re-linked to the gRPC client library will access the server API in step 3.
相对于现有技术,本发明的优点如下:1、该方案不用目标兼容程序的源代码,可以直接运行,Android本身是开源的,而闭源程序最终还是会访问开源的库;2、该方案的gRPC大幅度降低了API接口兼容的复杂度;3、该方案会使用Linux本地的Socket方式来通讯,性能也比较好;4、该方案没有再使用GPL协议的复杂的第三方仓库,使用的是最简单的内核的系统调用chroot,可以再次闭源;5、该方案绕过了闭源库和闭源代码,并且所有的修改都不是GPL协议,可以再次闭源;6、该方案会显著降低对芯片原厂的资源依赖,减低适配新操作系统的难度和时间资源投入,芯片原创不需要每一代操作系统Compared with the prior art, the advantages of the present invention are as follows: 1. The scheme can run directly without the source code of the target-compatible program, Android itself is open source, and the closed source program will eventually access the open source library; 2, the scheme gRPC greatly reduces the complexity of API interface compatibility; 3. The solution will use Linux's local Socket method to communicate, and the performance is better; It is the simplest system call chroot of the kernel, which can be closed source again; 5. This scheme bypasses closed source libraries and closed source code, and all modifications are not GPL agreement, and can be closed source again; 6. This scheme will significantly Reduce the resource dependence on the original chip factory, reduce the difficulty and time and resource investment of adapting to the new operating system, and the original chip does not require every generation of operating system
(及运行时库)或者每一种操作系统(及运行时库)都去重新做源代码级别的适配。只需要将程序所需的基础库做移植,并且实现其中的关键部分,目标闭源程序/库就可以正确的运行在新的操作系统(运行库环境)中。(and runtime libraries) or each operating system (and runtime libraries) to redo the source code level adaptation. As long as the basic library required by the program is transplanted and the key parts are implemented, the target closed source program/library can run correctly in the new operating system (runtime library environment).
附图说明Description of drawings
图1为现有技术架构关系图;Fig. 1 is a prior art architecture diagram;
图2为本发明技术架构关系图;Fig. 2 is the technical framework relation diagram of the present invention;
图3为本发明调用流程示意图。FIG. 3 is a schematic diagram of a calling flow of the present invention.
具体实施方式Detailed ways
为了加深对本发明的理解,下面结合附图对本实施例做详细的说明。In order to deepen the understanding of the present invention, the present embodiment will be described in detail below with reference to the accompanying drawings.
实施例1:参见图2-图3,一种使用chroot和gRPC来跨越不同用户空间和运行时库实现程序兼容性运行的方法,所述方法包括以下步骤:Embodiment 1: Referring to FIG. 2-FIG. 3, a method for realizing program compatibility operation across different user spaces and runtime libraries using chroot and gRPC, the method includes the following steps:
步骤1:准备基于Linux的操作系统Android的运行时环境;包括但不限于基础的libc运行时库等。Step 1: Prepare the runtime environment of the Linux-based operating system Android; including but not limited to the basic libc runtime library, etc.
步骤2:将必要的基础库的API实现,用gRPC协议做接口转换,产生服务端程序和客户端的库程序;Step 2: Implement the API of the necessary basic library, use the gRPC protocol for interface conversion, and generate the server program and the client library program;
步骤3:基于Linux的操作系统OpenHarmony启动宿主运行时空间中基础库服务程序;Step 3: The Linux-based operating system OpenHarmony starts the basic library service program in the host runtime space;
步骤4:基于Linux的操作系统OpenHarmony使用系统调用chroot切换运行时环境;切换到步骤1准备的Android运行时环境中,执行Android中需要兼容的程序;Step 4: Linux-based operating system OpenHarmony uses system call chroot to switch the runtime environment; switch to the Android runtime environment prepared by
步骤5:在Android运行时环境中的程序,在访问其运行时库或者系统基础库的API时候,通过连接到宿主运行时空间中的基础库服务器程序,用OpenHarmony中的实现完成Android的运行时库或者系统基础库的API实现。Step 5: When the program in the Android runtime environment accesses the API of its runtime library or system basic library, it connects to the basic library server program in the host runtime space, and uses the implementation in OpenHarmony to complete the Android runtime. The API implementation of the library or system base library.
其中,步骤1具体实现过程如下:The specific implementation process of
(1)通过readelf或者直接运行检查等方法,确认Android操作系统中需要兼容的应用程序所需要的依赖库和基础库;(1) Confirm the dependent libraries and basic libraries required by compatible applications in the Android operating system by means of readelf or direct running check;
(2)将这些依赖库收集起来放入指定的路径。不用目标兼容程序的源代码,可以直接运行(2) Collect these dependent libraries and put them in the specified path. It can be run directly without the source code of the target compatible program
其中,步骤2具体实现过程如下:The specific implementation process of step 2 is as follows:
(1)使用gRPC协议,将Android系统中必要的API调用转换为基于gRPC的服务端程序和客户端库程序;(1) Using the gRPC protocol, convert the necessary API calls in the Android system into gRPC-based server programs and client library programs;
(2)客户端库程序可以通过gRPC来访问服务端程序;(2) The client library program can access the server program through gRPC;
(3)服务器程序使用OpenHarmony中的实现,重新实现Android中的API功能;(3) The server program uses the implementation in OpenHarmony to re-implement the API function in Android;
(4)客户端库则需要在Android环境中编译运行;(4) The client library needs to be compiled and run in the Android environment;
(5)将步骤1收集的基础库和运行时库中需要重新实现的API,链接到本步骤中准备好的gRPC客户端库中。Android本身是开源的,而闭源程序最终还是会访问开源的库其中,步骤3具体实现过程如下:(5) Link the APIs that need to be reimplemented in the basic library and runtime library collected in
(1)OpenHarmony系统中启动一个后台服务,该服务就是步骤2中定义的服务端程序(1) Start a background service in the OpenHarmony system, which is the server program defined in step 2
(2)该服务会打开一个Linux的本地Socket接口(2) The service will open a Linux local socket interface
(3)该服务等待客户端连接;(3) The service waits for the client to connect;
优点:gRPC大幅度降低了API接口兼容的复杂度Advantages: gRPC greatly reduces the complexity of API interface compatibility
并且它会使用Linux本地的Socket方式来通讯,性能也比较好And it will use the Linux local Socket method to communicate, and the performance is better.
其中,步骤4具体实现过程如下:Wherein, the specific implementation process of
(1)OpenHarmony通过Linux的系统调用chroot,把根目录切换到步骤1中准备好的依赖库中,并且执行应该在Android操作系统中运行的程序。没有再使用GPL协议的复杂(1) OpenHarmony calls chroot through the Linux system, switches the root directory to the dependency library prepared in
的第三方仓库,使用的是最简单的内核的系统调用chroot,可以再次闭源The third-party repository, using the simplest kernel system call chroot, can be closed source again
其中,步骤5具体实现过程如下:Wherein, the specific implementation process of step 5 is as follows:
(1)Android操作系统运行的程序,会调用Android操作系统中的基础库或者运行时库的API来实现某些业务逻辑;(1) The program running on the Android operating system will call the basic library or the API of the runtime library in the Android operating system to implement some business logic;
(2)Android中的基础库和运行时库的已经被重新链接到gRPC客户端库的API,会去访问步骤3中的服务端API。(2) The APIs of the base library and runtime library in Android that have been re-linked to the gRPC client library will access the server API in step 3.
上述方案中,绕过了闭源库和闭源代码,并且所有的修改都不是GPL协议,可以再次闭源;在OpenHarmony系统中预制好Android系统的基础运行库文件;使用gRPC重新定义其中必要的API接口;在OpenHarmony系统中启动好gRPC的Service模块D;在OpenHarmony系统使用chroot切换到B系统的运行环境并且运行目标程序C;程序C根据自身需要访问依赖的运行时库,具体如下:依赖运行时库的需要访问gRPC的Client模块:In the above scheme, the closed source library and closed source code are bypassed, and all modifications are not GPL protocol, and can be closed again; the basic runtime library file of the Android system is prefabricated in the OpenHarmony system; use gRPC to redefine the necessary API interface; start the gRPC Service module D in the OpenHarmony system; use chroot to switch to the operating environment of the B system in the OpenHarmony system and run the target program C; the program C accesses the dependent runtime library according to its own needs, as follows: Dependency run The time library needs to access the Client module of gRPC:
(1)gRPC通过约定的访问方式(指gRPC的协议定义)将数据请求转递给D;(1) gRPC forwards the data request to D through the agreed access method (referring to the protocol definition of gRPC);
(2)D按照新的操作系统/运行时实现方式实现C的请求功能;(2) D implements the requested function of C according to the new operating system/runtime implementation;
(3)D通过约定的方式将数据应答给C;(3) D responds the data to C in an agreed manner;
(4)C拿到了处理结果继续运行。(4) C gets the processing result and continues to run.
需要说明的是上述实施例,并非用来限定本发明的保护范围,在上述技术方案的基础上所作出的等同变换或替代均落入本发明权利要求所保护的范围。It should be noted that the above-mentioned embodiments are not intended to limit the protection scope of the present invention, and equivalent transformations or substitutions made on the basis of the above-mentioned technical solutions all fall into the protection scope of the present invention.
Claims (6)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210810983.XA CN115016844A (en) | 2022-07-11 | 2022-07-11 | A method to use chroot and gRPC to achieve program compatibility based on different runtime libraries |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210810983.XA CN115016844A (en) | 2022-07-11 | 2022-07-11 | A method to use chroot and gRPC to achieve program compatibility based on different runtime libraries |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN115016844A true CN115016844A (en) | 2022-09-06 |
Family
ID=83082344
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202210810983.XA Pending CN115016844A (en) | 2022-07-11 | 2022-07-11 | A method to use chroot and gRPC to achieve program compatibility based on different runtime libraries |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN115016844A (en) |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103262057A (en) * | 2010-10-01 | 2013-08-21 | Flex Electronics ID Co.,Ltd. | Cross-environment communication framework |
| US20160164953A1 (en) * | 2014-12-05 | 2016-06-09 | Vmware, Inc. | Runtime generation of application programming interfaces for remote procedure call services |
| CN108762815A (en) * | 2018-05-16 | 2018-11-06 | 北京麟卓信息科技有限公司 | A kind of Android running environment implementation methods based on non-virtualized architectural framework |
| CN113535431A (en) * | 2021-07-19 | 2021-10-22 | 深圳市广通远驰科技有限公司 | Service calling method and system |
-
2022
- 2022-07-11 CN CN202210810983.XA patent/CN115016844A/en active Pending
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103262057A (en) * | 2010-10-01 | 2013-08-21 | Flex Electronics ID Co.,Ltd. | Cross-environment communication framework |
| US20160164953A1 (en) * | 2014-12-05 | 2016-06-09 | Vmware, Inc. | Runtime generation of application programming interfaces for remote procedure call services |
| CN108762815A (en) * | 2018-05-16 | 2018-11-06 | 北京麟卓信息科技有限公司 | A kind of Android running environment implementation methods based on non-virtualized architectural framework |
| CN113535431A (en) * | 2021-07-19 | 2021-10-22 | 深圳市广通远驰科技有限公司 | Service calling method and system |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US8812868B2 (en) | Secure execution of unsecured apps on a device | |
| CN111506366B (en) | Plug-in calling method, device, electronic device and storage medium | |
| US20080141270A1 (en) | Middleware application environment | |
| CN111176791A (en) | A cross-virtual machine calling method based on multi-virtual machine blockchain platform | |
| CN110659031A (en) | Application program compilation method, device, electronic device and storage medium | |
| US20150012732A1 (en) | Method and device for recombining runtime instruction | |
| US20080163266A1 (en) | Mechanism for transparently interfacing with a third party version control system | |
| US8141042B2 (en) | Extending portability of java code through the use of AOP | |
| WO2018032653A1 (en) | Function implementing method and apparatus for java card application | |
| RU2359316C2 (en) | Method of managing software components integrated into portable system | |
| CN119739390B (en) | Method for realizing abstract layer of operating system applied to drive development | |
| CN100487649C (en) | Call method between chip | |
| WO2024164742A1 (en) | Cloud storage data encryption and decryption methods and apparatus, medium and device | |
| EP3866443B1 (en) | Opc ua server, system operating using opc ua, and method of executing opc ua system | |
| CN113692576B (en) | Method and device for dynamic switching between Native and JavaCard | |
| CN105718796B (en) | A kind of system call level monitoring method of Android privacy of user data access | |
| CN105975333A (en) | Method and device for running control of application programs | |
| CN111045746B (en) | Code expansion method and framework | |
| CN103885784A (en) | Method for establishing Android platform with security module and plugging function | |
| WO2023071424A1 (en) | Electronic device | |
| CN115016844A (en) | A method to use chroot and gRPC to achieve program compatibility based on different runtime libraries | |
| CN110888674B (en) | Method and device for executing security calculation in Python virtual machine | |
| CN115994004B (en) | Application program interface calling method and device | |
| CN110852139B (en) | Biometric identification method, device, equipment and storage medium | |
| JP2003330736A (en) | Illegal resource use prevention system, method and program |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| TA01 | Transfer of patent application right |
Effective date of registration: 20240412 Address after: 905-916, West 9th Floor, Building 2, No. 168 Software Avenue, Yuhuatai District, Nanjing City, Jiangsu Province, 210012 Applicant after: Jiangsu Runkaihong Digital Technology Co.,Ltd. Country or region after: China Address before: No.168 software Avenue, Yuhuatai District, Nanjing City, Jiangsu Province, 210012 Applicant before: JIANGSU HOPERUN SOFTWARE CO.,LTD. Country or region before: China |
|
| TA01 | Transfer of patent application right | ||
| WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20220906 |