CN100489781C - Method and apparatus for positioning target file - Google Patents

Method and apparatus for positioning target file Download PDF

Info

Publication number
CN100489781C
CN100489781C CNB200510059346XA CN200510059346A CN100489781C CN 100489781 C CN100489781 C CN 100489781C CN B200510059346X A CNB200510059346X A CN B200510059346XA CN 200510059346 A CN200510059346 A CN 200510059346A CN 100489781 C CN100489781 C CN 100489781C
Authority
CN
China
Prior art keywords
file destination
target device
address
reorientation
carried out
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.)
Expired - Fee Related
Application number
CNB200510059346XA
Other languages
Chinese (zh)
Other versions
CN1841329A (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.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies 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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CNB200510059346XA priority Critical patent/CN100489781C/en
Publication of CN1841329A publication Critical patent/CN1841329A/en
Application granted granted Critical
Publication of CN100489781C publication Critical patent/CN100489781C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The provided locating method for target file comprises: before loading, relocating the absolute address of target file; after loading, relocating its relative address, and completing the whole process. Wherein, the related devices comprise: a specific memory, a distribution pre-processor, and a relocating module for target file. This invention can improve memory utilance greatly, and reduces complexity for relocation and maintenance.

Description

The method and apparatus that file destination is positioned
Technical field
The present invention relates to computer application field, relate in particular to a kind of method and apparatus that file destination is positioned.
Background technology
Embedded system is based on computer technology, and is application-centered, but and the dedicated computer system of software and hardware cutting.Embedded device or other equipment need so just relate to the problem of file destination being carried out dynamic relocation usually with a program module dynamic load to target device when realizing functions such as dynamic module or online patch.
File destination is meant the binary expression form of program module in computer system, at file destination not and before other modules of application program together constitute executable program, its position in internal memory is unfixed, and the address that wherein comprises all is a floating address.Floating address in the file destination comprises relative address and specific address two classes.Specific address is meant the address of other modules of the application program relevant with file destination, and sort address just can be determined after other modules of application program are determined.Relative address is meant the address of REFER object file inside, could determine after sort address will be determined in the position of file destination in internal memory.
Other modules of file destination and application program are combined, and file destination is assigned to ad-hoc location in the internal memory, and the floating address in the file destination is revised as definite memory address, this process is called as the reorientation of file destination.In the process of reorientation, will generate final symbol table and reset bit table.The address information that comprises all variablees of file destination and function in the symbol table; Reset to comprise in the bit table and need the positional information revised in all code segments.Repositioning process to file destination can be finished by compilation tool.
A kind of method of in the prior art file destination being carried out dynamic relocation is: will all be placed on the target device the repositioning process of file destination and carry out; this method can generate a huge symbol table, the address of writing down each symbol usually on target device.Such as: if each symbol accounts for 32 bytes, 1024 symbols will take the internal memory of 32K nearly.In actual applications, the data on a lot of equipment are big more than the data in this example.Therefore, this method has increased the resource consumption of target device greatly.
The another kind of method of in the prior art file destination being carried out reorientation is pre-method for relocating, and the ultimate principle of this method as shown in Figure 1.Its core is: first off-line carries out pre-reorientation to file destination on the maintain customer end, determines the position of file destination in the target device internal memory, directly the file destination of this pre-reorientation is loaded into predetermined position in the target device then.The concrete treatment scheme of this method comprises the steps: as shown in Figure 2
Step 2-1, in the internal memory of target device, keep a reserved area.
For preventing the loading failure of file destination, in the internal memory of the target device that needs the loaded targets file, keep a reserved area, the special file destination of dynamic load of giving uses, and that is to say that all file destinations that are loaded all are assigned to this reserved area.
Step 2-2, in maintenance host, set up the off-line position the record of target device.
Set up at off-line on the maintenance host on the target device need the loaded targets file all and locate relevant information record, comprising the information such as position of the symbol table of target device, internal memory operating position, each file destination of having loaded.
Step 2-3, maintain customer end read the position the record in the maintenance host.
Before file destination is carried out reorientation, earlier be provided with one and keep client, and utilize position the record in the maintenance host that maintain customer end read step 2-2 set up at the target device that needs the loaded targets file.
Step 2-4, maintain customer end carry out pre-reorientation according to the position the record that obtains to file destination.
The maintain customer end carries out pre-reorientation according to the position the record that obtains to file destination.Promptly pre-determine the position of file destination in the internal memory of target device,, be about to specific address and the memory address of relative address modification in the file destination for determining comprising specific address in the file destination and relative address are carried out pre-reorientation.This pre-repositioning process will generate the symbol table of file destination and reset bit table.Now also do not have ready-made general utility tool can finish the pre-repositioning process of this off-line, therefore, this step can only be encoded by the deviser and be finished.
Step 2-5, maintain customer end are with the position of the predetermined file destination of step 2-4 in the internal memory of target device, and the symbolic information of the file destination of step 2-4 generation, write in the maintenance host.
The file destination that step 2-6, maintain customer end will pass through pre-reorientation is loaded into the predetermined position of step 2-4 in the target device, and so far, the pre-repositioning process of file destination finishes.
Above the major defect of described pre-method for relocating be:
1, be necessary for each target device and be equipped with a maintenance host, this maintenance host off-line is safeguarded the information record that the whole of a target device are relevant with the location, and maintenance cost is higher.In case and the off-line record is inconsistent with target device, will cause serious consequence.Give an example, suppose to safeguard two target devices with a maintain customer end, loaded a file destination A on one of them equipment P, what another equipment Q goes up does not all have to load, now will be to P loaded targets file B, but used the position the record of equipment Q mistakenly, owing to there is not the information of file destination A on the Q, B just may directly cover on the A, causes system crash.Avoid this situation to take place, need to do complicated verification, cost is higher;
2, target device must be file destination reserved location in internal memory, could guarantee the certain success in off-line location to file destination, greatly reduces the utilization factor of the internal memory of target device.Give an example, if the off-line positioning equipment is distributed in this position of A1 to file destination, but this position the operation in occupied by certain program, the loading of file destination will be failed;
3, this method implements more complicated, can not effectively utilize existing resource, does not have ready-made general utility tool can finish the reorientation of this off-line to file destination, and whole off-line repositioning process can only be encoded by the deviser and be finished.
Summary of the invention
In view of above-mentioned existing in prior technology problem, the purpose of this invention is to provide a kind of method and apparatus that file destination is positioned, thereby improved the memory usage of target device widely, reduced the complexity of file destination being carried out the realization and the maintenance of reorientation system.
The objective of the invention is to be achieved through the following technical solutions:
A kind of method that file destination is positioned comprises:
A, before file destination is loaded into target device, the specific address in the file destination is carried out reorientation;
B, after described file destination is loaded into target device, the relative address in the file destination is carried out reorientation, finish all processes to the file destination reorientation.
Described steps A further comprises:
A1, set up the symbolic information record of target device;
A2, before file destination is loaded into target device, according to described symbolic information record the specific address in the file destination is carried out reorientation.
Described steps A 1 further comprises:
Off-line is set up the symbolic information record of the address information that comprises all global variables of target device and function.
Described steps A 2 further comprises:
A21, according to the symbolic information record of described target device, obtain the address of other modules of the application program relevant with file destination;
A22, before file destination is loaded into target device, according to the address of other modules of the described application program that obtains, the specific address in the file destination is carried out reorientation.
Described step B further comprises:
After described file destination is loaded into target device, the relative address in the file destination is carried out reorientation according to the position of file destination in internal memory.
A kind of device that file destination is positioned comprises:
Private memory: the symbolic information record that is used to set up the address information that comprises all variablees of target device and function;
Issue pretreating machine: be used for reading the symbolic information record of the target device of private memory, and, the specific address in the file destination carried out reorientation according to this symbolic information record;
File destination reorientation module: be arranged in the target device, be used to realize the loading of file destination, and, the relative address in the file destination that loads is carried out reorientation according to the position of file destination in internal memory.
Described target device can be embedded system.
Described issue pretreating machine can be realized by linker.
As seen from the above technical solution provided by the invention, utilize the method for the invention, can before file destination is published to target device, finish, do not need the final user of target device to intervene the pre-service of file destination; Do not need on the target device to be the file destination headspace, improved the memory usage of target device widely; In most of system, can directly use existing compiler to finish to the issue pre-treatment of file destination, reduce the complexity of file destination being carried out the realization and the maintenance of reorientation system.
Description of drawings
Fig. 1 is the ultimate principle figure of pre-method for relocating in the prior art;
The concrete processing flow chart of pre-method for relocating in Fig. 2 prior art;
Fig. 3 is the structural drawing of device of the present invention;
Fig. 4 is the ultimate principle figure of the method for the invention;
The concrete processing flow chart of Fig. 5 the method for the invention.
Embodiment
The invention provides a kind of method and apparatus that file destination is positioned, core of the present invention is: before giving a particular target device loaded targets file, earlier file destination is carried out the part pre-determined bit, promptly only the specific address in the file destination is carried out reorientation, the location of the relative address in the file destination then is deferred to file destination and finishes after being loaded on the target device.
The structural drawing of device of the present invention comprises as shown in Figure 3:
Private memory: the symbolic information record that is used to set up the address information that comprises all variablees of target device and function.
Private memory in the device of the present invention is that employing mode of off-line outside target device realizes.
Issue pretreating machine: be used for reading the symbolic information record of the target device of private memory, and, the specific address in the file destination carried out reorientation according to this symbolic information record.
Issue pretreating machine among the present invention can utilize some ready-made general utility tools to realize, can be directly in a lot of systems function by compilation tool itself realize.For example can utilize widely used gnu compilation tool in built-in field, as long as in Id script, describe the address of the symbol need absolute fix, use then-r parameter renegotiation new url once, can finish.
File destination reorientation module: be arranged in the target device, be used to cooperate the issue pretreating machine to realize the loading of file destination, and the position of definite file destination in internal memory, and, the relative address in the file destination that loads is carried out reorientation according to the position of file destination in internal memory.
Target device in the device of the present invention can be embedded system.
Below we describe the method for the invention in conjunction with the accompanying drawings in detail, the principle of the method for the invention is as shown in Figure 4.Its ultimate principle is:
Off-line is kept the symbolic information record that portion comprises the address information of whole functions of target device and variable in private memory.Before file destination is loaded into particular target device, earlier file destination is carried out the part pre-determined bit, promptly on the issue pretreating machine according to the off-line symbolic information record of target device, specific address to file destination is carried out reorientation, the file destination that will carry out the part pre-determined bit then is loaded on the particular target device, on particular target device, finish location, thereby finish the overall process of file destination being carried out reorientation the file destination relative address.
The concrete treatment scheme of the method for the invention comprises the steps: as shown in Figure 5
Step 5-1, off-line is set up the symbolic information record of target device in private memory.
Off-line is set up the symbolic information record of the address information that comprises whole functions of the target device that needs the loaded targets file and variable on private memory, comprising the symbol table of the target device that needs the loaded targets file.
Step 5-2, issue pretreating machine read the symbolic information record in the private memory.
Before file destination is carried out reorientation, earlier an issue pretreating machine is set, and utilizes the target device symbolic information record in the private memory that issue pretreating machine read step 4-1 set up at the target device that needs the loaded targets file.
Step 5-3, issue pretreating machine carry out reorientation according to the symbolic information record that obtains to the specific address of file destination.
The issue pretreating machine carries out the part pre-determined bit according to the target device symbolic information record that obtains to file destination, only the specific address of file destination is carried out pre-determined bit.Promptly write down the address of other modules of obtaining the application program relevant with file destination according to the target device symbolic information, and then the position of specific address in the internal memory of target device in definite file destination, and the specific address in the file destination is revised as definite memory address.
The file destination that step 5-4, issue pretreating machine will carry out the part pre-determined bit is loaded on the target device.
The issue pretreating machine will carry out the file destination that the part pre-determined bit crosses and be loaded on the target device, and determine the position of file destination in internal memory by the file destination reorientation module in the target device.
Step 5-5, the relative address to file destination on target device are carried out reorientation.
According to the position of file destination in internal memory, finish reorientation by the file destination reorientation module in the target device to the relative address of file destination, both the relative address modification in the file destination is definite memory address, so far, to the repositioning process end of file destination.
If will use the other side's symbolic information between file destination, can be after file destination be loaded into target device, reservation symbol wherein is so that in the destination end reorientation.Because this symbol is original just in file destination, can't increase the weight of the burden of target device.
So far, the concrete treatment scheme of the method for the invention finishes.
To sum up said, utilize the method for the invention, the memory usage of target device can be improved widely, and existing resource can be effectively utilized, reduced the complexity of file destination being carried out the realization and the maintenance of reorientation system.
The above; only for the preferable embodiment of the present invention, but protection scope of the present invention is not limited thereto, and anyly is familiar with those skilled in the art in the technical scope that the present invention discloses; the variation that can expect easily or replacement all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection domain of claim.

Claims (8)

1, a kind of method that file destination is positioned is characterized in that, comprising:
A, before file destination is loaded into target device, the specific address in the file destination is carried out reorientation;
B, after described file destination is loaded into target device, the relative address in the file destination is carried out reorientation, finish all processes to the file destination reorientation.
2, according to the described method that file destination is positioned of claim 1, it is characterized in that described steps A further comprises:
A1, set up the symbolic information record of the target device be used to realize specific address reorientation operation;
A2, before file destination is loaded into target device, according to described symbolic information record the specific address in the file destination is carried out reorientation.
According to the described method that file destination is positioned of claim 2, it is characterized in that 3, described steps A 1 further comprises:
Off-line is set up the symbolic information record of the address information that comprises all global variables of target device and function.
According to the described method that file destination is positioned of claim 2, it is characterized in that 4, described steps A 2 further comprises:
A21, according to the symbolic information record of described target device, obtain the address of other modules of the application program relevant with file destination;
A22, before file destination is loaded into target device, according to the address of other modules of the described application program that obtains, the specific address in the file destination is carried out reorientation.
5, according to claim 1,2, the 3 or 4 described methods that file destination is positioned, it is characterized in that described step B further comprises:
After described file destination is loaded into target device, the relative address in the file destination is carried out reorientation according to the position of file destination in internal memory.
6, a kind of device that file destination is positioned is characterized in that, comprising:
Private memory: the symbolic information record that is used to set up the address information that comprises all variablees of target device and function;
Issue pretreating machine: be used for reading the symbolic information record of the target device of private memory, and, the specific address in the file destination carried out reorientation according to this symbolic information record;
File destination reorientation module: be arranged in the target device, be used to realize the loading of file destination, and, the relative address in the file destination that loads is carried out reorientation according to the position of file destination in internal memory.
According to the described device that file destination is positioned of claim 6, it is characterized in that 7, described target device can be embedded system.
8, according to claim 6 or the 7 described devices that file destination is positioned, it is characterized in that described issue pretreating machine can be realized by linker.
CNB200510059346XA 2005-03-28 2005-03-28 Method and apparatus for positioning target file Expired - Fee Related CN100489781C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB200510059346XA CN100489781C (en) 2005-03-28 2005-03-28 Method and apparatus for positioning target file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB200510059346XA CN100489781C (en) 2005-03-28 2005-03-28 Method and apparatus for positioning target file

Publications (2)

Publication Number Publication Date
CN1841329A CN1841329A (en) 2006-10-04
CN100489781C true CN100489781C (en) 2009-05-20

Family

ID=37030368

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB200510059346XA Expired - Fee Related CN100489781C (en) 2005-03-28 2005-03-28 Method and apparatus for positioning target file

Country Status (1)

Country Link
CN (1) CN100489781C (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101661397B (en) * 2008-08-29 2012-09-12 宇龙计算机通信科技(深圳)有限公司 Method for realizing dynamic loading of program and method and equipment for generating mapping file
CN101706725B (en) 2009-11-20 2014-03-19 中兴通讯股份有限公司 Method and system for loading and debugging relocatable program
CN102831178B (en) * 2012-07-30 2016-05-25 华为技术有限公司 Heavy dispositions method and the device of multistage storage
CN102982277A (en) * 2012-12-24 2013-03-20 广东威创视讯科技股份有限公司 Method and system achieving embedded system software patching
CN110765027B (en) * 2019-12-27 2020-04-10 中国人民解放军国防科技大学 PE file address positioning system
CN115328454A (en) * 2021-05-10 2022-11-11 阿里云计算有限公司 Program compiling and program loading method

Also Published As

Publication number Publication date
CN1841329A (en) 2006-10-04

Similar Documents

Publication Publication Date Title
CN100489781C (en) Method and apparatus for positioning target file
CN100341007C (en) Multi-smart cards for internal operating system
CN105190571B (en) Page table data management
CN101236483A (en) Cooperative memory management
CN1933647B (en) Apparatus and method for controlling access to an external memory
CN1288591C (en) Portable information recording medium
US20080184006A1 (en) Method and System for Preloading Page Using Control Flow
CN100468349C (en) Method of testing memory
CN101894028A (en) Realization method and device for Linux kernel mirror image data supporting various CPUs
US20060101437A1 (en) Data processing device and method
KR20120050406A (en) Process, computer program, and device for security of intermediate code of programming for the execution thereof by a virtual machine
US20090276575A1 (en) Information processing apparatus and compiling method
CN101706788A (en) Cross-area access method for embedded file system
US20200327052A1 (en) Compiling application with multiple function implementations for garbage collection
CN103593301A (en) Bad block management method and system
CN103560934A (en) Power line modem production testing method and device
CN104182349A (en) Information processing method and electronic device
WO2018125408A1 (en) Automatic identification and generation of non-temporal store and load operations in a dynamic optimization environment
US9223697B2 (en) Computer reprogramming method, data storage medium and motor vehicle computer
US7251671B2 (en) Method and system for garbage collection wherein resetting the mark/allocation bit, and switching the mark/allocation bit to the mark bit to perform marking and scanning of objects using the identified object as a root object and providing mark/allocation bit information being displayed at the client
US9639477B2 (en) Memory corruption prevention system
CN103366115A (en) Safety detecting method and device
CN100492299C (en) Embedded software developing method and system
CN103164290A (en) Management method and management device of application memory
US20050268021A1 (en) Method and system for operating a cache memory

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20090520

Termination date: 20170328