Disclosure of Invention
In view of this, the present invention provides a hot update method for an application program, which can load an ELF file corresponding to the application program in a memory, so as to implement hot update of the application program, and after the update is completed, the application program is not restarted, so as to provide a better service for a user and improve the user experience. The invention also provides a hot updating device of the application program, which is used for supporting the realization and the application of the hot updating method of the application program in practice.
In order to achieve the purpose, the invention provides the following technical scheme:
a method of hot-updating an application, comprising:
when detecting an executable ELF file in a linkable format corresponding to a current application program, acquiring each loadable segment in the ELF file;
mapping each loadable segment to a corresponding memory;
determining a pointer node area of each loadable segment, calling a function pointer in the pointer node area, and executing a code corresponding to the function pointer in the loadable segment in the memory so as to update the code to the application program;
and when the code in each loadable segment is updated to the current application program, completing the loading of the ELF file in the memory so as to realize the hot update of the application program.
Optionally, the obtaining of each loadable segment in the ELF file includes:
acquiring a program header table in the ELF file;
reading each program head in the program head table;
determining whether the attribute parameters of each program header represent loadable attributes;
and if the attribute parameters of the program header represent loadable attributes, acquiring a loadable segment corresponding to the program header in the ELF file.
Optionally, the mapping each loadable segment to its corresponding memory includes:
determining a segment length for each of the loadable segments;
according to the length of each loadable segment, allocating a memory corresponding to the loadable segment;
and acquiring each loading parameter of each loadable segment, and mapping the loadable segment to a corresponding memory according to each loading parameter.
The above method, optionally, further includes:
judging whether the ELF file is encrypted by using a preset encryption algorithm;
if the ELF file is judged to be encrypted by using a preset encryption algorithm, determining a decryption algorithm corresponding to the encryption algorithm;
and decrypting the ELF file by using the decryption algorithm to obtain the decrypted ELF file.
Optionally, in the method, the determining a pointer section area of each loadable segment, calling a function pointer in the pointer section area, and executing a code corresponding to the function pointer in the loadable segment in the memory includes:
acquiring a pointer section identifier of the loadable segment, and determining a corresponding pointer section in the loadable segment according to the pointer section identifier;
acquiring a loader identifier in the loadable segment, and determining a loader corresponding to the loader identifier;
and calling a function pointer in the pointer node area, wherein the function pointer corresponds to a code in the loadable segment, and the loader is used for executing the code in the memory.
Optionally, the method for acquiring, in the ELF file, a loadable segment corresponding to the program header includes:
acquiring an offset parameter and a length parameter in the program header;
determining an offset position in the ELF file according to the offset parameter;
determining a data segment in the ELF file, starting from the offset position, which is consistent with the data length characterized by the length parameter;
and determining the data segment as a loadable segment corresponding to the program header.
The above method, optionally, further includes:
and when the loading of the ELF file in the memory is completed, clearing the loadable segment in the memory and the execution trace of the code.
A device for hot-updating an application, comprising:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring each loadable segment in an ELF file when detecting the ELF file in an executable and linkable format corresponding to a current application program;
a mapping unit, configured to map each loadable segment to a corresponding memory;
a first determining unit, configured to determine a pointer node area of each loadable segment, call a function pointer in the pointer node area, and execute, in the memory, a code corresponding to the function pointer in the loadable segment, so as to update the code into the application program;
and the loading unit is used for finishing the loading of the ELF file in the memory when the code in each loadable segment is updated to the current application program so as to realize the hot updating of the application program.
The above apparatus, the acquiring unit, includes:
the first acquiring subunit is used for acquiring a program header table in the ELF file;
a reading subunit, configured to read each program header in the program header table;
a first determining subunit, configured to determine whether an attribute parameter of each program header represents a loadable attribute;
and the second obtaining subunit is configured to, if the attribute parameter of the program header represents a loadable attribute, obtain, in the ELF file, a loadable segment corresponding to the program header.
The above apparatus, optionally, the mapping unit includes:
a second determining subunit, configured to determine a segment length of each of the loadable segments;
the allocation subunit is configured to allocate, according to the segment length of each loadable segment, a memory corresponding to the loadable segment;
and the mapping subunit is configured to acquire each loading parameter of each loadable segment, and map the loadable segment to a corresponding memory according to each loading parameter.
The above apparatus, optionally, further comprises:
the judging unit is used for judging whether the ELF file is encrypted by using a preset encryption algorithm;
the second determining unit is used for determining a decryption algorithm corresponding to the encryption algorithm if the ELF file is judged to be encrypted by using a preset encryption algorithm;
and the decryption unit is used for decrypting the ELF file by using the decryption algorithm to obtain the decrypted ELF file.
The above apparatus, optionally, the first determining unit includes:
a third obtaining subunit, configured to obtain a pointer section identifier of the loadable segment, and determine a corresponding pointer section in the loadable segment according to the pointer section identifier;
a fourth obtaining subunit, configured to obtain a loader identifier in the loadable segment, and determine a loader corresponding to the loader identifier;
and the calling subunit is used for calling the function pointer in the pointer node area, executing the code in the memory by using the loader according to the code corresponding to the function pointer in the loadable segment.
The above apparatus, optionally, the second obtaining subunit includes:
the acquisition module is used for acquiring the offset parameter and the length parameter in the program header;
the first determining module is used for determining an offset position in the ELF file according to the offset parameter;
a second determining module, configured to determine, from the offset position, a data segment in the ELF file that is consistent with the data length characterized by the length parameter;
and the third determining module is used for determining the data segment as a loadable segment corresponding to the program header.
The above apparatus, optionally, further comprises:
and the clearing unit is used for clearing the loadable segment in the memory and the execution trace of the code when the loading of the ELF file in the memory is completed.
A storage medium, the storage medium comprising stored instructions, wherein when the instructions are executed, a device on which the storage medium is located is controlled to execute the above hot update method of an application program.
An electronic device comprising a memory and one or more instructions, wherein the one or more instructions are stored in the memory and configured to be executed by one or more processors to perform the above-mentioned method for hot updating of an application.
Compared with the prior art, the invention has the following advantages:
in the method provided by the invention, when an ELF file corresponding to the current application program is detected, each loadable segment in the ELF file is obtained; mapping each loadable segment to a corresponding memory; determining a pointer node area of each loadable segment, calling a function pointer in the pointer node area, and executing a code corresponding to the function pointer in the loadable segment in the memory so as to update the code to the application program; and when the code in each loadable segment is updated to the current application program, completing the loading of the ELF file in the memory so as to realize the hot update of the application program. By applying the method provided by the invention, the ELF file is loaded in the memory, the codes in the current application program are updated, and the hot update of the application program is completed; by using the method, the application program does not need to be interrupted and restarted after being updated, so that better service is provided for the user, and the experience of the user in using the application program is improved.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In this application, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The method provided by the embodiment of the invention can be applied to various types of intelligent equipment such as a mobile terminal, a PC (personal computer) terminal, an IPAD (Internet protocol ad) and the like based on a Linux system, and the intelligent equipment can carry various application programs developed based on an android system; the execution subject of the invention can be a processor or a server in the intelligent device.
The method provided by the embodiment of the invention can load the ELF file in the memory to realize the hot update of the application program, and when the update of the application program is completed, the application program does not need to be stopped and restarted, so that the application program provides better service for a user, and the experience of the user in using the application program is improved. Referring to fig. 1, a specific process of the method provided by the embodiment of the present invention is described with reference to fig. 1:
s101, when detecting that the ELF file corresponding to the current application program can be executed and in a linkable format, acquiring each loadable segment in the ELF file.
In the method provided by the embodiment of the invention, when an application program runs in a terminal, whether an Executable and Linkable Format (ELF) file corresponding to the application program exists in a magnetic disk of the terminal is detected in real time, and if the ELF file corresponding to the application program is detected, the ELF file is analyzed to obtain each loadable segment in the ELF file; it should be noted that the detected ELF file is an ELF file that needs to be updated.
And S102, mapping each loadable segment to a corresponding memory.
In the method provided by the embodiment of the present invention, after each loadable segment in the ELF file is acquired, a memory corresponding to each loadable segment needs to be determined, and the loadable segment is mapped to the corresponding memory. Optionally, the bytes storable in the memory are greater than or equal to the size of the bytes included in the loadable segment, and in order to avoid occupying redundant memory and improve the data processing rate of the terminal, preferably, the size of the bytes storable in the memory is equal to the size of the bytes included in the loadable segment.
S103, determining a pointer section area of each loadable segment, calling a function pointer in the pointer section area, and executing a code corresponding to the function pointer in the loadable segment in the memory so as to update the code to the application program.
In the method provided in the embodiment of the present invention, after each loadable segment is mapped to a memory, a pointer section area of each loadable segment is determined, it should be noted that function pointers are stored in the pointer section area, the pointer section area includes, but is not limited to, init and ini _ array, the ini _ array is a function pointer set, and the ini _ array includes a plurality of function pointers. And calling each function pointer in the pointer section one by one, determining codes corresponding to the function pointers in the loadable section, and executing the codes corresponding to the called function pointers in the memory so as to update the codes to the application program.
And S104, when the codes in each loadable section are updated to the current application program, completing the loading of the ELF file in the memory so as to realize the hot updating of the application program.
In the method provided by the embodiment of the present invention, it is determined whether codes in each loadable segment in the ELF file have been updated to the current application program, and if it is determined that the codes in each loadable segment in the ELF file have been updated to the current application program, the ELF file is loaded in the memory, and the application program is updated in a hot manner.
In the method provided by the embodiment of the invention, when an ELF file corresponding to a current application program is detected, each loadable segment in the ELF file is obtained; mapping each loadable segment to a corresponding memory; determining a pointer node area of each loadable segment, calling a function pointer in the pointer node area, and executing a code corresponding to the function pointer in the loadable segment in the memory so as to update the code to the application program; and when the code in each loadable segment is updated to the current application program, completing the loading of the ELF file in the memory so as to realize the hot update of the application program. By applying the method provided by the invention, the ELF file is loaded in the memory, the codes in the current application program are updated, and the hot update of the application program is completed; by using the method, the application program does not need to be interrupted and restarted after being updated, so that better service is provided for the user, and the experience of the user in using the application program is improved.
In the method provided by the embodiment of the present invention, when an ELF file corresponding to a current application program is detected, each loadable segment in the ELF file is acquired, and a specific process of acquiring the loadable segment may refer to fig. 2, which explains fig. 2 as follows:
s201, acquiring a program header table in the ELF file.
In the method provided by the embodiment of the invention, the ELF file is analyzed to obtain a program header table in the ELF file, wherein the program header table comprises at least one program header; it should be noted that the ELF file includes, but is not limited to, a program Header table, and the ELF file also includes contents such as an ELF Header and Segment; the ELF Header represents an ELF file Header, the Segment represents a Segment, and the contents stored in the ELF file Header, the program Header table and the Segment are different.
And S202, reading each program head in the program head table.
In the method provided by the embodiment of the invention, each program head in the program head table is read in sequence to obtain each parameter stored in the program head, and each parameter represents different meanings. In the ELF file, each header has a Segment corresponding to the header, and the parameters stored in the header may indicate information such as the attribute and structure of the data in the Segment corresponding to the header.
S203, determining whether the attribute parameters of each program header represent loadable attributes.
In the method provided by the embodiment of the present invention, it is determined whether an attribute parameter of each program header is characterized as a loadable attribute, the attribute parameter may be specifically represented as p _ type in a parameter table, and it is determined whether the attribute of p _ type is PT _ LOAD, and if the attribute of p _ type is PT _ LOAD, the attribute parameter in the program header table is characterized as a loadable attribute.
And S204, if the attribute parameters of the program header represent loadable attributes, acquiring a loadable segment corresponding to the program header in the ELF file.
In the method provided by the embodiment of the present invention, if the attribute parameter of the program header is characterized as a loadable attribute, a loadable segment corresponding to the program header is acquired in the ELF file. The specific process of acquiring the loadable segment is as follows:
acquiring an offset parameter and a length parameter in the program header;
determining an offset position in the ELF file according to the offset parameter;
determining a data segment in the ELF file, starting from the offset position, which is consistent with the data length characterized by the length parameter;
and determining the data segment as a loadable segment corresponding to the program header.
In the method provided by the embodiment of the present invention, an offset parameter and a length parameter are determined in each parameter in the program header, the offset parameter represents an offset in the ELF file, and the offset parameter may be specifically represented as p _ offset; the length parameter characterizes the length of the data, and may be specifically denoted as p _ filesz. Determining an offset position in the ELF file according to the offset parameter; determining a data segment with the same length as the data represented by the length parameter in the ELF file from the offset position; it should be noted that, the offset position is a start position of the data segment; and determining the data segment as a loadable segment corresponding to the program header.
In the method provided by the embodiment of the present invention, by applying the method provided by the present invention, each loadable segment in an ELF file can be accurately obtained, and when a loadable segment is obtained, the loadable segment is mapped to a corresponding memory, so that data in the loadable segment is applied in the memory, and a process of mapping the loadable segment to the memory may refer to fig. 3, which specifically describes the following:
s301, determining the segment length of each loadable segment.
In the method provided by the embodiment of the invention, the length of each loadable segment is determined, and the length of each segment represents the data length of the loadable segment; it should be noted that, the manner of determining the segment length of the loadable segment includes, but is not limited to, determining the segment length according to the size characterized by the segment byte parameter of the loadable segment; the segment byte parameter may be stored in a segment parameter table of the loadable segment.
And S302, allocating a memory corresponding to each loadable segment according to the segment length of each loadable segment.
In the method provided in the embodiment of the present invention, it should be noted that the size of the memory allocated to the loadable segment is the same as the length of the loadable segment; and allocating the memory corresponding to the loadable segment according to the segment length of the loadable segment, so that the situation that the memory allocated to the loadable segment is too large or too small is avoided, the memory is reasonably utilized, and the data processing efficiency of the memory can be improved.
And S303, acquiring each loading parameter of each loadable segment, and mapping the loadable segment to a corresponding memory according to each loading parameter.
In the method provided by the embodiment of the present invention, each loading parameter of each loadable segment is obtained, the loading parameter may be stored in a segment parameter table of the loadable segment, and each loading parameter may represent a data structure in the loadable segment; and mapping the loadable segment to a corresponding memory according to each loading parameter.
In the method provided by the embodiment of the invention, when the loadable segment is mapped to the corresponding memory, the memory corresponding to the loadable segment is determined, and the corresponding memory is allocated to the loadable segment, so that the reasonable utilization of the memory is realized, and the working efficiency of the memory is improved; the loadable segment is mapped into the memory according to the loading parameters of the loadable segment, so that errors of a data structure mapped to the loadable segment in the memory are avoided, and the correctness of the data structure mapped to the loadable segment in the memory is ensured.
In the method provided in the embodiment of the present invention, in order to complete loading of the ELF file in the memory, the codes in the loadable segment need to be executed in the memory, and a process of executing the codes in the memory is shown in fig. 4, which is described in detail as follows:
s401, acquiring the pointer section identification of the loadable segment, and determining the corresponding pointer section in the loadable segment according to the pointer section identification.
In the method provided by the embodiment of the invention, the pointer node area identifier in the loadable segment is obtained, and the corresponding pointer node area is determined in the loadable segment according to the pointer node area identifier, wherein the pointer node area comprises a function pointer; the pointer node area identification may be stored in a segment parameter table of the loadable segment.
It should be noted that the loadable segment includes a plurality of sections, and each section stores different contents. For example, some loadable segments have dynamic link sections, and some loadable segments do not have dynamic link sections; if a dynamic link regulation area exists in the loadable section, determining a data link library corresponding to undefined symbol parameters in the dynamic link regulation area, and establishing a link with the data link library so as to call data in the data link library; it should be noted that each different node region implements different functions. It should be noted that the number of the sections and the section information such as the types of the sections stored in each loadable section may be different.
S402, obtaining loader identification in the loadable segment, and determining a loader corresponding to the loader identification.
In the method provided by the embodiment of the present invention, the loader identifier may be stored in the segment parameter table of the loadable segment, and the loader corresponding to the loader identifier is determined.
And S403, calling a function pointer in the pointer section, executing a code corresponding to the function pointer in the loadable segment by using the loader in the memory, and executing the code in the loadable segment by using the loader.
In the method provided by the embodiment of the present invention, a function pointer in the pointer node area is called, a code corresponding to the function pointer in a loadable segment is determined, and the code is loaded in the memory by using the loader, so that the code is executed in the memory; it should be noted that the function pointer points to a corresponding code in a loadable segment, and the code is stored in a section area corresponding to the loadable segment. It should be noted that when the loader loads the code, the loader executes the code in the memory to update the code into the application program.
In the method provided by the embodiment of the invention, a function pointer in a pointer node area is called, a code corresponding to the function pointer is determined, and the determined loader is applied to load the code, so that the code is executed in a memory, and the code is updated to the application program; and when the code in each loadable segment is updated to the current application program, the ELF file is loaded in the memory, and the hot update of the application program is completed.
In the method provided by the embodiment of the invention, in order to ensure the confidentiality of the data in the ELF file, the ELF file can be encrypted before being published so as to ensure that the data in the ELF file is not stolen, and when the loading of the ELF file in a memory is finished, the loadable data in the memory and the execution trace of the code are cleared, so that a dynamic dump is avoided, and the protection of the details of the code is realized.
In the method provided by the embodiment of the invention, when the ELF file corresponding to the current application program is detected, whether the ELF file is an encrypted ELF file is not determined, and whether the ELF file is encrypted by using a preset encryption algorithm can be judged firstly; if the ELF file is judged to be encrypted by using a preset encryption algorithm, determining a decryption algorithm corresponding to the encryption algorithm; and decrypting the ELF file by using the decryption algorithm to obtain the decrypted ELF file. It should be noted that, in order to ensure confidentiality of data in the ELF file, the ELF file may be encrypted and then published, and if the ELF file is an encrypted ELF file, the ELF file needs to be decrypted when being acquired, so as to obtain plaintext data of the ELF file.
The invention provides a specific example for detailed description, which is as follows:
assuming that when a user uses an application program in a terminal and the terminal detects an ELF file corresponding to the application program, the data codes in the ELF file need to be updated to the application program. Judging whether the ELF file is an encrypted ELF file or not, if the EFL file is the encrypted ELF file, decrypting the ELF file by applying a corresponding decryption algorithm to obtain a decrypted ELF file, and loading the decrypted ELF file in an internal memory; and if the ELF file is not encrypted, directly loading the ELF file in an internal memory.
It should be noted that, the specific process of loading the ELF file in the memory may be: analyzing the ELF file to obtain a program header table in the ELF file, reading each program header in the program header table, determining whether attribute parameters of each program header are characterized as loadable attributes, if the attribute parameters are characterized as the loadable attributes, determining a corresponding loadable segment in the ELF file according to offset parameters and length parameters in the program header, distributing a corresponding memory for the loadable segment according to the segment length of the loadable segment, and mapping the loadable segment to the memory. Determining a pointer node area in the loadable segment mapped to the memory, wherein the pointer node area can be determined according to the pointer node area identifier; determining a corresponding loader according to a loader identifier, and when a function pointer in a pointer node area is called, applying the loader to load a code corresponding to the function pointer in a memory, wherein the code is stored in the loadable segment; when the loader loads the code in the memory, the code is executed in the memory to update the code into the application program.
When the codes in each loadable section are updated to the application program, the loading of the ELF file in the memory is completed, the hot updating of the application program is realized, in order to ensure the privacy of the data in the ELF file, when the loading of the ELF file in the memory is completed, the loadable sections and the execution traces of the codes in the memory are removed, the dynamic memory dump is avoided, and the protection of the details of the codes is realized.
By applying the method provided by the invention, when the ELF file is loaded in the memory, the application program in the running state does not need to be stopped, the situation that the application program needs to be restarted after the code data in the ELF file is updated into the application program is avoided, and further, better service is provided for a user, and the use experience of the user in using the application program is improved.
Corresponding to fig. 1, the present invention further provides a hot-update apparatus for an application program, which is used for supporting the application of the hot-update method for the application program in practice; the hot updating device of the application program can be applied to various computer equipment or mobile terminals. The schematic structural diagram of the hot update apparatus for an application provided in the embodiment of the present invention may refer to fig. 5, which specifically describes the following:
an obtaining unit 501, configured to obtain, when an executable and linkable format ELF file corresponding to a current application program is detected, each loadable segment in the ELF file;
a mapping unit 502, configured to map each loadable segment into a corresponding memory;
a first determining unit 503, configured to determine a pointer node area of each loadable segment, call a function pointer in the pointer node area, and execute a code corresponding to the function pointer in the loadable segment in the memory, so as to update the code into the application program;
a loading unit 504, configured to complete loading of the ELF file in the memory when the code in each loadable segment is updated to the current application program, so as to implement hot update of the application program.
In the device provided by the embodiment of the invention, when an ELF file corresponding to a current application program is detected, each loadable segment in the ELF file is obtained; mapping each loadable segment to a corresponding memory; determining a pointer node area of each loadable segment, calling a function pointer in the pointer node area, and executing a code corresponding to the function pointer in the loadable segment in the memory so as to update the code to the application program; and when the code in each loadable segment is updated to the current application program, completing the loading of the ELF file in the memory so as to realize the hot update of the application program. By applying the method provided by the invention, the ELF file is loaded in the memory, the codes in the current application program are updated, and the hot update of the application program is completed; by using the device provided by the invention, the process does not need to be interrupted and restarted after the application program is updated, so that better service is provided for the user, and the experience of the user in using the application program is improved.
In the hot update apparatus of an application provided in an embodiment of the present invention, the obtaining unit 501 may be configured to:
the first acquiring subunit is used for acquiring a program header table in the ELF file;
a reading subunit, configured to read each program header in the program header table;
a first determining subunit, configured to determine whether an attribute parameter of each program header represents a loadable attribute;
and the second obtaining subunit is configured to, if the attribute parameter of the program header represents a loadable attribute, obtain, in the ELF file, a loadable segment corresponding to the program header.
In the hot update apparatus of an application provided in the embodiment of the present invention, the mapping unit 502 may be configured to:
a second determining subunit, configured to determine a segment length of each of the loadable segments;
the allocation subunit is configured to allocate, according to the segment length of each loadable segment, a memory corresponding to the loadable segment;
and the mapping subunit is configured to acquire each loading parameter of each loadable segment, and map the loadable segment to a corresponding memory according to each loading parameter.
In the hot update apparatus of an application provided in an embodiment of the present invention, the apparatus may further include:
the judging unit is used for judging whether the ELF file is encrypted by using a preset encryption algorithm;
the second determining unit is used for determining a decryption algorithm corresponding to the encryption algorithm if the ELF file is judged to be encrypted by using a preset encryption algorithm;
and the decryption unit is used for decrypting the ELF file by using the decryption algorithm to obtain the decrypted ELF file.
In the apparatus for updating an application program in heat according to the embodiment of the present invention, the first determining unit 503 may be configured to:
a third obtaining subunit, configured to obtain a pointer section identifier of the loadable segment, and determine a corresponding pointer section in the loadable segment according to the pointer section identifier;
a fourth obtaining subunit, configured to obtain a loader identifier in the loadable segment, and determine a loader corresponding to the loader identifier;
and the calling subunit is used for calling the function pointer in the pointer node area, executing the code in the memory by using the loader according to the code corresponding to the function pointer in the loadable segment.
In the apparatus for updating an application program in the embodiment of the present invention, the second obtaining subunit may be configured to:
the acquisition module is used for acquiring the offset parameter and the length parameter in the program header;
the first determining module is used for determining an offset position in the ELF file according to the offset parameter;
a second determining module, configured to determine, from the offset position, a data segment in the ELF file that is consistent with the data length characterized by the length parameter;
and the third determining module is used for determining the data segment as a loadable segment corresponding to the program header.
In the hot update apparatus of an application provided in an embodiment of the present invention, the apparatus may further include:
and the clearing unit is used for clearing the loadable segment in the memory and the execution trace of the code when the loading of the ELF file in the memory is completed.
The invention also provides a storage medium, which comprises stored instructions, wherein when the instructions are executed, the device where the storage medium is located is controlled to execute the hot updating method of the application program.
An electronic device is provided in an embodiment of the present invention, and the structural diagram of the electronic device is shown in fig. 6, which specifically includes a memory 601 and one or more instructions 602, where the one or more instructions 602 are stored in the memory 601 and configured to be executed by one or more processors 603 to perform the following operations on the one or more instructions 602:
when detecting an executable ELF file in a linkable format corresponding to a current application program, acquiring each loadable segment in the ELF file;
mapping each loadable segment to a corresponding memory;
determining a pointer node area of each loadable segment, calling a function pointer in the pointer node area, and executing a code corresponding to the function pointer in the loadable segment in the memory so as to update the code to the application program;
and when the code in each loadable segment is updated to the current application program, completing the loading of the ELF file in the memory so as to realize the hot update of the application program.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, the system or system embodiments are substantially similar to the method embodiments and therefore are described in a relatively simple manner, and reference may be made to some of the descriptions of the method embodiments for related points. The above-described system and system embodiments are only illustrative, wherein the units described as separate parts may or may not be physically separate, and the parts displayed 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 modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. 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 invention.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.