Static link method and related device

By introducing a binary differential isolation layer, the storage address dependence between components and operating system during static linking is isolated, independent updates between components and operating system are realized, and the high update cost problem caused by static library updates is solved.

CN119271231APending Publication Date: 2025-01-07HUAWEI TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202310829978.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-06
Publication Date
2025-01-07

AI Technical Summary

Technical Problem

During the static linking process, the application has a strong coupling relationship with the static library or operating system, which causes the application to recompile and link when the static library or operating system is updated, which increases the update cost.

Method used

Introduce a binary differential isolation layer to isolate the actual storage address dependence of third-party components on the operating system and system applications, so that third-party components and operating systems can be updated independently, and stored at fixed addresses through the system isolation layer and component isolation layer after static linkage. , components can be induced without sensing the actual storage address changes.

Benefits of technology

It realizes independent updates between third-party components and operating systems, reduces update costs, improves update efficiency, and avoids the need to recompile and link due to operating system or component updates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119271231A_ABST
    Figure CN119271231A_ABST
Patent Text Reader

Abstract

The invention provides a static link method and a related device. In a scene in which a third-party component and an operating system are subjected to full-static linking on MCU equipment, the static linking method provided by the invention isolates a dependency relationship of the third-party component on an actual storage address of a system function in the operating system through a binary difference isolation layer; and realizing decoupling of the third-party component and the operating system according to the actual storage address of the third-party component and the dependency relationship of the system application on the actual storage address of the third-party component. The third-party component and the operating system can be updated independently and do not influence each other. The updating cost of the third-party component and the operating system can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of terminal technology, and in particular to a static linking method and related devices. Background Art

[0002] The source file of the application needs to be compiled and linked to generate an executable file for the electronic device to run the application. When using a static library for static linking, the compiler and linker will relocate the symbols in the source file and convert the reference relationship of the symbols into an absolute address. Therefore, in the final executable file, all symbols such as code and data are mapped and stored in the memory at a unique fixed physical address. There is a strong coupling relationship between the application and the static library (or operating system). When the static library (or operating system) is updated, the function that the application needs to reference in the static library changes, and the source file of the application needs to be recompiled and linked. This results in a high update cost for the static library or operating system. Summary of the invention

[0003] The present application provides a static linking method and related devices. By introducing a binary difference isolation layer, the dependency of the third-party component on the actual storage address of the system function in the operating system and the dependency of the system application on the actual storage address of the third-party component are isolated, thereby achieving decoupling of the third-party component from the operating system. Both the third-party component and the operating system can be updated independently without affecting each other. This can reduce the update cost of the third-party component and the operating system.

[0004] In a first aspect, the present application provides a static linking method. The method is applied to an electronic device, the electronic device includes a first operating system, and a first storage area corresponding to a first address in the electronic device stores a first call instruction, and the first call instruction is used to call a first system function provided by the first operating system. The electronic device updates the first operating system, and the first operating system is updated by static linking; the electronic device updates the first call instruction in the first storage area to a second call instruction, and the second call instruction is used to call the first system function provided by the updated first operating system; the electronic device runs a first component on the updated first operating system, obtains a second call instruction from the first storage area according to the first address, and executes the second call instruction for the first component to call the first system function.

[0005] The first address may be a fixed address agreed upon in advance by the component provider and the integrator, and is used to store a binary difference isolation layer (or system isolation layer) that encapsulates the first system function. The first call instruction and the second call instruction may both be binary instructions generated by the system isolation layer that encapsulates the first system function after static compilation and linking.

[0006] Before the first operating system is updated, the system isolation layer is compiled and linked together with the first operating system before the update, and the system isolation layer can obtain the actual storage address of the first system function in the electronic device that loads the first operating system before the update, and the system isolation layer can be compiled and linked as a first call instruction. After the first operating system is updated, the system isolation layer can be compiled and linked together with the updated first operating system, and the system isolation layer can obtain the actual storage address of the first system function in the electronic device that loads the first operating system after the update, and the system isolation layer can be compiled and linked as a second call instruction. Since the actual storage address of the first system function may change before and after the first operating system is updated, the first call instruction and the second call instruction are different.

[0007] The source program of the first component can be statically linked into an executable file according to the first address. The executable file of the first component can include the first address.

[0008] The first component mentioned above may be a third-party component, or may also be a system application.

[0009] In some embodiments, the electronic device may store the first operating system in ROM and store the executable file of the above-mentioned first component in Flash. After the electronic device is turned on, the executable file of the first component may be read from Flash to RAM. Therefore, when the electronic device updates the first operating system in ROM, it may not affect the executable file of the first component in Flash and RAM. This can ensure that the first operating system and the first component can be updated independently. In other embodiments, the electronic device may store both the first operating system and the executable file of the first component in ROM. Among them, the storage area can be divided on the ROM. The executable files of the first operating system and the first component can be stored in two independent storage areas in the ROM respectively. When the electronic device re-burns the ROM to update the data, all the data on an independent storage area can be updated, while keeping the data on another independent storage area unchanged. This can also ensure that the first operating system and the first component can be updated independently.

[0010] It can be seen that regardless of whether the first operating system is updated, the first component can find the system isolation layer that encapsulates the first system function according to a fixed address (such as the first address), thereby using the system isolation layer to call the first system function. When the first operating system is updated, the system isolation layer can sense the changes of the first operating system on behalf of the component, and encapsulate the updated system functions of the first operating system according to its changes. In this way, the first component may not perceive the changes of the first operating system. When the first operating system is updated, the component may not need to be recompiled and linked. In this way, the first operating system can be updated independently of the component, reducing the update cost of the system.

[0011] In combination with the first aspect, in some embodiments, when the electronic device runs the first component on the first operating system before updating, it obtains a first calling instruction from the first storage area according to the first address, and executes the first calling instruction for the first component to call the first system function.

[0012] It can be seen that before and after the operating system is updated, the storage address of the system isolation layer used to encapsulate the first system function (such as the first call instruction and the second call instruction after the system isolation layer is compiled and linked) remains unchanged. The first component can always find the system isolation layer that encapsulates the first system function according to the fixed address (such as the first address), thereby using the system isolation layer to call the first system function. Therefore, even if the first operating system is updated, the first component does not need to be updated. This can reduce the update cost of the system.

[0013] In conjunction with the first aspect, in some embodiments, the first call instruction includes a storage address of the first system function in the electronic device before the first operating system is updated, and the second call instruction includes a storage address of the first system function in the electronic device after the first operating system is updated. The storage address of the first system function in the electronic device may be located in the ROM of the electronic device.

[0014] In conjunction with the first aspect, in some embodiments, before and after the first operating system is updated, the first component stored in the electronic device remains unchanged. Specifically, the first component remains unchanged may mean that the executable file of the first component stored in the electronic device remains unchanged.

[0015] In combination with the first aspect, in some embodiments, the electronic device updates a first component, and the updated first component still needs to call a first system function, and the first component is updated by static linking; the electronic device runs the updated first component on the first operating system before the update, obtains a first calling instruction from the first storage area according to the first address, and executes the first calling instruction for the updated first component to call the first system function.

[0016] When the first component is updated, the updated first component can be published to the electronic device after being compiled and linked. The electronic device can update the executable file of the first component stored in the memory.

[0017] It can be seen that when the first component is updated, the source program of the updated first component can still be statically linked as an executable file according to the fixed address (such as the first address) used to encapsulate the first system function. Then, the updated first component can still find the system isolation layer that encapsulates the first system function according to the fixed address (such as the first address), so as to call the first system function using the system isolation layer. The first component does not need to consider whether the first operating system is updated during the update process.

[0018] In combination with the first aspect, in some embodiments, a second storage area corresponding to a second address in the electronic device stores a third calling instruction, and the third calling instruction updates a second system function provided by the first operating system before the update, and the updated first component also needs to call the second system function. The electronic device runs the updated first component in the first operating system before the update, obtains the third calling instruction from the second storage area according to the second address, and executes the first calling instruction for the updated first component to call the second system function.

[0019] The third calling instruction may include a storage address of the first system function in the electronic device before the first operating system is updated.

[0020] Among them, when the first operating system is updated, the system isolation layer for encapsulating the second system function can be compiled and linked with the updated first operating system, and the system isolation layer can obtain the actual storage address of the second system function in the electronic device loaded with the updated first operating system. The call instruction generated after the system isolation layer for encapsulating the second system function is recompiled and linked can include the storage address of the first system function in the electronic device after the first operating system is updated, and the call instruction can still be stored in the second storage area corresponding to the above-mentioned second address.

[0021] It can be seen that the first component may need to call multiple system functions, and the calls to these system functions can be implemented through the system isolation layer that encapsulates these system functions respectively.

[0022] In combination with the first aspect, in some embodiments, the electronic device further includes a second component and a third component, the second component is a third-party component, the third component is a system application, the third component needs to call the second component, and the third storage area corresponding to the third address in the electronic device stores a fourth call instruction, and the fourth call instruction is used to call the second component. The electronic device updates the second component, and the second component is updated by static linking; the electronic device updates the fourth call instruction in the third storage area to a fifth call instruction, and the fifth call instruction is used to call the updated second component; the electronic device runs the third component after updating the second component, obtains the fifth call instruction from the third storage area according to the third address, and executes the fifth call instruction for the third component to call the second component.

[0023] The third address may be a fixed address agreed upon in advance by the component provider and the integrator, and is used to store the binary difference isolation layer (or component isolation layer) that encapsulates the second component. The fourth call instruction and the fifth call instruction may be binary instructions generated by the component isolation layer that encapsulates the second component after static compilation and linking.

[0024] Before the second component is updated, the component isolation layer is compiled and linked together with the second component before the update, and the component isolation layer can obtain the actual storage address of the second component before the update in the electronic device, and the component isolation layer can be compiled and linked as a fourth call instruction. After the second component is updated, the component isolation layer is compiled and linked together with the updated second component, and the component isolation layer can obtain the actual storage address of the updated second component in the electronic device, and the component isolation layer can be compiled and linked as a fifth call instruction. Because the actual storage address of the second component in the electronic device may change before and after the second component is updated, the fourth call instruction is different from the fifth call instruction.

[0025] The source program of the third component can be statically linked into an executable file according to the third address. The executable file of the third component can include the third address.

[0026] It can be seen that when a third-party component is updated, the system application and the operating system do not need to be updated accordingly. In order to allow the system application to call the updated third-party component without updating, the electronic device can update the component isolation layer in the fixed address used to encapsulate the third-party component. The system application can find the updated component isolation layer according to the fixed address, and then use the component isolation layer to call the updated third-party component. The above method can effectively reduce the update cost of the third-party component and improve the efficiency of the electronic device to update the third-party component.

[0027] In combination with the first aspect, in some embodiments, the electronic device runs a third component before the second component, obtains a fourth calling instruction from a third storage area according to a third address, and executes the fourth calling instruction for the third component to call the second component.

[0028] In combination with the first aspect, in some embodiments, the fourth calling instruction includes the storage address of the second component in the electronic device before updating, and the fifth calling instruction includes the storage address of the second component in the electronic device after updating.

[0029] Wherein, when the second electronic device is stored in the ROM of the electronic device, the storage address of the second component contained in the fourth call instruction and the fifth call instruction may be an address in the ROM. When the second component is stored in the Flash of the electronic device, since the executable file of the second component will be read into the RAM, the storage address of the second component contained in the fourth call instruction and the fifth call instruction may be an address in the RAM.

[0030] In conjunction with the first aspect, in some embodiments, before and after the second component is updated, the third component and the first operating system stored in the electronic device remain unchanged. Specifically, the third component and the first operating system remain unchanged, which may mean that the executable file of the first component stored in the electronic device remains unchanged, and the executable file of the first operating system remains unchanged.

[0031] In combination with the first aspect, in some embodiments, the update content of the first operating system includes one or more of the following: a change in the storage address of the first system function, a change in the content of the first system function.

[0032] In conjunction with the first aspect, in some embodiments, the first storage area is a storage area on a ROM in an electronic device. The second storage area and the third storage area may also be storage areas on a ROM in an electronic device.

[0033] In a second aspect, the present application provides an electronic device. The electronic device includes a memory and a processor, wherein the memory can be used to store a computer program. The processor can be used to call the computer program so that the electronic device executes any possible implementation method in the first aspect.

[0034] In a third aspect, the present application further provides an electronic device, which may be a first electronic device. The first electronic device includes a component providing module and a calling interface providing module, wherein the component providing module is used to provide a first component, the first component needs to call a first system function provided by a first operating system, and the first component is published to a second electronic device including the first operating system after static linking; the calling interface providing module is used to provide a first interface, the first interface is used to encapsulate the first system function in a first storage area corresponding to a first address in the second electronic device, and the first interface is published to the second electronic device after static linking; the program for implementing the first component includes the first address.

[0035] The first electronic device may represent a device used by a component provider to develop and publish components and binary difference isolation layers. The second electronic device may be a device product provided by an integrator. The second electronic device may include a first operating system, system applications, and third-party components, etc.

[0036] The first electronic device can provide the first component to the integrator (integrator server) through the component providing module, and provide the first interface to the integrator by calling the interface providing module. The first interface can also be called a system isolation layer. The first interface can be statically linked with the first operating system, and the first interface obtains the actual storage address of the first system function in the second electronic device loaded with the first operating system, and the system isolation layer can be compiled and linked as a first call instruction. When the first operating system is updated, the first interface can be compiled and linked with the updated first operating system, and the first interface can obtain the actual storage address of the first system function in the electronic device loaded with the updated first operating system, and the first interface can be compiled and linked as a second call instruction. Since the actual storage address of the first system function may change before and after the first operating system is updated, the first call instruction and the second call instruction are different. Among them, the first call instruction and the second call instruction can both be stored in the storage area corresponding to the fixed address in the second electronic device.

[0037] It can be seen that the first electronic device can provide a first component and a first interface for encapsulating a first system function. After the first component is released to the second electronic device, there is no need to perceive whether the first operating system in the second electronic device has changed. The first component can always find the first interface according to the fixed storage address of the first interface in the second electronic device, so as to call the first system function using the first interface. Even if the first operating system in the second electronic device is updated, the first electronic device does not need to update the first component and the first interface. The first component can also be released to the second electronic device without recompiling and linking.

[0038] In combination with the third aspect, in some embodiments, the first interface obtains the storage address of the first system function in the second electronic device during the static linking stage, and generates a calling instruction for calling the first system function after the static linking.

[0039] In combination with the third aspect, in some embodiments, the component providing module is also used to provide a second component, the second component is called by a third component in the second electronic device, and the second component is published to the second electronic device after static linking; the calling interface providing module is also used to provide a second interface, the second interface is used to encapsulate the second component in a third storage area corresponding to a third address in the second electronic device, and the second interface is published to the second electronic device after static linking.

[0040] The second component may be a third-party component, and the third component may be a system application. The third component may be developed by the manufacturer of the second electronic device. The first electronic device may provide the second component to the integrator (integrator server) through the component providing module, and provide the second interface to the integrator by calling the interface providing module. The second interface may also be referred to as a component isolation layer. The second interface is statically linked with the second component, and the second interface obtains the actual storage address of the second component in the second electronic device, and the second interface may be compiled and linked as a fourth call instruction.

[0041] In conjunction with the third aspect, in some embodiments, the component providing module is further used to provide an updated second component, and the updated second component is published to the second electronic device after static linking; wherein the second interface obtains the storage address of the updated second component in the second electronic device during the static linking stage, and generates a call instruction for calling the updated second component after static linking. The call instruction generated after the second interface is statically linked to the updated second component can be a fifth call instruction. Since the actual storage address of the second component in the electronic device may change before and after the second component is updated, the fourth call instruction is different from the fifth call instruction.

[0042] It can be seen that when a third-party component is updated, the system application and the operating system do not need to be updated accordingly. In order to allow the system application to call the updated third-party component without updating, the electronic device can update the component isolation layer in the fixed address used to encapsulate the third-party component. The system application can find the updated component isolation layer according to the fixed address, and then use the component isolation layer to call the updated third-party component. The above method can effectively reduce the update cost of the third-party component and improve the efficiency of the electronic device to update the third-party component.

[0043] In a fourth aspect, the present application provides a computer-readable storage medium, comprising instructions, which, when executed on an electronic device, enables the electronic device to execute any possible implementation method in the first aspect.

[0044] In a fifth aspect, the present application provides a computer program product, which may include computer instructions. When the computer instructions are run on an electronic device, the electronic device executes any possible implementation method in the first aspect.

[0045] In a sixth aspect, the present application provides a chip, which is applied to an electronic device, and the chip includes one or more processors, and the processor is used to call computer instructions to enable the electronic device to execute any possible implementation method as in the first aspect.

[0046] It can be understood that the electronic device provided in the second aspect, the electronic device provided in the third aspect, the computer-readable storage medium provided in the fourth aspect, the computer program product provided in the fifth aspect, and the chip provided in the sixth aspect are all used to execute the method provided in the embodiment of the present application. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1A is a schematic diagram of generating an executable file provided in an embodiment of the present application;

[0048] Figure 1B It is a schematic diagram of a static link provided in an embodiment of the present application;

[0049] Figure 1C It is a schematic diagram of an executable file and a static library stored in a ROM provided by an embodiment of the present application;

[0050] Figure 2 It is a schematic diagram of compiling and linking a component in different compilation environments provided by an embodiment of the present application;

[0051] Figure 3 It is a schematic diagram of compiling and linking components based on a binary difference isolation layer provided in an embodiment of the present application;

[0052] Figure 4A is a schematic diagram of the hardware structure of an electronic device 100 provided in an embodiment of the present application;

[0053] Figure 4B is a software structure block diagram of an electronic device 100 provided in an embodiment of the present application;

[0054] Figure 5A It is a schematic diagram of publishing a component and an operating system provided in an embodiment of the present application;

[0055] Figure 5B It is a schematic diagram of a storage location of a third-party component, a binary difference isolation layer, a system application, and an operating system in an electronic device 100 provided in an embodiment of the present application;

[0056] Figure 5C This is another schematic diagram of the storage location of the third-party component, binary difference isolation layer, system application and operating system in the electronic device 100 provided in the embodiment of the present application;

[0057] Fig. 6A It is a schematic diagram of a component update provided by an embodiment of the present application;

[0058] Figure 6BIt is a schematic diagram of a storage location of a third-party component, a binary difference isolation layer, a system application, and an operating system in an electronic device 100 provided in an embodiment of the present application;

[0059] Fig. 7A is a schematic diagram of an operating system update provided by an embodiment of the present application;

[0060] Figure 7B It is a schematic diagram of a storage location of a third-party component, a binary difference isolation layer, a system application, and an operating system in an electronic device 100 provided in an embodiment of the present application;

[0061] Figure 8 It is a schematic diagram of the architecture of a communication system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0062] The technical solutions in the embodiments of the present application are described below in conjunction with the drawings in the embodiments of the present application. Among them, in the description of the embodiments of the present application, the terms used in the following embodiments are only for the purpose of describing specific embodiments, and are not intended to be used as limitations on the present application. As used in the specification and the appended claims of the present application, the singular expressions "a", "said", "above", "the" and "this" are intended to also include expressions such as "one or more", unless there is a clear indication to the contrary in the context. It should also be understood that in the following embodiments of the present application, "at least one", "one or more" refer to one or more (including two). The term "and / or" is used to describe the association relationship of associated objects, indicating that three relationships can exist; for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in a "or" relationship.

[0063] References to "one embodiment" or "some embodiments" etc. described in this specification mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Thus, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways. The term "connection" includes direct connection and indirect connection, unless otherwise specified. "First" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated.

[0064] In the embodiments of the present application, the words "exemplarily" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplarily" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplarily" or "for example" is intended to present related concepts in a specific way.

[0065] To facilitate understanding, the components involved in this application are first conceptually introduced here.

[0066] A component may refer to a computer program for providing one or more functions. Components in an electronic device may include third-party components and system components. Among them, a third-party component may refer to a component provided or developed by a manufacturer of a non-electronic device. A system component may refer to a component provided or developed by a manufacturer of an electronic device.

[0067] The types of third-party components may include: applications (APP), services, functional functions, and so on. In some embodiments, services may be a smaller granularity division of applications based on the functions provided. An application may contain one or more services. For example, a shopping application may include a product browsing service (providing the function of product browsing), a shopping cart service (providing the function of adding products to a shopping cart), a payment service (providing the function of payment), and so on. The above services may also be referred to as atomic services and other names. In third-party components, applications (or services) provided by manufacturers of non-electronic devices may also be referred to as third-party applications (or third-party services) and other names, and functional functions provided by manufacturers of non-electronic devices may also be referred to as third-party functions and other names. Third-party functions can be called by system components.

[0068] The types of system components may include: APP, service. System components may also be referred to as system applications, etc. In the subsequent embodiments of this application, the name "system application" is used to introduce the static linking method provided by this application.

[0069] In some embodiments, components of the APP and service types may be displayed on the interface as visual interface elements such as APP icons, cards, shortcut function methods, widgets, etc., so that users can use the functions provided by the components.

[0070] The electronic devices to which the static link method provided in the present application is applied may include: devices with a microcontroller unit (MCU) as the computing core and with business requirements such as small size, low cost and low power consumption. In other words, the electronic devices of the present application can be distinguished from smart devices such as mobile phones and personal computers with powerful processing and storage capabilities. For example, the electronic devices of the present application may be wearable devices such as smart watches, smart bracelets, and smart glasses, or may be smart speakers, smart air conditioners, smart refrigerators, smart TVs, smart door locks, smart gateways, Internet of Vehicles roadside devices, Internet of Things sensors, smart medical devices and other Internet of Things devices. The embodiments of the present application do not limit the types of electronic devices.

[0071] Optionally, the electronic device of the present application may also include a device in which a main core processor and an MCU processor coexist. Among them, a central processing unit (CPU) and a memory may be integrated on the MCU processor. The memory may include a read-only memory (ROM) and a random access memory (RAM). Electronic devices have a demand to use as little RAM as possible on the MCU processor. The MCU processor can reduce the burden on the main core processor and reduce the power consumption of the device. The above-mentioned main core processor may include one or more processors such as an application processor, a graphics processor, an image signal processor, and a neural network processor. For example, when the main core processor is in a dormant state, the MCU processor can keep working in a low-power state and listen to events that need to wake up the main core processor. The above-mentioned events for waking up the main core processor may include voice wake-up instructions, etc. The MCU processor can wake up the main core processor after listening to the event of waking up the main core processor. In this way, the main core processor does not need to be in a working state in real time, which is conducive to saving power consumption of the device.

[0072] Understandably, wearable devices, IoT devices and other electronic devices can use MCUs to achieve business requirements of small size, low cost and low power consumption. MCU plays an important role in improving device endurance, reducing the burden on the main core processor and achieving low power consumption. MCU usually contains only a CPU, ROM, RAM and basic peripherals (serial interface, timer, etc.). These limited hardware resources can be integrated on a single chip.

[0073] Due to resource and performance limitations, the system image in an electronic device using an MCU can be statically compiled and stored in ROM, and components (such as third-party components, system applications) can also be statically compiled into executable files and stored in ROM. The system image can refer to the computer program corresponding to the operating system. In this way, the electronic device using the MCU (which can be called an MCU device) can directly fetch instructions on the chip and execute the corresponding instructions. The above-mentioned on-chip instruction fetch can mean that the CPU on the MCU reads the binary instructions required for the component to run from the ROM. The CPU can then execute the above-mentioned binary instructions read to implement the corresponding functions provided by the running component. The above-mentioned static compilation can reduce the RAM occupied by the application during operation and reduce the demand for RAM resources. The limited RAM in electronic devices using MCU can be used to save stacks and variables.

[0074] However, in the above static compilation process, the fully statically linked function generates an actual address during the linking stage. After the third-party component and the system application are statically linked, the system function must be called according to the actual address of the system function. After the system application is statically linked, the third-party function must be called according to the actual address of the third-party function.

[0075] In some embodiments, the third-party component may need to call a system function provided by the operating system during operation. After the third-party component is statically compiled and linked, the actual storage address of the system function that the third-party component needs to call may be recorded in the executable file of the third-party component. When the electronic device runs the third-party component, it can read and execute the executable file of the third-party component, and call the corresponding system function according to the actual storage address of the system function in the executable file of the third-party component.

[0076] Therefore, when the operating system is updated and the actual storage address of the system function that the third-party component needs to call changes, the electronic device needs to update the third-party component accordingly. Otherwise, the third-party component cannot correctly call the required system function according to the actual storage address of the original system function. This results in a high cost for updating the operating system.

[0077] In some embodiments, in addition to relying on the operating system during operation, the system application may also need to call one or more third-party functions (i.e., third-party components of the type of functional functions). Among them, the system application depends on the operating system, and the process of calling the system function can refer to the process of the third-party component calling the system function. After the system application is statically compiled and linked, the actual storage address of the third-party function that the system application needs to call may be recorded in the executable file of the system application. When running the system application, the electronic device can read and execute the executable file of the system application, and call the corresponding third-party function according to the actual storage address of the third-party function in the executable file of the system application.

[0078] Therefore, when the third-party function is updated and the actual storage address of the third-party function is changed, the electronic device needs to update the operating system accordingly. Otherwise, the system application cannot correctly call the required third-party function according to the actual storage address of the original third-party function. This results in a high update cost for the third-party function.

[0079] It can be seen that after the components and operating system are statically compiled, the addresses of the components and the operating system are coupled, and the system applications and third-party functions are also coupled. Any modification can only be done by re-linking the entire system, and the components or the system cannot be modified individually.

[0080] In some embodiments, electronic devices can use dynamic loading technology to dynamically link functions and other resources required by applications during operation to solve the problems caused by the coupling of components and systems. Devices such as personal computers (PCs) and mobile phones have the ability to load dynamically. The system will first read the library file into the memory and map its address to the memory address space of the application, and then associate the function address in the symbol table with the function call in the program, and finally access the interface function in the library file. The above symbol table may include the relative position relationship (i.e., offset address) of the interface function in the library file, which can be used to determine the actual address of each interface function in the library file in the memory according to the initial address of the library file in the memory. However, the above scheme first requires sufficient memory (RAM) space to store the loaded library file, but the RAM space of the MCU is precious and is not enough to support the loading of a large number of library files into the RAM for operation. Secondly, the address mapping function requires a memory management unit (MMU), but most MCU processors do not have MMU devices, and the physical shortcomings cannot be made up. Therefore, traditional dynamic loading technology cannot be directly used on wearable devices and IoT devices.

[0081] In other embodiments, the compiler may generate an interface function address table during the compilation phase of the system. The interface function address table may include the actual address of the interface function. The system may load the interface function address table into the memory (RAM) of the device and pass the interface function address table to the application. During operation, the application may determine the address of the interface function that it needs to call according to the interface function address table, thereby accessing the corresponding interface function. Exemplarily, a global offset table (GOT) is generated during the compilation phase. The GOT table may include an address mapping table of global symbols in the executable file. The application may obtain the address of the symbol by searching the GOT table, thereby accessing the corresponding interface function. Alternatively, an executable file is divided into independent functional modules, each module maintains its own interface function address list, and other modules can find the address of the interface function through the interface function address list.

[0082] However, the above interface function address table (such as GOT table) depends on compiler generation, which is dependent on the compiler's capabilities, and generates indexes for all functions, which will essentially lead to binary expansion. The above methods all require software to implement a function similar to MMU address mapping, recalculate the function address by initializing the address segment information and the offset address found, and the calculation process is relatively complicated. The loaded component file needs to be cached in an equal amount of memory (RAM), which has high demands on RAM resources and is difficult to apply to devices that need to use as little RAM as possible.

[0083] The present application provides a static linking method that can isolate the interdependence between third-party components and the operating system, so that both the third-party components and the operating system can be updated independently. Among them, the operating system's dependence on third-party components can be reflected in the need for system applications to call third-party components (such as third-party functions). When either the third-party component or the operating system in an electronic device is updated, the other party does not need to be updated accordingly. This can save the update time of the third-party component and the update time of the operating system. Especially when the third-party component is updated, since there is no need to update the operating system, the time for the electronic device to update the third-party component can be greatly reduced.

[0084] The following is an introduction to the component compilation and linking process.

[0085] In the process of component development, developers will write the source files of the components in high-level language codes to implement the corresponding functions of the components. The source files of the components can be files with suffixes such as .c, .cpp, etc. The source files can also be called source codes. The source files of the components need to be converted into executable files that can be recognized and executed by electronic devices. Figure 1AThe process of pre-compilation, compilation, assembly and linking shown in FIG. 1 is a process of pre-compilation, compilation, assembly and linking. The executable file can be a binary file, including binary instructions. The electronic device can execute the binary instructions in the executable file to implement the functions corresponding to the component.

[0086] like Figure 1A As shown, source file 1 can be converted into a file with a suffix of .i (i.e., .i file) after pre-compilation. In the pre-compilation stage, the compiler can process various pre-processing commands in the source file, load header files, macro replacement, conditional compilation, de-commenting, etc. The .i file can be converted into a file with a suffix of .s (i.e., .s file) after compilation. In the compilation stage, the compiler can perform syntax analysis, semantic analysis, and symbol aggregation on the .i file to generate assembly code. The .s file can be converted into a file with a suffix of .o (i.e., .o file, which can also be called a target file or target code, etc.) after assembly. In the assembly stage, the compiler can convert the assembly code into machine code. The linker can link the target file and the required related resources to generate an executable file 1. For example, the above-mentioned related resources for linking can include system functions in the operating system.

[0087] The above-mentioned pre-compilation, compilation and assembly performed by the compiler can be collectively referred to as compilation. That is, after compilation and linking, the source file 1 can be converted into an executable file 1. Among them, the compiler is a computer program that can be used to translate the source file written in the high-level programming language into an equivalent target program in the machine language format so that the computer can recognize and run it. The linker is a computer program that can be used to link one or more target files generated by the compiler with the target files in the library file into an executable file. During the development stage of the component, the developer can use the compiler to compile the source file of the component into the above-mentioned target file, and use the linker to link the target file of the component into an executable file.

[0088] Figure 1B A schematic diagram of a static link is shown as an example.

[0089] like Figure 1B As shown, a static library may include multiple target files, for example, target file 1, target file 2, etc. Static libraries can facilitate the reuse of computer programs. A target file in a static library may include one or more functional functions for implementing specific functions (for example, read-write functions, arithmetic operations, etc.). These one or more functional functions may be system functions provided by the operating system. A component may call a system function therein by referencing a target file in a static library. In some embodiments, a static library may be stored in a ROM of an electronic device after static compilation along with the operating system.

[0090] In the process of static linking, the linker can take out the resources required by the source file 1, such as the target file 1, from the static library, and link the target file compiled by the source file 1 and the target file 1 to generate an executable file 1. The executable file 1 may include symbols such as code and data in the target file compiled by the source file 1, as well as a code for indicating the storage location of the target file 1 and referencing the target file 1. The above executable file 1 can also be stored in the ROM of the electronic device. In this way, the electronic device can directly fetch instructions from the ROM chip and execute the instructions in the executable file 1.

[0091] In some embodiments, the static library may be part of an operating system. Functions contained in a target file in a static library may be referred to as system functions. When a component calls a function in a static library according to a resource statically linked in an executable file at runtime, it may be referred to as a system call.

[0092] In some embodiments, in addition to the system functions in the above-mentioned static library, the electronic device also includes third-party functions. When the system application is compiled and linked, the third-party functions to be called can be linked to the executable file of the system application through static linking. In this way, the system application can call the third-party functions according to the statically linked resources in the executable file when running.

[0093] Figure 1C The schematic diagram exemplarily shows that executable files and static libraries are stored in ROM.

[0094] like Figure 1C As shown, the storage area at address a1 in the ROM may store executable file 1, the storage area at address ak may store target file 1, and the storage area at address ak+1 may store target file 2. When executable file 1 needs to be executed, the electronic device may obtain executable file 1 from the storage area at address a1 in the ROM and execute the instructions therein. When the instructions related to target file 1 in executable file 1 are executed, the electronic device may index target file 1 in the ROM according to the instructions. The storage address of target file 1 in ROM (i.e., ak) may be recorded in executable file 1. In this way, the electronic device may index target file 1 in the storage area at address ak in the ROM, thereby executing the instructions in target file 1.

[0095] In some embodiments, the system application can be coupled with the operating system. The executable file of the system application can be stored in the ROM on the MCU chip of the electronic device together with the operating system. The executable file of the third-party component can also be stored in the ROM on the MCU chip.

[0096] In other embodiments, the executable file of the third-party component can also be stored in the flash memory on the MCU chip. The flash memory can be referred to as Flash. Flash is a non-volatile memory device. Different from the above-mentioned ROM, ROM can support random access of the CPU on the MCU chip, but Flash does not support random access. Among them, in the case where the executable file of the third-party component is stored in Flash, the electronic device can read the executable file of the third-party component from Flash to RAM, and then the electronic device can obtain the executable file of the third-party component from the RAM on-chip, thereby running the third-party component. That is to say, if the above-mentioned component 1 is a third-party component, then the executable file 1 of component 1 can be stored in Flash.

[0097] It should be noted that the location where the third-party component is read from the Flash and stored in the RAM can be determined by the third-party component during the compilation and linking stage. That is, there is a preset location in the RAM for storing the executable file of the third-party component read from the Flash. The location in the RAM for storing the executable file of the third-party component can also be called the execution location or execution address of the third-party component.

[0098] Figure 1C The storage locations of the executable files and static libraries shown are merely exemplary of the present application and should not be construed as limiting the present application.

[0099] Figure 2 The schematic diagram exemplarily shows the compiling and linking of components in different compiling environments.

[0100] like Figure 2 As shown, area 210 may include components and systems compiled and linked in compilation environment A: executable file f1 of third-party component 1, executable file f3 of third-party component 2, executable file f5 of system application 1, and operating system 1. Area 220 may include components and systems compiled and linked in compilation environment B: executable file f2 of third-party component 1, executable file f4 of third-party component 2, executable file f5 of system application 1, and operating system 2. Compilation environment A is different from compilation environment B.

[0101] In some embodiments, the above-mentioned compilation environment A and compilation environment B can be environments located in different servers respectively. Compilation environment A and compilation environment B can both include a compiler and a linker. The compiler can be used to compile a source program into a target file. The linker can be used to statically link the target file into an executable file. The components (such as third-party component 1, third-party component 2, system application 1, etc.) and the operating system that have been compiled and linked in area 210 can be stored in the memory of the electronic device (for example, stored in ROM). Similarly, the components and the operating system that have been compiled and linked in area 220 can all be stored in the memory of the electronic device. The storage location of the above-mentioned components and the operating system in the electronic device can be determined in the compilation and linking stage.

[0102] Both operating system 1 and operating system 2 may include system function 1. For example, the specific content of system function 1 may be located in the aforementioned Figure 1B In the target file 1 of the static library shown. That is, the target file 1 can be the target file corresponding to the system function 1, and can be used to implement the function of the system function 1.

[0103] In some embodiments, operating system 1 and operating system 2 may be different operating systems. The above-mentioned different operating systems may refer to different source programs of the operating systems. Among them, the location of system function 1 in operating system 1 and operating system 2 may be different. Then, after compilation and linking, the storage address of system function 1 in the electronic device loaded with operating system 1 is different from the storage address in the electronic device loaded with operating system 2.

[0104] In other embodiments, operating system 1 and operating system 2 may also be the same operating system. The above-mentioned same operating system may refer to the same source program of the operating system. In the scenario where the same operating system is compiled and linked in different compilation environments, the order of compiling and / or linking the source program of the operating system may be different due to the different compilation environments. Therefore, after the same operating system is compiled and linked in different compilation environments, the actual storage address of the same system function may be different. Although the source programs of operating system 1 and operating system 2 are the same, after being compiled and linked in different compilation environments (such as compilation environment A and compilation environment B), the storage address of system function 1 in the electronic device loaded with operating system 1 is different from the storage address in the electronic device loaded with operating system 2.

[0105] It can be seen from the above embodiments that in the scenario of operating system update, the source program changes before and after the operating system is updated. Then, compared with the operating system before the update, the storage address of the static library in the updated operating system may change. For example, the number of bytes occupied by a system function in the updated operating system increases, then the storage space used by this system function increases, and the addresses of the storage spaces used by other system functions may need to be shifted backward in sequence. In this way, after the operating system is updated, the storage address of one or more system functions in the static library changes. In addition, when the same operating system is compiled and linked in different compilation environments, affected by the compilation environment, the storage address of the static library in the operating systems compiled and linked in different compilation environments may be different.

[0106] The third-party component 1 needs to call the above-mentioned system function 1 during operation. In the process of statically linking the third-party component 1, the linker can write the storage address of the system function 1 into the executable file of the third-party component 1. In this way, when executing the executable file of the third-party component 1, the electronic device can index the system function 1 according to the storage address of the system function 1, thereby calling the system function 1. Since the positions of the system function 1 in the operating system 1 and the operating system 2 are different, the executable files of the third-party component 1 generated in the compilation environment A and the compilation environment B are also different. To distinguish, the executable file f1 of the third-party component 1 is used here to represent the executable file generated by the third-party component 1 in the compilation environment A, and the executable file f2 of the third-party component 1 is used to represent the executable file generated by the third-party component 1 in the compilation environment B. The executable file f1 of the third-party component 1 can record the storage address of the system function 1 in the electronic device that loads the operating system 1. The executable file f2 of the third-party component 1 can record the storage address of the system function 1 in the electronic device that loads the operating system 2. Among them, the executable file f1 of the third-party component 1 is only applicable to the operating system 1. The executable file f2 of the third-party component 1 is only applicable to the operating system 2.

[0107] Similarly, in order to distinguish the executable files generated by the third-party component 2 in different compilation environments, the executable file f3 of the third-party component 2 is used here to represent the executable file generated by the third-party component 2 in the compilation environment A, and the executable file f4 of the third-party component 2 is used to represent the executable file generated by the third-party component 2 in the compilation environment B. The third-party component 2 is a third-party component different from the third-party component 1. Among them, if the third-party component 2 needs to call a system function during operation, and the location of the system function in the operating system 1 and the operating system 2 is different, then the contents of the executable file f3 of the third-party component 2 and the executable file f4 of the third-party component 2 are different. If the third-party component 2 is a third-party function and does not need to call a system function during operation, then the contents of the executable file f3 of the third-party component 2 and the executable file f4 of the third-party component 2 may be the same.

[0108] Among them, since the order of compiling and / or linking the source program in different compilation environments may be different, the storage address of the executable file f3 of the third-party component 2 in the electronic device loaded with the operating system 1 may be different from the storage address of the executable file f4 of the third-party component 2 in the electronic device loaded with the operating system 2.

[0109] Here, an example is taken where a system application 1 needs to call a third-party component 2 during operation.

[0110] In the process of statically linking the system application 1, the linker can write the storage address of the third-party component 2 into the executable file of the system application 1. In this way, when executing the executable file of the system application 1, the electronic device can index the third-party component 2 according to the storage address of the third-party component 2, thereby calling the third-party component 2. Since the storage address of the executable file of the third-party component 2 in the electronic device loaded with the operating system 1 is different from the storage address in the electronic device loaded with the operating system 2, the executable files of the system application 1 generated in the compilation environment A and the compilation environment B are also different.

[0111] To distinguish, the executable file f5 of system application 1 may represent the executable file generated by system application 1 in compilation environment A. The executable file f6 of system application 1 may represent the executable file generated by system application 1 in compilation environment B. The executable file f5 of system application 1 may record the storage address of the executable file f3 of the third-party component 2 in the electronic device loaded with operating system 1. The executable file f6 of system application 1 may record the storage address of the executable file f4 of the third-party component 2 in the electronic device loaded with operating system 2. Among them, the executable file f5 of system application 1 is only applicable to operating system 1. The executable file f6 of system application 1 is only applicable to operating system 2.

[0112] Depend on Figure 2 It can be seen that in different operating systems, the executable files of the same component (such as third-party component 1, system application 1, etc.) cannot be reused. The above different operating systems may include operating systems with different source programs, and operating systems with the same source program but different after being compiled and linked in different compilation environments.

[0113] By the above Figure 1A , Figure 1B as well as Figure 2 It can be seen that due to the use of static linking in MCU devices, the components in the MCU device are strongly coupled with the static library. That is, once the static library changes (for example, the storage address of the static library in the ROM changes), the components in the MCU device need to be recompiled, linked, and then written into the MCU device. Otherwise, when the MCU device executes the executable file of the component, it cannot find the required resources according to the address of the static library that was once linked. In other words, developers cannot modify the static library or operating system in the MCU device alone. The cost of system updates is high.

[0114] In addition, some system applications also need to call third-party components (such as third-party functions) during operation. After the system application is statically linked, the actual storage address between the system application and the third-party component is coupled. That is, once the third-party component changes (for example, the storage address of the third-party component in the electronic device changes), the system application in the MCU device needs to be recompiled, linked, and then written into the MCU device. When the system application is coupled with the operating system and stored together in an area of ​​the MCU device, the need to recompile and link the system application means that the entire operating system needs to be recompiled and linked. Therefore, developers cannot modify the third-party components in the MCU device individually. The cost of updating third-party components is also high.

[0115] The present application provides a static linking method, which can realize independent update of components and operating systems by introducing a binary difference isolation layer. The independent update of components and operating systems may include: independent update of third-party components without the need for system applications and operating systems to be updated, independent update of operating systems without the need for third-party components to be updated, and independent update of operating systems without the need for system applications to be updated.

[0116] The binary difference isolation layer can be an interface for components to call function functions (such as system functions and third-party functions). The binary difference isolation layer can be used to encapsulate function functions to achieve decoupling between components and the actual storage addresses of function functions. The binary difference isolation layer can be stored in a preset fixed address after compilation and linking. The component can call the binary difference isolation layer through the fixed address to call the function function encapsulated by the binary difference isolation layer. In this way, the component does not need to perceive the changes in the actual storage address of the function function.

[0117] The binary difference isolation layer may include a system isolation layer and a component isolation layer.

[0118] The system isolation layer can be used to encapsulate system functions and realize the decoupling of third-party components from the actual storage address of system functions. In some embodiments, the system isolation layer can also realize the decoupling of system applications from the actual storage address of system functions. The system isolation layer can be statically linked with the operating system and written into the electronic device. In the process of statically linking the system isolation layer and the operating system, the system isolation layer can obtain the actual storage address of the system function in the operating system. The electronic device can store the above-mentioned statically linked system isolation layer in a preset fixed address.

[0119] The executable file of the third-party component may contain the fixed address of the system isolation layer encapsulating the system function that the third-party component needs to call. In this way, the third-party component can always call the system isolation layer according to the fixed address, thereby finding the system function in the actual storage address of the system function and calling it.

[0120] The component isolation layer can be used to encapsulate third-party functions and realize the decoupling of the system application and the actual storage address of the third-party function. The component isolation layer can be statically linked with the third-party function and written into the electronic device. In the process of static linking between the component isolation layer and the third-party function, the component isolation layer can obtain the actual storage address of the third-party function. The third-party function can be stored in ROM or Flash. When the third-party function is stored in ROM, the actual storage address of the third-party function can represent the storage address of the third-party function on ROM. When the third-party function is stored in Flash, the actual storage address of the third-party function can represent the storage address of the third-party function in RAM when it is read from Flash to RAM (that is, the execution address of the third-party function). The electronic device can store the above-mentioned statically linked component isolation layer in a preset fixed address.

[0121] The executable file of the system application may contain a fixed address of the component isolation layer encapsulating the third-party function that the system application needs to call. In this way, the system application can always call the component isolation layer according to the fixed address, thereby finding the third-party function in the actual storage address of the third-party function and calling it.

[0122] In some embodiments, the system isolation layer and the component isolation layer can be stored in different areas of the ROM of the MCU processor. Both areas storing the system isolation layer and the component isolation layer in the ROM can be re-burned separately without affecting each other. Among them, when the operating system is updated, the system isolation layer can be statically re-linked with the operating system and then written into the electronic device. After re-statically linking, the system isolation layer can obtain the actual storage address of the system function after the operating system is updated. The electronic device can re-burn the area storing the system isolation layer in the ROM, and burn the re-statically linked system isolation layer into the area. When a third-party function is updated, the component isolation layer can be statically re-linked with the third-party function and then written into the electronic device. After re-statically linking, the component isolation layer can obtain the actual storage address of the third-party function after the third-party function is updated. The electronic device can re-burn the area storing the component isolation layer in the ROM, and burn the re-statically linked component isolation layer into the area.

[0123] The fixed addresses for storing the binary difference isolation layer may be preset. For example, these fixed addresses may be determined by the component provider and the device manufacturer in advance.

[0124] Figure 3 The schematic diagram exemplarily shows the compiling and linking of components based on the binary difference isolation layer.

[0125] like Figure 3 As shown, area 310 may include components and systems compiled and linked in compilation environment A: executable file f7 of third-party component 1, executable file f8 of third-party component 2, executable file f9 of system application 1, system isolation layer 311, component isolation layer 312, and operating system 1. Area 320 may include components and systems compiled and linked in compilation environment B: executable file f7 of third-party component 1, executable file f8 of third-party component 2, executable file f9 of system application 1, system isolation layer 321, component isolation layer 322, and operating system 2.

[0126] Compilation environment A, compilation environment B, operating system 1, operating system 2 can refer to the above Figure 2 I will not go into details here.

[0127] 1. Compile and link components based on the system isolation layer.

[0128] By the aforementioned Figure 2It can be seen from the embodiments that the actual storage address of the system function 1 in the electronic device loaded with the operating system 1 is different from the actual storage address in the electronic device loaded with the operating system 2. In the process of compiling and linking the system isolation layer 311 in the compilation environment A, the actual storage address of the system function 1 in the electronic device loaded with the operating system 1 can be passed to the system isolation layer 311. The system isolation layer 311 can be stored in a fixed address in the electronic device. The linker in the compilation environment A can statically link the third-party component 1 according to the fixed address where the system isolation layer 311 is located. Similarly, in the process of compiling and linking the system isolation layer 321 in the compilation environment B, the actual storage address of the system function 1 in the electronic device loaded with the operating system 2 can be passed to the system isolation layer 321. The system isolation layer 321 can be stored in a fixed address in the electronic device. The linker in the compilation environment B can statically link the third-party component 1 according to the fixed address where the system isolation layer 321 is located.

[0129] The fixed address used to store the system isolation layer 311 and the fixed address used to store the system isolation layer 321 may be the same. For example, the electronic device loaded with the operating system 1 and the electronic device loaded with the operating system 2 may be devices of the same device manufacturer. The fixed address of the system isolation layer for storing the encapsulated system function 1 agreed by the device manufacturer may be the same in different devices. Then, the executable files generated by the third-party component 1 after static linking in the compilation environment A and the compilation environment B are the same, for example, both are executable files f7. The fixed address of the system isolation layer 311 (that is, the fixed address of the system isolation layer 321) may be recorded in the executable file f7.

[0130] It can be seen that although the locations of system function 1 in operating system 1 and operating system 2 are different, the address used to encapsulate system function 1 can be the same. That is to say, in different compilation environments, the same third-party component can be statically linked based on the fixed address of the system isolation layer used to encapsulate the system function to be called to generate the same executable file. Then, even in different operating systems, the executable file of the same third-party component can be reused. The above method can isolate the third-party component's dependence on the operating system and realize the decoupling of the third-party component from the actual storage address of the system function. When the operating system is updated, the third-party component does not need to be updated accordingly.

[0131] Similarly, system applications can also call system functions through the above system isolation layer. For details, please refer to the introduction of third-party applications calling system functions through the system isolation layer. The above method can isolate the dependence of system applications on the operating system and decouple the actual storage address of system applications and system functions. When the operating system is updated, system applications do not need to be updated accordingly.

[0132] 2. Compile and link system applications based on the component isolation layer.

[0133] It can be seen from the above-mentioned embodiment of compiling and linking components based on the system isolation layer that the contents of the executable files generated by the same third-party component after being compiled and linked in different compilation environments can be the same. Therefore, the contents of the executable files generated by the third-party component 2 after being compiled and linked in compilation environment A and compilation environment B can be the same, for example, both are executable files f8. However, since the order of compiling and / or linking programs in different compilation environments may be different, the actual storage address of the executable file f8 of the third-party component 2 in the electronic device loaded with the operating system 1 may be different from the actual storage address in the electronic device loaded with the operating system 2.

[0134] During the process of compiling and linking the component isolation layer 312 in the compilation environment A, the actual storage address of the executable file f8 of the third-party component 2 in the electronic device loaded with the operating system 1 can be passed to the component isolation layer 312. The component isolation layer 312 can be stored in a fixed address in the electronic device. The linker in the compilation environment A can statically link the system application 1 according to the fixed address where the component isolation layer 312 is located. Similarly, during the process of compiling and linking the component isolation layer 322 in the compilation environment B, the actual storage address of the executable file f8 of the third-party component 2 in the electronic device loaded with the operating system 2 can be passed to the component isolation layer 322. The component isolation layer 322 can be stored in a fixed address in the electronic device. The linker in the compilation environment B can statically link the system application 1 according to the fixed address where the component isolation layer 322 is located.

[0135] The fixed address for storing the component isolation layer 312 and the fixed address for storing the component isolation layer 322 may be the same. Then, the executable files generated by the system application 1 after static linking in the compilation environment A and the compilation environment B are the same, for example, both are executable files f9. The fixed address of the component isolation layer 312 (that is, the fixed address of the component isolation layer 322) may be recorded in the executable file f9.

[0136] It can be seen that although the third-party component 2 is stored in different locations in the electronic device after being compiled and linked in different compilation environments, the address used to encapsulate the third-party component 2 can be the same. In other words, in different compilation environments, the same system application can be statically linked based on the fixed address of the component isolation layer used to encapsulate and call third-party components (such as third-party functions) to generate the same executable file. Then, even if the third-party component changes, the executable file of the same system application can still be reused. The above method can isolate the operating system (specifically, it can be a system application coupled to the operating system) from its dependence on third-party components, and realize the decoupling of the actual storage address of the system application and the third-party component. When the third-party component is updated, the system application and the operating system do not need to be updated accordingly.

[0137] It can be seen from the above method that the upper-layer components do not need to perceive the changes in the actual storage address of the system function to be called. The above system isolation layer can isolate the dependency of the component on the actual storage address of the system function. In the case where the actual storage address of the system function changes due to the operating system update, since the fixed address of the system isolation layer used to encapsulate the system function remains unchanged, the component does not need to be recompiled and linked. The executable file of the component can continue to run on the updated operating system. In addition, the system application does not need to perceive the changes in the actual storage address of the third-party function to be called. The above component isolation layer can isolate the dependency of the system application on the actual storage address of the third-party function. In the case where the actual storage address of the third-party function changes due to the update of the third-party function, since the fixed address of the component isolation layer used to encapsulate the third-party function remains unchanged, the system application and the operating system do not need to be recompiled and linked. The system application and the operating system can still correctly find and call the third-party function without updating with the third-party function. The above method of introducing a binary difference isolation layer can realize the decoupling of the component and the operating system. Both the component and the operating system can be updated independently.

[0138] The structure of the electronic device 100 involved in this application is introduced below.

[0139] Figure 4A The schematic diagram of the hardware structure of the electronic device 100 is exemplarily shown.

[0140] like Figure 4A As shown, the electronic device 100 may include an MCU, an antenna, a wireless communication module, a speaker, a microphone, a display screen, buttons, a motor, a sensor module, a power management module, a battery, and the like.

[0141] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0142] The MCU may be integrated with a central processing unit (CPU), peripheral units, and basic functional units. The peripheral units may include memory (such as ROM, RAM, Flash, etc.), input / output interfaces, and registers. The basic functional units may include timers / counters, interrupt systems, and serial interfaces. The MCU may be used to implement functions including timing, connecting external channels as an input / output interface, implementing external interrupt control, and providing communication interfaces. The CPU, various devices in the peripheral units, and various devices in the basic functional units may be coupled through a bus.

[0143] Among them, the memory can be used to store computer programs and data. For example, the memory can store binary difference isolation layers and programs corresponding to the operating system, executable files of components, etc. The memory can include ROM, RAM, and Flash. Both ROM and RAM can support on-chip instruction fetching. The CPU can randomly access the contents on ROM and RAM. In some embodiments, the storage area on the ROM can be divided into regions. Different storage areas on the ROM can be updated independently. For example, the storage area on the ROM may include storage area 1 and storage area 2. The storage addresses occupied by storage area 1 and storage area 2 are different. Storage area 1 and storage area 2 can be used to store different contents respectively. When the content in storage area 1 needs to be updated, the electronic device 100 can re-burn the entire storage area 1 and store the updated content in storage area 1. At this time, the electronic device 100 can keep the content of storage area 2 unchanged, that is, not burn storage area 2. Flash does not support random access by the CPU. Flash power failure will not lose data. The electronic device 100 can read the content stored in Flash into RAM. Then, the CPU can access the relevant content from RAM. Among them, the content stored in Flash is read into RAM, and the storage location in RAM can be predetermined by the content in the compile and link stage. RAM will lose data in the event of power failure. Therefore, when RAM loses power (such as the electronic device 100 is turned off, the electronic device 100 runs out of power) and then powers on (such as the electronic device 100 is turned on), the data previously stored in RAM that is read from Flash is lost. The electronic device 100 can read the data in Flash into RAM again after the RAM is powered on.

[0144] In some embodiments, the electronic device 100 may store the system application together with the operating system in ROM. The system application may be coupled with the operating system and stored together in a storage area in the ROM. That is, the system application and the operating system are always updated together. Alternatively, the system application and the operating system are stored in different storage areas in the ROM respectively. The system application and the operating system can be updated independently. The electronic device 100 may store a third-party component in Flash. The electronic device 100 may read the executable file of the third-party component from Flash into RAM and then execute it.

[0145] In other embodiments, the electronic device 100 may also store the third-party component in ROM. The storage area of ​​the third-party component in ROM is different from the storage area of ​​the system application and the operating system in ROM. In this way, the third-party component can be updated independently of the system application and the operating system.

[0146] In some other embodiments, the electronic device 100 may also store the system application in Flash. The electronic device 100 may read the executable file of the system application from Flash into RAM for execution.

[0147] The embodiment of the present application does not limit the type of memory. For example, in addition to ROM, RAM, and Flash, the MCU may also be integrated with pseudo static random access memory (PSRAM) and the like.

[0148] The CPU may include components such as a controller and an arithmetic unit. The CPU can be used to read binary instructions from ROM and RAM and execute them. That is, the MCU can implement on-chip instruction fetching and execution. For example, the CPU can read the executable file of a component from ROM and RAM and execute the binary instructions therein to implement the corresponding functions of the component.

[0149] The input / output interface may include a USB interface. Not limited to the USB interface, the input / output interface integrated on the MCU may also include one or more of the following: an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, and the like.

[0150] Registers can be used to temporarily store data and operation structures involved in calculations.

[0151] Timers / Counters can be used to measure the time it takes for an event to occur or to measure the time difference between two events.

[0152] The interrupt system can be used to achieve real-time control, automatic fault handling, and data transmission between the CPU and peripheral devices.

[0153] The serial interface may be an expansion interface using a serial communication method, which may be used to implement sequential transmission of data bit by bit.

[0154] A speaker, also called a "horn", is used to convert audio electrical signals into sound signals.

[0155] A microphone, also known as a "microphone" or "microphone", is used to convert sound signals into electrical signals.

[0156] The display screen is used to display images, videos, etc. In some embodiments, the electronic device 100 may include 1 or N display screens, where N is a positive integer greater than 1.

[0157] The buttons include power button, volume button, etc.

[0158] The motor can generate vibration prompts.

[0159] The sensor module may include one or more of the following sensors: pressure sensor, gyroscope sensor, air pressure sensor, magnetic sensor, acceleration sensor, gravity sensor, distance sensor, proximity light sensor, fingerprint sensor, temperature sensor, touch sensor, ambient light sensor, bone conduction sensor, etc.

[0160] The power management module is used to connect the battery and the MCU. The power management module can receive charging input from the charger to charge the battery and power the MCU, speakers, microphones, displays, sensor modules, wireless communication modules, etc. The power management module can also receive input from the battery to power the MCU, speakers, microphones, displays, sensor modules, wireless communication modules, etc.

[0161] The wireless communication function of the electronic device 100 can be implemented through an antenna, a wireless communication module, etc.

[0162] The antenna is used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of the antenna. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.

[0163] The wireless communication module can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module can be one or more devices integrating at least one communication processing module. The wireless communication module receives electromagnetic waves via an antenna, modulates and filters the electromagnetic wave signals, and sends the processed signals to the MCU. The wireless communication module can also receive the signal to be sent from the MCU, modulate the frequency, amplify it, and convert it into electromagnetic waves for radiation through the antenna. In some embodiments, the wireless communication module can also provide solutions for wireless communications such as 2G / 3G / 4G / 5G.

[0164] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the layered architecture as an example to exemplify the software structure of the electronic device 100.

[0165] Figure 4B It is a software structure block diagram of the electronic device 100 according to an embodiment of the present application.

[0166] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the software system of the electronic device 100 can be divided into three layers, from top to bottom, namely, the application layer, the application framework and system service layer, and the kernel layer.

[0167] The application layer can include a series of application packages. Application packages can also be called component packages.

[0168] like Figure 4B As shown, the application package can include third-party components and system applications, such as compass, weather, WLAN, Bluetooth, time, camera, short message, etc.

[0169] The application framework and system service layer provide API and programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

[0170] like Figure 4B As shown, the application framework and system service layer may include a log management module, a communication management module, a view system, a memory management module, and the like.

[0171] The log management module can be used to provide log recording and log maintenance.

[0172] The communication management module can be used for unified management of semaphores and message handles.

[0173] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.

[0174] The memory management module can be used to implement memory management. For example, the electronic device 100 can manage different storage areas in the ROM through the memory management module.

[0175] In some embodiments, the application framework and the system service layer may further include a binary difference isolation layer. The binary difference isolation layer may include a component isolation layer and a system isolation layer. Among them, the component isolation layer may be an interface for calling a third-party function. The system isolation layer may be an interface for calling a system function. That is, the component isolation layer and the system isolation layer are both interface functions. The binary difference isolation layer may be specifically described in the aforementioned embodiment.

[0176] The kernel layer is the layer between hardware and software. The kernel layer contains at least the file system, hardware driver, and bus driver.

[0177] The file system can be used to manage files and data stored in the electronic device 100, and can be equivalent to a file explorer. The file system can be a method of organizing files in an electronic device. The file system can adopt a hierarchical structure, starting from a root directory and divided into multiple subdirectories. The file system can be responsible for functions such as creating files, storing, reading, modifying, and transferring files. For example, the file system can store files to a storage location corresponding to a file path. In this way, a user can find the corresponding file through the file path.

[0178] The hardware driver can be used for the software in the electronic device 100 (such as the content of the application layer, the content of the application framework layer and the system service layer) to drive the hardware in the electronic device 100. For example, the hardware in the electronic device 100 may include one or more of the following: display screen, camera, speaker, microphone, sensor, etc. Then, the hardware driver may include one or more of the following: display driver, camera driver, audio driver, sensor driver, etc.

[0179] The bus driver can be used to control bus components to implement corresponding functions. It is the bus controller, adapter and bridge.

[0180] In some embodiments, the software system of the electronic device 100 may also include a static library so that the components implemented based on static linking in the electronic device 100 can call required system functions during operation. The embodiment of the present application does not limit the position of the static library in the software system. For example, the static library may be located in the application framework and the system service layer, or in other layers between the application framework and the system service layer and the kernel layer.

[0181] In some embodiments, after the software system of the electronic device 100 is built, it can be packaged from top to bottom into a system image. This system image can be a binary file. The content in the system image can be divided according to preset rules. For example, the part of the system image that is allowed to be loaded later (such as a file system, a third-party component) and the part that is not allowed to be loaded later (such as an operating system) can be divided. Among them, the above-mentioned part that is allowed to be loaded later can be placed in the Flash of the electronic device 100. The above-mentioned part that is not allowed to be loaded later can be burned into the ROM of the electronic device 100. Therefore, the electronic device 100 can burn the operating system in the ROM and store the file system and third-party components in the Flash. The file system can manage the storage location of the third-party component in the Flash. The executable file of the third-party component in the Flash can be stored and indexed according to the file path. After the electronic device 100 is turned on, the instructions in the ROM can be executed first, and then the content in the Flash (such as the executable file of the third-party component) can be read into the preset storage area in the RAM.

[0182] The embodiment of the present application does not limit the type of operating system of the electronic device 100. For example, the operating system may be: OS, etc.

[0183] The following introduces the static linking method provided by this application in conjunction with some release updates of components and operating systems.

[0184] Case 1( Figure 5A to Figure 5C ):The component provider provides third-party components before the electronic device 100 leaves the factory.

[0185] In some embodiments, the component provider may develop components and binary difference isolation layers. The component provider may include PCs, servers and other devices used to develop the above components and binary difference isolation layers. The integrator may develop an operating system to load the operating system into the electronic device 100 produced by the integrator. The integrator may also be referred to as a device manufacturer or other names. The integrator may include PCs, servers and other devices used to develop the operating system and load the operating system into the electronic device 100.

[0186] Among them, the component provider and the integrator may be different. That is, the component provider may be a manufacturer of a non-electronic device 100, and there is a need to publish the components it develops in the electronic device 100. When the component provider and the integrator are different, the components provided by the component provider may be third-party components. The integrator can integrate third-party components provided by multiple component providers on the operating system and publish them on the electronic device 100. Alternatively, the component provider and the integrator may be the same party. That is, the component provider may be the manufacturer of the electronic device 100. For example, in addition to developing the operating system, the integrator may also develop one or more components to be published in the electronic device 100. When the component provider and the integrator are the same party, the components provided by the component provider may be system components (i.e., system applications).

[0187] Here, we take the example that the component provider is different from the integrator and the component provider provides third-party components.

[0188] In some embodiments, the component provider and the integrator may communicate in advance to determine the fixed address for encapsulating functional functions (including system functions and third-party functions) in the memory of the electronic device 100. That is, a part of the storage area may be preset in the memory of the electronic device 100 for storing the component isolation layer and the system isolation layer to realize the address solidification of the interface function. The above-mentioned interface functions are the system isolation layer and the component isolation layer, which can be used to call the system function and the third-party function. The preset storage area corresponding to the above-mentioned fixed address may not be affected by the change of the storage content in other storage areas in the electronic device 100, and is an independent storage area. Among them, the preset storage area corresponding to the above-mentioned fixed address may include two independent storage areas, which are used to store the system isolation layer and the component isolation layer respectively. Therefore, the system isolation layer and the component isolation layer can be updated independently and do not interfere with each other. The preset storage area corresponding to the above-mentioned fixed address may be a storage area on the ROM in the electronic device 100. An independent storage area on the ROM may be a slice with a continuous storage address on the ROM. When there is content update in an independent storage area on the ROM, this independent storage area can be re-burned as a whole and the updated content is written.

[0189] Here we take the following scenario as an example: the component provider develops third-party component 1 and third-party component 2, the integrator provides system application 1, third-party component 1 needs to call system function 1 provided by the operating system, and the system application needs to call third-party component 2, where the third-party component can be a third-party function.

[0190] It is understandable that a third-party component can call one or more system functions. A system application can also call one or more third-party components. In addition to system function 1, third-party component 1 can also call more system functions. The method for third-party component 1 to call other system functions can refer to the introduction of the method for third-party component 1 to call system function 1. In addition to third-party component 2, system application 1 can also call more third-party components. The method for system application 1 to call other third-party components can refer to the introduction of the method for system application 1 to call third-party component 2.

[0191] like Figure 5A As shown, the component provider can develop third-party component 1 and third-party component 2, and develop a binary difference isolation layer according to the fixed address agreed with the integrator. The binary difference isolation layer can include system isolation layer 1 and component isolation layer 1. Among them, system isolation layer 1 can be used to encapsulate system function 1 for components such as third-party component 1 to call system function 1. Component isolation layer 1 can be used to encapsulate third-party component 2 for components such as system application 1 to call third-party component 2.

[0192] The above fixed address may include a fixed address for encapsulating system function 1 (i.e., a fixed address for storing system isolation layer 1), and a fixed address for encapsulating third-party component 2 (i.e., a fixed address for storing component isolation layer 1). In this way, during the static linking process of third-party component 1, the linker may use the fixed address for storing system isolation layer 1 to statically link component 1, thereby isolating the dependency of third-party component 1 on the actual storage address of system function 1.

[0193] Not limited to the above-mentioned fixed addresses for encapsulating system functions 1 and the fixed addresses for encapsulating third-party components 2, the binary difference isolation layer can also be used to encapsulate other functional functions (such as system functions, third-party functions, etc.), so that the components can complete static links according to the fixed addresses for encapsulating the functional functions they need. In other words, not limited to the above-mentioned system isolation layer 1 and component isolation layer 1, the binary difference isolation layer can also include more system isolation layers for encapsulating other system functions, and component isolation layers for encapsulating other third-party components. The binary difference isolation layer can isolate the dependency of one or more components on the actual storage addresses of the functional functions they need.

[0194] It is understandable that different component providers can communicate with the integrator in advance to determine the fixed addresses for encapsulating system functions and the fixed addresses for encapsulating third-party components in the memory of the electronic device 100. In other words, different component providers can provide corresponding system isolation layers for their respective developed third-party components, and provide component isolation layers for encapsulating their developed third-party components.

[0195] Optionally, the binary difference isolation layer may also be provided by the integrator, which is not limited in the present application embodiment.

[0196] Before the electronic device 100 leaves the factory (that is, during the development process of the electronic device 100), the component provider may provide the integrator with the third-party component 1, the third-party component 2, the system isolation layer 1, and the component isolation layer 1. Upon receiving the above content provided by the component provider, the integrator may statically link the third-party component (including the third-party component 1 and the third-party component 2), the binary difference isolation layer (including the system isolation layer 1 and the component isolation layer 1), the system application (such as the system application 1), and the operating system and publish them to the electronic device 100. That is, when leaving the factory, the electronic device 100 may include the operating system, the instruction 511 of the system isolation layer 1, the instruction 512 of the component isolation layer 1, the executable file F1 of the third-party component 1, the executable file F2 of the third-party component 2, and the executable file F3 of the system application.

[0197] The instruction 511 of the system isolation layer 1 may be a binary instruction obtained after the source program of the system isolation layer 1 is compiled and linked.

[0198] The instruction 512 of the component isolation layer 1 may be a binary instruction obtained after the source program of the component isolation layer 1 is compiled and linked.

[0199] The above-mentioned static linking of the third-party component 1 may include: statically linking the target file of the third-party component 1 and the system function 1 into an executable file F1 according to the fixed address used to encapsulate the system function 1. The executable file F1 may contain a fixed address for encapsulating the system function 1. The storage area corresponding to the fixed address for encapsulating the system function 1 may store instructions 511 of the system isolation layer 1. In this way, when the electronic device 100 executes the executable file F1, the electronic device 100 can call the system isolation layer 1 according to the fixed address for encapsulating the system function 1, thereby using the system isolation layer 1 to call the system function 1.

[0200] The above-mentioned static linking of the system isolation layer 1 and the operating system may include: providing the actual storage address of the system function 1 to the system isolation layer 1. When the system isolation layer 1 is statically linked and published to the electronic device 100, the electronic device 100 may store the instructions 511 of the system isolation layer 1 in the storage area corresponding to the fixed address in the memory according to the fixed address used to encapsulate the system function 1. When the operating system is statically linked and published to the electronic device 100, the electronic device 100 may store the operating system in the memory. Among them, the electronic device 100 may store the instructions corresponding to the system functions in the corresponding storage area according to the actual storage address of each system function. For example, the electronic device 100 may store the instructions of the system function 1 in the storage area corresponding to the actual storage address of the system function 1.

[0201] The system application 1 can be compiled and linked together with the operating system. Static linking of the system application 1 may include: statically linking the target file of the system application 1 and the third-party component 2 into an executable file F3 according to the fixed address used to encapsulate the third-party component 2. The executable file F3 may contain a fixed address for encapsulating the third-party component 2. The storage area corresponding to the fixed address for encapsulating the third-party component 2 may store instructions 512 of the component isolation layer 1. In this way, when the electronic device 100 executes the executable file F3, the electronic device 100 can call the component isolation layer 1 according to the fixed address for encapsulating the third-party component 2, thereby using the component isolation layer 1 to call the third-party component 2.

[0202] The above-mentioned static linking of the third-party component 2 and the component isolation layer 1 may include: statically linking the target file of the third-party component 2 into the executable file F2, determining the actual storage address of the executable file F2, and providing the actual storage address of the executable file F2 to the component isolation layer 1. When the component isolation layer 1 is statically linked and published to the electronic device 100, the electronic device 100 may store the instructions 512 of the component isolation layer 1 in the storage area corresponding to the fixed address in the memory according to the fixed address used to encapsulate the third-party component 2. When the third-party component 2 is statically linked and published to the electronic device 100, the electronic device 100 may store the executable file F2 in the storage area corresponding to the actual storage address of the executable file F2.

[0203] In a possible implementation, the third-party component 1 provided by the component provider to the integrator may be a target file compiled from the source file of the third-party component 1. The third-party component 2 provided by the component provider to the integrator may be a target file compiled from the source file of the third-party component 2. The binary difference isolation layer provided by the component provider to the integrator may also be a target file compiled from the binary difference isolation layer. That is, the component provider may compile the third-party component 1, the third-party component 2 and the binary difference isolation layer and then provide them to the integrator.

[0204] Among them, the integrator can compile system applications such as system application 1 and operating system, and statically link the compiled system applications such as system application 1 and operating system with the target files of third-party components from the component provider and the target files of the binary difference isolation layer.

[0205] Figure 5B The diagram exemplarily shows a storage location diagram of a third-party component, a binary difference isolation layer, a system application, and an operating system in an electronic device 100.

[0206] like Figure 5B As shown, the memory of the electronic device 100 may include ROM, RAM, and Flash. Among them, the executable file F1 of the third-party component 1 and the executable file F2 of the third-party component 2 may be stored in Flash. The executable file F3 of the system application, the operating system, the instructions 511 of the system isolation layer 1, and the instructions 512 of the component isolation layer 1 may be stored in ROM.

[0207] After the RAM is powered on (such as after the electronic device 100 is turned on), the electronic device 100 can read the executable file F1 and the executable file F2 from the Flash into the RAM. Among them, the electronic device 100 can store the executable file F1 in the storage area corresponding to the address H1 in the RAM, and store the executable file F2 in the storage area corresponding to the address H2 in the RAM. The above-mentioned address H1 and address H2 can be determined by the third-party component 1 and the third-party component 2 in the compilation and linking stage. When it is necessary to run the third-party component 1, the electronic device 100 can obtain the executable file F1 from the storage area corresponding to the address H1 in the RAM and execute it. Address H1 can be called the execution address of the third-party component 1. Similarly, when it is necessary to run the third-party component 2, the electronic device 100 can obtain the executable file F2 from the storage area corresponding to the address H2 in the RAM and execute it. Address H2 can be called the execution address of the third-party component 2. Address H1 and address H2 are only exemplary descriptions of the present application and should not be construed as limiting the present application.

[0208] The storage area with address L1 in the ROM can store the executable file F3 of the system application 1, the storage area with address Ln can store the instruction 511 of the system isolation layer 1, the storage area with address Lk can store the system function 1, the storage area with address Lk+1 can store the system function 2, and the storage area with address Lq can store the instruction 512 of the component isolation layer 1.

[0209] The address Ln in the ROM may be a fixed address used to encapsulate the system function 1. The third-party component 1 may be statically linked according to the address Ln. Therefore, the executable file F1 of the third-party component 1 may contain the address Ln. When the third-party component 1 is running, the electronic device 100 may fetch instructions from the RAM on chip to obtain the executable file F1. When the electronic device 100 executes the executable file F1, it may read the instruction 511 of the system isolation layer 1 in the ROM according to the address Ln in the executable file F1 and call the system isolation layer 1. Since the system isolation layer 1 may obtain the actual storage address (i.e., the address Lk) of the system function 1 when statically linked, the electronic device 100 may execute the instruction 511 of the system isolation layer 1 to implement the call to the system function 1. In this way, during operation, the third-party component 1 may use the system isolation layer 1 to call the system function 1 according to the fixed address used to encapsulate the system function 1.

[0210] The address Lq in the ROM may be a fixed address used to encapsulate the third-party component 2. The system application 1 may be statically linked according to the address Lq, and therefore, the executable file F3 of the system application 1 may contain the address Lq. When the system application 1 is running, the electronic device 100 may fetch instructions from the ROM on-chip to obtain the executable file F3. When the electronic device 100 executes the executable file F3, it may read the instruction 512 of the component isolation layer 1 in the ROM according to the address Lq in the executable file F3 and call the component isolation layer 1. Since the component isolation layer 1 may obtain the actual storage address (i.e., address H2) of the third-party component 2 when statically linked, the electronic device 100 may execute the instruction 512 of the component isolation layer 1 to implement the call to the third-party component 2. In this way, the system application 1 may use the component isolation layer 1 to call the third-party component 2 according to the fixed address used to encapsulate the third-party component 2 during operation.

[0211] In some embodiments, the storage area where address Lk and address Lk+1 are located can be an area in the ROM where the operating system is stored. The operating system, system applications, and system isolation layer can be stored together in an independent area in the ROM, such as storage area A1. That is, the operating system, system applications, and system isolation layer are always updated together. If any one or more of the contents of the operating system, system applications, and system isolation layer need to be updated, the electronic device 100 can re-burn the storage area A1 as a whole, and write the updated operating system, system applications, and system isolation layer into the storage area A1. Among them, the system isolation layer is stored in the storage area corresponding to the fixed address in the storage area A1. Figure 5B The address L1, address Ln, address Lk and address Lk+1 shown can all be addresses in storage area A1. In other embodiments, the operating system and system applications can be stored in different independent areas in the ROM, respectively. For example, the operating system can be stored in storage area A2 in the ROM. The system application can be stored in storage area A3 in the ROM. When the operating system in storage area A2 is updated, storage area A3 can remain unchanged (that is, the system application does not need to be updated). When the system application in storage area A3 is updated, storage area A2 can remain unchanged (that is, the operating system does not need to be updated). In other embodiments, the system isolation layer and the operating system can also be stored in different independent areas in the ROM, respectively.

[0212] The storage area of ​​the component isolation layer (such as component isolation layer 1) in the ROM can be an independent area different from the operating system, system applications, and system isolation layer. In other words, when one or more of the operating system, system applications, and system isolation layer are updated, the component isolation layer stored in the ROM can remain unchanged without the need for re-burning.

[0213] The above-mentioned address Ln and address Lq are preset fixed addresses. Address L1, Ln, Lk and address Lq are all physical addresses in ROM. Figure 5B The storage address division and storage content in the ROM shown are only exemplary descriptions of the present application and should not constitute limitations on the present application.

[0214] It is understandable that the contents are not limited to being stored in ROM, and the system applications 1 and other system applications, binary difference isolation layer, operating system and the like may also be stored in other memories that support on-chip instruction fetching.

[0215] In some embodiments, one or more components pre-installed on the electronic device 100 before shipment may be removed.

[0216] Figure 5C Another schematic diagram of the storage location of third-party components, binary difference isolation layer, system applications and operating system in electronic device 100 is exemplified.

[0217] like Figure 5C As shown, the third-party components, binary difference isolation layer, system applications and operating system can all be stored in the ROM of the electronic device 100. The storage locations of the executable file F3 of the system application 1, the instruction 511 of the system isolation layer 1, the system function 1, and the system function 2 in the ROM can be referred to. Figure 5B Introduction.

[0218] The storage area at the address Lp in the ROM may store the executable file F1 of the third-party component 1 , and the storage area at the address Ls may store the executable file F2 of the third-party component 2 .

[0219] When running the third-party component 1, the electronic device 100 can fetch instructions from the ROM on-chip to obtain the executable file F1. As can be seen from the above embodiments, the executable file F1 can contain a fixed address Ln for encapsulating the system function 1. The electronic device 100 executes the executable file F1 and can use the system isolation layer 1 to call the system function 1 according to the address Ln in the executable file F1.

[0220] When running the system application 1, the electronic device 100 can fetch instructions from the ROM on-chip, obtain and execute the executable file F3. As can be seen from the above embodiments, the executable file F3 may contain a fixed address Lq for encapsulating the third-party component 2. The address Lq may store the instruction 512 of the component isolation layer 1. Since the component isolation layer 1 can obtain the actual storage address (i.e., address Ls) of the third-party component 2 during static linking, the electronic device 100 can use the component isolation layer 1 to call the third-party component 2 according to the address Lq in the executable file F3.

[0221] It should be noted that the storage area of ​​the third-party components in the ROM can be an independent area that is different from the operating system, system applications, and binary difference isolation layer. In other words, when one or more of the operating system, system applications, and binary difference isolation layer are updated, the third-party components stored in the ROM can remain unchanged without the need for re-burning. Optionally, the third-party components and the component isolation layer can be stored together in an independent area in the ROM. That is, the third-party components and the component isolation layer are always updated together.

[0222] The embodiment of the present application does not limit the partitioning of the storage area in the ROM.

[0223] In some embodiments, the component provider may also provide a new third-party component to the integrator after the electronic device 100 leaves the factory. Among them, the binary difference isolation layer that the component provider has provided to the integrator includes a system isolation layer for encapsulating the system functions required by the new third-party component. When receiving the new third-party component provided by the component provider, the integrator can link the new third-party component and publish it to the electronic device 100 according to the fixed address used to encapsulate the system function. The electronic device 100 can install the new third-party component, store the executable file of the new third-party component in Flash, and read it from Flash to RAM. Alternatively, the electronic device 100 can also directly store the executable file of the new third-party component in a memory (such as ROM) that supports on-chip instruction fetching. Optionally, the electronic device 100 may include an application market or other applications for installing components or APPs. The user can search for the new third-party component in the application market in the electronic device 100. In response to the user operation of installing the new third-party component, the electronic device 100 can obtain the executable file of the new third-party component and store the executable file of the new third-party component.

[0224] In some embodiments, system applications (such as system application 1, etc.) can also call system functions through the system isolation layer (such as system isolation layer 1) during operation. For details, please refer to the method in which the third-party component 1 calls the system function through the system isolation layer 1. In other words, the system application can also be decoupled from the operating system, and each can be updated independently without affecting each other.

[0225] That is to say, the third-party components installed by the electronic device 100 before leaving the factory and the third-party components triggered to be installed by the user after leaving the factory can be components released through static linking based on the fixed address used to encapsulate the system functions required by the third-party components. The system isolation layer encapsulates the system functions required by the third-party components, and can isolate the dependency of the third-party components on the actual storage address of the system functions. The component isolation layer encapsulates the third-party components required by the system applications, and can isolate the dependency of the system applications on the actual storage address of the third-party components. In this way, the components and the operating system can be updated independently without affecting each other.

[0226] Case 2( Fig. 6A and Figure 6B ): Third-party component update of the electronic device 100 after leaving the factory.

[0227] The component provider and the integrator can refer to the above description in case 1. It should be noted that since the component provider has provided the binary difference isolation layer (such as system isolation layer 1 and component isolation layer 1), the integrator can have the binary difference isolation layer. When updating the component, the component provider only needs to provide the updated third-party component.

[0228] Here, the updating of third-party component 1 and third-party component 2 by the component provider is taken as an example for explanation.

[0229] like Fig. 6A As shown, the component provider can update the third-party component 1 and the third-party component 2. The updated component of the third-party component 1 can be the third-party component 1′. The updated component of the third-party component 2 can be the third-party component 2′. The component provider can request the integrator to update the third-party component (including the third-party component 1 and the third-party component 2), and provide the third-party component 1′ and the third-party component 2′ to the integrator. For example, the component provider can provide the integrator with the target file after the source file of the third-party component 1′ and the third-party component 2′ is compiled. Upon receiving the target file of the third-party component 1′ and the target file of the third-party component 2′, the integrator can statically link the third-party component 1′, the third-party component 2′ and the component isolation layer 1 into an executable file and publish it to the electronic device 100. The electronic device 100 can update the third-party component 1, the third-party component 2, and the component isolation layer 1, and store the executable file F4 of the third-party component 1′, the executable file F5 of the third-party component 2′, and the instruction 611 of the component isolation layer 1. In the scenario where the third-party component 1 and the third-party component 2 are updated, system applications such as the system application 1, the system isolation layer 1 and the operating system can remain unchanged. The electronic device 100 may still store instructions of the system isolation layer 1 , the operating system, and the executable file F3 of the system application 1 .

[0230] contrast Figure 5A and Fig. 6AIt can be seen that when the third-party component 2 is updated, the instructions of the component isolation layer 1 used to encapsulate the third-party component 2 after static linking are updated accordingly. Figure 5A The instruction 512 shown is updated to Fig. 6A Instructions 611 are shown. Instructions 512 and instructions 611 may be different.

[0231] Here, the reason why the instructions of the component isolation layer 1 after static linking are updated along with the update of the third-party component 2 is explained.

[0232] When the third-party component 2 is updated to the third-party component 2′, statically linking the third-party component 2′ and the component isolation layer 1 may include: statically linking the target file of the third-party component 2′ to the executable file F5, determining the actual storage address of the executable file F5, and providing the actual storage address of the executable file F5 to the component isolation layer 1. Since the actual storage address of the executable file F5 may be different from the actual storage address of the executable file F2 of the third-party component 2 before the update, and the component isolation layer 1 needs to obtain the actual storage address of the third-party component 2 (or the third-party component 2′) to implement indexing and calling the third-party component 2 (or the third-party component 2′), the instructions after the static linking of the component isolation layer 1 need to be updated as the third-party component 2 is updated.

[0233] Among them, before the third-party component 2 is updated, Figure 5A The instruction 512 of the component isolation layer 1 shown can be used to find and call the third-party component 2 according to the actual storage address of the third-party component 2. After the third-party component 2 is updated, Fig. 6A The instruction 611 of the component isolation layer 1 shown may be used to find and call the third-party component 2 ′ according to the actual storage address of the third-party component 2 ′.

[0234] When the component isolation layer 1 is statically linked and released to the electronic device 100, the electronic device 100 can store the instruction 611 of the component isolation layer 1 in the storage area corresponding to the fixed address in the memory according to the fixed address used to encapsulate the third-party component 2. When the third-party component 2′ is statically linked and released to the electronic device 100, the electronic device 100 can store the executable file F5 in the storage area corresponding to the actual storage address of the executable file F5.

[0235] It is understandable that when the component isolation layer 1 is statically linked with the third-party component 2′, the source program of the component isolation layer 1 may remain unchanged, and the instructions of the component isolation layer 1 after static linking may be changed. That is, when the third-party component is updated, the component provider may not need to provide the binary difference isolation layer again.

[0236] In addition, although the instructions of the component isolation layer 1 after static linking are updated as the third-party component 2 is updated, the address where the instructions of the component isolation layer 1 are stored does not change. In other words, the fixed address used to encapsulate the third-party component 2 will not change as the third-party component 2 is updated. Therefore, the system application 1 can still find the instruction 611 of the component isolation layer 1 according to the fixed address used to encapsulate the third-party component 2, and use the component isolation layer 1 to call the third-party component 2′. The system application 1 does not need to be recompiled and linked. Since the operating system has not been updated, the operating system also does not need to be recompiled and linked. The actual storage address of the system function in the operating system has not changed, so the system isolation layer 1 does not need to be recompiled and linked.

[0237] In some embodiments, the third-party component 1′ still needs to call the system function 1. When the integrator uses the target file of the third-party component 1′ for static linking, the target file of the third-party component 1′ can be statically linked to the executable file F4 according to the fixed address used to encapsulate the system function 1. The executable file F4 may include a fixed address for encapsulating the system function 1. The instructions 511 of the system isolation layer 1 may be stored in the storage area corresponding to the fixed address for encapsulating the system function 1. In this way, when the electronic device 100 executes the executable file F4, the electronic device 100 can call the system isolation layer 1 according to the fixed address used to encapsulate the system function 1, thereby using the system isolation layer 1 to call the system function 1.

[0238] Optionally, after the third-party component 1 is updated, the third-party component 1′ also needs to call the system function 2. Figure 5A The component provider shown has provided a system isolation layer for encapsulating system function 2. For example, the ROM of the electronic device 100 contains a fixed address for encapsulating system function 2, and the fixed address may store instructions for the system isolation layer for encapsulating system function 2 after compilation and linking. When the integrator uses the target file of the third-party component 1′ for static linking, the target file of the third-party component 1′ may be statically linked to an executable file according to the fixed address for encapsulating system function 2. The executable file of the third-party component 1′ may contain a fixed address for encapsulating system function 2. In this way, when the electronic device 100 executes the executable file of the third-party component 1′, the system isolation layer may be called according to the fixed address for encapsulating system function 2, thereby calling the system function 2 using the system isolation layer.

[0239] The embodiment of the present application does not limit the above-mentioned method of updating the third-party component 1 and the third-party component 2 in the electronic device 100. In a possible implementation, after the third-party component 1 is updated, the executable file F4 of the third-party component 1′ can overwrite Figure 5AThe executable file F1 of the third-party component 1 is stored in the memory of the electronic device 100. In another possible implementation, the content that changes after the third-party component 1 is updated can be stored in the memory of the electronic device 100, and the content that does not change after the third-party component 1 is updated can remain unchanged in the memory and continue to be stored. The update method of the third-party component 2 can refer to the update method of the third-party component 1 mentioned above.

[0240] Figure 6B The diagram exemplarily shows a storage location diagram of a third-party component, a binary difference isolation layer, a system application, and an operating system in an electronic device 100.

[0241] like Figure 6B As shown, the memory of the electronic device 100 may include ROM, RAM, and Flash. The electronic device 100 may update the third-party component 1 and the third-party component 2 in Flash, and store the executable file F4 of the third-party component 1' and the executable file F5 of the third-party component 2' in Flash.

[0242] After the RAM is powered on, the electronic device 100 can read the executable file F4 and the executable file F5 from the Flash into the RAM. Among them, the electronic device 100 can store the executable file F4 in the storage area corresponding to the address H3 in the RAM, and store the executable file F5 in the storage area corresponding to the address H4 in the RAM. The above-mentioned address H3 and address H4 can be determined by the third-party component 1′ and the third-party component 2′ in the compilation and linking stage. When it is necessary to run the third-party component 1′, the electronic device 100 can obtain the executable file F4 from the storage area corresponding to the address H3 in the RAM and execute it. Address H3 can be called the execution address of the third-party component 1′. Similarly, when it is necessary to run the third-party component 2′, the electronic device 100 can obtain the executable file F5 from the storage area corresponding to the address H4 in the RAM and execute it. Address H4 can be called the execution address of the third-party component 2′. Address H3 and address H4 are only exemplary descriptions of the present application and should not constitute a limitation on the present application.

[0243] The address Lq in the ROM may be a fixed address for packaging the third-party component 2. When the third-party component 2 is updated to the third-party component 2′, the electronic device 100 may update the component isolation layer 1 in the storage area corresponding to the address Lq. The electronic device 100 may store the content in the storage area corresponding to the address Lq in the ROM from Figure 5B The instruction 512 of the component isolation layer 1 is shown to be updated as Figure 6B The instructions 611 of the component isolation layer 1 are shown. The storage contents of other areas in the ROM can refer to the aforementioned Figure 5B Introduction.

[0244] When the system application 1 is running, it can call the component isolation layer 1 through the instruction 611 of the component isolation layer 1 in the address Lq, and then use the component isolation layer 1 to call the third-party component 2'. It can be seen from the above embodiments that the executable file F3 of the system application 1 can contain the address Lq. When running the system application 1, the electronic device 100 can execute the executable file F3, read the instruction 611 of the component isolation layer 1 according to the address Lq in the executable file F3, and call the component isolation layer 1. Since the component isolation layer 1 can obtain the actual storage address (i.e., address H4) of the third-party component 2' during static linking, the electronic device 100 executes the instruction 611 of the component isolation layer 1 to call the third-party component 2'.

[0245] When the third-party component 1′ is running, it can call the system isolation layer 1 through the instruction 511 of the system isolation layer 1 in the address Ln, and then use the system isolation layer 1 to call the system function 1. It can be seen from the above embodiments that the executable file F4 of the third-party component 1′ can contain the address Ln. When the third-party component 1′ is running, the electronic device 100 can execute the executable file F4, read the instruction 511 of the system isolation layer 1 according to the address Ln in the executable file F4, and call the system isolation layer 1. The electronic device 100 executes the instruction 511 of the system isolation layer 1 to call the system function 1.

[0246] In some embodiments, the updated third-party component 1' and the third-party component 2' may also be stored in the ROM. Figure 5C I will not go into details here.

[0247] It can be seen that when the third-party component is updated, the system application and the operating system do not need to be updated accordingly. In order to allow the system application to call the updated third-party component without updating, the electronic device 100 can update the component isolation layer in the fixed address used to encapsulate the third-party component. The system application can find the updated component isolation layer according to the fixed address, and then use the component isolation layer to call the updated third-party component. The above method can effectively reduce the update cost of the third-party component and improve the efficiency of the electronic device 100 in updating the third-party component.

[0248] Case 3( Fig. 7A and Figure 7B ): The operating system of the electronic device 100 is updated after leaving the factory.

[0249] The integrator can refer to the above description in Case 1 and Case 2. It should be noted that the binary difference isolation layer (including system isolation layer 1 and component isolation layer 1) owned by the integrator can be the above Figure 5AThe binary difference isolation layer shown is provided by the component provider before the electronic device 100 leaves the factory. Alternatively, the binary difference isolation layer owned by the integrator may also be a binary difference isolation layer updated by the component provider after the electronic device 100 leaves the factory. Among them, after the binary difference isolation layer is updated, it may include more system isolation layers that encapsulate different system functions, and more component isolation layers that encapsulate different third-party components. In this way, more third-party components can use the system isolation layer to call the system functions they need, and more system applications can use the component isolation layer to call the third-party components they need.

[0250] like Fig. 7A As shown, the integrator can update the operating system, and statically link the system isolation layer 1, system application 1 and other system applications, and the updated operating system together and publish them to the electronic device 100. The electronic device 100 can update the system isolation layer 1, system application 1, and the storage area of ​​the operating system, storing the executable file F6 of the system application 1, the instruction 711 of the system isolation layer 1, and the updated operating system.

[0251] Among them, the source program of system application 1 may not change. Since the order of compiling and / or linking the source program of system application 1 may change after the operating system is updated compared to the compilation and linking process before the operating system is updated, the content of the executable file generated after the system application 1 is statically linked with the updated operating system may change, and the storage location of the executable file may also change. To distinguish, the executable file F6 is used here to represent the executable file generated after the system application 1 is statically linked with the updated operating system.

[0252] After the operating system is updated, the storage address of the system function in the electronic device 100 may change. The system isolation layer indexes and calls the system function by obtaining the actual storage address of the system function during static linking. Therefore, the instructions of the system isolation layer 1 after static linking must be updated as the operating system is updated. Among them, the above-mentioned system isolation layer 1 is statically linked with the updated operating system, and the actual storage address of the system function 1 in the electronic device 100 after the operating system is updated can be obtained. For the sake of distinction, instruction 711 is used here to represent the instruction generated after the system isolation layer 1 is statically linked with the updated operating system. Instruction 711 of the system isolation layer 1 can be used to find and call the system function 1 according to the actual storage address of the system function 1 after the operating system is updated. The aforementioned Figure 5A The instruction 511 of the system isolation layer 1 shown can be used to find and call the system function 1 according to the actual storage address of the system function 1 before the operating system is updated.

[0253] It is understandable that when the system isolation layer 1 is statically linked with the updated operating system, the source program of the system isolation layer 1 may remain unchanged, and the instructions of the system isolation layer 1 after static linking may be changed. That is, when the operating system is updated, the component provider may not need to provide the binary difference isolation layer again.

[0254] In addition, although the instructions of the system isolation layer 1 after static linking are updated as the operating system is updated, the address where the instructions of the system isolation layer 1 are stored does not change. In other words, the fixed address used to encapsulate the system function 1 will not change with the system update. Therefore, the third-party component 1 can still find the instruction 711 of the system isolation layer 1 according to the fixed address used to encapsulate the system function 1, and use the system isolation layer 1 to call the system function 1 after the operating system is updated. The third-party component 1 can be linked without recompiling. The third-party component 2 can also be linked without recompiling. Component isolation layer 1 is used to encapsulate the third-party component 2. Since the third-party component 2 has not been updated, the component isolation layer 1 can be linked without recompiling.

[0255] It can be seen that before and after the above operating system is updated, the instructions of the system isolation layer 1 may change. Figure 5A The instruction 511 shown changes to Fig. 7A Instruction 711 shown. However, the instructions of the system isolation layer 1 are always stored in the same storage area before and after the operating system is updated. The above storage in the same storage area can mean storage in the storage area corresponding to the same address (i.e., the fixed address used to encapsulate system function 1). In the present application, the unchanged storage area of ​​information can mean that the storage address of the information on the memory (such as ROM, RAM, etc.) remains unchanged.

[0256] Figure 7B The diagram exemplarily shows a storage location diagram of a third-party component, a binary difference isolation layer, a system application, and an operating system in an electronic device 100.

[0257] like Figure 7B As shown, the memory of the electronic device 100 may include ROM, RAM, and Flash. The electronic device 100 may update the system application 1, the system isolation layer 1, and the operating system in the ROM. Exemplarily, the electronic device 100 may store the executable file F6 of the system application 1 in the storage area at the address Lm in the ROM, store the system function 1 in the storage area at the address Lr in the ROM, store the system function 2 in the storage area at the address Lr+1 in the ROM, and still store the instruction 711 of the system isolation layer 1 in the storage area at the address Ln in the ROM.

[0258] Compared with the above Figure 5B and Figure 7BIt can be seen that after the operating system of the electronic device 100 is updated, the executable file of the system application 1 can be changed from executable file F3 to executable file F6, and the storage address can be changed from address L1 to Lm. After the operating system is updated, the storage address of the system function 1 can be changed from address Lk to Lr. The fixed address used to encapsulate the system function 1 before and after the operating system is updated can remain unchanged (for example, still address Ln), and the fixed address used to encapsulate the third-party component 2 can also remain unchanged (for example, still Lq). Since the instructions of the system isolation layer 1 are changed after the operating system is updated, the electronic device 100 can update the content in the storage area corresponding to the address Ln. Figure 5B The instruction 511 of the system isolation layer 1 is updated to the instruction 711 of the system isolation layer 1. Since the instruction of the component isolation layer 1 remains unchanged after the operating system is updated, the electronic device 100 can keep the content in the storage area corresponding to the address Lq unchanged, that is, it is still the instruction 512 of the component isolation layer 1.

[0259] The storage contents in Flash and RAM can refer to the above Figure 5B Introduction.

[0260] When the system application 1 is running, it can call the component isolation layer 1 through the instruction 711 of the component isolation layer 1 in the address Lq, and then use the component isolation layer 1 to call the third-party component 2. It can be seen from the above embodiment that when the integrator statically links the system application 1, it can statically link the target file of the system application 1 into the executable file F6 according to the fixed address (i.e., address Lq) used to encapsulate the third-party component 2. That is, the executable file F6 contains the address Lq. When running the system application 1, the electronic device 100 can fetch instructions from the ROM on-chip, obtain and execute the executable file F6. The electronic device 100 can read the instruction 512 of the component isolation layer 1 according to the address Lq in the executable file F6 and call the component isolation layer 1. Since the component isolation layer 1 can obtain the actual storage address (i.e., address H2) of the third-party component 2 when statically linking, the electronic device 100 executes the instruction 512 of the component isolation layer 1 to call the third-party component 2.

[0261] When running, the third-party component 1 can call the system isolation layer 1 through the instruction 711 of the system isolation layer 1 in the address Ln, and then use the system isolation layer 1 to call the system function 1. It can be seen from the above embodiments that the executable file F1 of the third-party component 1 may contain the address Ln. When running the third-party component 1, the electronic device 100 can execute the executable file F1, read the instruction 711 of the system isolation layer 1 according to the address Ln in the executable file F1, and call the system isolation layer. Since the system isolation layer 1 can obtain the actual storage address of the system function 1 (i.e., the address Lr) during static linking, the electronic device 100 can execute the instruction 711 of the system isolation layer 1 to call the system function 1.

[0262] Understandably, Figure 7B The storage address division and storage content in the ROM shown are only exemplary descriptions of the present application and should not constitute limitations on the present application.

[0263] In some embodiments, when system applications such as system application 1 and the operating system are stored in two independent storage areas in ROM, when the operating system is updated, the system application does not need to be recompiled and linked. That is, the electronic device 100 does not need to re-burn the storage area where the system application 1 and other system applications are located. Among them, if the system application needs to call the system function after the operating system is updated, the system application can use the system isolation layer to call the system function. For details, please refer to the method of third-party component 1 calling system function 1 using system isolation layer 1.

[0264] It can be seen that when the operating system is updated, the updated operating system can be statically linked with the system isolation layer and then released to the electronic device 100. The system isolation layer can sense changes in the operating system and encapsulate the updated system functions of the operating system according to the changes. In this way, third-party components and / or system applications can still find the system isolation layer according to the fixed address, thereby calling the updated system functions of the operating system. Among them, the upper-layer components may not perceive the changes in the above-mentioned operating system. When the operating system is updated, the components may not need to be recompiled and linked. In this way, the operating system can be updated independently of the components, reducing the update cost of the system.

[0265] The following describes a method for implementing a binary difference isolation layer provided in an embodiment of the present application.

[0266] In a possible implementation, the binary difference isolation layer can use the "__attribute__" function of the C language to encapsulate the function. The "__attribute__" function can solidify the interface address for calling the function after the function is encapsulated. Regardless of whether the storage address of the function encapsulated by the binary difference isolation layer changes, the binary difference isolation layer can be stored in a fixed address.

[0267] Here, the system function (read function) for reading data is taken as an example to illustrate how to implement the system isolation layer.

[0268] The read function may include: int read(int fd, char*buf, size_tlen). When the component is running, it can call the read function to read the specified data by passing in the corresponding parameters in the read function. For example, the parameters that the component can pass in the read function may include the storage address of the data to be read. In this way, the component can call the read function to read the data in the above storage address.

[0269] The content of the system isolation layer used to encapsulate the read function may include: int__attribute__((section(".adaptor"),address(0x10000)))adaptor_read(int fd,char*buf,size_tlen).

[0270] Among them, "0x10000" may be a fixed address for encapsulating the read function. That is, after the system isolation layer is statically linked, the electronic device 100 may store the instructions of the system isolation layer in the storage area corresponding to the fixed address. In some embodiments, the above fixed address may be located in the ROM of the electronic device 100. The fixed address is only an exemplary description of the present application and should not constitute a limitation on the present application.

[0271] During the process of statically linking the system isolation layer with the operating system, the system isolation layer can obtain the actual storage address of the read function in the electronic device 100 .

[0272] Based on the fixed address used to encapsulate the read function, the component can call the read function in the following ways: int(0x10000)(int fd, char*buf, size_tlen). In other words, when developing a component, the component developer can write the above fixed address in the source program of the component, and use the fixed address to indicate that the component needs to apply the system function encapsulated by the fixed address. Among them, since the above fixed address is written in the source program of the component, after compilation and linking, the executable file of the component can include the above fixed address used to encapsulate the read function, so that the component can index to the system isolation layer based on the fixed address and use the system isolation layer to call the read function.

[0273] It can be seen that the system isolation layer is a computer program that is used to encapsulate system functions in a specified fixed address. After compilation and linking, the system isolation layer can be stored in the electronic device 100 for the component to call according to the fixed address during operation. The component can call the target system function by calling the system isolation layer.

[0274] The above-mentioned "__attribute__" function of C language is only one implementation method for encapsulating system functions and should not be construed as limiting the present application. The binary difference isolation layer can also be implemented by other methods of encapsulating functional functions.

[0275] The implementation of the component isolation layer can refer to the implementation of the system isolation layer, which will not be repeated here. The component isolation layer can be compiled and linked together with the third-party components it encapsulates to obtain the actual storage address of the third-party components it encapsulates in the electronic device 100.

[0276] Among them, since the actual storage address of the functional function encapsulated by the binary difference isolation layer may be located in ROM or RAM, the actual storage address of the functional function obtained by the binary difference isolation layer during the static linking process may include: the address in ROM and the address in RAM.

[0277] The embodiment of the present application does not limit the name of the binary difference isolation layer. For example, the binary difference isolation layer can also be called an isolation module, an isolation function, an isolation interface, etc. Other programs that can encapsulate the actual storage address of the target system function in a specified fixed address are all within the protection scope of this solution.

[0278] Figure 8 The schematic diagram of the architecture of a communication system 80 provided by the present application is exemplified.

[0279] like Figure 8 As shown, the communication system 80 may include an electronic device 100, a component and binary difference isolation layer publishing server 810, a component and binary difference isolation layer development environment 820, an integrator server 830, and an integrator development environment 840.

[0280] The electronic device 100 may be an electronic device using an MCU as a computing core. The structure of the electronic device 100 may refer to the description of the above embodiments.

[0281] The component and binary difference isolation layer publishing server 810 and the component and binary difference isolation layer development environment 820 may be the devices of the aforementioned component provider. The component and binary difference isolation layer development environment 820 may include one or more devices used by the developers of the component provider to develop third-party components and binary difference isolation layers. In some embodiments, the component and binary difference isolation layer development environment 820 or the component and binary difference isolation layer publishing server 810 may compile the source file and the binary difference isolation layer of the third-party component to obtain the target file of the third-party component and the target file of the binary difference isolation layer.

[0282] The component and binary difference isolation layer development environment 820 can upload the developed third-party component and binary difference isolation layer to the component and binary difference isolation layer publishing server 810. For example, the component and binary difference isolation layer development environment 820 can upload the source file and / or target file of the third-party component to the component and binary difference isolation layer publishing server 810, and upload the source file of the binary difference isolation layer to the component and binary difference isolation layer publishing server 810.

[0283] The component and binary difference isolation layer publishing server 810 may send the target file of the third-party component and the target file of the binary difference isolation layer to the integrator server 830 .

[0284] The integrator server 830 and the integrator development environment 840 may be the aforementioned integrator's equipment. The integrator may also be referred to as a device provider or the like. The integrator development environment 840 may include one or more devices used by the integrator's developers to develop an operating system and implement the design of the electronic device 100. The integrator development environment 840 may upload the developed operating system to the integrator server 830. In some embodiments, the integrator's developers may also develop system applications. The integrator development environment 840 may upload the developed system applications to the integrator server 830.

[0285] When receiving the operating system, the integrator server 830 may compile the operating system. Alternatively, the integrator development environment 840 may compile the operating system and upload the compiled operating system to the integrator server 830.

[0286] The integrator server 830 can statically link the compiled operating system, compiled components (such as third-party components, system applications, etc.) and the binary difference isolation layer, and publish them to the electronic device 100. The specific process can refer to the introduction of the above embodiment.

[0287] In some embodiments, the component and binary difference isolation layer development environment 820 can upload the updated third-party component to the component and binary difference isolation layer publishing server 810. The component and binary difference isolation layer publishing server 810 can send the target file of the updated third-party component to the integrator server 830. Then, the integrator server 830 can statically link the updated third-party component and publish it to the electronic device 100. In some embodiments, the integrator server 830 can statically link the updated third-party component and the component isolation layer for encapsulating the updated third-party component, and then publish it to the electronic device 100.

[0288] In some embodiments, the integrator development environment 840 may upload the updated operating system to the integrator server 830. The integrator server 830 may statically link the system isolation layer and the updated operating system together and publish them to the electronic device 100.

[0289] It can be seen from the above communication system 80 that in the scenario where components and operating systems are fully statically linked on the MCU device, the static linking method provided by the present application can isolate the dependency of components on the actual storage address of system functions through the system isolation layer, and the component isolation layer can isolate the dependency of system applications on the actual storage address of third-party components. The above method can achieve the decoupling of components and operating systems. Both components and operating systems can be updated independently. This can effectively reduce the update cost of components and the update cost of the operating system.

[0290] It is understandable that the various user interfaces described in the embodiments of the present application are only example interfaces and do not limit the present application scheme. In other embodiments, the user interface may adopt a different interface layout, may include more or fewer controls, and may increase or decrease other functional options, as long as they are based on the same inventive concept provided by the present application, they are all within the scope of protection of the present application.

[0291] It should be noted that, without causing any contradiction or conflict, any feature in any embodiment of the present application, or any part of any feature, can be combined, and the combined technical solution is also within the scope of the embodiments of the present application.

[0292] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A static linking method, characterized in that: The method is applied to an electronic device, the electronic device includes a first operating system, a first storage area corresponding to a first address in the electronic device stores a first calling instruction, the first calling instruction is used to call a first system function provided by the first operating system, and the method includes: The electronic device updates the first operating system, and the first operating system is updated in a static link manner; The electronic device updates the first calling instruction in the first storage area to a second calling instruction, where the second calling instruction is used to call the first system function provided by the updated first operating system; The electronic device runs a first component on the updated first operating system, obtains the second calling instruction from the first storage area according to the first address, and executes the second calling instruction for the first component to call the first system function.

2. The method according to claim 1, characterized in that The method further comprises: When the electronic device runs the first component on the first operating system before updating, it obtains the first calling instruction from the first storage area according to the first address, and executes the first calling instruction for the first component to call the first system function.

3. The method according to claim 1 or 2, characterized in that: The first calling instruction includes a storage address of the first system function in the electronic device before the first operating system is updated, and the second calling instruction includes a storage address of the first system function in the electronic device after the first operating system is updated.

4. The method according to any one of claims 1 to 3, characterized in that Before and after the first operating system is updated, the first component stored in the electronic device remains unchanged.

5. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: The electronic device updates the first component, the updated first component still needs to call the first system function, and the first component is updated in a static link manner; The electronic device runs the updated first component on the first operating system before updating, obtains the first calling instruction from the first storage area according to the first address, and executes the first calling instruction for the updated first component to call the first system function.

6. The method according to claim 5, characterized in that A second storage area corresponding to a second address in the electronic device stores a third calling instruction, a second system function provided by the first operating system before the third calling instruction is updated, and the first component after the update also needs to call the second system function, and the method further includes: The electronic device runs the updated first component in the first operating system before updating, obtains the third calling instruction from the second storage area according to the second address, and executes the first calling instruction for the updated first component to call the second system function.

7. The method according to any one of claims 1 to 6, characterized in that The electronic device further includes a second component and a third component, the second component is a third-party component, the third component is a system application, the third component needs to call the second component, a third storage area corresponding to a third address in the electronic device stores a fourth calling instruction, and the fourth calling instruction is used to call the second component, and the method further includes: The electronic device updates the second component, and the second component is updated in a static link manner; The electronic device updates the fourth calling instruction in the third storage area to a fifth calling instruction, where the fifth calling instruction is used to call the updated second component; The electronic device runs the third component after updating the second component, obtains the fifth calling instruction from the third storage area according to the third address, and executes the fifth calling instruction for the third component to call the second component.

8. The method according to claim 7, characterized in that The method further comprises: The electronic device runs the third component before the second component, obtains the fourth calling instruction from the third storage area according to the third address, and executes the fourth calling instruction for the third component to call the second component.

9. The method according to claim 7 or 8, characterized in that: The fourth calling instruction includes a storage address of the second component in the electronic device before updating, and the fifth calling instruction includes a storage address of the second component in the electronic device after updating.

10. The method according to any one of claims 7 to 9, characterized in that: Before and after the second component is updated, the third component and the first operating system stored in the electronic device remain unchanged.

11. The method according to any one of claims 1 to 10, characterized in that The update content of the first operating system includes one or more of the following: a change in the storage address of the first system function, a change in the content of the first system function.

12. The method according to any one of claims 1 to 11, characterized in that The first storage area is a storage area on a ROM in the electronic device.

13. The method according to claims 1-12, characterized in that The first component is a third-party component.

14. An electronic device, characterized in that: The electronic device comprises a memory and a processor, wherein the memory is used to store a computer program; and the processor is used to call the computer program so that the electronic device executes the method according to any one of claims 1 to 13.

15. An electronic device, the electronic device being a first electronic device, characterized in that: The first electronic device includes a component providing module and a calling interface providing module, wherein: The component providing module is used to provide a first component, the first component needs to call a first system function provided by a first operating system, and the first component is published to a second electronic device including the first operating system after being statically linked; The calling interface providing module is used to provide a first interface, and the first interface is used to encapsulate the first system function in a first storage area corresponding to a first address in the second electronic device, and the first interface is published to the second electronic device after static linking; the first address is included in the program used to implement the first component.

16. The electronic device according to claim 15, characterized in that: The first interface obtains the storage address of the first system function in the second electronic device during the static linking stage, and generates a calling instruction for calling the first system function after the static linking.

17. The electronic device according to claim 15 or 16, characterized in that: The component providing module is further used to provide a second component, the second component is called by a third component in the second electronic device, and the second component is published to the second electronic device after being statically linked; The calling interface providing module is further used to provide a second interface, where the second interface is used to encapsulate the second component in a third storage area corresponding to a third address in the second electronic device, and the second interface is published to the second electronic device after static linking.

18. The electronic device according to claim 17, characterized in that: The second interface obtains the storage address of the second component in the second electronic device during the static linking stage, and generates a calling instruction for calling the second component after the static linking.

19. The electronic device according to claim 17 or 18, characterized in that: The component providing module is also used to provide the updated second component, and the updated second component is published to the second electronic device after static linking; wherein, the second interface obtains the storage address of the updated second component in the second electronic device during the static linking stage, and generates a calling instruction for calling the updated second component after static linking.

20. A computer-readable storage medium comprising instructions, characterized in that: When the instructions are executed on an electronic device, the electronic device executes the method according to any one of claims 1 to 13.

21. A computer program product, characterized in that The computer program product comprises computer instructions, and when the computer instructions are run on an electronic device, the electronic device executes the method according to any one of claims 1 to 13.

Citation Information

Cited By

  • Static linking method and related apparatus

    EP4708033A1

  • Static linking method and related apparatus

    WO2025007828A1