WO2017107415A1 - 应用加载方法和装置 - Google Patents

应用加载方法和装置 Download PDF

Info

Publication number
WO2017107415A1
WO2017107415A1 PCT/CN2016/086217 CN2016086217W WO2017107415A1 WO 2017107415 A1 WO2017107415 A1 WO 2017107415A1 CN 2016086217 W CN2016086217 W CN 2016086217W WO 2017107415 A1 WO2017107415 A1 WO 2017107415A1
Authority
WO
WIPO (PCT)
Prior art keywords
data segment
memory
address
storage space
application
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.)
Ceased
Application number
PCT/CN2016/086217
Other languages
English (en)
French (fr)
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.)
Baidu Online Network Technology Beijing Co Ltd
Original Assignee
Baidu Online Network Technology Beijing 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 Baidu Online Network Technology Beijing Co Ltd filed Critical Baidu Online Network Technology Beijing Co Ltd
Priority to KR1020177027992A priority Critical patent/KR101955145B1/ko
Priority to JP2017552148A priority patent/JP6506412B2/ja
Priority to US15/564,412 priority patent/US11086638B2/en
Priority to EP16877228.3A priority patent/EP3267308B1/en
Publication of WO2017107415A1 publication Critical patent/WO2017107415A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0238Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
    • G06F12/0246Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/54Link editing before load time
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44557Code layout in executable memory
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44568Immediately runnable code
    • G06F9/44578Preparing or optimising for loading
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/17Embedded application
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/20Employing a main memory using a specific memory technology
    • G06F2212/202Non-volatile memory
    • G06F2212/2022Flash memory
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/72Details relating to flash memory management
    • G06F2212/7211Wear leveling
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present application relates to the field of computers, and in particular to an application field, and in particular, to an application loading method and apparatus.
  • the usual way is to store the binary code of the executable file in flash memory and run the instruction directly on the flash memory.
  • the symbols in the application's assembly code need to be relocated so that the symbols have absolute addresses to load the application.
  • each relocation of the symbol corresponds to an erasing operation of the entire memory block of the memory in which the symbol is located, thereby greatly increasing system overhead and increasing the loss of the flash memory.
  • the present application provides an application loading method and apparatus for solving the technical problems existing in the above background art.
  • the application provides an application loading method, which includes: selecting, in a programmable read-only memory, a storage space for storing a preset data segment in an executable file of an application, where the preset data segment is an application.
  • the preset data segment is an application.
  • the preset data segment is copied to the memory, and the preset data segment is relocated based on the starting address of the storage space; the relocated pre- Copy the data segment to the storage space to load the application.
  • the application provides an application loading device, the device includes: a selecting unit configured to select, in a programmable read only memory, a storage space for storing a preset data segment in an executable file of the application, where The preset data segment is a data segment that is loaded in the programmable read-only memory when the application is loaded; the relocation unit is configured to copy the preset data segment to the memory, and based on the starting address of the storage space The data segment is relocated; the loading unit is configured to copy the relocated preset data segment to the storage space to load the application.
  • the application loading method and apparatus provided by the present application selects, by using a programmable read-only memory, a storage space for storing preset data segments in an executable file of an application; copying the preset data segment to the memory, and based on the storage space
  • the starting address relocates the preset data segment; the relocated preset data segment is copied to the storage space.
  • the relocation reduces the overhead of the application's loading process and reduces the loss to the programmable read-only memory.
  • FIG. 1 is an exemplary system architecture diagram to which the present application can be applied;
  • FIG. 2 shows a flow chart of one embodiment of an application loading method in accordance with the present application
  • FIG. 3 shows an exemplary schematic diagram of loading an application in the embodiment
  • FIG. 4 shows an exemplary flowchart of an application loading method in the present application
  • Figure 5 is a block diagram showing the structure of an embodiment of an application loading device according to the present application.
  • FIG. 6 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server of an embodiment of the present application.
  • FIG. 1 illustrates an exemplary system architecture 100 in which an application loading method or application loading device of the present application may be applied.
  • system architecture 100 can include terminal devices 101, 102, 103, network 104, and server 105.
  • the network 104 is used to provide a medium for the transmission link between the terminal devices 101, 102, 103 and the server 105.
  • Network 104 may include various types of connections, such as wired, wireless transmission links, or fiber optic cables, to name a few.
  • the user can interact with the server 105 over the network 104 using the terminal devices 101, 102, 103 to receive or transmit messages and the like.
  • Various communication applications such as network security applications, instant communication tools, and the like, can be installed on the terminal devices 101, 102, and 103.
  • the terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting network communication, including but not limited to smart phones, tablets, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, dynamic The video specialist compresses the standard audio layer 3), MP4 (Moving Picture Experts Group Audio Layer IV) player, laptop portable computer and desktop computer, and the like.
  • MP3 players Motion Picture Experts Group Audio Layer III, dynamic The video specialist compresses the standard audio layer 3
  • MP4 Moving Picture Experts Group Audio Layer IV
  • the server 105 may be a server that provides various services, such as a server that provides data support for applications on the terminal devices 101, 102, 103.
  • the server 105 can receive the query request sent by the terminal device 101, 102, 103 and process the query request.
  • the processing result (relocation information of the executable file of the application) is fed back to the terminal device.
  • terminal devices, networks, and servers in Figure 1 is merely illustrative. Depending on the implementation needs, there can be any number of terminal devices, networks, and servers.
  • FIG. 2 illustrates a flow 200 of one embodiment of an application loading method in accordance with the present application.
  • the application loading method provided by this embodiment can be performed by the terminal devices 101, 102, and 103 in FIG.
  • the method includes the following steps:
  • Step 201 Select a storage space for storing a preset data segment in an executable file of the application in the programmable read-only memory.
  • the executable file of the application can be stored in a programmable read only memory.
  • the executable file contains a plurality of data segments.
  • the preset data segment is a data segment that is loaded and executed in the programmable read-only memory.
  • a storage space for storing a preset data segment may be selected in the programmable read-only memory, and the storage space is used to store the relocated preset data segment.
  • the programmable read only memory is a flash memory.
  • the executable file of the application may be stored in the flash memory, and the storage space for storing the relocated preset data segment may be selected in advance in the flash memory.
  • Step 202 Copy the preset data segment to the memory, and reposition the preset data segment based on the starting address of the storage space.
  • the preset data segment when the application is loaded, the preset data segment may be first copied to the memory, and then the preset data segment may be weighted based on the starting address of the pre-selected storage space in the programmable read-only memory. Positioning, which determines the loading address of the symbol in the preset data segment.
  • the assembly instructions jmp exp and exp:push are taken as an example to illustrate the principle of relocation:
  • the assembly instruction exp:push indicates that the push instruction corresponding to the symbol exp stores a push instruction, that is, a push instruction.
  • the assembly instruction jmp exp functions to jump to the address corresponding to the symbol exp and execute the push instruction at the address.
  • the compile address of the symbol exp at compile time is 1000h.
  • jmp exp is converted to jmp 1000h.
  • the assembly instruction is compiled with the address 0 as the starting address at compile time, and may be loaded at any position during the loading. Therefore, the symbol needs to be relocated to re-determine the assembly instruction.
  • the symbol corresponding to the load address also referred to as an absolute address
  • the symbol in the assembly instruction, that is, the address corresponding to the exp symbol is modified to the determined load address, thereby executing the instruction.
  • the executable file is an ELF file
  • the preset data segment includes: a machine instruction data segment, a read-only data data segment; and a preset data segment based on a starting address of the storage space.
  • Relocation includes: machine pointing in ELF file Locating the address offset corresponding to the operand of the machine instruction in the machine instruction data segment in the address offset data segment; calculating the load address corresponding to the operand according to the start address and the address offset, to the machine instruction data segment Perform relocation; look up the address offset corresponding to the read-only data in the read-only data segment in the read-only data address offset data segment of the ELF file; calculate the read-only data corresponding to the start address and the address offset Load address to relocate read-only data segments.
  • the executable file may be a relocatable file format ELF format file (which may be simply referred to as an ELF file).
  • ELF file contains the following data segments: the machine instruction data segment (.text), and the data in the machine instruction data segment is the machine code of the compiled application.
  • Read-only data data segment (.rodata) the data in the read-only data segment is read-only data.
  • the global variable data segment (.data) has been initialized, and the data in the initialized global variable data segment is the initialized global variable.
  • the global variable data segment (.bss) is not initialized.
  • the executable file of the application is an ELF file
  • the application when the application is loaded, that is, when the ELF file of the application is loaded, the machine instruction data segment (.text) and the read-only data segment (.rodata) in the ELF file are loaded. It can be loaded into flash memory, and the initialized global variable data segment (.data) and uninitialized global variable data segment (.bss) in the ELF file can be loaded in memory.
  • the machine instruction data segment (.text) and the read-only data data segment (.rodata) may be collectively referred to as a code portion.
  • the initialized global variable data segment (.data) and the uninitialized global variable data segment (.bss) can be collectively referred to as a data portion (data).
  • the method further includes: copying the uninitialized global variable data segment and the initialized global variable data segment in the ELF file to the memory;
  • the stored value in the storage space corresponding to the uninitialized global variable data segment is set to 0; the address offset corresponding to the initialized global variable in the initialized global variable data segment is found from the initialized global variable address offset data segment of the ELF file.
  • the amount of shifting based on the starting address of the initialized global variable in memory and the address offset, calculate the load address of the initialized global variable to relocate the initialized global variable data segment.
  • the code portion of the ELF file can be relocated in the following manner: first, in the flash memory, the code portion, ie, the machine instruction data segment (.text) and the read-only data segment. (.rodata) allocates the storage space of the size of the storage space occupied by the code portion (code), and records the starting address of the storage space. Then, a memory space equal to the size of the above-mentioned storage space is allocated in the memory, and the machine instruction data segment (.text) and the read-only data data segment (.rodata) are copied into the memory.
  • the address offset corresponding to the read-only data of the read-only data segment can be looked up from the read-only data address offset data segment (.rel.rodata).
  • the load address corresponding to the read-only data is calculated according to the start address and the address offset, thereby relocating the read-only data segment.
  • the data portion (data) in the ELF file can be relocated in the following manner: the initialized global variable data segment (.data) and the uninitialized global variable data segment (.bss) are allocated in the memory.
  • the storage space of the size of the storage space occupied by the two data segments, and the initialized global variable data segment (.data) and the uninitialized global variable data segment (.bss) are copied into the allocated memory.
  • the values in the memory space in the memory occupied by the uninitialized global variable data segment (.bss) are all initialized to zero.
  • Step 203 Copy the relocated preset data segment to the storage space to load the application.
  • the relocated preset data segment may be copied back to the pre-programmable only Reading memory (for example, flash memory) for storing the relocated preset data segment, so that the relocated preset data segment is loaded on the programmable read only memory, and at the same time, the memory can be
  • the initialized global variable data segment (.data) and the uninitialized global variable data segment (.bss) are relocated and loaded, thereby completing the loading of the application.
  • the method further includes: storing a starting address of the storage space in the programmable read-only memory, so as to When the application is loaded, the relocated initial data segment already stored in the programmable read only memory is searched by the starting address and the preset data segment is loaded.
  • the offset and size of each data segment in the ELF file in the ELF file during the relocation process can also be recorded at the same time. Then, the offset, size and relocation of each data segment in the ELF file can be recorded.
  • the code portion of the ELF code is stored in the flash memory together with the start address of the ELF file and the name of the ELF file, which may be referred to as a relocation information file.
  • the relocation information file is found by the name of the applied ELF file.
  • the data portion (data) recorded in the relocation information file that is, the offset and the size of the initialized global variable data segment (.data) and the uninitialized global variable data segment (.bss) in the ELF file, can be directly read. Take the data in the data part (data) of the ELF file, and reload the data part (data) and load it.
  • FIG. 3 shows an exemplary schematic diagram of loading an application in this embodiment.
  • machine instructions in an ELF file stored in flash memory are shown Data segment (.text), machine instruction address offset data segment (.rel.text), read-only data segment (.rodata), initialized global variable data segment (.data), initialized global variable address offset data Segment (.rel.data), uninitialized global variable data segment (.bss).
  • Machine instruction data segment (.text), read-only data segment (.rodata), initialized global variable data segment (.data), uninitialized global variable data segment (.bss) are first copied to memory, and at the same time, in flash memory
  • the storage space for storing the machine instruction data segment (.text) and the read-only data segment (.rodata) after relocation is selected.
  • the storage space is different from the storage space in the flash memory currently storing the preset data segment, and the storage space functions to store the relocated preset data segment.
  • the memory based on the starting address of the storage space, combined with the machine instruction address offset data segment (.rel.text) and the read-only data address offset data segment (.rel.rodata) for the machine instruction data segment ( .text), read-only data segment (.rodata) for relocation, and finally, after one copy, write back to the flash to select the machine instruction data segment (.text) and read-only data segment for relocation. (.rodata) in the storage space.
  • the uninitialized global variable data segment .bss is initialized to 0, and the initialized global variable data segment (.data) is relocated in conjunction with the initialized global variable address offset data segment (.rel.data).
  • FIG. 4 shows an exemplary flowchart of the application loading method in the present application. Contains the following steps:
  • Step 401 The system starts loading the application.
  • Step 402 Pre-allocate the storage space of the size of the storage space occupied by the code portion on the flash memory.
  • Step 403 Allocate the same amount of memory for the code portion in the memory.
  • Step 404 Relocate the code portion in the memory by using the relocation segment and the starting address of the code segment in the pre-allocated storage space in the flash memory.
  • the relocation segment includes: a machine instruction address offset data segment, and a read-only data address offset data segment.
  • Step 405 Copy the relocated code portion back into the pre-allocated storage space in the flash memory.
  • Step 406 Allocate a memory of a required size for the data portion in the memory.
  • Step 407 Store the relocation information, the application name, and the address of the relocation code segment on the flash memory in the flash memory, and name it as a relocation information file.
  • the relocation information includes: the starting address of the pre-allocated storage space in the flash memory
  • the code part of the relocated ELF file can be directly run, and the code part of the ELF is loaded, and the code part of the ELF file does not need to be relocated again.
  • the data portion of the ELF file is relocated and loaded, and the application is loaded, thereby reducing the loss of the flash during the loading process of the application and increasing the loading speed of the application.
  • the data in the data portion (data) in the ELF file can be directly read according to the offset and size of the data portion recorded in the relocation information file in the ELF file, without reacquiring the auxiliary relocation information, Further increase the loading speed of the application.
  • FIG. 5 shows a schematic structural diagram of an embodiment of an application loading device according to the present application.
  • the apparatus 500 includes: a selecting unit 501, a relocating unit 502, and a loading unit 503.
  • the selecting unit 501 is configured to select, in the programmable read only memory, a storage space for storing a preset data segment in the executable file of the application, wherein the preset data segment is loaded in the programmable only when the application is loaded.
  • Reading a data segment executed in the memory is configured to copy the preset data segment to the memory, and relocating the preset data segment based on the starting address of the storage space; the loading unit 503 is configured to use the weight The preset preset data segment is copied to the storage space to load the application.
  • the selecting unit 501 may select a storage space for storing a preset data segment in the programmable read-only memory, where the address of the storage space is different from the programmable read-only memory in which the current preset data segment is located.
  • the address of the storage space which is used to store the relocated default data segment.
  • the relocation unit 502 can copy the preset data segment stored in the programmable read-only memory to the memory, and then can be based on the programmable read-only memory.
  • the preset address of the pre-selected storage space relocates the preset data segment, that is, determines the loading address of the symbol in the instruction in the preset data segment and the loading address of the data in the preset data segment.
  • the loading unit 503 may copy the relocated preset data segment back into the storage space selected in the programmable read-only memory for storing the relocated preset data segment, thereby The relocated preset data segment is loaded on the programmable read-only memory.
  • the initialized global variable data segment and the uninitialized global variable data segment in the memory can be relocated and then loaded, thereby completing the loading of the application. .
  • the programmable read only memory is a flash memory.
  • the relocation unit 502 includes: a first lookup subunit (not shown) configured to: when the executable file is an ELF file, the preset data segment includes: machine instruction data In the segment, read-only data segment, the address offset corresponding to the operand of the machine instruction in the machine instruction data segment is searched in the machine instruction address offset data segment of the ELF file; the first calculation subunit (not shown) Configuring to calculate a load address corresponding to the operand according to the start address and the address offset to relocate the machine instruction data segment; a second lookup subunit (not shown) configured for use in the ELF file Finding an address offset corresponding to the read-only data in the read-only data segment in the read-only data address offset data segment; a second calculation sub-unit (not shown) configured to be based on the start address and the address offset Calculate the load address corresponding to the read-only data to relocate the read-only data segment.
  • a first lookup subunit (not shown) configured to: when the executable file is an ELF file, the preset data segment
  • the apparatus 500 further includes: a copy unit (not shown) configured to copy the uninitialized global variable data segment and the initialized global variable data segment in the ELF file to the memory a setting unit (not shown) configured to set a storage value in a storage space corresponding to the uninitialized global variable data segment to 0; an offset searching unit (not shown) configured to be used from the ELF file Initializing a global variable address offset data segment to find an address offset corresponding to the initialized global variable in the initialized global variable data segment; a load address calculation unit (not shown) configured to initialize the global variable data segment The starting address in memory and the address offset, calculate the load address of the initialized global variable to weight the initialized global variable data segment Positioning.
  • a copy unit (not shown) configured to copy the uninitialized global variable data segment and the initialized global variable data segment in the ELF file to the memory
  • a setting unit (not shown) configured to set a storage value in a storage space corresponding to the uninitialized global variable data segment
  • the apparatus 500 further includes: a storage unit (not shown) configured to be programmable read-only after copying the relocated preset data segment to the storage space.
  • the start address of the storage space is saved in the memory, so that when the application is loaded again, the relocated initial data segment stored in the programmable read only memory is searched by the starting address and the preset data segment is performed. load.
  • FIG. 6 is a block diagram showing the structure of a computer system suitable for implementing a terminal device or a server of an embodiment of the present application.
  • computer system 600 includes a central processing unit (CPU) 601 that can be loaded into a program in random access memory (RAM) 603 according to a program stored in read only memory (ROM) 602 or from storage portion 608. And perform various appropriate actions and processes.
  • RAM random access memory
  • ROM read only memory
  • RAM random access memory
  • various programs and data required for the operation of the system 600 are also stored.
  • the CPU 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604.
  • An input/output (I/O) interface 605 is also coupled to bus 604.
  • the following components are connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, etc.; an output portion 607 including, for example, a cathode ray tube (CRT), a liquid crystal display (LCD), and the like, and a storage portion 608 including a hard disk or the like. And a communication portion 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the Internet.
  • Driver 610 is also coupled to I/O interface 605 as needed.
  • a removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory or the like, is mounted on the drive 610 as needed so that a computer program read therefrom is installed into the storage portion 608 as needed.
  • an embodiment of the present disclosure includes a computer program product comprising a computer program tangibly embodied on a machine readable medium, the computer program comprising program code for executing the method illustrated in the flowchart.
  • the computer program can be downloaded and installed from the network via communication portion 609, and/or installed from removable media 611.
  • Each block in the flowchart or block diagram may represent a module, a program segment, or a portion of code, the module, the program segment, or a portion of code comprising one or more components for implementing the specified logical functions. Execute the instruction. It should also be noted that in some alternative implementations, the functions noted in the blocks may also occur in a different order than that illustrated in the drawings. For example, two successively represented blocks may in fact be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending upon the functionality involved.
  • each block of the block diagrams and/or flowcharts, and combinations of blocks in the block diagrams and/or flowcharts can be implemented in a dedicated hardware-based system that performs the specified function or operation. Or it can be implemented by a combination of dedicated hardware and computer instructions.
  • the present application further provides a non-volatile computer storage medium, which may be a non-volatile computer storage medium included in the apparatus described in the foregoing embodiments; It may be a non-volatile computer storage medium that exists alone and is not assembled into the terminal.
  • the non-volatile computer storage medium stores one or more programs, when the one or more programs are executed by a device, causing the device to: select an executable for storing an application in a programmable read-only memory a storage space of the preset data segment in the file, wherein the preset data segment is a data segment that is loaded in the programmable read-only memory when the application is loaded; and the preset data segment is copied to the memory, And relocating the preset data segment based on a starting address of the storage space; copying the relocated first preset data segment to the storage space to load an application.

Landscapes

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

Abstract

一种应用加载方法和装置。该方法包括:在可编程只读存储器中选取用于存储应用的可执行文件中的预设数据段的存储空间(201);将预设数据段拷贝至内存,以及基于存储空间的起始地址对预设数据段进行重定位(202);将经重定位的预设数据段拷贝至存储空间(203)。实现了在内存中对可执行文件的代码部分进行重定位,然后将重定位后的代码部分写回到可编程只读存储器中,从而仅需一次针对存储块的擦除操作即可完成代码部分的重定位,减少了应用的加载过程中的系统开销以及降低对可编程只读存储器的损耗。

Description

应用加载方法和装置
相关申请的交叉引用
本申请要求于2015年12月25日提交的中国专利申请号为“201510994261.4”的优先权,其全部内容作为整体并入本申请中。
技术领域
本申请涉及计算机领域,具体涉及应用领域,尤其涉及应用加载方法和装置。
背景技术
在嵌入式系统中,在对应用进行加载时,通常采用的方式为:在闪存中存储可执行文件的二进制代码,并在闪存上直接运行指令。在应用加载过程中,需要对应用的汇编代码中的符号进行重定位,使得符号具有绝对地址,以对应用进行加载。
然而,当采用上述方式对应用进行加载时,每一次针对符号的重定位均会对应一次对该符号所在内存的整个存储块的擦除操作,进而极大地增加系统开销以及对增加闪存的损耗。
发明内容
本申请提供了应用加载方法和装置,用于解决上述背景技术部分存在的技术问题。
第一方面,本申请提供了应用加载方法,该方法包括:在可编程只读存储器中选取用于存储应用的可执行文件中的预设数据段的存储空间,其中,预设数据段为应用被加载时,被加载在可编程只读存储器中执行的数据段;将预设数据段拷贝至内存,以及基于存储空间的起始地址对预设数据段进行重定位;将经重定位的预设数据段拷贝至存储空间,以对应用进行加载。
第二方面,本申请提供了应用加载装置,该装置包括:选取单元,配置用于在可编程只读存储器中选取用于存储应用的可执行文件中的预设数据段的存储空间,其中,预设数据段为应用被加载时,被加载在可编程只读存储器中执行的数据段;重定位单元,配置用于将预设数据段拷贝至内存,以及基于存储空间的起始地址对预设数据段进行重定位;加载单元,配置用于将经重定位的预设数据段拷贝至存储空间,以对应用进行加载。
本申请提供的应用加载方法和装置,通过在可编程只读存储器中选取用于存储应用的可执行文件中的预设数据段的存储空间;将预设数据段拷贝至内存,以及基于存储空间的起始地址对预设数据段进行重定位;将经重定位的预设数据段拷贝至存储空间。实现了在内存中对可执行文件的代码部分进行重定位,然后将重定位后的代码部分写回到可编程只读存储器中,从而仅需一次针对存储块的擦除操作即可完成代码部分的重定位,减少了应用的加载过程中的系统开销以及降低对可编程只读存储器的损耗。
附图说明
通过阅读参照以下附图所作的对非限制性实施例所作的详细描述,本申请的其它特征、目的和优点将会变得更明显:
图1是本申请可以应用于其中的示例性系统架构图;
图2示出了根据本申请的应用加载方法的一个实施例的流程图;
图3示出了本实施例中的对应用进行加载的一个示例性原理图;
图4示出了本申请中的应用加载方法的一个示例性流程图;
图5示出了根据本申请的应用加载装置的一个实施例的结构示意图;
图6是适于用来实现本申请实施例的终端设备或服务器的计算机系统的结构示意图。
具体实施方式
下面结合附图和实施例对本申请作进一步的详细说明。可以理解 的是,此处所描述的具体实施例仅仅用于解释相关发明,而非对该发明的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与有关发明相关的部分。
需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。下面将参考附图并结合实施例来详细说明本申请。
图1示出了可以应用本申请的应用加载方法或应用加载装置的实施例的示例性系统架构100。
如图1所示,系统架构100可以包括终端设备101、102、103,网络104和服务器105。网络104用以在终端设备101、102、103和服务器105之间提供传输链路的介质。网络104可以包括各种连接类型,例如有线、无线传输链路或者光纤电缆等等。
用户可以使用终端设备101、102、103通过网络104与服务器105交互,以接收或发送消息等。终端设备101、102、103上可以安装有各种通讯应用,例如网络安全类应用、即时通信工具等。
终端设备101、102、103可以是具有显示屏并且支持网络通信的各种电子设备,包括但不限于智能手机、平板电脑、电子书阅读器、MP3播放器(Moving Picture Experts Group Audio Layer III,动态影像专家压缩标准音频层面3)、MP4(Moving Picture Experts Group Audio Layer IV,动态影像专家压缩标准音频层面4)播放器、膝上型便携计算机和台式计算机等等。
服务器105可以是提供各种服务的服务器,例如对终端设备101、102、103上的应用提供数据支持的服务器。服务器105可以接收到终端设备101、102、103发送的查询请求,并对查询请求进行处理。并将处理结果(应用的可执行文件的重定位信息)反馈给终端设备。
应该理解,图1中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器。
请参考图2,其示出了根据本申请的应用加载方法的一个实施例的流程200。本实施例所提供的应用加载方法可以由图1中的终端设备101、102、103执行。该方法包括以下步骤:
步骤201,在可编程只读存储器中选取用于存储应用的可执行文件中的预设数据段的存储空间。
在本实施例中,应用的可执行文件可以存储在可编程只读存储器中。可执行文件包含多个数据段,当应用加载时,即应用的可执行文件加载时,预设数据段为被加载在可编程只读存储器中执行的数据段。在本实施例中,可以在可编程只读存储器中选取用于存储预设数据段的存储空间,该存储空间用于存储经重定位后的预设数据段。
在本实施例的一些可选的实现方式中,可编程只读存储器为闪存存储器。在本实施例中,应用的可执行文件可以存储在闪存存储器中,可以预先在闪存存储器中选取用于存储重定位后的预设数据段的存储空间。
步骤202,将预设数据段拷贝至内存,以及基于存储空间的起始地址对预设数据段进行重定位。
在本实施例中,在应用加载时,可以首先将预设数据段拷贝至内存,然后,可以基于在可编程只读存储器中预先选取的存储空间的起始地址对该预设数据段进行重定位,即确定预设数据段中的符号的加载地址。
下面首先以汇编指令jmp exp和exp:push为例,说明重定位的原理:汇编指令exp:push表示符号exp对应的地址上存储有入栈指令即push指令。汇编指令jmp exp的作用为跳转到符号exp对应的地址,执行该地址上的入栈指令。假设,符号exp在编译时的编译地址为1000h,在对汇编指令进行编译之后,则jmp exp被转换为jmp 1000h。在应用加载时,由于汇编指令在编译时统一采用地址0作为起始地址进行编译,而在加载时则可能被加载在任意的位置运行,因此,需要对符号进行重定位即重新确定汇编指令中的符号对应的加载地址(也可称之为绝对地址),并且将汇编指令中的符号即exp符号对应的地址修改为确定出的加载地址,从而执行该指令。
在本实施例的一些可选的实现方式中,可执行文件为ELF文件,预设数据段包括:机器指令数据段、只读数据数据段;以及基于存储空间的起始地址对预设数据段进行重定位包括:在ELF文件的机器指 令地址偏移数据段中查找机器指令数据段中的机器指令的操作数对应的地址偏移量;根据起始地址和地址偏移量,计算操作数对应的加载地址,以对机器指令数据段进行重定位;在ELF文件的只读数据地址偏移数据段中查找只读数据数据段中的只读数据对应的地址偏移量;根据起始地址和地址偏移量,计算只读数据对应的加载地址,以对只读数据数据段进行重定位。
在本实施例中,为支持应用在嵌入式设备(例如物联网设备)上的加载,可执行文件可以为可重定位的文件格式ELF格式的文件(可以简称为ELF文件)。首先说明ELF文件的组成:在ELF文件中,采用数据段(section)描述文件的内容。ELF文件中包含以下数据段:机器指令数据段(.text),机器指令数据段中的数据为已编译应用的机器代码。只读数据数据段(.rodata),只读数据数据段中的数据为只读数据。已初始化全局变量数据段(.data),已初始化全局变量数据段中的数据为已初始化的全局变量。未初始化全局变量数据段(.bss)。当应用的可执行文件为ELF文件时,在对应用进行加载时,即对应用的ELF文件进行加载时,ELF文件中的机器指令数据段(.text)和只读数据数据段(.rodata)可以加载到闪存中,ELF文件中的已初始化全局变量数据段(.data)和未初始化全局变量数据段(.bss)可以加载在内存中。
在本实施例中,可以将机器指令数据段(.text)和只读数据数据段(.rodata)统称为代码部分(code)。可以将已初始化全局变量数据段(.data)和未初始化全局变量数据段(.bss)统称为数据部分(data)。在对ELF文件进行加载时,需要对代码部分(code)和数据部分(data)进行重定位,即计算ELF文件中的代码部分(code)和数据部分(data)中的符号的加载地址。在对代码部分(code)和数据部分(data)的重定位过程中,可以利用ELF文件中的机器指令地址偏移数据段(.rel.text),只读数据地址偏移数据段(.rel.rodata),已初始化全局变量地址偏移数据段(.rel.data),对代码部分和数据部分进行重定位。
在本实施例的一些可选的实现方式中,还包括:将ELF文件中的未初始化全局变量数据段和已初始化全局变量数据段拷贝至内存;将 未初始化全局变量数据段对应的存储空间中的存储值设置为0;从ELF文件的已初始化全局变量地址偏移数据段中查找出已初始化全局变量数据段中的已初始化全局变量对应的地址偏移量;根据已初始化全局变量在内存中的起始地址以及地址偏移量,计算已初始化全局变量的加载地址,以对已初始化全局变量数据段进行重定位。
下面以可编程只读存储器为闪存为例,分别说明对ELF文件中的代码部分(code)和数据部分(data)的重定位的过程。在本实施例中,可以采用以下方式对ELF文件中的代码部分(code)进行重定位:首先预先在闪存中为代码部分(code)即机器指令数据段(.text)和只读数据数据段(.rodata)分配代码部分(code)占用的存储空间的大小的存储空间,并记录该存储空间的起始地址。然后,在内存中分配与上述存储空间的大小相等的存储空间,将机器指令数据段(.text)和只读数据数据段(.rodata)拷贝到内存中。在内存中对机器指令数据段(.text)进行重定位时,可以从机器指令地址偏移数据段(.rel.te xt)中查找机器指令数据段中的机器指令的操作数即指令中引用的符号对应的地址偏移量,根据上述起始地址和地址偏移量,计算操作数对应的加载地址,从而计算出指令中的操作数的加载地址即指令中引用的符号对应的加载地址。在计算出机器指令中的所有符号对应的加载地址之后,完成对机器指令数据段进行重定位。在内存中对只读数据数据段(.rodata)进行重定位时,可以从只读数据地址偏移数据段(.rel.rodata)中查找只读数据数据段的只读数据对应的地址偏移量;根据起始地址和地址偏移量,计算只读数据对应的加载地址,从而对只读数据数据段进行重定位。
在本实施例中,可以采用以下方式对ELF文件中的数据部分(data)进行重定位:在内存中分配已初始化全局变量数据段(.data)和未初始化全局变量数据段(.bss)这两个数据段占据的存储空间的大小的存储空间,并将已初始化全局变量数据段(.data)和未初始化全局变量数据段(.bss)拷贝到分配的内存中。对未初始化全局变量数据段(.bss)占据的内存中的存储空间中的数值全部初始化为0。然后,可以从已初始化全局变量地址偏移数据段(.rel.data)中查找已初始化 全局变量数据段中的已初始化全局变量对应的地址偏移量;根据已初始化全局变量数据段在内存中的起始地址以及地址偏移量,计算已初始化全局变量的加载地址,从而对已初始化全局变量数据段(.data)进行重定位。
步骤203,将经重定位的预设数据段拷贝至存储空间,以对应用进行加载。
在本实施例中,在内存中完成对预设数据段(例如机器指令数据段、只读数据数据段)的重定位之后,可以将重定位后的预设数据段拷贝回预先在可编程只读存储器(例如闪存)中选取出的用于存储重定位后的预设数据段的存储空间中,从而使得重定位后的预设数据段在可编程只读存储器上加载,同时,可以对内存中的已初始化全局变量数据段(.data)和未初始化全局变量数据段(.bss)进行重定位之后进行加载,从而完成对应用的加载。
在本实施例的一些可选的实现方式中,在将经重定位的预设数据段拷贝至存储空间之后,还包括:在可编程只读存储器中存储存储空间的起始地址,以使得再次对应用进行加载时,利用起始地址查找出已存储在可编程只读存储器中的经重定位的预设数据段并对预设数据段进行加载。
在本实例中,还可以同时记录重定位过程中ELF文件中的各个数据段在ELF文件中的偏移、大小,然后,可以将各个数据段在ELF文件中的偏移、大小与重定位后的ELF的代码部分(code)在闪存中的起始地址以及ELF文件的名称一起以文件形式存储在闪存中,可以将该文件称之为重定位信息文件。从而,当再次对应用进行加载时,通过应用的ELF文件的名称,查找出重定位信息文件。然后,可以基于重定位信息文件中记录的数据部分(data)即已初始化全局变量数据段(.data)和未初始化全局变量数据段(.bss)在ELF文件中的偏移和大小,直接读取ELF文件中数据部分(data)中的数据,对数据部分(data)进行重定位后加载。
请参考图3,其示出了本实施例中的对应用进行加载的一个示例性原理图。在图3中,示出了存储在闪存中的ELF文件中的机器指令 数据段(.text)、机器指令地址偏移数据段(.rel.text)、只读数据数据段(.rodata)、已初始化全局变量数据段(.data)、已初始化全局变量地址偏移数据段(.rel.data)、未初始化全局变量数据段(.bss)。机器指令数据段(.text)、只读数据数据段(.rodata)、已初始化全局变量数据段(.data)、未初始化全局变量数据段(.bss)首先被拷贝至内存,同时,在闪存中选取用于存储重定位后的机器指令数据段(.text)、只读数据数据段(.rodata)的存储空间。该存储空间不同于当前存储预设数据段的闪存中的存储空间,该存储空间的作用为存储经重定位后的预设数据段。然后,在内存中,基于该存储空间的起始地址,结合机器指令地址偏移数据段(.rel.text)和只读数据地址偏移数据段(.rel.rodata)对机器指令数据段(.text)、只读数据数据段(.rodata)进行重定位,最后,经过一次拷贝写回到闪存中选取的用于存储重定位后的机器指令数据段(.text)、只读数据数据段(.rodata)的存储空间中。同时,对未初始化全局变量数据段.bss初始化为0,并且,结合已初始化全局变量地址偏移数据段(.rel.data)对已初始化全局变量数据段(.data)进行重定位。
请参考图4,其示出了本申请中的应用加载方法的一个示例性流程图。包含以下步骤:
步骤401:系统启动加载应用。
步骤402:在闪存上预分配代码部分占据的存储空间的大小的存储空间。
步骤403:在内存中为代码部分分配同样大小的内存。
步骤404:在内存中,利用重定位段和代码段在闪存中的预分配的存储空间的起始地址对代码部分进行重定位。重定位段包括:机器指令地址偏移数据段、只读数据地址偏移数据段。
步骤405:将重定位后的代码部分拷贝回闪存中的预分配的存储空间中。
步骤406:在内存中为数据部分分配所需大小的内存。
步骤407:将重定位信息、应用名称、重定位代码段在闪存上的地址,存储在闪存中,命名为重定位信息文件。重定位信息包括:在闪存中的预分配的存储空间的起始地址
下面以可编程只读存储器为闪存为例,说明本实施例中的应用的加载方式与现有技术的区别:在现有技术中,对应用的代码部分(code)重定位的过程中,因每一次对符号的重定位均需一次对符号所在的闪存中的存储块的擦除操作,从而造成系统开销增加以及flash损耗增加。而在本实例中,应用的代码部分(code)仅需在首次加载时加载一次。当再次对应用进行加载时,例如,系统重启时,由于在闪存中已经预先存储了首次加载时,存储在闪存中的经重定位后的ELF文件的代码部分(code)的起始地址,因此,根据该起始地址即可直接运行经重定位后的ELF文件的代码部分(code),完成ELF的代码部分(code)的加载,无需再次对ELF文件的代码部分(code)进行重定位。同时,仅需对ELF文件的数据部分(data)进行重定位后进行加载,即可完成对应用的加载,从而,减少了应用的加载过程中对闪存的损耗以及提升应用的加载速度。并且,由于可以根据重定位信息文件中记录的数据部分(data)在ELF文件中的偏移和大小直接读取ELF文件中数据部分(data)中的数据,而无需重新获取辅助重定位信息,进一步提升了应用的加载速度。
请参考图5,其示出了根据本申请的应用加载装置的一个实施例的结构示意图。装置500包括:选取单元501,重定位单元502,加载单元503。选取单元501配置用于在可编程只读存储器中选取用于存储应用的可执行文件中的预设数据段的存储空间,其中,预设数据段为应用被加载时,被加载在可编程只读存储器中执行的数据段;重定位单元502配置用于将预设数据段拷贝至内存,以及基于存储空间的起始地址对预设数据段进行重定位;加载单元503配置用于将经重定位的预设数据段拷贝至存储空间,以对应用进行加载。
在本实施例中,选取单元501可以在可编程只读存储器中选取用于存储预设数据段的存储空间,该存储空间的地址不同于当前预设数据段所处的可编程只读存储器中的存储空间的地址,该存储空间的作用为存储经重定位后的预设数据段。
在本实施例中,重定位单元502可以将存储在可编程只读存储器中的预设数据段拷贝至内存,然后,可以基于在可编程只读存储器中 预先选取的存储空间的起始地址对该预设数据段进行重定位,即确定预设数据段中的指令中的符号的加载地址以及预设数据段中的数据的加载地址。
在本实施例中,加载单元503可以将重定位后的预设数据段拷贝回预先在可编程只读存储器中选取出的用于存储重定位后的预设数据段的存储空间中,从而使得重定位后的预设数据段在可编程只读存储器上加载,同时,可以对内存中的已初始化全局变量数据段和未初始化全局变量数据段进行重定位之后进行加载,从而完成对应用的加载。
在本实施例的一些可选的实现方式中,可编程只读存储器为闪存存储器。
在本实施例的一些可选的实现方式中,重定位单元502包括:第一查找子单元(未示出),配置用于当可执行文件为ELF文件,预设数据段包括:机器指令数据段、只读数据数据段时,在ELF文件的机器指令地址偏移数据段中查找机器指令数据段中的机器指令的操作数对应的地址偏移量;第一计算子单元(未示出),配置用于根据起始地址和地址偏移量,计算操作数对应的加载地址,以对机器指令数据段进行重定位;第二查找子单元(未示出),配置用于在ELF文件的只读数据地址偏移数据段中查找只读数据数据段中的只读数据对应的地址偏移量;第二计算子单元(未示出),配置用于根据起始地址和地址偏移量,计算只读数据对应的加载地址,以对只读数据数据段进行重定位。
在本实施例的一些可选的实现方式中,装置500还包括:拷贝单元(未示出),配置用于将ELF文件中的未初始化全局变量数据段和已初始化全局变量数据段拷贝至内存;设置单元(未示出),配置用于将未初始化全局变量数据段对应的存储空间中的存储值设置为0;偏移量查找单元(未示出),配置用于从ELF文件的已初始化全局变量地址偏移数据段中查找出已初始化全局变量数据段中的已初始化全局变量对应的地址偏移量;加载地址计算单元(未示出),配置用于根据已初始化全局变量数据段在内存中的起始地址以及地址偏移量,计算已初始化全局变量的加载地址,以对已初始化全局变量数据段进行重 定位。
在本实施例的一些可选的实现方式中,装置500还包括:存储单元(未示出),配置用于在将经重定位的预设数据段拷贝至存储空间之后,在可编程只读存储器中保存存储空间的起始地址,以使得再次对应用进行加载时,利用起始地址查找出已存储在可编程只读存储器中的经重定位的预设数据段并对预设数据段进行加载。
图6示出了适于用来实现本申请实施例的终端设备或服务器的计算机系统的结构示意图。
如图6所示,计算机系统600包括中央处理单元(CPU)601,其可以根据存储在只读存储器(ROM)602中的程序或者从存储部分608加载到随机访问存储器(RAM)603中的程序而执行各种适当的动作和处理。在RAM 603中,还存储有系统600操作所需的各种程序和数据。CPU601、ROM 602以及RAM603通过总线604彼此相连。输入/输出(I/O)接口605也连接至总线604。
以下部件连接至I/O接口605:包括键盘、鼠标等的输入部分606;包括诸如阴极射线管(CRT)、液晶显示器(LCD)等以及扬声器等的输出部分607;包括硬盘等的存储部分608;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分609。通信部分609经由诸如因特网的网络执行通信处理。驱动器610也根据需要连接至I/O接口605。可拆卸介质611,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器610上,以便于从其上读出的计算机程序根据需要被安装入存储部分608。
特别地,根据本公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括有形地包含在机器可读介质上的计算机程序,所述计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分609从网络上被下载和安装,和/或从可拆卸介质611被安装。
附图中的流程图和框图,图示了按照本申请各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点 上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,所述模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。
作为另一方面,本申请还提供了一种非易失性计算机存储介质,该非易失性计算机存储介质可以是上述实施例中所述装置中所包含的非易失性计算机存储介质;也可以是单独存在,未装配入终端中的非易失性计算机存储介质。上述非易失性计算机存储介质存储有一个或者多个程序,当所述一个或者多个程序被一个设备执行时,使得所述设备:在可编程只读存储器中选取用于存储应用的可执行文件中的预设数据段的存储空间,其中,预设数据段为应用被加载时,被加载在所述可编程只读存储器中执行的数据段;将所述预设数据段拷贝至内存,以及基于所述存储空间的起始地址对所述预设数据段进行重定位;将经重定位的所述预设数据段拷贝至所述存储空间,以对应用进行加载。
以上描述仅为本申请的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本申请中所涉及的发明范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离所述发明构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本申请中公开的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。

Claims (12)

  1. 一种应用加载方法,其特征在于,所述方法包括:
    在可编程只读存储器中选取用于存储应用的可执行文件中的预设数据段的存储空间,其中,预设数据段为应用被加载时,被加载在所述可编程只读存储器中执行的数据段;
    将所述预设数据段拷贝至内存,以及基于所述存储空间的起始地址对所述预设数据段进行重定位;
    将经重定位的所述预设数据段拷贝至所述存储空间,以对应用进行加载。
  2. 根据权利要求1所述的方法,其特征在于,所述可编程只读存储器为闪存存储器。
  3. 根据权利要求1-2之一所述的方法,其特征在于,所述可执行文件为ELF文件,所述预设数据段包括:机器指令数据段、只读数据数据段;以及
    基于所述存储空间的起始地址对所述预设数据段进行重定位包括:
    在所述ELF文件的机器指令地址偏移数据段中查找机器指令数据段中的机器指令的操作数对应的地址偏移量;
    根据所述起始地址和所述地址偏移量,计算所述操作数对应的加载地址,以对机器指令数据段进行重定位;
    在所述ELF文件的只读数据地址偏移数据段中查找只读数据数据段中的只读数据对应的地址偏移量;
    根据所述起始地址和所述地址偏移量,计算所述只读数据对应的加载地址,以对只读数据数据段进行重定位。
  4. 根据权利要求3所述的方法,其特征在于,所述方法还包括:
    将所述ELF文件中的未初始化全局变量数据段和已初始化全局变 量数据段拷贝至内存;
    将未初始化全局变量数据段对应的存储空间中的存储值设置为0;
    从所述ELF文件的已初始化全局变量地址偏移数据段中查找出已初始化全局变量数据段中的已初始化全局变量对应的地址偏移量;
    根据已初始化全局变量数据段在内存中的起始地址以及所述地址偏移量,计算已初始化全局变量的加载地址,以对已初始化全局变量数据段进行重定位。
  5. 根据权利要求4所述的方法,其特征在于,在将经重定位的所述预设数据段拷贝至所述存储空间之后,所述方法还包括:
    在可编程只读存储器中存储所述存储空间的起始地址,以使得再次对应用进行加载时,利用所述起始地址查找出已存储在可编程只读存储器中的经重定位的预设数据段并对预设数据段进行加载。
  6. 一种应用加载装置,其特征在于,所述装置包括:
    选取单元,配置用于在可编程只读存储器中选取用于存储应用的可执行文件中的预设数据段的存储空间,其中,预设数据段为应用被加载时,被加载在所述可编程只读存储器中执行的数据段;
    重定位单元,配置用于将所述预设数据段拷贝至内存,以及基于所述存储空间的起始地址对所述预设数据段进行重定位;
    加载单元,配置用于将经重定位的所述预设数据段拷贝至所述存储空间,以对应用进行加载。
  7. 根据权利要求6所述的装置,其特征在于,所述可编程只读存储器为闪存存储器。
  8. 根据权利要求6-7之一所述的装置,其特征在于,所述重定位单元包括:
    第一查找子单元,配置用于当所述可执行文件为ELF文件,所述 预设数据段包括:机器指令数据段、只读数据数据段时,在所述ELF文件的机器指令地址偏移数据段中查找机器指令数据段中的机器指令的操作数对应的地址偏移量;
    第一计算子单元,配置用于根据所述起始地址和所述地址偏移量,计算所述操作数对应的加载地址,以对机器指令数据段进行重定位;
    第二查找子单元,配置用于在所述ELF文件的只读数据地址偏移数据段中查找只读数据数据段中的只读数据对应的地址偏移量;
    第二计算子单元,配置用于根据所述起始地址和所述地址偏移量,计算所述只读数据对应的加载地址,以对只读数据数据段进行重定位。
  9. 根据权利要求8所述的装置,其特征在于,所述装置还包括:
    拷贝单元,配置用于将所述ELF文件中的未初始化全局变量数据段和已初始化全局变量数据段拷贝至内存;
    设置单元,配置用于将未初始化全局变量数据段对应的存储空间中的存储值设置为0;
    偏移量查找单元,配置用于从所述ELF文件的已初始化全局变量地址偏移数据段中查找出已初始化全局变量数据段中的已初始化全局变量对应的地址偏移量;
    加载地址计算单元,配置用于根据已初始化全局变量数据段在内存中的起始地址以及所述地址偏移量,计算已初始化全局变量的加载地址,以对已初始化全局变量数据段进行重定位。
  10. 根据权利要求9所述的装置,其特征在于,所述装置还包括:
    存储单元,配置用于在将经重定位的所述预设数据段拷贝至所述存储空间之后,在可编程只读存储器中存储所述存储空间的起始地址,以使得再次对应用进行加载时,利用所述起始地址查找出已存储在可编程只读存储器中的经重定位的预设数据段并对预设数据段进行加载。
  11. 一种设备,包括:
    处理器;和
    存储器,
    所述存储器中存储有能够被所述处理器执行的计算机可读指令,在所述计算机可读指令被执行时,所述处理器执行应用加载方法,所述方法包括:
    在可编程只读存储器中选取用于存储应用的可执行文件中的预设数据段的存储空间,其中,预设数据段为应用被加载时,被加载在所述可编程只读存储器中执行的数据段;
    将所述预设数据段拷贝至内存,以及基于所述存储空间的起始地址对所述预设数据段进行重定位;
    将经重定位的所述预设数据段拷贝至所述存储空间,以对应用进行加载。
  12. 一种非易失性计算机存储介质,所述计算机存储介质存储有能够被处理器执行的计算机可读指令,当所述计算机可读指令被处理器执行时,所述处理器执行应用加载方法,所述方法包括:
    在可编程只读存储器中选取用于存储应用的可执行文件中的预设数据段的存储空间,其中,预设数据段为应用被加载时,被加载在所述可编程只读存储器中执行的数据段;
    将所述预设数据段拷贝至内存,以及基于所述存储空间的起始地址对所述预设数据段进行重定位;
    将经重定位的所述预设数据段拷贝至所述存储空间,以对应用进行加载。
PCT/CN2016/086217 2015-12-25 2016-06-17 应用加载方法和装置 Ceased WO2017107415A1 (zh)

Priority Applications (4)

Application Number Priority Date Filing Date Title
KR1020177027992A KR101955145B1 (ko) 2015-12-25 2016-06-17 애플리케이션 로딩 방법 및 장치
JP2017552148A JP6506412B2 (ja) 2015-12-25 2016-06-17 アプリケーションロード方法及び装置
US15/564,412 US11086638B2 (en) 2015-12-25 2016-06-17 Method and apparatus for loading application
EP16877228.3A EP3267308B1 (en) 2015-12-25 2016-06-17 Application loading method and device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510994261.4 2015-12-25
CN201510994261.4A CN105426223B (zh) 2015-12-25 2015-12-25 应用加载方法和装置

Publications (1)

Publication Number Publication Date
WO2017107415A1 true WO2017107415A1 (zh) 2017-06-29

Family

ID=55504451

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/086217 Ceased WO2017107415A1 (zh) 2015-12-25 2016-06-17 应用加载方法和装置

Country Status (6)

Country Link
US (1) US11086638B2 (zh)
EP (1) EP3267308B1 (zh)
JP (1) JP6506412B2 (zh)
KR (1) KR101955145B1 (zh)
CN (1) CN105426223B (zh)
WO (1) WO2017107415A1 (zh)

Families Citing this family (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105426223B (zh) 2015-12-25 2019-01-04 百度在线网络技术(北京)有限公司 应用加载方法和装置
CN106598674A (zh) * 2016-12-16 2017-04-26 中南大学 一种基于可重定位elf文件的软件快速加载方法
CN107450960A (zh) * 2017-09-18 2017-12-08 珠海亿智电子科技有限公司 一种对可执行elf文件重新链接和加载的方法
CN108241516B (zh) * 2018-02-09 2021-06-18 深圳科立讯通信有限公司 嵌入式系统程序加载方法、装置、计算机设备和存储介质
CN108874468B (zh) * 2018-06-20 2021-03-26 深圳市腾讯网络信息技术有限公司 应用程序的加载方法、装置、计算机设备及存储介质
CN109901891B (zh) * 2019-03-19 2022-06-14 北京智游网安科技有限公司 一种elf程序里添加数据的方法、存储介质及智能终端
CN110765027B (zh) * 2019-12-27 2020-04-10 中国人民解放军国防科技大学 一种pe文件地址定位系统
CN114090099B (zh) * 2020-08-03 2025-11-18 北京三六零智领科技有限公司 加固elf文件的加载方法、设备、存储介质及装置
CN116097218B (zh) * 2020-08-03 2025-08-22 华为技术有限公司 应用服务元数据编码和初始化
CN114692213B (zh) * 2020-12-30 2025-09-09 深圳Tcl新技术有限公司 数据防篡改方法、装置、智能终端及计算机可读存储介质
CN113032737B (zh) * 2021-03-15 2021-11-30 清华大学 软件的保护方法、装置、电子设备及存储介质
CN113821458B (zh) * 2021-09-18 2023-09-05 日立楼宇技术(广州)有限公司 一种数据操作方法、装置、计算机设备和存储介质
CN113849245B (zh) * 2021-09-23 2023-09-12 武汉深之度科技有限公司 一种应用程序运行方法、计算设备及存储介质
CN116107644B (zh) * 2022-12-08 2026-03-31 中船凌久电子(武汉)有限责任公司 一种基于dsp的实时操作系统启动时间优化方法
CN115934213A (zh) * 2022-12-28 2023-04-07 杭州和利时自动化有限公司 一种控制器栈调用方法、装置、设备及存储介质
CN117435257B (zh) * 2023-12-18 2024-02-27 美智纵横科技有限责任公司 系统加载方法及装置、存储介质、计算机程序产品和芯片

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5581768A (en) * 1995-02-27 1996-12-03 Intel Corporation Method and apparatus for executing applications in place from write once/seldom memories
CN101246427A (zh) * 2007-02-15 2008-08-20 凌阳科技股份有限公司 应用程序可重定位加载的方法及地址重定位装置
CN101470619A (zh) * 2007-12-29 2009-07-01 安凯(广州)软件技术有限公司 一种基于微核操作系统的应用程序动态加载方法
CN101661397A (zh) * 2008-08-29 2010-03-03 宇龙计算机通信科技(深圳)有限公司 实现程序动态加载的方法和生成映射文件的方法及设备
CN103377131A (zh) * 2012-04-13 2013-10-30 索尼公司 数据处理装置和方法
CN105426223A (zh) * 2015-12-25 2016-03-23 百度在线网络技术(北京)有限公司 应用加载方法和装置

Family Cites Families (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5379398A (en) 1992-04-20 1995-01-03 International Business Machines Corporation Method and system for concurrent access during backup copying of data
JPH103385A (ja) * 1996-06-18 1998-01-06 Dainippon Printing Co Ltd Icカード及びアプリケーション・プログラム導入方法
US5923878A (en) * 1996-11-13 1999-07-13 Sun Microsystems, Inc. System, method and apparatus of directly executing an architecture-independent binary program
US6505297B1 (en) * 1998-09-09 2003-01-07 Hitachi, Ltd. IC card terminal device and installation of application program into IC card terminal device
JP3976106B2 (ja) * 1998-09-09 2007-09-12 株式会社日立製作所 アプリケーション登録端末システムおよび登録方法
TWI240864B (en) * 2001-06-13 2005-10-01 Hitachi Ltd Memory device
KR100518584B1 (ko) * 2003-07-12 2005-10-04 삼성전자주식회사 공유 라이브러리 시스템 및 상기 시스템 구축 방법
US7415703B2 (en) * 2003-09-25 2008-08-19 International Business Machines Corporation Loading software on a plurality of processors
JP2005284963A (ja) * 2004-03-30 2005-10-13 Toshiba Corp プログラムローディング装置およびプログラムローディング方法
JP2006048431A (ja) * 2004-08-05 2006-02-16 Matsushita Electric Ind Co Ltd 動的リンクライブラリ処理装置
US7987158B2 (en) * 2005-02-09 2011-07-26 International Business Machines Corporation Method, system and article of manufacture for metadata replication and restoration
US20060277541A1 (en) * 2005-06-07 2006-12-07 Sony Computer Entertainment America Inc. Relocatable component file format
CN101484878B (zh) * 2006-07-18 2012-11-28 英特尔公司 为基于efi的固件中的预efi初始化模块使用全局变量的方法
US8082385B2 (en) * 2008-05-02 2011-12-20 Sony Corporation Systematic memory shift for pre-segmented memory
CN101277265B (zh) * 2008-05-07 2011-05-04 浙江大学 一种无线传感网络中加速加载elf文件的方法
CN101697131B (zh) * 2009-11-04 2013-07-03 中兴通讯股份有限公司 一种可重定位文件动态加载的方法及装置
CN101706725B (zh) * 2009-11-20 2014-03-19 中兴通讯股份有限公司 一种可重定位程序的加载及调试方法及系统
US20150332043A1 (en) * 2014-05-15 2015-11-19 Auckland Uniservices Limited Application analysis system for electronic devices
US9974492B1 (en) * 2015-06-05 2018-05-22 Life365, Inc. Health monitoring and communications device
TWI588742B (zh) * 2015-07-27 2017-06-21 晨星半導體股份有限公司 應用程式的程式碼載入方法及應用其方法的電腦系統

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5581768A (en) * 1995-02-27 1996-12-03 Intel Corporation Method and apparatus for executing applications in place from write once/seldom memories
CN101246427A (zh) * 2007-02-15 2008-08-20 凌阳科技股份有限公司 应用程序可重定位加载的方法及地址重定位装置
CN101470619A (zh) * 2007-12-29 2009-07-01 安凯(广州)软件技术有限公司 一种基于微核操作系统的应用程序动态加载方法
CN101661397A (zh) * 2008-08-29 2010-03-03 宇龙计算机通信科技(深圳)有限公司 实现程序动态加载的方法和生成映射文件的方法及设备
CN103377131A (zh) * 2012-04-13 2013-10-30 索尼公司 数据处理装置和方法
CN105426223A (zh) * 2015-12-25 2016-03-23 百度在线网络技术(北京)有限公司 应用加载方法和装置

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3267308A4 *

Also Published As

Publication number Publication date
CN105426223B (zh) 2019-01-04
CN105426223A (zh) 2016-03-23
JP2018511132A (ja) 2018-04-19
US11086638B2 (en) 2021-08-10
KR20170123337A (ko) 2017-11-07
EP3267308A1 (en) 2018-01-10
EP3267308B1 (en) 2022-07-27
JP6506412B2 (ja) 2019-04-24
EP3267308A4 (en) 2018-07-25
KR101955145B1 (ko) 2019-03-06
US20180329725A1 (en) 2018-11-15

Similar Documents

Publication Publication Date Title
WO2017107415A1 (zh) 应用加载方法和装置
US20140324873A1 (en) Method, device and recording medium for managing application icon
US20150032690A1 (en) Virtual synchronization with on-demand data delivery
EP3260993A1 (en) File operation method and device
US9164919B2 (en) Method and apparatus for inputting/outputting virtual operating system from removable storage device on a host using virtualization technique
CN105760201A (zh) 一种嵌入式装置的启动方法和装置
US20070011674A1 (en) Computer system and method for selectively installing one operating system among a plurality of operating systems
US20190050423A1 (en) Integrating virtual machine file system into a native file explorer
CN107646102B (zh) 引导设备及其操作方法
US11176089B2 (en) Systems and methods for implementing dynamic file systems
CN106293963B (zh) 一种用于windows系统中应用层和驱动层通讯的方法及系统
US10341852B2 (en) Informational articles in response to detection of devices or software
CN107402749B (zh) 实现图片加载库的方法及装置
US8667485B2 (en) Method and system for executing a file stored in a hidden storage area of a storage device
JP7522775B2 (ja) 不揮発性記憶区画識別子
US8719498B2 (en) Data storage device and data providing method therein
US7702890B2 (en) Information processing apparatus and program
CN101944034B (zh) 文件执行方法及系统
US20110106861A1 (en) Interface Techniques Providing Contiguous Storage For Files
CN104461636A (zh) 一种皮肤资源加载方法及电子设备
JP2015138272A (ja) 情報処理装置、情報処理方法、および情報処理プログラム
CN119884031A (zh) 一种通过文件拷贝的方式迁移Windows系统的方法
US20090037667A1 (en) Electronic device data access system and method
US10067945B2 (en) File and move data to shrink datafiles
HK1247324B (zh) 实现图片加载库的方法及装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16877228

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 20177027992

Country of ref document: KR

Kind code of ref document: A

ENP Entry into the national phase

Ref document number: 2017552148

Country of ref document: JP

Kind code of ref document: A

REEP Request for entry into the european phase

Ref document number: 2016877228

Country of ref document: EP

WWE Wipo information: entry into national phase

Ref document number: 15564412

Country of ref document: US

NENP Non-entry into the national phase

Ref country code: DE