WO2022237610A1 - Procédé de compilation de programme et procédé de chargement de programme - Google Patents
Procédé de compilation de programme et procédé de chargement de programme Download PDFInfo
- Publication number
- WO2022237610A1 WO2022237610A1 PCT/CN2022/090916 CN2022090916W WO2022237610A1 WO 2022237610 A1 WO2022237610 A1 WO 2022237610A1 CN 2022090916 W CN2022090916 W CN 2022090916W WO 2022237610 A1 WO2022237610 A1 WO 2022237610A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- symbol
- relocation
- application
- code segment
- target
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 46
- 238000012545 processing Methods 0.000 claims abstract description 15
- 238000011068 loading method Methods 0.000 claims description 61
- 238000007906 compression Methods 0.000 claims description 3
- 230000006835 compression Effects 0.000 claims description 2
- 230000001419 dependent effect Effects 0.000 claims description 2
- 230000003247 decreasing effect Effects 0.000 abstract 1
- 230000000717 retained effect Effects 0.000 abstract 1
- 238000004590 computer program Methods 0.000 description 20
- 238000003860 storage Methods 0.000 description 12
- 238000010586 diagram Methods 0.000 description 10
- 230000006870 function Effects 0.000 description 10
- 238000004891 communication Methods 0.000 description 9
- 238000005516 engineering process Methods 0.000 description 8
- 230000008569 process Effects 0.000 description 7
- 230000003068 static effect Effects 0.000 description 5
- 238000004458 analytical method Methods 0.000 description 4
- 230000002452 interceptive effect Effects 0.000 description 4
- 230000004044 response Effects 0.000 description 4
- 230000005236 sound signal Effects 0.000 description 4
- 230000003993 interaction Effects 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 230000009471 action Effects 0.000 description 2
- 238000011161 development Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 238000007781 pre-processing Methods 0.000 description 2
- 230000005540 biological transmission Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000005457 optimization Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/37—Compiler construction; Parser generation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/42—Syntactic analysis
- G06F8/427—Parsing
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44521—Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
Definitions
- the present application relates to the technical field of data processing, in particular to a program compiling and program loading method.
- RTOS Real Time Operating System
- IoT devices can install applications to achieve specific functions.
- the RTOS loads the executable file of the application program to the local.
- the larger the executable file of the application the more memory it occupies on the IoT device.
- Various aspects of the present application provide a program compiling and program loading method to reduce the memory usage of an executable file of an application program.
- An embodiment of the present application provides a program compilation method, including:
- An executable file of the application is generated according to the target code segment, the target data segment, the second symbol table and the first relocation table.
- the embodiment of the present application also provides a program loading method, including:
- the embodiment of the present application also provides a computer device, including: a memory and a processor; wherein, the memory is used to store a computer program;
- the processor is coupled to the memory for executing the computer program for performing the steps in the above-mentioned program compiling and/or program loading methods.
- An embodiment of the present application further provides a computer program product, including: a computer program; the computer program is executed by a processor to implement the above method for program compiling and/or program loading.
- the embodiment of the present application also provides a computer-readable storage medium storing computer instructions, when the computer instructions are executed by one or more processors, causing the one or more processors to perform the above-mentioned program compilation and/or Steps in the program loading method.
- the code segment and data segment of multiple target files compiled by the application source code are merged to obtain the target code segment and target data segment, which can reduce the header information ;
- only retaining the symbol table corresponding to the relocation table required when the application is loaded can reduce the space consumption of the symbol table;
- the symbol table corresponding to the location table and the size of the executable file of the generated application help to reduce the memory consumption when loading the application.
- Fig. 1a is a schematic flow diagram of the program compiling method provided by the embodiment of the present application.
- Figure 1b is a schematic diagram of the composition of the object file and the executable file provided by the embodiment of the present application;
- FIG. 2 is a schematic flowchart of a program loading method provided in an embodiment of the present application
- FIG. 3 is a schematic structural diagram of a computer device provided by an embodiment of the present application.
- RTOS Real Time Operating System
- RTOS Real Time Operating System
- Some RTOS systems require user application code to be compiled together with the operating system kernel as a complete executable file. User applications cannot be compiled separately, and cannot be upgraded through OTA alone.
- RTOS systems do not support dynamic loading of SO files, and some RTOS systems support dynamic loading of .O files or ELF files, allowing users to compile user applications separately into programs and dynamically load them into the RTOS system to run.
- the code segments and data segments of multiple target files compiled from the application source code are merged processing to obtain the target code segment and target data segment, which can reduce the table header information; on the other hand, only retaining the symbol table corresponding to the relocation table required for application loading can reduce the space consumption of the symbol table; therefore, it is helpful Reduce the size of the executable file of the application that is subsequently generated based on the target code segment, target data segment, relocation table, and symbol table corresponding to the relocation table, thereby helping to reduce memory consumption when loading the application.
- Fig. 1a is a schematic flowchart of a program compiling method provided by an embodiment of the present application. As shown in Figure 1a, the method includes:
- the application refers to the application to be compiled.
- the application can be one or more software function modules. Multiple refers to 2 or more.
- the source code of the application needs to be compiled to generate an executable file, which can be loaded by a computer device to realize the application function.
- multiple object files obtained by compiling the source code of the application may be obtained.
- a plurality means two or more.
- the target file can be .O file or .obj file, etc.
- the target file can be an .O file.
- preprocessing can be performed on the source code of the application (such as .c files, etc.), such as macro definition checking and expansion, preprocessing instructions, comment replacement spaces, header files, etc.; further, the preprocessed files (such as .i files, etc.) for lexical analysis, semantic analysis, syntax analysis and optimization to generate corresponding assembly codes (such as .s files, etc.); further, the assembler can convert the assembly codes into machine-executable instructions to obtain the target file (such as .O files, etc.).
- the source code of the application such as .c files, etc.
- preprocessed files such as .i files, etc.
- the assembler can convert the assembly codes into machine-executable instructions to obtain the target file (such as .O files, etc.).
- step 102 in order to reduce the size of the executable file of the application, in step 102, the code segment and data segment of multiple target files can be combined to obtain the target code segment and target data segment. In this way, Multiple object files can be merged into one object file to reduce header information.
- a source code file may refer to or depend on another source code file, which results in a reference relationship between multiple target files compiled from the source code of the application.
- multiple target files may be linked to obtain an intermediate file of the application.
- the main task of the link is to correctly connect each target file and the parts of the mutual references between the modules in the target file to obtain the intermediate file.
- the file type of the intermediate file may be the same as a plurality of object files. For example, if the multiple object files are .O files, the intermediate files obtained by linking the multiple object files may also be .O files.
- multiple target files may be linked in a partial link manner to obtain an intermediate file of the application.
- the above-mentioned operation of linking multiple object files can be completed by a compiler.
- code segments and data segments respectively corresponding to multiple target files may be obtained from the intermediate file.
- the corresponding relationship between the compiler identifier and the target file format can be preset, so that when obtaining the code segment and data segment respectively corresponding to multiple target files from the intermediate file, Obtaining the compiler identifier for compiling the source code of the application; and using the compiler identifier to match the preset correspondence between the compiler identifier and the object file format, so as to obtain the object file format of multiple object files; Afterwards, according to the target file formats of the multiple target files, the code segments and data segments respectively corresponding to the multiple target files are obtained from the intermediate file.
- the implementation manner of obtaining the identifier of the compiler for compiling the source code of the application is not limited.
- the compiler can be improved, for example, the compiler can compile the source code of the application to obtain multiple object files; and the identifier of the compiler can be encapsulated in the multiple object files. In this way, the identifiers of the compiler carried in can be parsed from multiple object files subsequently, and used as compiler identifiers for compiling the source code of the application.
- the identifier of the compiler currently compiling the application can also be set by the technician.
- a human-computer interaction interface can be provided.
- the interactive interface may include a compiler identification setting control; through this control, the technician may set the compiler identification for compiling the application.
- the user can trigger the compiler flag setting control to select the compiler flag.
- the computer device in response to the interactive operation of setting the control for the compiler identification, display the compiler identification to be selected; and in response to the interactive operation for the compiler identification, determine the compiler identification selected by the interactive operation as the Compiler flags for application compilation, etc.
- the compiler identification can be used to match in the corresponding relationship between the preset compiler identification and the target file format, so as to obtain the target file format of multiple target files; after that, According to the target file formats of the multiple target files, the code segments and data segments respectively corresponding to the multiple target files are obtained from the intermediate file.
- linking multiple target files can sort out the mutual reference relationship between modules in multiple target files, that is, the link relationship; therefore, when merging the code segments and data segments of multiple target files, you can According to the link relationship between the code segments in the intermediate file, the code segments of multiple target files are merged to obtain the target code segment; and according to the link relationship between the data segments in the intermediate file, the data segments of multiple target files are merged Merge processing is performed to obtain the target data segment.
- the data segment of the above-mentioned target file may include: a Data segment and a BSS (Block Started by Symbol) segment.
- the BSS segment refers to a memory area used to store global variables that are not initialized or have an initial value of 0 in the program, and belong to static memory allocation.
- the Data segment refers to a memory area used to store initialized global variables in the program, which belongs to static memory allocation.
- the link between the Data segments in the intermediate file can be relationship, merge the Data segments of multiple target files to obtain the merged Data segment; and according to the link relationship between the BSS segments in the intermediate file, merge the BSS segments of multiple target files to obtain the merged BSS segment .
- the merged Data segment and the merged BSS segment constitute the target data segment.
- step 103 Since the symbol positions in the code segment and the data segment are changed when the code segment and the data segment of multiple target files are respectively merged, based on this, in step 103, according to the target code segment and the target data segment The symbol position of the target file is modified, and the symbol table and relocation table corresponding to multiple object files are modified to the modified symbol table and the modified relocation table.
- the modified symbol table and the modified relocation table obtained in step 103 are respectively defined as the first symbol table and the first relocation table.
- the symbol table and relocation table corresponding to the above multiple object files refer to the symbol table and relocation table including the symbol table and relocation table in each object file.
- the symbol tables and relocation tables in multiple target files can also be linked to obtain a symbol table and a relocation.
- the linked symbol tables and relocation tables include: symbol tables and relocation tables in multiple object files.
- the symbol tables and relocation tables corresponding to the multiple target files in step 103 above refer to the linked symbol tables and relocation tables, that is, the symbol tables and relocation tables in the intermediate file.
- the relocation table and symbol table in multiple target files can also be combined into one symbol table and one relocation table according to the link relationship between multiple target files Table, the symbol table and relocation table corresponding to multiple target files in the above step 103 refers to the symbol table and relocation table after the relocation table and symbol table in multiple target files are merged and processed.
- the symbols corresponding to the instructions that do not need to be relocated can be directly executed.
- the symbols corresponding to the instructions that need to be relocated it is necessary to base on the symbol table corresponding to the relocated symbols.
- the located instruction is relocated.
- the second symbol table corresponding to the first relocation table can be obtained from the first symbol table.
- symbol tables other than the second symbol table in the first symbol table may be deleted.
- the dependencies between the symbols recorded in the first relocation table can be used to determine the symbols on which the relocation symbols depend; and the relocation symbols and the relocation symbols recorded in the first relocation table can be obtained from the first symbol table
- the symbol table corresponding to the dependent symbol is used as the second symbol table.
- step 105 After obtaining the target code segment, the target data segment, the first relocation table and the second symbol table corresponding to the first relocation table, in step 105, according to the target code segment, the target data segment, the second symbol table and the first A relocation table to generate an executable file of the application.
- the second symbol table and the first relocation table may be copied to the file where the target code segment and the target data segment are located to obtain an executable file of the application.
- the code segment and data segment of multiple target files compiled by the application source code are merged to obtain the target code segment and target data segment, which can reduce the header information, It can reduce the memory consumption of the table header; on the other hand, only retaining the symbol table corresponding to the relocation table required for loading the application can reduce the space consumption of the symbol table; The segment and the relocation table and the symbol table corresponding to the relocation table, the size of the executable file of the generated application, which in turn helps to reduce the memory consumption when loading the application.
- this embodiment can process the target files generated by various compilers into executable files with a uniform format.
- the same set of codes can be used to implement the corresponding target files generated by different compilers.
- the executable file is loaded.
- the target file may include: defined symbols and undefined symbols.
- Definition symbols usually refer to defined functions, global variables, etc., which are symbols customized by application developers.
- An undefined symbol refers to a symbol whose type (Type) is undefined, specifically refers to a symbol that is referenced by an object file but whose value is not defined in the object file.
- the undefined symbols that the application depends on may include: the undefined symbols that the application directly depends on and the undefined symbols that the application depends on indirectly.
- the undefined symbols that the application directly depends on refer to: the undefined symbols contained in the object file of the application.
- An undefined symbol that an application indirectly depends on is an undefined symbol associated with an undefined symbol contained in an application's object file. For example, an undefined symbol in another object file related to an undefined symbol included in an object file, etc.
- the actual loading address of the code segment corresponding to the defined symbol can be determined according to the definition of the defined symbol, and the actual loading address of the code segment corresponding to the undefined symbol needs to be reset. position.
- the undefined symbols that the application depends on can also be determined according to the symbol types recorded in the first symbol table; and the character strings corresponding to the undefined symbols can be obtained from the character string tables corresponding to multiple target files ; After that, compress the string corresponding to the undefined symbol to obtain the processed string table, which helps to reduce the memory consumption of the string.
- a hash (Hash) algorithm may be used to compress the character strings corresponding to undefined symbols to obtain a processed character string table.
- a hash algorithm can be used to compress the character string corresponding to the undefined symbol into a set number of bytes, such as 4 bytes.
- the code segment corresponding to the defined symbol can be determined according to the definition of the defined symbol, the actual loading address of the code segment corresponding to the defined symbol can be compressed, and the character string corresponding to the undefined symbol can be compressed and deleted.
- the character string corresponding to the symbol Define the character string corresponding to the symbol, and obtain the processed character string table.
- compressing the strings corresponding to undefined symbols can reduce the memory consumption of strings corresponding to undefined symbols; on the other hand, deleting the strings corresponding to unneeded defined symbols can further reduce the The memory consumption of the corresponding string, thereby reducing the memory consumption of the string table in the subsequent executable file, helps to further reduce the size of the executable file, and further helps to reduce the memory consumption when loading the application.
- the first relocation table, the second symbol table corresponding to the first relocation table, the first relocation table, and the processed word string table can also be copied Go to the file where the target code segment and the target data segment are located to obtain the executable file of the application.
- the processed string table is used as a string hash (hash) table for illustration, but it does not constitute a limitation.
- the code segment and data segment of multiple target files compiled by applying the source code are merged to obtain the target code segment and target data segment, which can reduce header information and can Reduce the memory consumption of the table header; on the other hand, only retain the symbol table corresponding to the relocation table required when the application is loaded, which can reduce the space consumption of the symbol table; in addition, compress the string corresponding to the undefined symbol, which can Reduce the memory consumption of strings corresponding to undefined symbols; delete the strings corresponding to unneeded defined symbols, which can further reduce the memory consumption of strings corresponding to defined symbols. Therefore, this embodiment can reduce the memory consumption of the string table in the executable file from various aspects, which helps to further reduce the size of the executable file, and further helps to reduce the memory consumption when loading the application.
- the application loading speed of the computer device can be improved.
- the program compiling method provided by the embodiment of the present application can realize separate compiling of the application, without compiling into an executable file together with the RTOS, and can realize the separate upgrade and loading of the application.
- the executable file can be released.
- the terminal can load executable files to implement loading of applications.
- the terminal can dynamically load the executable file and run the code logic of the executable file.
- the embodiment of the present application also provides a program loading method. The program loading method provided by the embodiment of the present application is described below as an example.
- FIG. 2 is a schematic flowchart of a program loading method provided by an embodiment of the present application. As shown in Figure 2, the method includes:
- the computer device can load the executable file of the application, run the code logic of the executable file, and realize the function corresponding to the application.
- executable files can be loaded to broadcast weather, news, music, or implement other functions.
- step 201 the executable file of the application can be obtained; and in step 202, the executable file is parsed to obtain the code segment, data segment, string table, heavy The symbol table corresponding to the location table and the relocation table.
- the legality of the executable file can also be checked.
- the file header format of the executable file may be obtained; if the file header format of the executable file conforms to the set file header format, it is determined that the executable file has passed the legality check, and the above step 202 is entered. If the file header format of the executable file does not conform to the set file header format, the loading will end.
- the code segment mainly refers to the target code segment after the code segments of the multiple target files compiled by the above application are merged;
- the data segment mainly refers to the data segment of the multiple target files compiled by the above application. After the target data segment.
- the relocation table refers to the above-mentioned first relocation table obtained by modifying the relocation tables corresponding to multiple target files according to the symbol positions of the target code segment and the target data segment; correspondingly, in this embodiment, the relocation table corresponds to
- the symbol table of is the second symbol table corresponding to the above-mentioned first relocation table.
- step 203 relocate the instructions that need to be relocated in the code segment; in step 204, based on the data points in the memory, execute the relocated instructions And the instructions in the code segment that do not need to be relocated, so as to realize the loading of the application.
- step 203 in order to implement dynamic loading of applications, before step 203, for computer devices that do not support Execute In Place (XIP) in a chip, the code segment, data segment, string table, The location table and symbol table are stored in memory.
- XIP Execute In Place
- the memory occupied by the code segment, the string table, the relocation table, and the symbol table corresponding to the relocation table can also be released.
- step 203 the data segment, string table, relocation table and Symbol table is stored in memory; and code segment is stored in flash memory.
- memory may be allocated according to the total size of the data segment, string table, relocation table, and symbol table; and the data segment, string table, relocation table, and symbol table are stored in the allocated memory.
- the memory occupied by the string table, the relocation table, and the symbol table corresponding to the relocation table can also be released.
- the header information can be reduced , which can reduce the memory consumption of the header;
- the symbol table in the executable file only retains the symbol table corresponding to the relocation table required when the application is loaded, which can reduce the space consumption of the symbol table; it helps to further reduce The size of the executable file, so that the terminal can reduce memory consumption when dynamically loading applications.
- the string of undefined symbols that the application depends on may also be compressed.
- the character string table includes character strings after character string compression of undefined symbols that the application depends on.
- the character string after compressing the character string with undefined symbols can be one or more characters, and the number of characters is less than that before the compression process.
- the string table may be a string hash table.
- the compressed string table records can be used to relocate String, find the actual loading address of the code segment corresponding to the undefined symbol through the operating system.
- the string table stores symbolic names, such as symbolic names with a length greater than 8 bytes. Taking the symbol name as an example, in the object file, the size of the structure corresponding to the symbol is fixed, and some bytes (such as 8 bytes, etc.) can be set aside to store the symbol name. If the symbol name is relatively short, less than or equal to the byte used to store the symbol name in the symbol table, it will be directly stored in the structure of the symbol table; if the length of the symbol name is greater than the byte used to store the symbol name in the symbol table, the symbol name will be stored Store it in the string table (string-table), and then record the offset address of the symbol name in the string table to the place where the symbol table is used to store the symbol name.
- the string table stores compressed character strings corresponding to undefined symbols, that is, compressed character strings for symbol names of undefined symbols. Based on this, in this embodiment, the compressed string corresponding to the undefined symbol can be determined in the string table according to the offset address of the undefined symbol recorded in the symbol table in the string table, and according to the The compressed character string recorded in the table is used to find the actual loading address of the code segment corresponding to the undefined symbol through the operating system.
- a new symbol table can be created according to the actual loading address of the code segment corresponding to the undefined symbol and the symbol table; and according to the new symbol table and the relocation table, relocate the instructions that need to be relocated in the code segment .
- the loading address of the code segment corresponding to the undefined symbol recorded in the symbol table can be modified to obtain a new symbol table.
- the main attributes include: symbol name and offset address (relative address) of the symbol, etc.
- the actual loading address of the code segment corresponding to the defined symbol can be searched through the operating system; after that, according to the actual loading address of the code segment corresponding to the undefined symbol and the address corresponding to the defined symbol
- the name of the relocation symbol can be determined according to the symbol index in the relocation table; according to the name of the relocation symbol, the new symbol table can be queried to obtain The actual loading address of the code segment corresponding to the relocation symbol; then, according to the relocation type in the relocation table, use the actual loading address of the code segment corresponding to the relocation symbol to relocate the instructions in the code segment that need to be relocated.
- the relocation type in the relocation table may be absolute positioning or relative positioning. If the relocation type is absolute positioning, the actual loading address of the code segment corresponding to the relocation symbol plus the address of the instruction to be relocated in the code segment can be used to obtain the relocation address of the instruction to be relocated. If the relocation type is relative positioning, you can use the actual loading address of the code segment corresponding to the relocation symbol plus the address difference between the instruction that needs to be relocated in the code segment and the next instruction of the instruction to get the instruction that needs to be relocated The relocation address of .
- the relocated instructions and the instructions in the code segment that do not need to be relocated can be executed to implement application loading.
- the program loading method provided in this embodiment is applicable to dynamic loading and static loading, and is especially suitable for dynamic loading of a single-process system.
- applications are dynamically loaded/unloaded during the running of a single-process RTOS system.
- the subject of execution of each step of the method provided in the foregoing embodiments may be the same device, or the method may also be executed by different devices.
- the execution subject of steps 101 and 102 may be device A; for another example, the execution subject of step 101 may be device A, and the execution subject of step 102 may be device B; and so on.
- the embodiment of the present application also provides a computer-readable storage medium storing computer instructions.
- the computer instructions are executed by one or more processors, one or more processors are caused to execute the above-mentioned program compilation and/or program Steps in the load method.
- An embodiment of the present application further provides a computer program product, including: a computer program; the computer program is executed by a processor to implement the program compiling method and/or program loading method described above in the claims.
- FIG. 3 is a schematic structural diagram of a computer device provided by an embodiment of the present application.
- the computer device may include: a memory 30a and a processor 30b; wherein, the memory 30a is used to store computer programs.
- the computer device is a program compiling device, such as a computer.
- the processor 30b is coupled to the memory 30a, and is used to execute a computer program for: obtaining multiple target files obtained by compiling the source code of the application; merging the code segments and data segments of the multiple target files, respectively, to obtaining the target code segment and the target data segment; modifying the corresponding symbol tables and relocation tables of a plurality of target files according to the symbol positions in the target code segment and the target data segment to obtain the first symbol table and the first relocation table; from In the first symbol table, a second symbol table corresponding to the first relocation table is obtained; and an executable file of the application is generated according to the target code segment, the target data segment, the second symbol table and the first relocation table.
- the processor 30b is further configured to: link the multiple target files to obtain an intermediate file of the application before combining the code segment and the data segment of the multiple target files; and from the intermediate file, Obtain code segments and data segments corresponding to multiple target files.
- the processor 30b merges the code segments and data segments of the multiple target files, it is specifically configured to: merge the code segments of the multiple target files according to the link relationship between the code segments in the intermediate file processing to obtain the target code segment; and according to the link relationship between the data segments in the intermediate file, the data segments of multiple target files are merged to obtain the target data segment.
- the processor 30b when the processor 30b obtains the code segments and data segments respectively corresponding to the multiple target files from the intermediate file, it is specifically configured to: obtain a compiler identifier for compiling the source code of the application; Match the corresponding relationship between the compiler identifier and the target file format to obtain the target file format of multiple target files; and according to the target file format of multiple target files, obtain multiple target files from the intermediate file respectively Corresponding code segment and data segment.
- the processor 30b when the processor 30b acquires the second symbol table corresponding to the first relocation table from the first symbol table, it is specifically configured to: determine according to the dependencies between symbols recorded in the first relocation table The symbols on which the relocation symbol depends; and obtaining the relocation symbol recorded in the first relocation table and the symbol table corresponding to the symbol on which the relocation symbol depends from the first symbol table as a second symbol table.
- the processor 30b is further configured to: determine the undefined symbol that the application depends on according to the symbol type recorded in the first symbol table; obtain the character string corresponding to the undefined symbol from the character string tables corresponding to the multiple target files; Compress the character string corresponding to the undefined symbol to obtain the processed character string table.
- the processor 30b compresses the character string corresponding to the undefined symbol
- it is specifically configured to: use a hash algorithm to compress the character string corresponding to the undefined symbol, so as to obtain a processed character string table.
- the processor 30b compresses the character string corresponding to the undefined symbol
- it is specifically configured to: compress the character string corresponding to the undefined symbol, and delete the character string corresponding to the defined symbol, to obtain the processed string table.
- the processor 30b when the processor 30b generates the executable file of the application, it is specifically configured to: copy the second symbol table, the first relocation table, and the processed string table to the target code segment and the target data segment file to get the executable file of the application.
- the computer equipment provided by this embodiment when the application program is compiled, on the one hand, merges the code segments and data segments of multiple target files compiled with the application source code to obtain the target code segment and target data segment, which can reduce the header information; on the other hand, only retaining the symbol table corresponding to the relocation table required when the application is loaded can reduce the space consumption of the symbol table; The symbol table corresponding to the relocation table and the size of the executable file of the generated application help to reduce the memory consumption when loading the application.
- the computer device provided in this embodiment can be implemented as a program loading device, such as an intelligent terminal device.
- a program loading device such as an intelligent terminal device.
- the IoT device may be a smart speaker, a smart TV, a smart refrigerator, or a smart robot, etc.
- the processor 30b is coupled to the memory 30a, and is used to execute a computer program for: acquiring the application Executable file; parse the executable file to obtain the code segment, data segment, string table, relocation table and symbol table corresponding to the relocation table contained in the executable file; according to the string table, symbol table and relocation table to relocate the instructions that need to be relocated in the code segment; and based on the data segment, execute the relocated instructions and the instructions that do not need to be relocated in the code segment to load the application.
- the string table includes a compressed string of undefined symbols that the application depends on.
- the processor 30b relocates the instruction that needs to be relocated in the code segment, it is specifically used to: search for the code segment corresponding to the undefined symbol through the operating system according to the compressed character string recorded in the string label. The actual loading address; create a new symbol table according to the actual loading address and symbol table of the code segment corresponding to the undefined symbol; and relocate the instructions that need to be relocated in the code segment according to the new symbol table and relocation table.
- the processor 30b when creating a new symbol table, is specifically configured to: use the operating system to search for the actual loading address of the code segment corresponding to the defined symbol according to the name of the defined symbol in the symbol table; The actual loading address of the code segment and the actual loading address of the code segment corresponding to the defined symbol, modify the offset address of the symbol corresponding to the symbol table to obtain a new symbol table.
- the processor 30b relocates the instruction that needs to be relocated in the code segment, it is specifically used to: determine the name of the relocation symbol according to the symbol index in the relocation table; symbol table to obtain the actual loading address of the code segment corresponding to the relocation symbol; and according to the relocation type in the relocation table, use the actual loading address of the code segment corresponding to the relocation symbol to relocate the instructions in the code segment Do the relocation.
- the processor 30b is also configured to: before relocating the instructions in the code segment that need to be relocated, store the code segment, data segment, string table, relocation table and symbol table in the memory 30a1 or, store the data segment, string table, relocation table and symbol table in the memory 30a1; and store the code segment in the flash memory 30a2.
- the processor 30b is also used to: after loading the application, release the memory occupied by the code segment, string table, relocation table and symbol table; or, after loading the application, release the memory occupied by the string table, relocation table and symbol table The memory occupied by the table.
- the table can be reduced. Header information, which can reduce the memory consumption of the header; on the other hand, the symbol table in the executable file only retains the symbol table corresponding to the relocation table required when the application is loaded, which can reduce the space consumption of the symbol table; it helps The size of the executable file is further reduced, so that the terminal can reduce memory consumption when dynamically loading applications.
- the computer device may further include optional components such as a communication component 30c, a power supply component 30d, a display component 30e, and an audio component 30f.
- Figure 3 only schematically shows some components, which does not mean that the computer equipment must include all the components shown in Figure 3, nor does it mean that the computer equipment can only include the components shown in Figure 3.
- the memory is used to store computer programs, and may be configured to store other various data to support operations on the device where it is located.
- the processor can execute the computer program stored in the memory to realize the corresponding control logic.
- the memory can be realized by any type of volatile or non-volatile storage devices or their combination, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable Read Only Memory (EPROM), Programmable Read Only Memory (PROM), Read Only Memory (ROM), Magnetic Memory, Flash Memory, Magnetic or Optical Disk.
- SRAM static random access memory
- EEPROM electrically erasable programmable read-only memory
- EPROM erasable programmable Read Only Memory
- PROM Programmable Read Only Memory
- ROM Read Only Memory
- Magnetic Memory Flash Memory
- Magnetic or Optical Disk any type of volatile or non-volatile storage devices or their combination, such as static random access memory (SRAM), electrically erasable programmable read-only memory
- the processor may be any hardware processing device capable of executing the logic of the above method.
- the processor can be a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) or a micro control unit (Microcontroller Unit, MCU); it can also be a field programmable gate array (Field -Programmable Gate Array, FPGA), programmable array logic device (Programmable Array Logic, PAL), general array logic device (General Array Logic, GAL), complex programmable logic device (Complex Programmable Logic Device, CPLD) and other programmable devices ; or advanced RISC processors (Advanced RISC Machines, ARM) or system chips (System on Chip, SOC), etc., but not limited to this.
- the communication component is configured to facilitate wired or wireless communication between the device where it is located and other devices.
- the device where the communication component is located can access a wireless network based on communication standards, such as WiFi, 2G or 3G, 4G, 5G or a combination thereof.
- the communication component receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel.
- the communication component may also be based on Near Field Communication (NFC) technology, Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology or other techniques to achieve.
- NFC Near Field Communication
- RFID Radio Frequency Identification
- IrDA Infrared Data Association
- UWB Ultra Wideband
- Bluetooth Bluetooth
- the display component may include a liquid crystal display (LCD) and a touch panel (TP). If the display assembly includes a touch panel, the display assembly may be implemented as a touch screen to receive input signals from a user.
- the touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may not only sense a boundary of a touch or swipe action, but also detect duration and pressure associated with the touch or swipe action.
- the power supply component is configured to provide power to various components of the device where it is located.
- a power supply component may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device in which the power supply component resides.
- the audio component may be configured to output and/or input audio signals.
- the audio component includes a microphone (MIC), which is configured to receive an external audio signal when the device on which the audio component is located is in an operation mode, such as a calling mode, a recording mode, and a speech recognition mode.
- the received audio signal may be further stored in a memory or sent via a communication component.
- the audio component further includes a speaker for outputting audio signals. For example, for a device with a language interaction function, the voice interaction with the user can be realized through the audio component.
- the embodiments of the present application may be provided as methods, systems, or computer program products. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
- computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
- These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions
- the device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
- a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
- processors CPUs
- input/output interfaces network interfaces
- memory volatile and non-volatile memory
- Memory may include non-permanent storage in computer-readable media, in the form of random access memory (RAM) and/or nonvolatile memory such as read-only memory (ROM) or flash RAM. Memory is an example of computer readable media.
- RAM random access memory
- ROM read-only memory
- flash RAM flash random access memory
- Computer-readable media including both permanent and non-permanent, removable and non-removable media, can be implemented by any method or technology for storage of information.
- Information may be computer readable instructions, data structures, modules of a program, or other data.
- Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Flash memory or other memory technology, Compact Disc Read-Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, A magnetic tape cartridge, disk storage or other magnetic storage device or any other non-transmission medium that can be used to store information that can be accessed by a computing device.
- computer-readable media excludes transitory computer-readable media, such as modulated data signals and carrier waves.
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
Procédé de compilation de programme et procédé de chargement de programme. Lorsqu'un programme d'application est compilé, un traitement de fusion est effectué sur des segments de code et des segments de données d'une pluralité de fichiers cibles qui sont compilés au moyen d'un code source d'une application, de façon à obtenir un segment de code cible et un segment de données cible, de telle sorte que les informations d'en-tête peuvent être réduites ; de plus, seulement une table de symboles correspondant à une table de réaffectation, qui est nécessaire lorsque l'application est chargée, est retenue, de telle sorte que la consommation d'espace de tables de symboles peut être réduite, ce qui facilite la réduction de la taille d'un fichier exécutable d'une application qui est ensuite généré selon le segment de code cible, le segment de données cible, la table de réaffectation et la table de symboles correspondant à la table de réaffectation, et ce qui facilite en outre la diminution de la consommation de mémoire lorsque l'application est chargée.
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110507123.4 | 2021-05-10 | ||
CN202110507123.4A CN115328454A (zh) | 2021-05-10 | 2021-05-10 | 程序编译和程序加载方法 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2022237610A1 true WO2022237610A1 (fr) | 2022-11-17 |
Family
ID=83912146
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2022/090916 WO2022237610A1 (fr) | 2021-05-10 | 2022-05-05 | Procédé de compilation de programme et procédé de chargement de programme |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN115328454A (fr) |
WO (1) | WO2022237610A1 (fr) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117075960A (zh) * | 2023-10-17 | 2023-11-17 | 统信软件技术有限公司 | 程序重构方法、应用跨平台迁移方法、装置与计算设备 |
WO2024169933A1 (fr) * | 2023-02-17 | 2024-08-22 | 苏州元脑智能科技有限公司 | Système et procédé d'optimisation d'espace vectoriel d'exception de programme, dispositif et support |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116069304B (zh) * | 2023-04-06 | 2023-07-14 | 紫光同芯微电子有限公司 | 一种程序数据生成方法及装置 |
CN116820568B (zh) * | 2023-06-09 | 2024-01-05 | 北京市合芯数字科技有限公司 | 指令翻译方法及装置、存储介质和终端 |
CN117435257B (zh) * | 2023-12-18 | 2024-02-27 | 美智纵横科技有限责任公司 | 系统加载方法及装置、存储介质、计算机程序产品和芯片 |
CN117435258B (zh) * | 2023-12-18 | 2024-03-08 | 美智纵横科技有限责任公司 | 系统加载方法及装置、存储介质、计算机程序产品和芯片 |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6704928B1 (en) * | 1999-09-03 | 2004-03-09 | Stmicroelectronics Limited | Relocation format for linking |
CN1841329A (zh) * | 2005-03-28 | 2006-10-04 | 华为技术有限公司 | 对目标文件进行定位的方法和装置 |
CN101470619A (zh) * | 2007-12-29 | 2009-07-01 | 安凯(广州)软件技术有限公司 | 一种基于微核操作系统的应用程序动态加载方法 |
CN102819439A (zh) * | 2011-06-10 | 2012-12-12 | 中兴通讯股份有限公司 | 一种基于重定位的多制式应用程序的动态加载方法和装置 |
CN107391190A (zh) * | 2017-07-18 | 2017-11-24 | 杭州中天微系统有限公司 | 一种程序模块动态装载方法 |
CN111506491A (zh) * | 2019-01-31 | 2020-08-07 | 阿里巴巴集团控股有限公司 | 信息处理方法及装置、存储介质和处理器 |
CN111736839A (zh) * | 2019-03-25 | 2020-10-02 | 华为技术有限公司 | 一种编译链接方法及装置 |
-
2021
- 2021-05-10 CN CN202110507123.4A patent/CN115328454A/zh active Pending
-
2022
- 2022-05-05 WO PCT/CN2022/090916 patent/WO2022237610A1/fr active Application Filing
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6704928B1 (en) * | 1999-09-03 | 2004-03-09 | Stmicroelectronics Limited | Relocation format for linking |
CN1841329A (zh) * | 2005-03-28 | 2006-10-04 | 华为技术有限公司 | 对目标文件进行定位的方法和装置 |
CN101470619A (zh) * | 2007-12-29 | 2009-07-01 | 安凯(广州)软件技术有限公司 | 一种基于微核操作系统的应用程序动态加载方法 |
CN102819439A (zh) * | 2011-06-10 | 2012-12-12 | 中兴通讯股份有限公司 | 一种基于重定位的多制式应用程序的动态加载方法和装置 |
CN107391190A (zh) * | 2017-07-18 | 2017-11-24 | 杭州中天微系统有限公司 | 一种程序模块动态装载方法 |
CN111506491A (zh) * | 2019-01-31 | 2020-08-07 | 阿里巴巴集团控股有限公司 | 信息处理方法及装置、存储介质和处理器 |
CN111736839A (zh) * | 2019-03-25 | 2020-10-02 | 华为技术有限公司 | 一种编译链接方法及装置 |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2024169933A1 (fr) * | 2023-02-17 | 2024-08-22 | 苏州元脑智能科技有限公司 | Système et procédé d'optimisation d'espace vectoriel d'exception de programme, dispositif et support |
CN117075960A (zh) * | 2023-10-17 | 2023-11-17 | 统信软件技术有限公司 | 程序重构方法、应用跨平台迁移方法、装置与计算设备 |
CN117075960B (zh) * | 2023-10-17 | 2024-01-23 | 统信软件技术有限公司 | 程序重构方法、应用跨平台迁移方法、装置与计算设备 |
Also Published As
Publication number | Publication date |
---|---|
CN115328454A (zh) | 2022-11-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2022237610A1 (fr) | Procédé de compilation de programme et procédé de chargement de programme | |
EP3377968B1 (fr) | Mise à jour dynamique d'une application dans une compilation, et mise en oeuvre | |
EP3035191B1 (fr) | Identification d'un code source utilisé pour construire des fichiers exécutables | |
US10140119B2 (en) | Modular serialization | |
WO2017193885A1 (fr) | Procédé et appareil de lancement d'application | |
US20190004774A1 (en) | Automated source code adaption to inject features between platform versions | |
CN109597621B (zh) | 封装Dagger的方法、装置、终端设备及存储介质 | |
US20070169011A1 (en) | Delayed loading and instantiation of resources defined in markup | |
US20170351506A1 (en) | Automating feature graduation | |
WO2023213263A1 (fr) | Procédé de compilation de programme, procédé de démarrage de programme, et dispositif et support de stockage | |
CN108021370B (zh) | 字节码的优化方法、装置、存储介质、处理器及终端 | |
CN110399384A (zh) | Udf适配方法、数据处理方法、设备及存储介质 | |
KR20220113372A (ko) | 통합된 참조물 및 2차 객체 표시 | |
US11048489B2 (en) | Metadata application constraints within a module system based on modular encapsulation | |
US10733095B2 (en) | Performing garbage collection on an object array using array chunk references | |
CN108153530B (zh) | 字节码的优化方法、装置、存储介质、处理器及终端 | |
US20200356384A1 (en) | Intelligently determining a virtual machine configuration during runtime based on garbage collection characteristics | |
CN114077575B (zh) | 用于内存快照文件的格式转换方法、设备和系统 | |
US9720660B2 (en) | Binary interface instrumentation | |
US20150278089A1 (en) | Execution control method and execution control apparatus | |
US10891213B2 (en) | Converting between a carried thread and a carrier thread for debugging the carried thread | |
CN115454439A (zh) | 编译优化方法、装置、电子设备及计算机可读介质 | |
Shixiang et al. | Portability of Dalvik in iOS | |
CN117519691A (zh) | 应用程序处理方法、装置、计算机设备和存储介质 | |
CN113282329A (zh) | 一种在线定制系统固件的方法、装置、设备及存储介质 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 22806578 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 22806578 Country of ref document: EP Kind code of ref document: A1 |