CN117850916A - Application program loading method and device, readable storage medium and terminal equipment - Google Patents
Application program loading method and device, readable storage medium and terminal equipment Download PDFInfo
- Publication number
- CN117850916A CN117850916A CN202410036081.4A CN202410036081A CN117850916A CN 117850916 A CN117850916 A CN 117850916A CN 202410036081 A CN202410036081 A CN 202410036081A CN 117850916 A CN117850916 A CN 117850916A
- Authority
- CN
- China
- Prior art keywords
- application
- application program
- memory
- symbol table
- kernel
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 230000015654 memory Effects 0.000 claims abstract description 148
- 238000011068 loading method Methods 0.000 claims abstract description 65
- 238000000034 method Methods 0.000 claims abstract description 52
- 230000008569 process Effects 0.000 claims abstract description 28
- 238000004590 computer program Methods 0.000 claims description 23
- 238000011084 recovery Methods 0.000 claims description 3
- 238000004806 packaging method and process Methods 0.000 abstract 1
- 230000006870 function Effects 0.000 description 14
- 238000010586 diagram Methods 0.000 description 4
- 238000012545 processing Methods 0.000 description 4
- 238000004064 recycling Methods 0.000 description 4
- 230000004044 response Effects 0.000 description 4
- 230000006978 adaptation Effects 0.000 description 3
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 238000001514 detection method Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 238000004364 calculation method Methods 0.000 description 2
- 238000004891 communication Methods 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004422 calculation algorithm Methods 0.000 description 1
- 230000007423 decrease Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Classifications
-
- 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
-
- 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
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The application belongs to the technical field of computers, and particularly relates to an application program loading method, an application program loading device, a computer readable storage medium and terminal equipment. The method comprises the following steps: compiling and linking the kernel program to obtain a kernel symbol table; according to the kernel symbol table, externally linking the application program on a link terminal; wherein the external link includes an address relocation procedure; and loading the application program. By the method, the compiling link can be carried out on the application program before the application program is loaded, and the address repositioning is carried out in the compiling link process, so that the need of packaging a repositioning table and a symbol into a FLASH or a hard disk and other nonvolatile memories to carry out the address repositioning after the compiling of the application program is completed is eliminated, the nonvolatile storage space is saved, and the loading speed of the application program is improved.
Description
Technical Field
The application belongs to the technical field of computers, and particularly relates to an application program loading method, an application program loading device, a computer readable storage medium and terminal equipment.
Background
When an application program is dynamically loaded, the memory address is usually uncertain, and in order to ensure that the application program can correctly access and call various functions and variables, address repositioning is usually required for the application program. However, in the prior art, when the address relocation is performed on the application program, the relocation table and the symbol table need to be packed into a FLASH memory (FLASH) or a nonvolatile memory device such as a hard disk, so that a large amount of nonvolatile memory space is occupied, and the loading speed of the application program is low.
Disclosure of Invention
In view of this, the embodiments of the present application provide an application loading method, apparatus, computer readable storage medium, and terminal device, so as to solve the problem that in the prior art, a large amount of nonvolatile storage space is required to be occupied when address relocation is performed, which also results in low application loading speed.
A first aspect of an embodiment of the present application provides an application loading method, which may include:
compiling and linking the kernel program to obtain a kernel symbol table;
according to the kernel symbol table, externally linking the application program on a link terminal; wherein the external link includes an address relocation procedure;
and loading the application program.
In a specific implementation manner of the first aspect, the externally linking, according to the kernel symbol table, the application program on the link terminal may include:
acquiring a link end address of the kernel program;
and carrying out external link on the application program on a link terminal according to the kernel symbol table and the link ending address.
In a specific implementation manner of the first aspect, the address relocation procedure may include:
obtaining a relocatable file of the application program;
and carrying out address relocation on the application program according to the relocatable file and the kernel symbol table.
In a specific implementation manner of the first aspect, the address relocation for the application program according to the relocatable file and the kernel symbol table may include:
reading an application symbol table and a relocation table from the relocatable file;
determining a combined symbol table according to the kernel symbol table and the application program symbol table;
determining relocation code segments and symbol table labels according to the relocation table;
determining a jump memory address according to the symbol table label and the combined symbol table;
and modifying the relocation code section according to the jump memory address.
In a specific implementation manner of the first aspect, the loading the application program with the application program may include:
starting the kernel program;
loading the application program into a reserved memory; and the reservation is distributed in the initialization process of the operating system.
In a specific implementation manner of the first aspect, the allocating process of the reserved memory includes:
calculating the memory occupation of the application program;
determining the reserved memory according to the memory occupation of the application program; wherein, the reserved memory is larger than or equal to the memory occupation of the application program;
and in the initialization process of the operating system, the reserved memory is allocated.
In a specific implementation manner of the first aspect, after the loading the application program into the reserved memory, the method may further include:
if the residual memory exists, performing memory recovery on the residual memory; and the residual memory is unoccupied memory in the reserved memory after the application program is loaded.
A second aspect of the embodiments of the present application provides an application loading device, which may include:
the compiling link module is used for compiling and linking the kernel program to obtain a kernel symbol table;
the external link module is used for externally linking the application program on the link terminal according to the kernel symbol table; wherein the external link includes an address relocation procedure;
and the application loading module is used for loading the application program.
In a specific implementation manner of the second aspect, the external link module may include:
an end address obtaining sub-module, configured to obtain a link end address of the kernel program;
and the external link sub-module is used for carrying out external link on the application program on a link terminal according to the kernel symbol table and the link ending address.
In a specific implementation manner of the second aspect, the application loading device may further include:
a relocatable file acquisition module for acquiring a relocatable file of the application program;
and the address repositioning module is used for repositioning the address of the application program according to the repositionable file and the kernel symbol table.
In a specific implementation manner of the second aspect, the address relocation module may include:
a relocatable file reading sub-module for reading an application symbol table and a relocation table from the relocatable file;
a combined symbol table determining sub-module, configured to determine a combined symbol table according to the kernel symbol table and the application symbol table;
a repositioning information determining sub-module for determining repositioning code segment and symbol table label according to the repositioning table;
the jump memory address determining submodule is used for determining the jump memory address according to the symbol table label and the combined symbol table;
and the code segment modification submodule is used for modifying the repositioning code segment according to the jump memory address.
In a specific implementation manner of the second aspect, the application loading module may include:
the kernel program starting module is used for starting the kernel program;
an application program loading sub-module for loading the application program into a reserved memory; and the reservation is distributed in the initialization process of the operating system.
In a specific implementation manner of the second aspect, the application loading module may further include:
the memory occupation calculation module is used for calculating the memory occupation of the application program;
a reserved memory determining module, configured to determine the reserved memory according to the memory occupation of the application; wherein, the reserved memory is larger than or equal to the memory occupation of the application program;
and the memory allocation module is used for allocating the reserved memory in the initialization process of the operating system.
In a specific implementation manner of the second aspect, the application loading device may further include:
the memory recycling module is used for recycling the memory of the residual memory if the residual memory exists; and the residual memory is unoccupied memory in the reserved memory after the application program is loaded.
A third aspect of the embodiments of the present application provides a computer-readable storage medium storing a computer program which, when executed by a processor, implements the steps of any of the application loading methods described above.
A fourth aspect of the embodiments of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of any one of the application loading methods described above when the processor executes the computer program.
A fifth aspect of the embodiments of the present application provides a computer program product for causing a terminal device to perform the steps of any one of the application loading methods described above when the computer program product is run on the terminal device.
Compared with the prior art, the embodiment of the application has the beneficial effects that: according to the embodiment of the application, compiling and linking are carried out on the kernel program to obtain a kernel symbol table; according to the kernel symbol table, externally linking the application program on a link terminal; wherein the external link includes an address relocation procedure; and loading the application program. By the method, the external link can be carried out on the application program on the link terminal before the application program is loaded, and the address relocation is carried out in the process of the external link, so that the relocation table and the symbol table do not need to be packed into a nonvolatile memory such as FLASH or a hard disk for address relocation after the compiling of the application program is completed, the nonvolatile memory space is saved, and the loading speed of the application program is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following description will briefly introduce the drawings that are needed in the embodiments or the description of the prior art, it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of one embodiment of a method for loading an application program according to the embodiments of the present application;
FIG. 2 is a block diagram of one embodiment of an application loading device according to the embodiments of the present application;
fig. 3 is a schematic block diagram of a terminal device in an embodiment of the present application.
Detailed Description
In order to make the objects, features and advantages of the present invention more obvious and understandable, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is apparent that the embodiments described below are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
It should be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in this specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
As used in this specification and the appended claims, the term "if" may be interpreted as "when..once" or "in response to a determination" or "in response to detection" depending on the context. Similarly, the phrase "if a determination" or "if a [ described condition or event ] is detected" may be interpreted in the context of meaning "upon determination" or "in response to determination" or "upon detection of a [ described condition or event ]" or "in response to detection of a [ described condition or event ]".
In addition, in the description of the present application, the terms "first," "second," "third," etc. are used merely to distinguish between descriptions and are not to be construed as indicating or implying relative importance.
When an application program is dynamically loaded, dynamic memory needs to be applied to a kernel, and a memory address is usually uncertain, so that a link address of the application program needs to be mapped to an address where the application program actually runs, for example, a function a accesses a variable x, and addresses when a and x are loaded into the memory and addresses when the a and x are compiled are usually inconsistent. In order to ensure that the application program can access and call various functions and variables correctly, address relocation is usually required for the application program, in the above example, the address of a accessing x needs to be remapped, so that a can access x smoothly, and normal operation of the application program is ensured.
However, in the prior art, when the address relocation is performed on the application program, the relocation table and the symbol table need to be packed into a nonvolatile storage device such as a FLASH or a hard disk, and then copied into a memory, and because the nonvolatile storage device on the terminal device is usually smaller, for example, the FLASH on the network camera (Internet Protocol Camera, IPC) is usually in a smaller specification such as 4 megabytes, 8 megabytes or 16 megabytes, the relocation table and the symbol table usually need to occupy a space of 500 kilobytes to 1 megabyte, which causes a large amount of FLASH resources or hard disk resources to be occupied, and causes that the loading speed of the application program is not high.
In view of this, the embodiments of the present application provide an application loading method, apparatus, computer readable storage medium, and terminal device, so as to solve the problem that in the prior art, a large amount of nonvolatile storage space is required to be occupied when address relocation is performed, which also results in low application loading speed.
It should be noted that, the execution body of the method of the present application is a terminal device, specifically, may be a computing device of a common application Real-time operating system (Real-Time Operating System, RTOS) such as a tablet computer, a notebook computer, an intelligent monitor, an intelligent home appliance, or may be other computing devices.
Referring to fig. 1, an embodiment of an application loading method in an embodiment of the present application may include:
and step S101, compiling and linking the kernel program to obtain a kernel symbol table.
In the embodiment of the application, a preset compiling and linking tool may be specifically used to compile and link the kernel program; wherein the compilation linking tool may include, but is not limited to, a cross-tool chain, and the cross-tool chain may include at least a compiler for compilation and a linker for linking.
Specifically, during the compilation of the kernel, the compiler may compile the source code of the kernel into a relocatable file. The linker may then link the kernel; in linking the kernel program, functions and variables used in the kernel program may be matched with their definitions and linked together to form an executable file. In the link process, the addresses of all parts (code segment, data segment, BSS segment, interrupt stack space) of the kernel program in the memory can be fixed; after the linking is completed, a kernel symbol table can be generated; the kernel symbol table may include a kernel symbol and a physical address corresponding to the kernel symbol.
In one specific implementation, one example of a kernel symbol table may be as follows: abt_stack_size=0x 00000500;
AESDMA_Verify=0x21b21ab9;
AES_KEY=0x21d9daa0;
AE_Acc_Pre.30276=0x21e6153c;
AE_Apex2Plain=0x21c06549;
wherein, each kernel symbol and the physical address corresponding to the kernel symbol can be recorded in the kernel symbol table. In the above example, from the kernel symbol table, the physical address corresponding to each kernel symbol and each kernel symbol can be known, for example, the physical address corresponding to the kernel symbol "abt_stack_size" can be known to be "0x00000500", and the physical address corresponding to the kernel symbol "aesdma_verify" is "0x21b21ab9".
In addition, other compiling and linking tools can be used in the kernel compiling and linking process according to practical situations, which is not particularly limited in the application.
And step S102, externally linking the application program on the link terminal according to the kernel symbol table.
Specifically, the process of externally linking the application program according to the embodiment of the present application may include an address relocation process.
In the embodiment of the application, the application program can be compiled and linked by using a compiling and linking tool which is the same as the compiling and linking process of the kernel program; the compiling and linking tool may generally include a compiler, a linker, and other tools. Specifically, during compilation of an application, a compiler may compile source code of the application into executable machine code, and may generate a relocatable file from the source code; the linker may then externally link the application program on a link terminal, where the link terminal may be a terminal device (e.g. a personal computer (Personal Computer, PC)) for externally linking the application program, and the link terminal of the embodiment of the present application is different from a terminal device (a terminal device of an application RTOS system) for loading the application program, that is, the linking and loading of the application program may be performed on two different terminal devices, respectively; here, the link end address (usually the address of the BSS segment) of the kernel program may be obtained according to the link script, and the link end address may be used as the link start address of the application program, where the application program is externally linked, so that the problem of address conflict between the kernel program and the application program may be avoided, and smooth execution of compiling the link may be ensured.
When an application is externally linked, a kernel symbol table may be used and used as an external link symbol table.
In a specific implementation manner of the embodiment of the present application, the symbol table file used by the linker may be specified by using the command line parameter, and the kernel symbol table may be specified as the external link symbol table. Specifically, the command line parameters —wl, -, just-symbols=symbols may be used to designate the kernel symbol table as an externally linked symbol table, where symbols is the derived kernel symbol table file.
In the external linking process, a relocatable file generated in the compiling process can be obtained, and address relocation can be performed on the application program according to the relocatable file and the kernel symbol table of the application program.
Specifically, the application symbol table and relocation table may be read from the relocatable file; the relocatable file may be a file in executable and linkable format (Executable and Linkable Format, ELF), and the ELF header of the relocatable file records the architecture, the processor bit width, the file type (one of the relocatable file, the executable file and the dynamic library file), the number of section tables, the position of the section tables, and the like of the application program, and the section tables are descriptions of sections (sections), and may specifically contain information of the type, the position, the size, and the like of the sections, and the sections are a set formed by the same type of data; for example, the code may constitute a text section, the data may constitute a data section, the read-only data may constitute a rodata section, and the symbol table may be a symtab section.
In the embodiment of the present application, the node table may be read from the relocatable file according to the position of the node table, and the application symbol table (may be a symtab) may be read from the relocatable file according to the node table, and then the merge symbol table may be determined according to the kernel symbol table and the application symbol table, and specifically, the kernel symbol table and the application symbol table may be merged to obtain the merge symbol table.
Thereafter, a relocation table (which may be called a relocation segment, and may generally include. Rel.text,. Rel.data … … rel.rodata, and/or. Rel.bss) may also be read from the relocatable file, and the application may be address relocated based on the relocation table and the merge symbol table. Specifically, the relocation table may include entries, where each entry may correspond to a relocation code section that needs to be relocated; according to each entry of the relocation table, each relocation code section needing relocation can be determined, and the symbol table label corresponding to the relocation code section can be determined; the symbol table labels can be used for distinguishing each entry in the combined symbol table, and the entry corresponding to the symbol table label can be positioned in the combined symbol table according to the determined symbol table label; then, according to the corresponding item of the symbol table label, determining the symbol value in the item, wherein the symbol value is the jump memory address corresponding to the relocation code section; the addresses in the relocated code segments may be modified based on the type of relocated code segments and the corresponding jump memory addresses.
For ease of understanding, the process of address relocation will be described below in connection with specific examples.
Each entry in the relocation table may include two parts of Offset address information (Offset) and relocation information (Info) of the relocation code section, and the specific format of the entry in the relocation table may be:
Offset | Info |
wherein the offset address information of the relocation code section may indicate the offset address of the relocation code section in the relocation table, and the relocation information may include a relocation type and a symbol table reference number. Through one entry of the relocation table, the offset address of the relocation code section corresponding to the entry in the relocation table, the relocation type of the relocation code section and the symbol table label corresponding to the relocation code section can be determined.
And the specific format of the entries in the combined symbol table may be:
each entry in the merged Symbol table may include six parts, namely, symbol Name (Symbol Name), symbol information (Symbol Info), other Symbol information (Symbol Other), index (Section Index) of the Section where the Symbol is located, symbol Value (Symbol Value), and Symbol Size (Symbol Size); in particular, a symbolic name may represent the name of a symbol, typically a function name, variable name, or other identifier; the symbol information may describe the type of symbol and binding information, and may be, for example, a function, global variable, local variable, and the like; other symbol information may be other information of a symbol, which may include, but is not limited to, visibility of the symbol, storage category, etc.; the index of the section where the symbol is located may indicate the index of the section where the symbol is located, i.e. the section or segment where the symbol is located; the symbol value may represent a numeric value of the symbol, typically a memory address of the symbol; the symbol size may be the size of a symbol, typically the size of a space occupied by a variable or function.
For example, the offset address information of an entry in the relocation table may be 0000000e, which may indicate that the offset address of the relocation code segment corresponding to the entry in the relocation table is Oxe, the relocation information may be 00b3340a, the lowest byte in the relocation information is 0xa, it may be determined that the relocation type of the relocation code segment is r_arm_thm_call according to the corresponding relationship between the preset number and the relocation type, and the high byte in the relocation information is 0xb334, which may indicate that the jump memory address corresponding to the relocation code segment is recorded in the 0xb334 entry of the merging symbol table. By reading the symbol value of the 0xb334 entry in the merged symbol table, the jump memory address corresponding to the relocated code segment can be obtained, and then the address in the relocated code segment can be modified into the jump memory address, so that the application program can correctly access and call various functions and variables during operation.
After the external linking is completed, the linked executable file may be stored in a file system, where the file system is typically managed by a kernel, there may be multiple file systems in one operating system, and the file system storing the program may be typically a FLASH-based Read-only file system (Read-Only Memory File System, romafs).
Compared with the scheme of linking the application program during loading in the prior art, the method can carry out address relocation when the external linking of the application program is carried out, so that a relocation table and a symbol table do not need to be packed into a nonvolatile memory such as a Flash or a hard disk after compiling of the application program is completed, the nonvolatile memory space can be saved, and the loading speed of the application program is improved.
Step S103, loading the application program.
It should be noted that, in order to ensure that the physical address corresponding to the application program is not occupied in the operating system when the external link is performed, a preset memory space may be reserved, and the application program may be loaded by using the memory space. Specifically, the operating system may manage the heap space, and when the operating system is initialized, a larger memory space (denoted as reserved memory) may be partitioned, and the reserved memory may not be allocated to the heap space, so that the reserved memory may be used for loading an application program.
In the embodiment of the application, the memory occupation of the application program can be calculated, and the reserved memory can be determined according to the memory occupation of the application program; the reserved memory can be larger than or equal to the memory occupation of the application program; the reserved memory may then be allocated during the operating system initialization process. The specific size of the reserved memory may be set according to the actual memory occupation of the application, where the reserved memory may be preferably set to a larger value than the memory occupation of the application, so as to ensure that there is enough reserved memory for loading of the application.
In a specific implementation manner, the size of the application program can be calculated according to the code, data and other conditions of the application program, so as to estimate and predict the memory occupation of the application program after loading.
In the embodiment of the present application, the kernel may be started, and then the application may be loaded into the reserved memory.
Since the reserved memory in the embodiment of the application is set to a value larger than the memory occupation of the application, when the application is loaded, the reserved memory may have unoccupied memory (referred to as residual memory), and the residual memory does not exist in the heap space or used by the application, which is easy to cause memory waste.
Therefore, in the embodiment of the present application, after the application program is loaded, if there is a remaining memory, memory recovery may be performed on the remaining memory; specifically, the residual memory can be recycled to the heap space, so that the residual memory can be provided for other application programs for use, and the memory utilization rate and the system performance can be improved.
Compared with the scheme of dynamic memory allocation when the application program is loaded in the prior art, the scheme of the application can divide the reserved memory when the operating system is initialized, and can recover the residual memory after the application program is loaded, so that the smooth operation of external linkage of the application program can be ensured, and the memory utilization rate can be improved. In addition, because special relocation tool adaptation (for example, hardware adaptation of a memory management unit (Memory Management Unit, MMU) and a monitor Call (SVC) mechanism) are not needed in the scheme, hardware resources can be saved, and the adaptation difficulty of an application program loading method can be reduced.
In summary, in the embodiment of the present application, compiling and linking are performed on the kernel program to obtain the kernel symbol table; according to the kernel symbol table, externally linking the application program on a link terminal; wherein the external link includes an address relocation procedure; and loading the application program. By the method, the external link can be carried out on the application program on the link terminal before the application program is loaded, and the address relocation is carried out in the process of the external link, so that the relocation table and the symbol table do not need to be packed into a nonvolatile memory such as FLASH or a hard disk for address relocation after the compiling of the application program is completed, the nonvolatile memory space is saved, and the loading speed of the application program is improved.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic of each process, and should not limit the implementation process of the embodiment of the present application in any way.
Corresponding to the application loading method described in the above embodiments, fig. 2 shows a block diagram of an embodiment of an application loading device provided in the embodiment of the present application.
In an embodiment of the present application, an application loading device may include:
a compiling link module 201, configured to compile and link the kernel program to obtain a kernel symbol table;
an external link module 202, configured to externally link an application program on a link terminal according to the kernel symbol table; wherein the external link includes an address relocation procedure;
and the application loading module 203 is configured to load an application program for the application program.
In a specific implementation manner of the embodiment of the present application, the external link module may include:
an end address obtaining sub-module, configured to obtain a link end address of the kernel program;
and the external link sub-module is used for carrying out external link on the application program on a link terminal according to the kernel symbol table and the link ending address.
In a specific implementation manner of the embodiment of the present application, the application loading device may further include:
a relocatable file acquisition module for acquiring a relocatable file of the application program;
and the address repositioning module is used for repositioning the address of the application program according to the repositionable file and the kernel symbol table.
In a specific implementation manner of the embodiment of the present application, the address relocation module may include:
a relocatable file reading sub-module for reading an application symbol table and a relocation table from the relocatable file;
a combined symbol table determining sub-module, configured to determine a combined symbol table according to the kernel symbol table and the application symbol table;
a repositioning information determining sub-module for determining repositioning code segment and symbol table label according to the repositioning table;
the jump memory address determining submodule is used for determining the jump memory address according to the symbol table label and the combined symbol table;
and the code segment modification submodule is used for modifying the repositioning code segment according to the jump memory address.
In a specific implementation manner of the embodiment of the present application, the application loading module may include:
the kernel program starting module is used for starting the kernel program;
an application program loading sub-module for loading the application program into a reserved memory; and the reservation is distributed in the initialization process of the operating system.
In a specific implementation manner of the embodiment of the present application, the application loading device may further include:
the memory occupation calculation module is used for calculating the memory occupation of the application program;
a reserved memory determining module, configured to determine the reserved memory according to the memory occupation of the application; wherein, the reserved memory is larger than or equal to the memory occupation of the application program;
and the memory allocation module is used for allocating the reserved memory in the initialization process of the operating system.
In a specific implementation manner of the embodiment of the present application, the application loading device may further include:
the memory recycling module is used for recycling the memory of the residual memory if the residual memory exists; and the residual memory is unoccupied memory in the reserved memory after the application program is loaded.
It will be clearly understood by those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described apparatus, modules and units may refer to corresponding procedures in the foregoing method embodiments, and are not repeated herein.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Fig. 3 shows a schematic block diagram of a terminal device provided in an embodiment of the present application, and for convenience of explanation, only a portion relevant to the embodiment of the present application is shown.
As shown in fig. 3, the terminal device 3 of this embodiment includes: a processor 30, a memory 31 and a computer program 32 stored in said memory 31 and executable on said processor 30. The steps of the respective application loading method embodiments described above, such as steps S101 to S103 shown in fig. 1, are implemented when the processor 30 executes the computer program 32. Alternatively, the processor 30 may implement the functions of the modules/units in the above-described device embodiments when executing the computer program 32, such as the functions of the modules 201 to 203 shown in fig. 2.
By way of example, the computer program 32 may be partitioned into one or more modules/units that are stored in the memory 31 and executed by the processor 30 to complete the present application. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions for describing the execution of the computer program 32 in the terminal device 3.
It will be appreciated by those skilled in the art that fig. 3 is merely an example of the terminal device 3 and does not constitute a limitation of the terminal device 3, and may comprise more or less components than shown, or may combine certain components, or different components, e.g. the terminal device 3 may further comprise input and output devices, network access devices, buses, etc.
The processor 30 may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 31 may be an internal storage unit of the terminal device 3, such as a hard disk or a memory of the terminal device 3. The memory 31 may be an external storage device of the terminal device 3, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) or the like, which are provided on the terminal device 3. Further, the memory 31 may also include both an internal storage unit and an external storage device of the terminal device 3. The memory 31 is used for storing the computer program as well as other programs and data required by the terminal device 3. The memory 31 may also be used for temporarily storing data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other manners. For example, the apparatus/terminal device embodiments described above are merely illustrative, e.g., the division of the modules or units is merely a logical function division, and there may be additional divisions in actual implementation, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated modules/units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application may implement all or part of the flow of the method of the above embodiment, or may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program may implement the steps of each method embodiment described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable storage medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the computer readable storage medium may include content that is subject to appropriate increases and decreases as required by jurisdictions and by jurisdictions in which such computer readable storage medium does not include electrical carrier signals and telecommunications signals.
The above embodiments are only for illustrating the technical solution of the present application, and are not limiting; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.
Claims (10)
1. An application loading method, comprising:
compiling and linking the kernel program to obtain a kernel symbol table;
according to the kernel symbol table, externally linking the application program on a link terminal; wherein the external link includes an address relocation procedure;
and loading the application program.
2. The application loading method according to claim 1, wherein said externally linking the application on the link terminal according to the kernel symbol table comprises:
acquiring a link end address of the kernel program;
and carrying out external link on the application program on a link terminal according to the kernel symbol table and the link ending address.
3. The application loading method according to claim 1, wherein the address relocation process includes:
obtaining a relocatable file of the application program;
and carrying out address relocation on the application program according to the relocatable file and the kernel symbol table.
4. The application loading method according to claim 3, wherein said address relocating said application according to said relocatable file and said kernel symbol table comprises:
reading an application symbol table and a relocation table from the relocatable file;
determining a combined symbol table according to the kernel symbol table and the application program symbol table;
determining relocation code segments and symbol table labels according to the relocation table;
determining a jump memory address according to the symbol table label and the combined symbol table;
and modifying the relocation code section according to the jump memory address.
5. The application loading method according to any one of claims 1 to 4, characterized in that the application loading of the application comprises:
starting the kernel program;
loading the application program into a reserved memory; and the reservation is distributed in the initialization process of the operating system.
6. The application loading method according to claim 5, wherein the allocation process of the reserved memory includes:
calculating the memory occupation of the application program;
determining the reserved memory according to the memory occupation of the application program; wherein, the reserved memory is larger than or equal to the memory occupation of the application program;
and in the initialization process of the operating system, the reserved memory is allocated.
7. The application loading method according to claim 5, further comprising, after said loading the application into the reserved memory:
if the residual memory exists, performing memory recovery on the residual memory; and the residual memory is unoccupied memory in the reserved memory after the application program is loaded.
8. An application loading apparatus, comprising:
the compiling link module is used for compiling and linking the kernel program to obtain a kernel symbol table;
the external link module is used for externally linking the application program on the link terminal according to the kernel symbol table; wherein the external link includes an address relocation procedure;
and the application loading module is used for loading the application program.
9. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the steps of the application loading method according to any one of claims 1 to 7.
10. Terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the application loading method according to any of claims 1 to 7 when the computer program is executed.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410036081.4A CN117850916A (en) | 2024-01-08 | 2024-01-08 | Application program loading method and device, readable storage medium and terminal equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410036081.4A CN117850916A (en) | 2024-01-08 | 2024-01-08 | Application program loading method and device, readable storage medium and terminal equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117850916A true CN117850916A (en) | 2024-04-09 |
Family
ID=90541453
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410036081.4A Pending CN117850916A (en) | 2024-01-08 | 2024-01-08 | Application program loading method and device, readable storage medium and terminal equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117850916A (en) |
-
2024
- 2024-01-08 CN CN202410036081.4A patent/CN117850916A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN113868155B (en) | Memory space expansion method and device, electronic equipment and storage medium | |
US8434064B2 (en) | Detecting memory errors using write integrity testing | |
CN103853665B (en) | Memory allocation method and apparatus | |
US5297285A (en) | System for dynamically linking modular portions of computer software | |
US8578357B2 (en) | Endian conversion tool | |
US20080005728A1 (en) | Methods, systems, and computer program products for enabling cross language access to an addressable entity in an execution environment | |
US20060064576A1 (en) | Boot systems and methods | |
US20050066108A1 (en) | Managing peripheral device address space resources using a tunable bin-packing/knapsack algorithm | |
US20080005727A1 (en) | Methods, systems, and computer program products for enabling cross language access to an addressable entity | |
GB2083254A (en) | Address translation and generation mechanism in information processing system | |
US20040019774A1 (en) | Processor device and information processing device, compiling device, and compiling method using said processor device | |
EP4231138A1 (en) | Method and apparatus for fixing weak memory ordering problem | |
CN111767056A (en) | Source code compiling method, executable file running method and terminal equipment | |
CN113468079A (en) | Memory access method and device | |
CN117573419A (en) | Page exception handling method and device | |
WO2023208012A1 (en) | Program processing method and apparatus, program running method and apparatus, terminal, smart card and storage medium | |
US7293207B2 (en) | Method for testing memory in a computer system utilizing a CPU with either 32-bit or 36-bit memory addressing | |
KR102658600B1 (en) | Apparatus and method for accessing metadata when debugging a device | |
US7979606B2 (en) | Method for storing data | |
CN117850916A (en) | Application program loading method and device, readable storage medium and terminal equipment | |
CN115994348A (en) | Control method for program pipeline, processing device and storage medium | |
CN117667228A (en) | Method, system, computer equipment and storage medium for calibrating chip parameters | |
CN114416057A (en) | Project code packaging method and device, terminal equipment and storage medium | |
US11055202B1 (en) | Compilation scheme for tagged global variables | |
CN115167862A (en) | Patch method and related equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |