CN110837391A - Application program hot updating method and device, storage medium and electronic equipment - Google Patents

Application program hot updating method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN110837391A
CN110837391A CN201911065642.9A CN201911065642A CN110837391A CN 110837391 A CN110837391 A CN 110837391A CN 201911065642 A CN201911065642 A CN 201911065642A CN 110837391 A CN110837391 A CN 110837391A
Authority
CN
China
Prior art keywords
loadable
segment
memory
elf file
application program
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.)
Granted
Application number
CN201911065642.9A
Other languages
Chinese (zh)
Other versions
CN110837391B (en
Inventor
卢雄涛
王妍鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Cubesili Information Technology Co Ltd
Original Assignee
Guangzhou Huaduo Network Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Guangzhou Huaduo Network Technology Co Ltd filed Critical Guangzhou Huaduo Network Technology Co Ltd
Priority to CN201911065642.9A priority Critical patent/CN110837391B/en
Publication of CN110837391A publication Critical patent/CN110837391A/en
Application granted granted Critical
Publication of CN110837391B publication Critical patent/CN110837391B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/656Updates while running
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/658Incremental updates; Differential updates

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a hot updating method and device of an application program, a storage medium and electronic equipment, comprising the following steps: when an ELF file corresponding to the current application program is detected, acquiring each loadable segment in the ELF file; mapping each loadable segment to a corresponding memory; 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 into an 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 updating of the application program. By applying the method provided by the invention, the ELF file is loaded in the memory, the code in the current application program is updated, the hot update of the application program is completed, the process is not required to be interrupted after the update of the application program is completed, the application program is restarted, the better service is provided for the user, and the use experience of the user is improved.

Description

Application program hot updating method and device, storage medium and electronic equipment
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for hot updating an application program, a storage medium, and an electronic device.
Background
With the development of internet technology, numerous Applications (APPs) are carried on the intelligent mobile terminal, and the intelligent mobile terminal can be realized powerful function by multiple kinds of APPs. Along with the increasing demand of people, developers need to continuously maintain and update application programs.
During the maintenance of the application program, a developer can research and develop a corresponding patch or script according to the defects of the application program, add the patch or script to the corresponding installation package, generate a new installation package corresponding to the application program, and update the application program by prompting a user to install the new installation package.
The inventor researches to find that part of program code needing to be updated in an application program usually exists in Executable and Linkable Format (ELF) files, and such files are called ELF files. When updating the ELF file in the application program, the application program needs to be updated by downloading the full installation package containing the ELF file, and the service provided by the application program for the user needs to be interrupted when the update is completed, and the application program needs to be restarted after the update is completed, which results in the reduction of the application experience of the user in using the application program.
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.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
FIG. 1 is a flowchart illustrating a method for hot updating an application according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating another method for hot updating an application according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating another method for hot updating an application according to an embodiment of the present invention;
FIG. 4 is a flowchart illustrating another method for hot updating an application according to an embodiment of the present invention;
FIG. 5 is a schematic structural diagram of a hot-update apparatus for an application according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
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.

Claims (10)

1. A method for 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.
2. The method of claim 1, wherein obtaining each loadable segment in the ELF file comprises:
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.
3. The method of claim 1, wherein said mapping each of said loadable segments into its corresponding memory comprises:
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.
4. The method of claim 1, further comprising:
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.
5. The method according to claim 1, wherein said determining a pointer section area of each of the loadable segments, and calling a function pointer in the pointer section area, and executing code corresponding to the function pointer in the loadable segment in the memory comprises:
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.
6. The method of claim 2, wherein obtaining, in the ELF file, a loadable segment corresponding to the program header comprises:
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.
7. The method of claim 1, further comprising:
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.
8. An apparatus 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.
9. A storage medium, characterized in that the storage medium comprises stored instructions, wherein when the instructions are executed, a device on which the storage medium is located is controlled to execute a hot update method of an application program according to any one of claims 1 to 7.
10. 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 a method for hot-updating of an application according to any one of claims 1-7.
CN201911065642.9A 2019-11-04 2019-11-04 Application program hot updating method and device, storage medium and electronic equipment Active CN110837391B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911065642.9A CN110837391B (en) 2019-11-04 2019-11-04 Application program hot updating method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911065642.9A CN110837391B (en) 2019-11-04 2019-11-04 Application program hot updating method and device, storage medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN110837391A true CN110837391A (en) 2020-02-25
CN110837391B CN110837391B (en) 2021-02-12

Family

ID=69575954

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911065642.9A Active CN110837391B (en) 2019-11-04 2019-11-04 Application program hot updating method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN110837391B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111666096A (en) * 2020-07-02 2020-09-15 腾讯科技(深圳)有限公司 Hot updating method and device for target application, storage medium and electronic equipment
CN111736847A (en) * 2020-06-15 2020-10-02 北京奇艺世纪科技有限公司 Script language mapping method, electronic device and readable storage medium
CN111913730A (en) * 2020-07-15 2020-11-10 上海莉莉丝科技股份有限公司 User-insensitive application program internal updating method, user side and program server

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020112158A1 (en) * 2001-02-14 2002-08-15 Golchikov Andrey Vladimirovich Executable file protection
CN101277265A (en) * 2008-05-07 2008-10-01 浙江大学 Method for accelerating loading ELF document in wireless sensing network
CN105608393A (en) * 2016-01-19 2016-05-25 北京鼎源科技有限公司 Reinforcement method of executable file reorganization on basis of Android
CN109086059A (en) * 2017-06-14 2018-12-25 腾讯科技(北京)有限公司 Code loads update method, device and server
US20190095119A1 (en) * 2015-06-05 2019-03-28 Life365, Inc. Device configured for dynamic software change
CN109800012A (en) * 2019-03-01 2019-05-24 四川长虹电器股份有限公司 A kind of MCU firmware upgrade method
CN110113151A (en) * 2019-04-09 2019-08-09 天津大学 A kind of non-intrusion type real-time encryption and decryption method of pair of ELF format program

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020112158A1 (en) * 2001-02-14 2002-08-15 Golchikov Andrey Vladimirovich Executable file protection
CN101277265A (en) * 2008-05-07 2008-10-01 浙江大学 Method for accelerating loading ELF document in wireless sensing network
US20190095119A1 (en) * 2015-06-05 2019-03-28 Life365, Inc. Device configured for dynamic software change
CN105608393A (en) * 2016-01-19 2016-05-25 北京鼎源科技有限公司 Reinforcement method of executable file reorganization on basis of Android
CN109086059A (en) * 2017-06-14 2018-12-25 腾讯科技(北京)有限公司 Code loads update method, device and server
CN109800012A (en) * 2019-03-01 2019-05-24 四川长虹电器股份有限公司 A kind of MCU firmware upgrade method
CN110113151A (en) * 2019-04-09 2019-08-09 天津大学 A kind of non-intrusion type real-time encryption and decryption method of pair of ELF format program

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
/DEV/POSTS/: "The ELF file format", 《HTTPS://WWW.GABRIEL.URDHR.FR/2015/09/28/ELF-FILE-FORMAT/》 *
YOOOOOOOO: "ELF文件的加载过程(load_elf binary函数详解)--Linux进程的管理与调度(十三)", 《HTTPS://WWW.CNBLOGS.COM/LINHAOSTUDY/ARCHIVE/2018/09/16/9655301.HTML》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111736847A (en) * 2020-06-15 2020-10-02 北京奇艺世纪科技有限公司 Script language mapping method, electronic device and readable storage medium
CN111736847B (en) * 2020-06-15 2023-07-18 北京奇艺世纪科技有限公司 Script language mapping method, electronic device and readable storage medium
CN111666096A (en) * 2020-07-02 2020-09-15 腾讯科技(深圳)有限公司 Hot updating method and device for target application, storage medium and electronic equipment
CN111913730A (en) * 2020-07-15 2020-11-10 上海莉莉丝科技股份有限公司 User-insensitive application program internal updating method, user side and program server

Also Published As

Publication number Publication date
CN110837391B (en) 2021-02-12

Similar Documents

Publication Publication Date Title
CN110837391B (en) Application program hot updating method and device, storage medium and electronic equipment
CN105335187B (en) Application processing method and device
CN104838405B (en) The method and system of test frame for application program
CN102761856B (en) Terminal room shares the methods, devices and systems of software
EP2993603B1 (en) Permission determining method and device for application program
CN108540509B (en) Processing method and device of terminal browser, server and intelligent terminal
CN110968331B (en) Method and device for running application program
CN106055375B (en) Application program installation method and device
CN107797818A (en) Application program updating method and device
CN113553218A (en) Method for cloning and backing up real machine based on cloud mobile phone, terminal device and storage medium
CN110851151A (en) Method, device, terminal, server and storage medium for pre-installing application
CN106293790B (en) application program upgrading method and device based on Firefox operating system
CN113961179A (en) Service access method, system, electronic device and storage medium of SOAR platform
JP2012159924A (en) Installation system
CN113867768A (en) Operating system processing method and device, electronic equipment and storage medium
CN106293814B (en) Upgrading method and device
US7328007B2 (en) System and method for organizing wireless communication device system software
CN110401934B (en) Method for managing equipment, management equipment and computer readable storage medium
CN108021801B (en) Virtual desktop-based anti-leakage method, server and storage medium
CN110610080A (en) Application isolation implementation method, mobile terminal, computer equipment and storage medium
CN114327548A (en) Software upgrading method and related device
CN106778270B (en) Malicious application detection method and system
CN110502251B (en) Application installation method and device
CN111638896B (en) Upgrade method, upgrade device, storage medium, processor and mobile terminal
CN113220314A (en) APP resource loading and APK generation method, device, equipment and medium

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
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20210111

Address after: 510000 3108, 79 Wanbo 2nd Road, Nancun Town, Panyu District, Guangzhou City, Guangdong Province

Applicant after: GUANGZHOU CUBESILI INFORMATION TECHNOLOGY Co.,Ltd.

Address before: 28th floor, block B1, Wanda Plaza, Nancun Town, Panyu District, Guangzhou City, Guangdong Province

Applicant before: GUANGZHOU HUADUO NETWORK TECHNOLOGY Co.,Ltd.

GR01 Patent grant
GR01 Patent grant
EE01 Entry into force of recordation of patent licensing contract
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20200225

Assignee: GUANGZHOU HUADUO NETWORK TECHNOLOGY Co.,Ltd.

Assignor: GUANGZHOU CUBESILI INFORMATION TECHNOLOGY Co.,Ltd.

Contract record no.: X2021440000052

Denomination of invention: Hot update method and device of application program, storage medium and electronic equipment

Granted publication date: 20210212

License type: Common License

Record date: 20210222