Binary loadable file generation method and device, equipment and medium

By converting binary intermediate files into binary loadable files that utilize external function link information, the problem of low loading efficiency of the WebAssembly module on resource-constrained devices is solved, and more efficient download and execution is achieved.

CN119127210APending Publication Date: 2024-12-13BEIJING CEC HUADA ELECTRONIC DESIGN CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411198402.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-29
Publication Date
2024-12-13

AI Technical Summary

Technical Problem

In the prior art, binary intermediate files occupy a large storage capacity, resulting in low loading efficiency of the WebAssembly module on resource-constrained devices, and timely compilation cannot be completed on small devices such as smart cards and security components.

Method used

By obtaining the compiled binary intermediate file and binary link file of the program source code, converting it into a binary loadable file, using the binary link file to provide external function link information, and generating a binary loadable file smaller than the original intermediate file.

Benefits of technology

Improve the download and execution efficiency of WebAssembly module in resource-constrained devices and reduce the resource consumption of the device.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119127210A_ABST
    Figure CN119127210A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a binary loadable file generation method and device, equipment and a medium. The binary loadable file generation method comprises the steps that a binary intermediate file generated after a program source code is compiled and a binary link file of a module imported into the binary intermediate file are obtained; converting the binary intermediate file into a binary loadable file according to the binary link file; wherein the binary loadable file comprises a first segment, a function segment, a global segment and a code segment. According to the technical scheme provided by the embodiment of the invention, the downloading and execution efficiency of the WebAssessment module in the resource-constrained equipment can be improved, and the resource consumption of the equipment is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a method, apparatus, device and medium for generating a binary loadable file. Background Art

[0002] As a bytecode format, WebAssembly is designed to run on various platforms. It can also serve as a common compilation target for various high-level languages ​​​​(such as Rust, C++, C), and exhibits better runtime performance than other general-purpose languages ​​​​. The bytecode can be written once and run everywhere.

[0003] The binary intermediate file is directly loaded into the memory of the device. During the loading process, in the prior art, the storage capacity occupied by the binary intermediate file is relatively large. The existing source code compilation method seriously reduces the program loading efficiency. In addition, timely compilation is performed on resource-constrained devices to speed up execution. This method requires additional resource support to complete. For smaller devices such as smart cards and secure elements (SE), it is impossible to support the completion of the compilation. Summary of the invention

[0004] The embodiments of the present application provide a binary loadable file generation method, apparatus, device and medium, which can improve the download and execution efficiency of WebAssembly modules in resource-constrained devices and reduce the resource consumption of the devices.

[0005] According to one aspect of an embodiment of the present application, a method for generating a binary loadable file is provided, the method comprising:

[0006] Obtain a binary intermediate file generated after compiling the program source code, and a binary link file of the module imported by the binary intermediate file;

[0007] According to the binary link file, converting the binary intermediate file into a binary loadable file;

[0008] The binary loadable file includes: a header segment, a function segment, a global segment and a code segment.

[0009] According to another aspect of an embodiment of the present application, a binary loadable file generation device is provided, the device comprising:

[0010] An input file acquisition module is used to acquire a binary intermediate file generated after compiling the program source code, and a binary link file of a module imported by the binary intermediate file;

[0011] A file generation module, used for converting the binary intermediate file into a binary loadable file according to the binary link file;

[0012] The binary loadable file includes: a header segment, a function segment, a global segment and a code segment.

[0013] According to another aspect of an embodiment of the present application, an electronic device is provided, the electronic device comprising:

[0014] at least one processor; and

[0015] a memory communicatively connected to the at least one processor; wherein,

[0016] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the binary loadable file generation method described in any embodiment of the present application.

[0017] According to another aspect of an embodiment of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the binary loadable file generation method described in any embodiment of the present application when executed.

[0018] The technical solution provided by the embodiment of the present application is a technical means for converting the binary intermediate file into a binary loadable file according to the binary link file by obtaining a binary intermediate file generated after compiling the program source code and a binary link file of the module imported by the binary intermediate file. Since the binary link file is used to provide external function link information of the binary intermediate file, compared with the standard binary intermediate file in the prior art, when executing on the device, if accessing external functions and variables, it is necessary to find a matching module name, function name or variable name for positioning, the embodiment of the present application only needs to obtain the external function link information of the binary intermediate file according to the binary link file outside the device, and generate a binary loadable file smaller than the binary intermediate file according to the external function link information, thereby improving the download and execution efficiency of the WebAssembly module in resource-constrained devices and reducing the resource consumption of the device.

[0019] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the embodiments of the present application. Other features of the embodiments of the present application will become easy to understand through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0021] Figure 1a is a flowchart of a binary loadable file generation method provided according to an embodiment of the present application;

[0022] Figure 1b It is a conversion diagram of a binary intermediate file provided according to an embodiment of the present application;

[0023] Figure 2 is a flowchart of another binary loadable file generation method provided according to an embodiment of the present application;

[0024] Figure 3 It is a structural schematic diagram of a binary loadable file generating device provided according to an embodiment of the present application;

[0025] Figure 4 It is a structural schematic diagram of an electronic device that implements the binary loadable file generation method of an embodiment of the present application. DETAILED DESCRIPTION

[0026] In order to enable those skilled in the art to better understand the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this application.

[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the embodiments of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0028] Figure 1aThis is a flowchart of a binary loadable file generation method provided in an embodiment of the present application. This embodiment is applicable to the case of converting a binary intermediate file to generate a binary loadable file. The method can be executed by a binary loadable file generation device. The binary loadable file generation device can be implemented in the form of hardware and / or software. The binary loadable file generation device can be configured in an electronic device. Figure 1a As shown, the method includes:

[0029] Step 110: Obtain a binary intermediate file generated after compiling the program source code, and a binary link file of the module imported by the binary intermediate file.

[0030] In this embodiment, the program source code can be a code written in an application programming language (such as C language). After the program source code is compiled into standard WebAssembly bytecode, a binary intermediate file .wasm is generated. During the compilation process, function signatures, functions, tables, memories, global variables, local variables, and jump labels (each element item) generate their own indexes.

[0031] The binary intermediate file may include the following 12 segments: user-defined segment, type segment, import segment, function segment, table segment, memory segment, global segment, export segment, start segment, element segment, code segment and data segment.

[0032] Among them, the custom segment is used to store custom information; the type segment is used to list all function types (also called function signatures, or function prototypes) used by the binary intermediate file module; the import segment is used to list all import items of the module, and multiple modules can be linked together through import and export items; the function segment is used to store partial function information, list the corresponding type indexes of all functions in the module, and the type segment is indexed in the function segment to identify its own parameter and return value type; the table segment is used to list all tables defined in the module; the memory segment is used to list all memories defined in the module, and the memory segment is 64K as 1 unit, and the content is the number of units; the global segment is used to list all global variable information defined in the module; the export segment is used to list all export items of the module, and multiple modules can be linked together through import and export items; the starting segment is used to list the starting function index of the module; the element segment is used to list table initialization data; the code segment is used to store partial function information, store local variable information and bytecode of functions in the module, and the number of items stored in the function segment and the code segment is consistent and one-to-one corresponding; the data segment is used to list memory initialization data.

[0033] In this embodiment, the binary intermediate file and the binary link file of the module imported by the binary intermediate file can be input into the application converter (i.e., the conversion device). The binary link file is used to provide the application converter with the external function link information of the converted binary intermediate file.

[0034] Step 120: Convert the binary intermediate file into a binary loadable file according to the binary link file.

[0035] In this embodiment, the conversion device can complete the card link for the binary intermediate file according to the binary link file, and output a smaller binary loadable file. The binary link file and the binary loadable file have the same version number. Specifically, the .link file represents the binary link file, and the .sef file represents the binary loadable file.

[0036] In one implementation of this embodiment, the module types corresponding to the binary loadable file include library modules and application modules.

[0037] In this embodiment, taking the library module as an example, Figure 1b It can be a conversion diagram of a binary intermediate file in this embodiment, such as Figure 1b As shown, the binary intermediate file of the library module (lib.wasm) and the binary link file of the called system API module (cuos.link) are used as input, and the conversion device converts and outputs the binary loadable file (lib.sef) of the library module and the binary link file (lib.link) corresponding to the library module. Among them, the binary link file corresponding to the library module is used to call the application module of the library module to perform off-card link conversion to generate a binary loadable file.

[0038] In this embodiment, the binary loadable file may include: a first segment, a function segment, a global segment, and a code segment. The first segment is a header segment or a configuration segment, which is used to store the module's space and configuration information; the function segment lists the corresponding parameter information, local variable information, and virtual machine stack of all functions in the module; the global segment stores the address allocation and space information of various variables defined in the module; and the code segment stores the local variable information and bytecode of the function.

[0039] The technical solution provided by the embodiment of the present application is a technical means for converting the binary intermediate file into a binary loadable file according to the binary link file by obtaining a binary intermediate file generated after compiling the program source code and a binary link file of the module imported by the binary intermediate file. Since the binary link file is used to provide external function link information of the binary intermediate file, compared with the standard binary intermediate file in the prior art, when executing on the device, if accessing external functions and variables, it is necessary to find a matching module name, function name or variable name for positioning, the embodiment of the present application only needs to obtain the external function link information of the binary intermediate file according to the binary link file outside the device, and generate a binary loadable file smaller than the binary intermediate file according to the external function link information, thereby improving the download and execution efficiency of the WebAssembly module in resource-constrained devices and reducing the resource consumption of the device.

[0040] Figure 2 A flowchart of another binary loadable file generation method provided in an embodiment of the present application, such as Figure 2 As shown, the method includes:

[0041] Step 210: Obtain a binary intermediate file generated after compiling the program source code, and a binary link file of the module imported by the binary intermediate file.

[0042] Step 220: Convert the binary intermediate file into a binary loadable file according to the binary link file.

[0043] In this embodiment, the binary loadable file also includes at least one of the following: an import segment, an application segment, an export segment, an element segment, a data segment, and a custom segment. Among them, the import segment lists all the import items of the module; the export segment lists all the export items of the module, and multiple modules can be linked together through import and export items; the application segment contains information that can be registered as an application module in the module, and each group of information contains application identification AID and application installation and interface registration method ID information; the element segment stores the function index of the function called through the function pointer; the data segment lists read-only data and memory initialization data; the custom segment can store custom information.

[0044] The binary loadable file encoding starts with a 4-byte magic number and a 4-byte version number. The magic number is 0x00736566 and the version number is 0x01000000. After the magic number and version number are some segments. Each module has the following unified format:

[0045] sef{

[0046] u32 magic

[0047] u32 version

[0048] section sections[]

[0049] }

[0050] There are 10 types of segments in a binary loadable file, and each segment is assigned an ID. Each segment that appears in a binary loadable file has the following unified format:

[0051] section{

[0052] u8 sect ion_id

[0053] u32 size

[0054] u8 contents[]

[0055] }

[0056] Each segment begins with a 1-byte section_id that identifies the entire segment type. The size item indicates the number of bytes in the contents array of the segment, excluding the section_id and size items. The content and format of the contents array vary with the segment type. Specifically, the segment ID allocation and valid section_id in the binary loadable file are listed in Table 1:

[0057] Table 1

[0058]

[0059]

[0060] In a specific embodiment, the custom segment stores custom data, which may include debugging information such as function names and local variable names and third-party extension information. The custom segment includes at least one of the following: custom segment ID, custom data, and the number of bytes of custom data. The items in the segment structure are as follows:

[0061]

[0062] Among them, the section_id value is 0; size indicates the number of bytes in the custom_section structure, excluding the section_id and size items; contents indicates the data in the custom section.

[0063] The header includes at least one of the following: header ID, header length, module information, binary loadable file length, configuration field, number of imported modules, number of imported functions, function segment space size, application segment space size, element segment space size, data segment space size, and code segment space size. The module information includes at least one of the following: module version information, module identifier AID, and module AID length. The items in the header structure are as follows:

[0064]

[0065]

[0066] Among them, the section_id value is 0x0D; segSize indicates the length of the first segment; module_Info indicates module information; module_version indicates the module version; module_aid_size indicates the module AID length; mudule_aid[module_aid_size] indicates the module AID; SEFLen indicates the binary loadable file length; SefConfig indicates the Sef configuration field, which is reserved.

[0067] Specifically, to maintain compatibility, the following fields are reserved and users can choose to process them:

[0068] import_module_count indicates the number of imported modules (the lower 4 bits are valid, the upper 4 bits are RFU); import_function_count indicates the number of imported functions; segFuncLen indicates the size of the function segment space, which is equal to the function segment size; segAppLen indicates the size of the application segment space, which is equal to the application segment size; segElemLen indicates the size of the element segment space, which is equal to the element segment size; segDataLen indicates the size of the data segment space, which is equal to the data segment size; segCodeLen indicates the size of the code segment space, which is equal to the code segment size.

[0069] The import segment includes at least one of the following: the import segment ID, the number of bytes of all information in the import segment, the number of imported modules, the number of imported functions, the imported module information array, and the imported function information array. The imported module information array includes at least one of the following: the imported module version, the imported module AID, and the imported module AID length; the imported function information array includes at least one of the following: the index of the module where the imported function is located in the imported module information array, and the index of the imported function in the imported module. The items in the import segment structure are as follows:

[0070]

[0071]

[0072] Among them, the value of section_id is 2; size indicates the number of bytes in the import_section structure, excluding the section_id and size items; import_module_count indicates the number of modules imported in the module; import_module_items indicates the detailed information of the imported modules; version indicates the imported module version; module_aid_size indicates the length of the imported module AID; module_aid indicates the imported module AID; import_function_count indicates the number of imported functions. import_function_items indicates the detailed information of the imported functions.

[0073] Specifically, the high 4 bits of import_moduleidx_funcidx represent the index of the module where the imported function is located in import_module_items, and the low 12 bits of import_funcidx represent the index of the imported function in the imported module.

[0074] The function segment lists the function related information in the module, excluding imported functions. The function segment includes at least one of the following: function segment ID, the number of bytes in the function segment, and the number of code bytes corresponding to a function. The items in the function segment structure are as follows:

[0075]

[0076] Among them, the section_id value is 3; size represents the number of bytes in the function_section structure, excluding the section_id and size items; code_size represents the number of code bytes corresponding to a function.

[0077] The application segment includes at least one of the following: application segment ID, number of bytes in the application segment, number of registrable application module information groups, and application module information groups. The application module information group includes at least one of the following: application module AID, length of application module AID content in this group of information, and entry function information for application module installation and interface registration. The items in the application segment structure are as follows:

[0078]

[0079]

[0080] Among them, the section_id value is 14; size indicates the number of bytes of the App_section structure, excluding the section_id and size items; AppNum indicates the number of registrable application module information groups, and its value must be greater than 0; AIDLen indicates the length of the AppAID content in this group of information; AppAID[] is used to distinguish the installable application module identifiers; AppBuilderMethodID: used to indicate the entry function information for application module installation and interface registration.

[0081] The global segment includes at least one of the following: global segment ID, number of bytes in the global segment, module read-only data start address, module global variable start address, reserved field, global variable end address. The items in the global segment structure are as follows:

[0082] global_section{

[0083] u8 section_id

[0084] u32 size

[0085] u16 rodata_base

[0086] u16 rwdata_base

[0087] u16 RFU_1

[0088] u16 RFU_2

[0089] u16 data_end

[0090] }

[0091] Among them, the section_id value is 6; size indicates the number of bytes in the global_section structure, excluding the section_id and size items; rodata_base indicates the starting address of the module's read-only data; the module's read-only data size rodataSize is rwdata_base-rodata_base; rwdata_base indicates the starting address of the module's global variables; the module's global variable space size is RFU_1-rwdata_base; RFU_1 is a reserved field; RFU_2 is a reserved field; data_end indicates the end address of the global variables.

[0092] The export segment includes at least one of the following items: the export segment ID, the number of bytes in the export segment, and the function index corresponding to each export function. The items in the export segment structure are as follows:

[0093]

[0094] Among them, the section_id value is 7; size represents the number of bytes in the export_section structure, excluding the section_id and size items; function_idxs lists the function indexes of each exported function.

[0095] The element segment stores the function index of the function called by the function pointer, and the element segment includes at least one of the following items: the element segment ID, the number of bytes in the element segment, and the function index of the function called by the function pointer. The items in the element segment structure are as follows:

[0096] elem_section{

[0097] u8 section_id

[0098] u32 size

[0099] u16 function_idx[size / 2]

[0100] }

[0101] Among them, the section_id value is 9; size represents the number of bytes in the elem_section structure, excluding the section_id and size items; function_idx lists the function index.

[0102] The code segment includes at least one of the following: code segment ID, number of bytes in the code segment, all function information defined in the module content, and bytecodes of all functions defined in the module. All function information defined in the module content includes at least one of the following: function code flag, number of parameters, number of local variables, number of units of the maximum stack frame of the function, and number of units of the indirect access variable stack used by the function. The items in the code segment structure are as follows:

[0103]

[0104]

[0105] Among them, the section_id value is 0x0A; size indicates the number of bytes in the code_section structure, excluding the section_id and size items; CodeInfo lists all function information defined in the module content; the highest bit of headconfig_paraNum defaults to 1, and the lower 7 bits of paraNum indicate the number of parameters; localNum indicates the number of local variables; max_cell_stack indicates the number of cells of the maximum stack frame of the function, one unit is 4 bytes; stackBlockNum indicates the number of cells used by the function to indirectly access the variable stack, one unit is 16 bytes; ByteCode lists the bytecodes of all functions defined in the module.

[0106] The data segment includes at least one of the following: data segment ID, number of bytes in the data segment, module read-only data space size, module global data space size with initial value, reserved field length, module read-only data, module global data initial value not equal to 0, and reserved field. The items in the data segment structure are as follows:

[0107] data_section{

[0108] u8 section_id

[0109] u32 size

[0110] u16 rodata_size

[0111] u16 rwdata_init_size

[0112] u16 RFU_size

[0113] u8 rodata[rodata_size]

[0114] u8 rwdata[rwdata_init_size]

[0115] u8 RFU[RFU_size]

[0116] }

[0117] Among them, the section_id value is 0x0B; size indicates the number of bytes in the data_section structure, excluding the section_id and size items; rodata_size indicates the size of the module's read-only data space; rwdata_init_size indicates the size of the module's global data space with initial values; RFU_size indicates the reserved field length; rodata lists the module's read-only data; rwdata lists the module's global data initial value, and is not 0; RFU is a reserved field.

[0118] In one implementation of the present embodiment, the binary intermediate file is converted into a binary loadable file, including: deleting the type segment in the binary intermediate file; deleting the type information of the function segment in the binary intermediate file and generating the function code size; generating a function index corresponding to the function segment in the binary intermediate file, replacing the function information in the export segment with the function index, and updating the size of the export segment.

[0119] In a specific embodiment, the function type can be obtained from the type segment according to the type index information of the function segment and the export segment in the binary intermediate file, the correctness of the function type in the type segment can be checked, and then the type segment can be deleted to generate the index function_idx for all functions in the function segment in the file. The index start code is the number of export segment functions, the index length is 2 bytes, the index increases in sequence starting from the start code, and a mapping relationship between the function name and the function index is established. The type information in the function segment of the binary intermediate file is deleted and replaced with the size code_size of each function code, and the function segment function_section of the binary loadable file is output. After the code segment is converted, the size of each function in the executable file finally output is obtained, and the size code_size of each function in the function segment is updated accordingly. The information of each function in the export segment is converted into the function index function_idx, and the size of the export segment is updated. According to the function name of the export segment of the binary intermediate file, the index function_idx of each function in the export segment is obtained through the mapping relationship between the function name and the function index established above, and the export segment of the binary loadable file is generated accordingly.

[0120] In another implementation of the present embodiment, the binary intermediate file is converted into a binary loadable file, including: obtaining corresponding module AID information in the binary link file according to the import function information of the binary link file and the binary intermediate file; obtaining corresponding function index in the binary link file according to the import function name in the binary intermediate file; generating import module information corresponding to the import segment in the binary loadable file according to the corresponding module AID information in the binary link file, organizing all import module information, and generating an import module information array of the import segment in the binary loadable file; generating the number of import modules of the import segment in the binary loadable file according to the number of import modules in the binary link file; optimizing (e.g., replacing) the function information in the binary intermediate file according to the module index in the binary intermediate file obtained and the function index obtained in the binary link file, and obtaining the import function information array of the import segment in the binary loadable file.

[0121] In a specific embodiment, the conversion device performs import function linking from the binary intermediate file according to the module name and the function name: searches for the import function information (module name and function name) of the input binary link file and the binary intermediate file, and obtains the mudule_aid information recorded in the binary link file; searches for the matching function name and function index function_id from the binary link file according to the function name of the import function in the binary intermediate file; generates the import_module_count data segment of the import segment according to the number of modules imported by the import segment; arranges all the import modules in sequence according to the AIDs of all the import modules, assigns indexes to all the imported modules, organizes the AID information of all the import modules, and generates the module_aid_size and mudule_aid data in the import_function_items item of the import segment; uses the assigned module index and the found function index to replace the function information in the binary intermediate file, generates the import_module_idx and import_function_idx information in the import_function_items item, and finally generates the export segment of the binary loadable file.

[0122] In another implementation of this embodiment, converting the binary intermediate file into a binary loadable file includes: deleting a memory segment and / or a table segment in the binary intermediate file.

[0123] In another implementation of the present embodiment, the binary intermediate file is converted into a binary loadable file, including: deleting the variable information of the global segment in the binary intermediate file, generating the module read-only data starting address of the global segment in the binary loadable file according to the global variable starting address of the global segment in the binary intermediate file; generating the global variable ending address of the global segment in the binary loadable file according to the global variable ending address of the global segment in the binary intermediate file; generating the module global variable starting address of the global segment in the binary loadable file according to the read-only data information corresponding to the data segment and the custom segment in the binary intermediate file.

[0124] In a specific embodiment, the information of each variable in the global segment, as well as the information of the memory and table segments can be deleted, and the rodata_base information of the global segment of the binary loadable file can be generated according to the global_base value in the global segment of the binary intermediate file; the data_end information of the global segment of the binary loadable file can be generated according to the data_end value in the global segment of the binary intermediate file; and the rwata_base information of the global segment of the binary loadable file can be generated according to the <.rodata> attribute in the data segment and the custom segment of the binary intermediate file.

[0125] In another implementation of the present embodiment, the binary intermediate file is converted into a binary loadable file, including: generating module read-only data of the data segment in the binary loadable file and a module global data initial value that is not 0, respectively, based on the read-only data information, global variable information and custom module information of the data segment and the custom segment in the binary intermediate file.

[0126] In a specific embodiment, the binary intermediate file data segment and the custom segment <.rodata>, <.data>,<MOD_SGE> Attributes, respectively generate rodata, rwdata and moddata information of the binary loadable file data segment.

[0127] In another implementation of this embodiment, the binary intermediate file is converted into a binary loadable file, including: obtaining the table index and table offset information of the element segment in the binary intermediate file; and generating a function index corresponding to the element segment in the binary loadable file based on the table index and table offset information.

[0128] In another implementation of the present embodiment, the binary intermediate file is converted into a binary loadable file, including: obtaining the application module AID and the function name of the installation and interface registration function according to the conversion parameter configuration file; obtaining the corresponding function index and the entry function information of the application module installation and interface registration corresponding to the binary loadable file according to the installation and interface registration function name; outputting the application module AID and the entry function information of the application module installation and interface registration as an application module information group to the application segment in the binary loadable file, and generating the number of registrable application module information groups in the application segment according to the number of application execution modules; wherein the application segment in the binary loadable file includes one or more application module information groups.

[0129] In another implementation of the present embodiment, the binary intermediate file is converted into a binary loadable file, including: determining the number of parameters and the number of local variables corresponding to the binary loadable file according to the number of local variables and the number of parameters in the binary intermediate file; simulating the execution of the function code in the binary intermediate file, calculating the maximum number of units of the operand stack space during the execution process, and generating the maximum number of units of the stack frame of the function corresponding to the binary loadable file; generating the number of units of the indirect access variable stack used by the function corresponding to the binary loadable file according to the bytecode of the operation allocation indirect access variable stack space in the function code of the binary intermediate file; determining the function code flag of the code segment in the binary loadable file according to the number of parameters, the number of local variables, the number of units of the maximum stack frame of the function, and the number of units of the indirect access variable stack used by the function.

[0130] In another implementation of this embodiment, the binary intermediate file is converted into a binary loadable file, including: generating a first segment in the binary loadable file based on an import segment, a function segment, an application segment, an element segment, a data segment, and a code segment in the binary loadable file.

[0131] In a specific embodiment, according to the conversion parameter configuration file, the AID of the binary loadable file is obtained, and the module AID length and the module AID are generated; the number of imported modules in the import segment of the binary loadable file is obtained, and import_module_count is generated; the number of imported functions in the import segment is obtained, and import_function_count is generated; the size information of the generated function segment is obtained, and the first segment segFuncLen is generated; the size of the generated application segment is obtained, and the first segment segAppLen is generated; the size of the generated element segment is obtained, and the first segment segElemLen is generated; the size of the generated data segment is obtained, and the first segment segDataLen is generated; the size of the generated code segment is obtained, and the first segment segCodeLen is generated.

[0132] In a specific embodiment, converting the binary intermediate file to a binary loadable file includes: generating version information corresponding to the binary loadable file according to the version information in the conversion parameter configuration file. Converting the binary intermediate file to a binary loadable file according to the binary link file includes: checking whether the version information corresponding to the binary intermediate file and the binary link file are consistent; if so, converting the binary intermediate file to a binary loadable file according to the binary intermediate file and the binary link file.

[0133] Among them, checking whether the version information corresponding to the binary intermediate file is consistent with that of the binary link file includes: checking whether the major version information corresponding to the binary intermediate file is the same as the major version information corresponding to the binary link file; if so, checking whether the minor version information corresponding to the binary intermediate file is not lower than the minor version information corresponding to the binary link file; if so, determining that the version information corresponding to the binary intermediate file is consistent with that of the binary link file.

[0134] Step 230: In response to the download command stream, download the binary loadable file to the resource-constrained device to obtain a binary executable file.

[0135] In this step, specifically, the first segment, import segment, function segment, application segment, global segment, export segment, element segment, code segment, and data segment in the binary loadable file can be downloaded to the resource-constrained device in sequence according to a preset download order.

[0136] In this embodiment, the first segment will be downloaded first, so import_module_count, import_function_count, segFuncLen, segAppLen, segElemLen, segDataLen, and segCodeLen in the first segment can be used as the space information required for other subsequent segments, and storage space is pre-allocated for each segment when the first segment is downloaded.

[0137] In one implementation of the present embodiment, downloading the import segment in the binary loadable file to the resource-constrained device includes: directly storing the import segment code in the corresponding storage space; or parsing the module AID imported in the import segment; and / or, according to the index of the module where the import function is located in the imported module information array in the import segment, querying the module AID corresponding to the index from the imported module information array, and parsing the module AID; and / or, parsing the index of the module where the import function is located in the imported module information array, after obtaining the import module identifier, locating the import module from the module registration information according to the index of the import function in the import module, querying the export segment information corresponding to the import module, and checking the legitimacy of the index of the import function in the import module according to the export segment information; and / or, obtaining the function address of the import module, and optimizing the function information of the import module to the function address.

[0138] In a specific embodiment, when downloading the import segment, the import segment code can be directly stored in the storage space of the import segment; mudule_aid can also be preliminarily linked, and the linking process is to parse the import module mudule_aid information into a simpler module representation, such as a module identifier. The mudule_aid of each module will be managed by the operating system, and the module identifier and module AID can be used on the device to uniquely identify each module; import_module_idx can also be preliminarily linked, and the linking process is to find the mudule_aid corresponding to the index value from the import_module_items array according to the import_module_idx information, so as to further parse and obtain the import module identifier. The mudule_aid of each import module will be managed by the operating system, and the module identifier and module AID can be used on the device to uniquely identify each module; import_function_idx can also be preliminarily linked, and the linking process is to parse the import_module_idx to obtain the import module identifier, and then find the export segment information of the imported module according to the import_function_idx information, check whether the import_function_idx index is legal, and if the imported module is a system module, the function address can also be obtained.

[0139] In another implementation of this embodiment, the function segment in the binary loadable file is downloaded to the resource-constrained device, including: directly storing the function segment code in the corresponding storage space (such as a registry, a specific space for the module code); or, according to the program running requirements, storing the target information in the function segment (necessary code information, such as the stack space unit size, the indirect access variable stack size) in the corresponding storage space.

[0140] In another implementation of this embodiment, the application segment in the binary loadable file is downloaded to the resource-constrained device, including: directly storing the application segment code in the corresponding storage space; or, according to the program running requirements, parsing the entry function information of the application module installation and interface registration to obtain the function address information, organizing the application module AID in the application segment, and the function address information, and storing them in the corresponding storage space.

[0141] In another implementation of the present embodiment, the global segment in the binary loadable file is downloaded to the resource-constrained device, including: directly storing the global segment code in the corresponding storage space; or, according to the program running requirements, storing the target field in the global segment in the corresponding storage space; or, according to the module global variable starting address and the module read-only data starting address in the global segment, obtaining the module read-only data size, and storing the module read-only data size in the corresponding storage space.

[0142] In another implementation of this embodiment, downloading the export segment in the binary loadable file to the resource-constrained device includes: directly storing the export segment code in the corresponding storage space; or, if the export segment passes the integrity check during the download process, ignoring the export segment.

[0143] In another implementation of this embodiment, downloading the element segment in the binary loadable file to the resource-constrained device includes: directly storing the element segment code in the corresponding storage space.

[0144] In another implementation of this embodiment, the code segment in the binary loadable file is downloaded to the resource-constrained device, including: directly storing the code segment code in the corresponding storage space; or, according to the program running requirements, storing all function information defined in the module content in the code segment and the bytecode of all functions defined in the module in the corresponding storage space.

[0145] In another implementation of this embodiment, the data segment in the binary loadable file is downloaded to the resource-constrained device, including: directly storing the data segment code in the corresponding storage space; or, according to the program running requirements, and the module global variable starting address and the module read-only data starting address in the global segment, obtaining the module read-only data size, and storing the module read-only data size, module read-only data, and the module global data initial value and size that are not 0 in the storage space corresponding to the read-only data in the data segment.

[0146] It should be noted that, in this embodiment, during the entire binary loadable file download process, all storage space information is managed by the module registry, each storage space can be dynamically allocated from the heap, and the information of the allocated space is associated with the registry.

[0147] Step 240: Link the binary loadable file outside the device, or directly store the binary loadable file, and generate a mask data structure according to the processing result; or, convert and link the binary intermediate file, and generate a mask data structure according to the processing result; or, compile, convert and link the source file, and generate a mask data structure according to the processing result.

[0148] In this embodiment, the Mask tool can generate a mask file (such as a ".c" file) by specifying a standard ".wasm" file as input, or specify a standard ".hef" file of a mask module as input and then parse it, organize it according to the mask data format specified by the virtual machine, and finally output the required mask file; or even more directly, take the user programming file (such as .c / .h) file as input, and generate a mask file through compilation, conversion and Mask.

[0149] In this step, optionally, the storage address of the data can be configured by the mask tool, the format of the output code can be set, and the binary loadable file can be linked. The linking process of the binary loadable file is consistent with the data conversion method in the binary loadable file download process, that is, when generating the mask data structure, the information such as modules, functions, and global segments in the binary loadable file can be preliminarily linked to generate an optimized data structure.

[0150] The advantage of this setting is that the download process can be omitted. The source files of all system modules or possible application modules or the intermediate files generated by compilation are the input of the Mask tool. At the same time, the configuration file sets the storage space of the mask data for the Mask tool. The Mask tool generates the data of the binary executable file according to the physical address provided by the storage space.

[0151] Step 250: Generate a mask file of a binary executable file according to the mask data structure.

[0152] The technical solution provided by the embodiment of the present application is to obtain the binary intermediate files generated after all program source codes are compiled, and the binary link files of the modules imported by the binary intermediate files, convert the binary intermediate files into binary loadable files according to the binary link files, and download the binary loadable files to the resource-constrained device in response to the download command stream to obtain the binary executable file; use the source files and / or binary intermediate files and mask tool configuration parameters to convert and link (optional compilation), generate a mask data structure according to the link results, and generate a mask file of the binary executable file according to the mask data structure. Since the binary link file is used to provide external function link information of the binary intermediate file, compared with the standard binary intermediate file in the prior art, when executing on the device, if accessing external functions and variables, it is necessary to find the matching module name, function name or variable name for positioning. In the embodiment of the present application, only the external function link information of the binary intermediate file can be obtained according to the binary link file outside the device, and a binary loadable file smaller than the binary intermediate file is generated according to the external function link information, thereby improving the download and execution efficiency of the WebAssembly module in the resource-constrained device and reducing the resource consumption of the device.

[0153] Figure 3 A schematic diagram of a binary loadable file generating device provided in an embodiment of the present application, wherein the device is applied to an electronic device, such as Figure 3 As shown, the device includes: an input file acquisition module 310 and a file generation module 320.

[0154] An input file acquisition module 310 is used to acquire a binary intermediate file generated after the program source code is compiled, and a binary link file of a module imported by the binary intermediate file;

[0155] A file generation module 320, configured to convert the binary intermediate file into a binary loadable file according to the binary link file;

[0156] The binary loadable file includes: a header segment, a function segment, a global segment and a code segment.

[0157] The technical solution provided by the embodiment of the present application is a technical means for converting the binary intermediate file into a binary loadable file according to the binary link file by obtaining a binary intermediate file generated after compiling the program source code and a binary link file of the module imported by the binary intermediate file. Since the binary link file is used to provide external function link information of the binary intermediate file, compared with the standard binary intermediate file in the prior art, when executing on the device, if accessing external functions and variables, it is necessary to find a matching module name, function name or variable name for positioning, the embodiment of the present application only needs to obtain the external function link information of the binary intermediate file according to the binary link file outside the device, and generate a binary loadable file smaller than the binary intermediate file according to the external function link information, thereby improving the download and execution efficiency of the WebAssembly module in resource-constrained devices and reducing the resource consumption of the device.

[0158] Based on the above embodiment, the binary loadable file further includes at least one of the following: an import segment, an application segment, an export segment, an element segment, a data segment, and a custom segment;

[0159] The custom segment includes at least one of the following: a custom segment ID, custom data, and the number of bytes of the custom data;

[0160] The header includes at least one of the following: header ID, header length, module information, binary loadable file length, configuration field, number of imported modules, number of imported functions, function segment space size, application segment space size, element segment space size, data segment space size, and code segment space size;

[0161] The module information includes at least one of the following: module version information, module identification AID and module AID length;

[0162] The import segment includes at least one of the following: an import segment ID, the number of bytes in the import segment, the number of imported modules, the number of imported functions, an imported module information array, and an imported function information array;

[0163] The imported module information array includes at least one of the following: imported module version, imported module AID, and imported module AID length;

[0164] The imported function information array includes at least one of the following: the index of the module where the imported function is located in the imported module information array, and the index of the imported function in the imported module;

[0165] The function segment includes at least one of the following: a function segment ID, the number of bytes in the function segment, and the number of code bytes corresponding to a function;

[0166] The application segment includes at least one of the following: an application segment ID, the number of bytes in the application segment, the number of registrable application module information groups, and an application module information group;

[0167] The application module information group includes at least one of the following: application module AID, the length of the application module AID content in this group of information, and entry function information for application module installation and interface registration;

[0168] The global segment includes at least one of the following: a global segment ID, the number of bytes in the global segment, a module read-only data start address, a module global variable start address, a reserved field, and a global variable end address;

[0169] The export segment includes at least one of the following: an export segment ID, the number of bytes in the export segment, and a function index corresponding to each export function;

[0170] The element segment includes at least one of the following: an element segment ID, the number of bytes in the element segment, and a function index of a function pointer calling a function;

[0171] The code segment includes at least one of the following: a code segment ID, the number of bytes in the code segment, all function information defined in the module content, and the bytecodes of all functions defined in the module;

[0172] All function information defined in the module content includes at least one of the following: function code flag, number of parameters, number of local variables, number of units of the maximum stack frame of the function, and number of units of the indirect access variable stack used by the function;

[0173] The data segment includes at least one of the following items: data segment ID, number of bytes in the data segment, module read-only data space size, module global data space size with initial value, reserved field length, module read-only data, module global data initial value not equal to 0 and reserved field.

[0174] The file generation module 320 includes:

[0175] A deleting unit, used to delete the type segment in the binary intermediate file; and to delete the memory segment and / or table segment in the binary intermediate file;

[0176] A function segment processing unit, used to delete the type information of the function segment in the binary intermediate file and generate the function code size;

[0177] An export segment processing unit, used to generate a function index corresponding to the function segment in the binary intermediate file, replace the function information in the export segment with the function index, and update the size of the export segment;

[0178] The import segment processing unit is used to obtain the corresponding module AID information in the binary link file according to the import function information of the binary link file and the binary intermediate file; obtain the corresponding function index in the binary link file according to the import function name in the binary intermediate file; generate the import module information corresponding to the import segment in the binary loadable file according to the corresponding module AID information in the binary link file, organize all the import module information, and generate the import module information array of the import segment in the binary loadable file; generate the number of import modules in the import segment in the binary loadable file according to the number of import modules in the binary link file; replace the function information in the binary intermediate file according to the module index in the binary intermediate file and the function index obtained in the binary link file, and obtain the import function information array of the import segment in the binary loadable file;

[0179] The global segment processing unit is used to delete the variable information of the global segment in the binary intermediate file, generate the module read-only data starting address of the global segment in the binary loadable file according to the global variable starting address of the global segment in the binary intermediate file; generate the global variable ending address of the global segment in the binary loadable file according to the global variable ending address of the global segment in the binary intermediate file; generate the module global variable starting address of the global segment in the binary loadable file according to the read-only data information corresponding to the data segment and the custom segment in the binary intermediate file;

[0180] A data segment processing unit, used to generate module read-only data of the data segment in the binary loadable file and a module global data initial value that is not 0, respectively, according to the read-only data information of the data segment and the custom segment in the binary intermediate file, the global variable information, and the custom module information;

[0181] An element segment processing unit, used to obtain a table index and table offset information of an element segment in a binary intermediate file; and generate a function index corresponding to the element segment in a binary loadable file according to the table index and table offset information;

[0182] The application segment processing unit is used to obtain the application module AID and the function name of the installation and registration interface function according to the conversion parameter configuration file; obtain the corresponding function index and the entry function information of the application module installation and interface registration corresponding to the binary loadable file according to the installation and registration interface function name; output the application module AID and the entry function information of the application module installation and interface registration as an application module information group to the application segment in the binary loadable file, and generate the number of registrable application module information groups in the application segment according to the number of application execution modules; wherein the application segment in the binary loadable file includes one or more application module information groups;

[0183] A code segment processing unit is used to determine the number of parameters and the number of local variables corresponding to the binary loadable file according to the number of local variables and the number of parameters in the binary intermediate file; simulate the execution of the function code in the binary intermediate file, calculate the maximum number of units of the operand stack space during the execution process, and generate the maximum number of units of the stack frame of the function corresponding to the binary loadable file; generate the number of units of the indirect access variable stack used by the function corresponding to the binary loadable file according to the bytecode of the operation allocation indirect access variable stack space in the function code of the binary intermediate file; determine the function code flag of the code segment in the binary loadable file according to the number of parameters, the number of local variables, the maximum number of units of the stack frame of the function, and the number of units of the indirect access variable stack used by the function;

[0184] A version information generating unit, used to generate version information corresponding to the binary loadable file according to the version information in the conversion parameter configuration file;

[0185] A version checking unit, used to check whether the version information corresponding to the binary intermediate file and the binary link file is consistent; if so, converting the binary intermediate file into a binary loadable file according to the binary intermediate file and the binary link file;

[0186] a version information checking unit, used to check whether the major version information corresponding to the binary intermediate file is the same as the major version information corresponding to the binary link file; if so, check whether the minor version information corresponding to the binary intermediate file is not lower than the minor version information corresponding to the binary link file; if so, determine that the version information corresponding to the binary intermediate file is consistent with the version information corresponding to the binary link file;

[0187] The first segment processing unit is used to generate the first segment in the binary loadable file according to the import segment, function segment, application segment, element segment, data segment and code segment in the binary loadable file.

[0188] The device also includes: a file downloading module and a mask file generating module.

[0189] The file download module is used to download the binary loadable file to the resource-constrained device in response to the download command stream to obtain a binary executable file.

[0190] The mask file generation module is used to link the binary loadable file using the binary link file, generate a mask data structure according to the link result; and generate a mask file of the binary loadable file according to the mask data structure.

[0191] The file download module includes:

[0192] A sequential download unit, used to download the first segment, import segment, function segment, application segment, global segment, export segment, element segment, code segment, and data segment in the binary loadable file to the resource-constrained device in sequence according to a preset download sequence;

[0193] An import segment download unit is used to directly store the import segment code into the corresponding storage space; or, to parse the module AID imported in the import segment; and / or, according to the index of the module where the import function is located in the imported module information array in the import segment, query the module AID corresponding to the index from the imported module information array, and parse the module AID; and / or, after parsing the index of the module where the import function is located in the imported module information array, after obtaining the import module identifier, locate the import module from the module registration information according to the index of the import function in the import module, query the export segment information corresponding to the import module, and check the legitimacy of the index of the import function in the import module according to the export segment information; and / or, obtain the function address of the import module, and optimize the function information of the import module to the function address.

[0194] A function segment downloading unit is used to directly store the function segment code into the corresponding storage space; or, according to the program running requirements, store the target information in the function segment into the corresponding storage space;

[0195] An application segment download unit is used to directly store the application segment code into a corresponding storage space; or, according to the program running requirements, parse the entry function information of the application module installation and interface registration to obtain the function address information, organize the application module AID in the application segment, and the function address information, and store them into a corresponding storage space;

[0196] The global segment download unit is used to directly store the global segment code into the corresponding storage space; or, according to the program running requirements, store the target field in the global segment into the corresponding storage space; or, according to the module global variable starting address and the module read-only data starting address in the global segment, obtain the module read-only data size, and store the module read-only data size into the corresponding storage space;

[0197] An export segment downloading unit, used to directly store the export segment code into a corresponding storage space; or, if the export segment passes the integrity check during the downloading process, the export segment is ignored;

[0198] An element segment downloading unit, used to store the element segment code directly into a corresponding storage space;

[0199] The code segment downloading unit is used to directly store the code segment code into the corresponding storage space; or, according to the program running requirements, store all the function information defined by the module content in the code segment and the bytecode of all the functions defined in the module into the corresponding storage space;

[0200] The data segment download unit is used to directly store the data segment code into the corresponding storage space; or, according to the program running requirements and the module global variable starting address and the module read-only data starting address in the global segment, obtain the module read-only data size, and store the module read-only data size, the module read-only data, and the module global data initial value and size that are not 0 into the storage space corresponding to the read-only data in the data segment;

[0201] The module registration management unit is used to manage the information of all downloaded library modules and application modules.

[0202] The above device can execute the methods provided by all the above embodiments of the present application, and has the corresponding functional modules and beneficial effects of executing the above methods. For technical details not described in detail in the embodiments of the present application, please refer to the methods provided by all the above embodiments of the present application.

[0203] Figure 4 A schematic diagram of an electronic device 10 that can be used to implement an embodiment of the present application is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the embodiments of the present application described and / or required herein.

[0204] like Figure 4As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0205] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0206] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a binary loadable file generation method.

[0207] In some embodiments, the binary loadable file generation method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the binary loadable file generation method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the binary loadable file generation method in any other appropriate manner (e.g., by means of firmware).

[0208] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0209] The computer program for implementing the method of the embodiment of the present application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program can be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.

[0210] In the context of the present application embodiment, computer readable storage medium can be a tangible medium, which can contain or store a computer program for use by an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. Computer readable storage medium can include but is not limited to electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the above. Alternatively, computer readable storage medium can be a machine readable signal medium. A more specific example of a machine readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0211] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0212] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0213] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0214] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in the embodiments of the present application can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions of the embodiments of the present application can be achieved, and this document does not limit them here.

[0215] The above specific implementation manner does not constitute a limitation on the protection scope of the embodiments of the present application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the embodiments of the present application should be included in the protection scope of the embodiments of the present application.

Claims

1. A method for generating a binary loadable file, characterized in that: include: Obtain a binary intermediate file generated after compiling the program source code, and a binary link file of the module imported by the binary intermediate file; According to the binary link file, converting the binary intermediate file into a binary loadable file; The binary loadable file includes: a header segment, a function segment, a global segment and a code segment; and the version numbers of the binary link file and the binary loadable file are consistent.

2. The method according to claim 1, characterized in that The binary loadable file also includes at least one of the following: an import segment, an application segment, an export segment, an element segment, a data segment, and a custom segment; Converting the binary intermediate file into a binary loadable file includes: Deleting the type segment in the binary intermediate file; Delete the type information of the function segment in the binary intermediate file and generate the function code size; Generate a function index corresponding to the function segment in the binary intermediate file, replace the function information in the export segment with the function index, and update the size of the export segment.

3. The method according to claim 2, characterized in that Converting the binary intermediate file into a binary loadable file includes: According to the import function information of the binary link file and the binary intermediate file, obtain the corresponding module AID information in the binary link file; According to the imported function name in the binary intermediate file, obtain the corresponding function index in the binary link file; Generate import module information corresponding to the import segment in the binary loadable file according to the corresponding module AID information in the binary link file, organize all import module information, and generate an import module information array of the import segment in the binary loadable file; Generate the number of import modules in the import section of the binary loadable file according to the number of import modules in the binary link file; According to the module index in the binary intermediate file and the function index obtained in the binary link file, the function information in the binary intermediate file is replaced to obtain the import function information array of the import segment in the binary loadable file.

4. The method according to claim 1, characterized in that: Converting the binary intermediate file into a binary loadable file includes: Delete the variable information of the global segment in the binary intermediate file, and generate the module read-only data starting address of the global segment in the binary loadable file according to the global variable starting address of the global segment in the binary intermediate file; Generate the end address of global variables in the global segment of the binary loadable file according to the end address of global variables in the global segment of the binary intermediate file; Generate the module global variable start address of the global segment in the binary loadable file according to the read-only data information corresponding to the data segment and the custom segment in the binary intermediate file.

5. The method according to claim 2, characterized in that: Converting the binary intermediate file into a binary loadable file includes: According to the read-only data information, global variable information and custom module information of the data segment and custom segment in the binary intermediate file, the module read-only data of the data segment in the binary loadable file and the module global data initial value which is not 0 are generated respectively.

6. The method according to claim 2, characterized in that Converting the binary intermediate file into a binary loadable file includes: Get the table index and table offset information of the element segment in the binary intermediate file; A function index corresponding to the element segment in the binary loadable file is generated according to the table index and the table offset information.

7. The method according to claim 2, characterized in that: Converting the binary intermediate file into a binary loadable file includes: According to the conversion parameter configuration file, obtain the application module AID and the function names of the installation and interface registration functions; According to the installation and interface registration function name, obtain the corresponding function index and the entry function information of the application module installation and interface registration corresponding to the binary loadable file; Output the application module AID, the entry function information of the application module installation and interface registration as the application module information group to the application segment in the binary loadable file, and generate the number of registrable application module information groups in the application segment according to the number of application execution modules; The application segment in the binary loadable file includes one or more application module information groups.

8. A binary loadable file generating device, characterized in that: The device comprises: An input file acquisition module is used to acquire a binary intermediate file generated after compiling the program source code, and a binary link file of a module imported by the binary intermediate file; A file generation module, used for converting the binary intermediate file into a binary loadable file according to the binary link file; The binary loadable file includes: a header segment, a function segment, a global segment and a code segment; and the version numbers of the binary link file and the binary loadable file are consistent.

9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method according to any one of claims 1 to 7 when executed.