CN103218428A - Dynamic link method and system - Google Patents

Dynamic link method and system Download PDF

Info

Publication number
CN103218428A
CN103218428A CN2013101211166A CN201310121116A CN103218428A CN 103218428 A CN103218428 A CN 103218428A CN 2013101211166 A CN2013101211166 A CN 2013101211166A CN 201310121116 A CN201310121116 A CN 201310121116A CN 103218428 A CN103218428 A CN 103218428A
Authority
CN
China
Prior art keywords
function
built
application
address
jump
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
CN2013101211166A
Other languages
Chinese (zh)
Other versions
CN103218428B (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.)
Shenzhen Jiuzhou Electric Appliance Co Ltd
Original Assignee
Shenzhen Jiuzhou Electric Appliance 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 Shenzhen Jiuzhou Electric Appliance Co Ltd filed Critical Shenzhen Jiuzhou Electric Appliance Co Ltd
Priority to CN201310121116.6A priority Critical patent/CN103218428B/en
Publication of CN103218428A publication Critical patent/CN103218428A/en
Application granted granted Critical
Publication of CN103218428B publication Critical patent/CN103218428B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention is suitable for the technical field of computer software and provides a dynamic link method and system. The method comprises the following steps of reading a library of an executable and linkable format (ELF); copying a jump address of a library function to a jump table reserved space of an application, and copying a code segment of the library function to an application part reserved space of the application, wherein the address of the code segment of the library function in the library and the address of the code segment of the library function in the application are consistent; querying the jump address of the library function in the jump table of the application when the library function is called by the application, and jumping to the code segment of the library function for execution according to the jump address of the library function; and querying a corresponding function address in the jump table of the application when the application is called by the library function, and jumping to the code segment of the application for execution according to the function address which corresponds to the application. According to the dynamic link method and system provided by the invention, through copying the jump address and the code segment of the library function into the application, the problem that a dynamic link library cannot be called by the application under the condition that the dynamic link library is not supported by certain system in the prior art is solved.

Description

A kind of dynamic link method and system
Technical field
The invention belongs to computer software technical field, relate in particular to a kind of dynamic link method and system.
Background technology
(English: Dynamic Link Library, be called for short: DLL) be one and comprise the code that can be used simultaneously by a plurality of programs and the storehouse of data, DLL is not an executable file to dynamic link library.Dynamic link provides a kind of method, make process can call the function that does not belong to its executable code, the executable code of function is arranged in a DLL, this DLL comprise one or more by compiling, link and with the function of the process separate storage of using them.DLL also helps shared data and resource.
But dynamic link depends on the support of system, just can finish the link of dynamic link library by the function of dynamic link under linux system, and some systems does not support dynamic link.
Summary of the invention
The purpose of the embodiment of the invention is to provide a kind of dynamic link method and system, and prior art exists to solve, and some systems do not support dynamic link, and application can't be called the problem of dynamic link library.
Embodiments of the invention are achieved in that a kind of dynamic link method, said method comprising the steps of:
Read the storehouse that can carry out linking format ELF, described storehouse of carrying out linking format ELF comprises: the jump address of built-in function and the code segment of built-in function;
The jump address of duplicating built-in function is to the jump list headspace of using, and the code segment that duplicates built-in function is to the applying portion headspace of using, and the code segment of described built-in function is consistent with the address in the application in the storehouse;
During the application call built-in function, the jump address of inquiry built-in function in the jump list of using, according to the jump address of described built-in function, the code segment that jumps to built-in function is carried out;
When library function call was used, corresponding function address was used in inquiry in the jump list of application, and according to the described function address of using correspondence, the code segment that jumps to application is carried out.
Another purpose of embodiments of the invention is to provide a kind of dynamic linkage system, and described system comprises:
Reading unit is used to read the storehouse that can carry out linking format ELF, and described storehouse of carrying out linking format ELF comprises: the jump address of built-in function and the code segment of built-in function;
Copied cells, the jump address that is used to duplicate built-in function are to the jump list headspace of using, and the code segment that duplicates built-in function is to the applying portion headspace of using, and the code segment of described built-in function is consistent with the address in the application in the storehouse;
First call unit, when being used for the application call built-in function, the jump address of inquiry built-in function in the jump list of using, according to the jump address of described built-in function, the code segment that jumps to built-in function is carried out;
Second call unit, when being used for the library function call application, corresponding function address is used in inquiry in the jump list of using, and according to the corresponding function address of described application, the code segment that jumps to application is carried out.
The embodiment of the invention is by copying to the jump address of built-in function and the code segment of built-in function in the application, make application and built-in function to call mutually, solved that prior art exists, some systems do not support that under the situation of dynamic link, application can't be called the problem of dynamic link library.
Description of drawings
In order to be illustrated more clearly in the technical scheme in the embodiment of the invention, to do to introduce simply to the accompanying drawing of required use in embodiment or the description of the Prior Art below, apparently, accompanying drawing in describing below only is some embodiments of the present invention, for those of ordinary skills, under the prerequisite of not paying creative work, can also obtain other accompanying drawing according to these accompanying drawings.
Fig. 1 is the realization flow figure of the dynamic link method that provides of the embodiment of the invention;
Fig. 2 is the structural representation in the storehouse of the linking format carried out that provides of the embodiment of the invention;
Fig. 3 is the structural representation that duplicates application before that the embodiment of the invention provides;
Fig. 4 is the structural representation that duplicates application afterwards that the embodiment of the invention provides;
Fig. 5 is the modular structure figure of the dynamic linkage system that provides of the embodiment of the invention.
Embodiment
In order to make purpose of the present invention, technical scheme and advantage clearer,, the present invention is further elaborated below in conjunction with drawings and Examples.Should be appreciated that specific embodiment described herein only in order to explanation the present invention, and be not used in qualification the present invention.
The embodiment of the invention provides the dynamic link method, and the executive agent of described method is the dynamic base link system, described method as shown in Figure 1, concrete steps comprise:
S11, read can carry out linking format (English: Executable and Linkable Format, be called for short: storehouse ELF).
Before the described S11 of step, the storehouse of ELF constitutes by the jump list of compiling link DLL and manual creation, Fig. 2 is the structural representation that can carry out the storehouse of linking format, the storehouse of described ELF comprises existing output jump list, virtual input jump list and applying portion, the jump address and the attribute of described existing output jump list thesaurus function, applying portion has been stored code segment, data and the static data of built-in function.
S12, duplicate described built-in function jump address to the jump list headspace of using, the code segment that duplicates built-in function is to the applying portion headspace of using.
Need to prove, when the jump address of built-in function is used for application or other function call built-in function, find the position of the code segment of built-in function by the jump address of described built-in function; The code segment of built-in function copies to from the storehouse in the application, and the code segment address stored of built-in function is constant, otherwise can't accurately find the code segment of built-in function by the jump address of built-in function.
Fig. 3 is the structural representation that duplicates application before, Fig. 4 is the structural representation that duplicates application afterwards, the process of duplicating comprises: the space that the applying portion that existing output jump list virtual output jump list to Fig. 3 in the reconstructed chart 2, the code segment in the reconstructed chart 2, data and static data area are used to Fig. 3 is reserved.
When S13, application call built-in function, in the jump address of the jump list inquiry built-in function of using, according to the jump address of described built-in function, the code segment that jumps to built-in function is carried out;
When S14, library function call application, corresponding function address is used in inquiry in the jump list of using, and according to the corresponding function address of described application, the code segment that jumps to application is carried out.
Need to prove, before the code segment of jump address of not duplicating built-in function and built-in function, in the jump list of using, just store and use corresponding function address.
As shown in Figure 4, the jump list that virtual output jump list and existing input jump list general designation are used, code segment on the DLL latter end, data and static data duplicate from the storehouse, exist in using before code, data and the static data below the DLL latter end duplicates; When step 1 is the application call built-in function, find the jump address of built-in function in virtual output jump list, step 2 is that the code segment that jumps to built-in function is carried out then; When step 3 is the function of library function call application correspondence, finds in existing input jump list and use corresponding function address, step 4 is that the code segment that jumps to application is carried out then.
Need to prove, may have the relation of calling mutually between the function of built-in function and application, realized that by said method the function of built-in function and application calls mutually, make application and dynamic link library call mutually easily and flexibly.
In the present embodiment, copy to the jump list of application by jump address with built-in function, can be so that during the application call built-in function, find the jump address of built-in function and carry out at the jump list of using according to the code segment that described jump address jumps to built-in function, realized using calling to dynamic link library, when having solved some systems that prior art exists and not supporting dynamic link, application can't call the problem of dynamic link library.
The embodiment of the invention provides dynamic linkage system, and described system specifically comprises as shown in Figure 5:
Reading unit 51, the storehouse that is used to read ELF, the storehouse of described ELF comprises: the code segment of the jump address of built-in function, the attribute of built-in function, built-in function, the data of built-in function and the static data of built-in function.
Copied cells 52, the jump address that is used to duplicate built-in function are to the jump list headspace of using, and the code segment that duplicates built-in function is to the applying portion headspace of using, and the code segment of described built-in function is consistent with the address in the application in the storehouse.
First call unit 53, when being used for the application call built-in function, the jump address of inquiry built-in function in the jump list of using, according to the jump address of described built-in function, the code segment that jumps to built-in function is carried out.
Second call unit 54, when being used for the library function call application, corresponding function address is used in inquiry in the jump list of using, and according to the corresponding function address of described application, the code segment that jumps to application is carried out.
One of ordinary skill in the art will appreciate that to each included module of the foregoing description is to divide according to function logic, but be not limited to above-mentioned division, as long as can realize function corresponding; In addition, the concrete title of each functional module also just for the ease of mutual differentiation, is not limited to protection scope of the present invention.
Those of ordinary skills it is also understood that, realize that all or part of step in the foregoing description method is to instruct relevant hardware to finish by program, described program can be in being stored in read/write memory medium, and described storage medium comprises ROM/RAM etc.
The above only is preferred embodiment of the present invention, not in order to restriction the present invention, all any modifications of being done within the spirit and principles in the present invention, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.

Claims (4)

1. a dynamic link method is characterized in that, described method comprises:
Read the storehouse that can carry out linking format ELF, described storehouse of carrying out linking format ELF comprises: the jump address of built-in function and the code segment of built-in function;
The jump address of duplicating built-in function is to the jump list headspace of using, and the code segment that duplicates built-in function is to the applying portion headspace of using, and the code segment of described built-in function is consistent with the address in the application in the storehouse;
During the application call built-in function, the jump address of inquiry built-in function in the jump list of using, according to the jump address of described built-in function, the code segment that jumps to built-in function is carried out;
When library function call was used, corresponding function address was used in inquiry in the jump list of application, and according to the described function address of using correspondence, the code segment that jumps to application is carried out.
2. the method for claim 1 is characterized in that, the described storehouse that can carry out linking format ELF of reading comprises before:
The jump list of compiling link dynamic link library (DLL) and manual creation constitutes the storehouse of ELF.
3. a dynamic linkage system is characterized in that, described system comprises:
Reading unit is used to read the storehouse that can carry out linking format ELF, and described storehouse of carrying out linking format ELF comprises: the jump address of built-in function and the code segment of built-in function;
Copied cells, the jump address that is used to duplicate built-in function are to the jump list headspace of using, and the code segment that duplicates built-in function is to the applying portion headspace of using, and the code segment of described built-in function is consistent with the address in the application in the storehouse;
First call unit, when being used for the application call built-in function, the jump address of inquiry built-in function in the jump list of using, according to the jump address of described built-in function, the code segment that jumps to built-in function is carried out;
Second call unit, when being used for the library function call application, corresponding function address is used in inquiry in the jump list of using, and according to the corresponding function address of described application, the code segment that jumps to application is carried out.
4. system as claimed in claim 3 is characterized in that, described system also comprises:
Compilation unit, the jump list that is used for compiling link dynamic link library (DLL) and manual creation constitutes the storehouse of ELF.
CN201310121116.6A 2013-04-09 2013-04-09 A kind of dynamic link method and system Expired - Fee Related CN103218428B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310121116.6A CN103218428B (en) 2013-04-09 2013-04-09 A kind of dynamic link method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310121116.6A CN103218428B (en) 2013-04-09 2013-04-09 A kind of dynamic link method and system

Publications (2)

Publication Number Publication Date
CN103218428A true CN103218428A (en) 2013-07-24
CN103218428B CN103218428B (en) 2016-07-06

Family

ID=48816215

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310121116.6A Expired - Fee Related CN103218428B (en) 2013-04-09 2013-04-09 A kind of dynamic link method and system

Country Status (1)

Country Link
CN (1) CN103218428B (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105677435A (en) * 2015-12-30 2016-06-15 小米科技有限责任公司 Function invoking method, apparatus and terminal
CN105955762A (en) * 2016-04-19 2016-09-21 北京金山安全软件有限公司 Method and device for injecting dynamic link library file and electronic equipment
CN106354536A (en) * 2016-08-31 2017-01-25 北京奇虎科技有限公司 Method and device of loading ELF file of Linux system in Windows system
WO2017015856A1 (en) * 2015-07-28 2017-02-02 华为技术有限公司 Method, device and system for calling operating system library
WO2018086313A1 (en) * 2016-11-10 2018-05-17 华为技术有限公司 Method for acquiring address of function, and electronic device
CN109144575A (en) * 2017-06-16 2019-01-04 北京海誉动想科技股份有限公司 Device, method, electronic equipment and the memory of cross operating system operation application
CN111142969A (en) * 2019-12-27 2020-05-12 贵阳动视云科技有限公司 Method, device, medium and equipment for calling 32-bit program module by 64-bit program

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6708330B1 (en) * 2000-06-13 2004-03-16 Cisco Technology, Inc. Performance improvement of critical code execution
CN101026825A (en) * 2005-12-01 2007-08-29 三星电子株式会社 System and method for a patch minimization tool
CN101026826A (en) * 2005-12-01 2007-08-29 三星电子株式会社 System and method for providing monolithic image for use in a wireless device
CN101441566A (en) * 2008-11-18 2009-05-27 腾讯科技(深圳)有限公司 Embedded type platform and method for dynamically linking program on the same

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6708330B1 (en) * 2000-06-13 2004-03-16 Cisco Technology, Inc. Performance improvement of critical code execution
CN101026825A (en) * 2005-12-01 2007-08-29 三星电子株式会社 System and method for a patch minimization tool
CN101026826A (en) * 2005-12-01 2007-08-29 三星电子株式会社 System and method for providing monolithic image for use in a wireless device
CN101441566A (en) * 2008-11-18 2009-05-27 腾讯科技(深圳)有限公司 Embedded type platform and method for dynamically linking program on the same

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017015856A1 (en) * 2015-07-28 2017-02-02 华为技术有限公司 Method, device and system for calling operating system library
CN107615243A (en) * 2015-07-28 2018-01-19 华为技术有限公司 A kind of method, apparatus and system of call operation system library
CN107615243B (en) * 2015-07-28 2019-12-13 华为技术有限公司 Method, device and system for calling operating system library
CN105677435A (en) * 2015-12-30 2016-06-15 小米科技有限责任公司 Function invoking method, apparatus and terminal
CN105955762A (en) * 2016-04-19 2016-09-21 北京金山安全软件有限公司 Method and device for injecting dynamic link library file and electronic equipment
CN106354536A (en) * 2016-08-31 2017-01-25 北京奇虎科技有限公司 Method and device of loading ELF file of Linux system in Windows system
WO2018086313A1 (en) * 2016-11-10 2018-05-17 华为技术有限公司 Method for acquiring address of function, and electronic device
CN109144575A (en) * 2017-06-16 2019-01-04 北京海誉动想科技股份有限公司 Device, method, electronic equipment and the memory of cross operating system operation application
CN109144575B (en) * 2017-06-16 2021-07-16 北京海誉动想科技股份有限公司 Device and method for running application across operating systems, electronic equipment and memory
CN111142969A (en) * 2019-12-27 2020-05-12 贵阳动视云科技有限公司 Method, device, medium and equipment for calling 32-bit program module by 64-bit program

Also Published As

Publication number Publication date
CN103218428B (en) 2016-07-06

Similar Documents

Publication Publication Date Title
CN103218428A (en) Dynamic link method and system
CN103473067B (en) Built-in Linux subregion and data restoration method, system and system development method
US8707286B2 (en) Unique context-based code enhancement
CN103365668A (en) Loading and linking method and device of dynamic link library
CN110457045B (en) Component combining and compiling method, device, equipment and storage medium
CN104714788A (en) Method and device for automatically generating software installation package
JP2005032259A (en) Shared library system and its formulation method
US10768944B2 (en) Method and system for customizing desktop launcher of mobile terminal
CN101980157A (en) Mobile terminal starting method and mobile terminal
CN105426223A (en) Application loading method and device
CN103218227B (en) The method of compatible multiple file system and device on a kind of Android device built-in hard disk
CN104063284B (en) The method and apparatus running application program
CN101403966B (en) Method for implementing portable software
KR101036675B1 (en) A method to use global variables for pre-efi initialization modules in efi-based firmware
CN101930377B (en) Link library compiling method by dynamically acquiring UID
CN103514004A (en) Method and device for managing system environment under Windows system
CN104063234A (en) Compatible method and device
CN102819439A (en) Method and device of dynamically loading multi-system application programs based on relocation
CN115700470A (en) File loading processing method and device, computer storage medium and electronic equipment
CN101650668A (en) Method and device for realizing virtual environment
CN102216901B (en) Module expansion method and device thereof
CN105786613A (en) Method for improving utilization rate of internal memory
CN104331311A (en) Upgrade package generating method and device
CN109918059B (en) Application function expansion method and device, terminal equipment and storage medium
CN103235745A (en) Address conflict detection method and device

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: 20160706

Termination date: 20180409