JP2006113935A - Dynamic link library calling code generation method, program, and apparatus - Google Patents

Dynamic link library calling code generation method, program, and apparatus Download PDF

Info

Publication number
JP2006113935A
JP2006113935A JP2004302542A JP2004302542A JP2006113935A JP 2006113935 A JP2006113935 A JP 2006113935A JP 2004302542 A JP2004302542 A JP 2004302542A JP 2004302542 A JP2004302542 A JP 2004302542A JP 2006113935 A JP2006113935 A JP 2006113935A
Authority
JP
Japan
Prior art keywords
dynamic link
link library
library
wrapper
code
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.)
Pending
Application number
JP2004302542A
Other languages
Japanese (ja)
Inventor
Tomoya Ota
智也 太田
Hiroyasu Nishiyama
博泰 西山
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.)
Hitachi Ltd
Original Assignee
Hitachi 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 Hitachi Ltd filed Critical Hitachi Ltd
Priority to JP2004302542A priority Critical patent/JP2006113935A/en
Publication of JP2006113935A publication Critical patent/JP2006113935A/en
Pending legal-status Critical Current

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To create a loading image of a dynamic link library for each application program in an execution environment where one process can execute a plurality of applications. <P>SOLUTION: A wrapper library generation apparatus 1 performs: a first reading step for reading a dynamic link library 31 stored in a storage part 30, a generation step for generating a wrapper library 34 based on functions described in the read dynamic link library 31, a second reading step for reading an application program 35 stored in the storage part 30, and a converting step for specifying a code calling the dynamic link library 31 in the application program 35 to convert the calling code into a code for calling the wrapper library 34. <P>COPYRIGHT: (C)2006,JPO&NCIPI

Description

本発明は、ダイナミックリンクライブラリを呼び出す技術に関する。   The present invention relates to a technique for calling a dynamic link library.

Windows(登録商標)などのオペレーティングシステム(以下、「OS」)は、当該OS上で動作するアプリケーションプログラムの実行ごとに、1つのプロセス(ジョブの単位)を割り当てる。そして、アプリケーションプログラムがダイナミックリンクライブラリ(dynamic link library)(以下、「DLL」)の関数を利用する場合、OSは、プロセスにDLLを動的に取り込む。すなわち、OSは、DLLのメモリ領域の確保、初期化、再配置などを行う。そして、アプリケーションプログラムは、再配置後のアドレスを利用して、DLLの関数の呼び出しを行う。なお、DLLは、プログラムの実行時に動的(ダイナミック)にリンクされるライブラリである。非特許文献1には、このようなDLLについて記載されている。   An operating system (hereinafter referred to as “OS”) such as Windows (registered trademark) allocates one process (unit of job) for each execution of an application program running on the OS. When the application program uses a function of a dynamic link library (hereinafter referred to as “DLL”), the OS dynamically loads the DLL into the process. In other words, the OS secures, initializes, and rearranges a DLL memory area. Then, the application program calls a DLL function by using the relocated address. The DLL is a library that is dynamically linked when the program is executed. Non-Patent Document 1 describes such a DLL.

また、近年、仮想マシンによるプログラム実行環境の利用が広まっている。その代表的なものに、サンマイクロシステム社によるJava(登録商標)仮想マシン、マイクロソフト社によるCLR(Common Language Runtime)がある。仮想マシンは、OS上で稼動する1つのアプリケーションプログラムとして実装されていることが多い。この場合、OSは、仮想マシンによる実行環境ごとに1つのプロセスを割り当てる。そして、仮想マシンにおいては、1つの仮想マシンの実行環境(1つのプロセス)で、複数のアプリケーションプログラムを実行することができる場合がある。   In recent years, the use of program execution environments by virtual machines has become widespread. Typical examples include Java (registered trademark) virtual machines by Sun Microsystems, and CLR (Common Language Runtime) by Microsoft. A virtual machine is often implemented as one application program that runs on an OS. In this case, the OS allocates one process for each execution environment of the virtual machine. In a virtual machine, a plurality of application programs may be executed in the execution environment (one process) of one virtual machine.

John R. Levin, "linkers & loaders", Morgan Kaufmann Pub, 2000.John R. Levin, "linkers & loaders", Morgan Kaufmann Pub, 2000.

さて、DLLをプロセスに取り込む場合、DLLのロードイメージ(メモリにローディングされたロードモジュール)は、プロセスごとに作成される。そのため、DLLに含まれるグローバル変数の領域もプロセスごとに作成される。1つのプロセスで1つのアプリケーションプログラムが実行される場合、グローバル変数はアプリケーションプログラムごとに作成されるため、あるアプリケーションプログラムがグローバル変数の値を変更した場合であっても、他のアプリケーションプログラムの処理に影響を及ぼさない。   When a DLL is taken into a process, a DLL load image (a load module loaded in a memory) is created for each process. Therefore, a global variable area included in the DLL is also created for each process. When one application program is executed in one process, a global variable is created for each application program. Therefore, even if a certain application program changes the value of the global variable, it can be used for processing other application programs. Has no effect.

一方、仮想マシンのような1つのプロセス内で複数のアプリケーションプログラムが実行される環境においては、プロセス毎に1つのDLLが読み込まれ、1つのグローバル変数領域が作成される。すなわち、グローバル変数領域が、プロセス内で実行される複数のアプリケーションプログラム間で共有されることになる。このような実行環境において、DLLがグローバル変数等に状態情報(ステータス)を保持する場合、あるアプリケーションプログラムによるDLLの状態情報の変更が、同一プロセス内で実行中の他のアプリケーションプログラムの処理に影響を与えてしまう。すなわち、1つのプロセスで1つのアプリケーションプログラムを実行した場合と、1つのプロセスで複数のアプリケーションプログラムを実行した場合とで、処理が異なることになる。   On the other hand, in an environment where a plurality of application programs are executed in one process such as a virtual machine, one DLL is read for each process, and one global variable area is created. That is, the global variable area is shared among a plurality of application programs executed in the process. In such an execution environment, when a DLL holds state information (status) in a global variable or the like, a change in the state information of a DLL by a certain application program affects the processing of another application program being executed in the same process. Will be given. That is, processing differs between when one application program is executed by one process and when a plurality of application programs are executed by one process.

本発明は上記事情を鑑みてなされたものであり、本発明の目的は、1つのプロセス内で複数のアプリケーションプログラムが実行される環境でDLLを呼び出す場合において、所定のアプリケーションプログラムの処理が他のアプリケーションプログラムの処理に影響を及ぼすことを防止することにある。   The present invention has been made in view of the above circumstances, and an object of the present invention is to execute processing of a predetermined application program when calling a DLL in an environment in which a plurality of application programs are executed in one process. It is to prevent the application program processing from being affected.

上記課題を解決するために、本発明では、アプリケーションプログラムごとに異なるダイナミックリンクライブラリのロードイメージを作成するラッパライブラリを生成する。また、アプリケーションプログラムにおけるダイナミックリンクライブラリの呼び出しコードを、ラッパライブラリを呼び出すように変更する。   In order to solve the above-described problem, in the present invention, a wrapper library for creating a load image of a dynamic link library that differs for each application program is generated. Also, the calling code of the dynamic link library in the application program is changed so as to call the wrapper library.

例えば、ダイナミックリンクライブラリを呼び出すためのダイナミックリンクライブラリ呼び出しコード生成方法であって、情報処理装置は、演算処理部と記憶部とを有する。そして、演算処理部は、記憶部に記憶されたダイナミックリンクライブラリを読み出す第1の読み出しステップと、読み出したダイナミックリンクライブラリに記述された関数にもとづいて、アプリケーションプログラム毎にダイナミックリンクライブラリのロードイメージを作成するラッパライブラリを生成する生成ステップと、記憶部に記憶されたアプリケーションプログラムを読み出す第2の読み出しステップと、アプリケーションプログラムにおいて、ダイナミックリンクライブラリを呼び出すコードを特定し、当該ダイナミックリンクライブラリの呼び出しコードを、生成したラッパライブラリを呼び出すコードに変更する変更ステップと、を行う。   For example, in the dynamic link library call code generation method for calling the dynamic link library, the information processing apparatus includes an arithmetic processing unit and a storage unit. Then, the arithmetic processing unit creates a load image of the dynamic link library for each application program based on the first read step of reading the dynamic link library stored in the storage unit and the function described in the read dynamic link library. A generation step for generating a wrapper library to be created, a second reading step for reading an application program stored in the storage unit, and a code for calling the dynamic link library in the application program is specified, and the calling code for the dynamic link library is And a change step for changing the code to call the generated wrapper library.

本発明では、1つのプロセス内で複数のアプリケーションプログラムが実行される環境でDLLを呼び出す場合において、所定のアプリケーションプログラムの処理が他のアプリケーションプログラムの処理に影響を及ぼすことを防止することができる。   In the present invention, when a DLL is called in an environment where a plurality of application programs are executed in one process, it is possible to prevent the processing of a predetermined application program from affecting the processing of other application programs.

以下、本発明の実施の形態を説明する。   Embodiments of the present invention will be described below.

図1は、本発明の一実施形態が適用されたラッパライブラリ生成装置1の概略図である。本実施形態のラッパライブラリ生成装置1は、仮想マシン上で動作するプログラム毎に、DLLの領域確保し、初期化および再配置を行うダミーDLL(すなわち、ラッパライブラリ)を生成する。   FIG. 1 is a schematic diagram of a wrapper library generation apparatus 1 to which an embodiment of the present invention is applied. The wrapper library generation device 1 of this embodiment generates a dummy DLL (that is, a wrapper library) that secures a DLL area and performs initialization and rearrangement for each program operating on a virtual machine.

ラッパライブラリ生成装置1は、図示するように、ラッパコード生成部10と、呼び出しコード生成部20と、記憶部30と、を有する。ラッパコード生成部10は、記憶部30に記憶されたDLL31を読み出し、ラッパライブラリ34を生成する。ラッパコード生成部10は、DLL入力部11と、コード生成部12と、出力部13と、を有する。   The wrapper library generation device 1 includes a wrapper code generation unit 10, a call code generation unit 20, and a storage unit 30, as illustrated. The wrapper code generation unit 10 reads the DLL 31 stored in the storage unit 30 and generates a wrapper library 34. The wrapper code generation unit 10 includes a DLL input unit 11, a code generation unit 12, and an output unit 13.

DLL入力部11は、DLL31を記憶部30から読み出して解析し、外部関数シンボルの一覧を取得する。そして、DLL入力部11は、取得した各外部関数シンボルを、シンボル管理テーブル32に記録する。外部関数シンボルは、呼び出しプログラム35が使用可能(呼び出し可能)なDLL31の関数である。なお、シンボル管理テーブル32については、後述する。   The DLL input unit 11 reads the DLL 31 from the storage unit 30 and analyzes it to obtain a list of external function symbols. Then, the DLL input unit 11 records each acquired external function symbol in the symbol management table 32. The external function symbol is a function of the DLL 31 that can be used (callable) by the calling program 35. The symbol management table 32 will be described later.

コード生成部12は、シンボル管理テーブル33に登録されている外部関数シンボル毎に、ラッパコード(不図示)を作成する。なお、ラッパコードについては後述する。   The code generator 12 creates a wrapper code (not shown) for each external function symbol registered in the symbol management table 33. The wrapper code will be described later.

出力部13は、シンボル管理テーブル32と、コード生成部12が生成したラッパコードとにもとづいて、ラッパライブラリ34を生成し、記憶部30に記憶する。また、出力部13は、DLL31の名称と、当該DLL31から生成したラッパライブラリ34の名称とを名称対応テーブル33に記憶する。なお、ラッパライブラリ34および名称対応テーブル33については、後述する。   The output unit 13 generates a wrapper library 34 based on the symbol management table 32 and the wrapper code generated by the code generation unit 12 and stores it in the storage unit 30. In addition, the output unit 13 stores the name of the DLL 31 and the name of the wrapper library 34 generated from the DLL 31 in the name correspondence table 33. The wrapper library 34 and the name correspondence table 33 will be described later.

呼び出しコード生成部20は、呼び出しプログラム35を記憶部30から読み出して解析する。そして、呼び出しコード生成部20は、呼び出しプログラム35の中で、DLL31を呼び出しているコード(ソースコード)の部分を特定する。そして、呼び出しコード生成部20は、特定したコード部分を、DLL31ではなくラッパライブラリ34を呼び出すように変更する。そして、呼び出しコード生成部20は、変更後の呼び出しプログラム36を、記憶部30に記憶する。なお、呼び出しコード生成部20は、名称対応テーブル33を参照し、呼び出すラッパライブラリ34の名称を取得する。   The call code generation unit 20 reads the call program 35 from the storage unit 30 and analyzes it. Then, the calling code generation unit 20 specifies a part of the code (source code) calling the DLL 31 in the calling program 35. Then, the calling code generation unit 20 changes the specified code portion so as to call the wrapper library 34 instead of the DLL 31. Then, the calling code generation unit 20 stores the changed calling program 36 in the storage unit 30. The call code generation unit 20 refers to the name correspondence table 33 and acquires the name of the wrapper library 34 to be called.

記憶部30には、DLL31と、シンボル管理テーブル32と、名称対応テーブル33と、ラッパライブラリ34と、呼び出しプログラム35と、変更後呼び出しプログラム36とが記憶されている。   The storage unit 30 stores a DLL 31, a symbol management table 32, a name correspondence table 33, a wrapper library 34, a calling program 35, and a changed calling program 36.

DLL31は、プログラムの実行時に動的(ダイナミック)にリンクされる(呼び出される)ライブラリである。OSは、呼び出しプログラム35の実行時に、当該プログラムのアドレス空間(プロセス)にDLLをローディングする。   The DLL 31 is a library that is dynamically linked (called) when the program is executed. When the calling program 35 is executed, the OS loads the DLL into the address space (process) of the program.

図2は、DLL31の一例を示した図である。DLL31は、ヘッダセクション21と、テキストセクション22、データセクション23、エクスポートシンボルセクション24とを有する。ヘッダセクション21には、他のセクション22、23、24のサイズと開始アドレスとが設定されている。   FIG. 2 is a diagram illustrating an example of the DLL 31. The DLL 31 includes a header section 21, a text section 22, a data section 23, and an export symbol section 24. In the header section 21, the sizes and start addresses of the other sections 22, 23, and 24 are set.

テキストセクション22には、少なくとも1つの関数が定義されている。図示するテキストセクション22には、関数「func_A」221と、関数「func_B」222と、関数「func_C」223とが含まれている。データセクション23には、テキストセクション22で定義されている各関数が使用するグローバル変数などのデータ領域が定義されている。エクスポートシンボルセクション24には、少なくとも1つの外部に公開される外部関数シンボルの名称と、当該シンボルの仮想相対アドレスとが設定されている。   In the text section 22, at least one function is defined. The illustrated text section 22 includes a function “func_A” 221, a function “func_B” 222, and a function “func_C” 223. In the data section 23, a data area such as a global variable used by each function defined in the text section 22 is defined. In the export symbol section 24, the name of at least one external function symbol disclosed to the outside and the virtual relative address of the symbol are set.

シンボル管理テーブル32は、DLL31に定義された外部関数シンボルを管理するためのテーブルである。   The symbol management table 32 is a table for managing external function symbols defined in the DLL 31.

図3は、シンボル管理テーブル32の一例を示した図である。シンボル管理テーブル32は、外部関数シンボル毎に、シンボル番号321と、シンボル名322と、アドレス323と、ラッパコード領域ポインタ324と、を有する。   FIG. 3 is a diagram showing an example of the symbol management table 32. The symbol management table 32 includes a symbol number 321, a symbol name 322, an address 323, and a wrapper code area pointer 324 for each external function symbol.

シンボル番号321は、外部関数シンボルを識別するための識別情報である。シンボル名332は、外部関数シンボルの名称である。図示する例では、図2に示すDLL31のエクスポートシンボルセクション24に設定された外部関数シンボルの名称(「func_A」、「func_B」)が設定されている。なお、DLL入力部11が、シンボル番号321およびシンボル名称322を設定する。   The symbol number 321 is identification information for identifying the external function symbol. The symbol name 332 is a name of the external function symbol. In the illustrated example, the names of external function symbols (“func_A”, “func_B”) set in the export symbol section 24 of the DLL 31 shown in FIG. 2 are set. The DLL input unit 11 sets a symbol number 321 and a symbol name 322.

アドレス323には、生成されるラッパライブラリ34における外部関数シンボル毎に生成されるラッパコードのテキストセクション中での位置(アドレス)が設定される。   In the address 323, the position (address) in the text section of the wrapper code generated for each external function symbol in the generated wrapper library 34 is set.

ラッパコード領域ポインタ324には、外部関数シンボル毎に生成されたラッパコードが記憶部30のどの位置に格納されているかを表すポインタ情報(格納場所情報)が設定されている。なお、コード生成部12が、アドレス323およびラッパコード領域ポインタ324を設定する。   In the wrapper code area pointer 324, pointer information (storage location information) indicating where the wrapper code generated for each external function symbol is stored in the storage unit 30 is set. The code generation unit 12 sets the address 323 and the wrapper code area pointer 324.

名称対応テーブル33は、DLL31と当該DLLから生成されたラッパライブラリ34とを対応付けたテーブルである。   The name correspondence table 33 is a table in which the DLL 31 is associated with the wrapper library 34 generated from the DLL.

図4は、名称対応テーブル33の一例を示した図である。名称対応テーブル33は、DLL31の名称であるDLL名称331と、当該DLL31に対応するラッパライブラリ34の名称332と、を有する。なお、本実施形態では、ラッパライブラリ名称332は、DLL名称331の先頭に「W」を付加した名称とする。   FIG. 4 is a diagram showing an example of the name correspondence table 33. The name correspondence table 33 includes a DLL name 331 that is the name of the DLL 31 and a name 332 of the wrapper library 34 corresponding to the DLL 31. In the present embodiment, the wrapper library name 332 is a name in which “W” is added to the head of the DLL name 331.

呼び出しプログラム35は、仮想マシン上で動作するアプリケーションプログラムであって、当該プログラムの実行時にDLL31を呼び出すプログラムである。なお、呼び出しプログラムが動作する仮想マシンのソフトウェア構成については後述する。   The calling program 35 is an application program that operates on the virtual machine, and is a program that calls the DLL 31 when the program is executed. The software configuration of the virtual machine on which the calling program operates will be described later.

変更後呼び出しプログラム36は、呼び出しコード生成部20が呼び出しプログラム35を変更した後のプログラムである。ラッパライブラリ34は、呼び出しプログラム35(変更後の呼び出しプログラム36)毎に、DLL31の領域を確保し、初期化および再配置を行うダミーのDLLである。なお、呼び出しプログラム35、変更後呼び出しプログラム36、および、ラッパライブラリ34については、後述する。   The post-change call program 36 is a program after the call code generation unit 20 changes the call program 35. The wrapper library 34 is a dummy DLL that secures an area for the DLL 31, and performs initialization and rearrangement for each calling program 35 (the calling program 36 after the change). The calling program 35, the changed calling program 36, and the wrapper library 34 will be described later.

以上説明した、ラッパライブラリ生成装置1は、例えば図5に示すようなCPU901と、メモリ902と、HDD等の外部記憶装置903と、キーボードやマウスなどの入力装置904と、モニタやプリンタなどの出力装置905と、ネットワーク接続するための通信制御装置906と、これらの各装置を接続するバス907と、を備えた汎用的なコンピュータシステムを用いることができる。このコンピュータシステムにおいて、CPU901がメモリ902上にロードされた所定のプログラムを実行することにより、ラッパライブラリ生成装置1の各機能が実現される。すなわち、ラッパライブラリ生成装置1の各機能は、ラッパライブラリ生成装置1のCPU901が、ラッパライブラリ生成装置1用のプログラムを実行することにより実現される。この場合、ラッパライブラリ生成装置1の記憶部30には、ラッパライブラリ生成装置1のメモリ902または外部記憶装置903が用いられる。   The wrapper library generation device 1 described above includes, for example, a CPU 901, a memory 902, an external storage device 903 such as an HDD, an input device 904 such as a keyboard and a mouse, an output such as a monitor and a printer, as shown in FIG. A general-purpose computer system including a device 905, a communication control device 906 for connecting to a network, and a bus 907 for connecting these devices can be used. In this computer system, when the CPU 901 executes a predetermined program loaded on the memory 902, each function of the wrapper library generation device 1 is realized. That is, each function of the wrapper library generation device 1 is realized by the CPU 901 of the wrapper library generation device 1 executing a program for the wrapper library generation device 1. In this case, the memory 902 of the wrapper library generation device 1 or the external storage device 903 is used for the storage unit 30 of the wrapper library generation device 1.

次に、仮想マシンのソフトウェア構成について説明する。仮想マシンは、OSの1つのプロセス(ジョブの単位)である。そして、仮想マシンは、当該プロセス内において、複数のアプリケーションプログラムを実行することができる。なお、アプリケーションプログラムは、本実施形態における呼び出しプログラム35(または、変更後の呼び出しプログラム36)である。   Next, the software configuration of the virtual machine will be described. The virtual machine is one process (unit of job) of the OS. The virtual machine can execute a plurality of application programs in the process. The application program is the calling program 35 (or the changed calling program 36) in the present embodiment.

図13は、仮想マシンのソフトウェア構成の一例を示した図である。図示するように、仮想マシン62は、OS61上で動作する。また、仮想マシン62上では、少なくとも1つの呼び出しプログラム35が実行される。なお、仮想マシン62は、メモリ管理部621と、型管理部622と、実行管理部623とを有する。メモリ管理部621は、仮想マシン上で使用されるメモリを管理する。型管理部622は、オブジェクト指向プログラミングにおけるクラスを管理する。実行管理部623は、仮想マシン上で動作する各プログラムの実行を管理する。   FIG. 13 is a diagram illustrating an example of a software configuration of a virtual machine. As illustrated, the virtual machine 62 operates on the OS 61. In addition, at least one calling program 35 is executed on the virtual machine 62. The virtual machine 62 includes a memory management unit 621, a type management unit 622, and an execution management unit 623. The memory management unit 621 manages the memory used on the virtual machine. The type management unit 622 manages classes in object-oriented programming. The execution management unit 623 manages the execution of each program operating on the virtual machine.

次に、ラッパライブラリ生成装置1のラッパコード生成部10の処理を説明する。   Next, processing of the wrapper code generation unit 10 of the wrapper library generation device 1 will be described.

図6は、ラッパコード生成部10のDLL入力部11およびコード生成部12の処理フローを示したものである。まず、DLL入力部11は、あらかじめ記憶部30に記憶されたDLL31を読み出し、当該DLL31のエクスポートシンボルセクション24(図2参照)に記述された外部関数シンボルの一覧を取得する(S61)。そして、DLL入力部11は、取得した外部関数シンボルの名称を、シンボル管理テーブル32のシンボル名322に順に登録する(S62)。なお、DLL入力部11は、外部関数シンボル名をシンボル名322に設定する際に、各シンボル番号321には「1」から順に連番を設定する。   FIG. 6 shows a processing flow of the DLL input unit 11 and the code generation unit 12 of the wrapper code generation unit 10. First, the DLL input unit 11 reads the DLL 31 stored in advance in the storage unit 30, and obtains a list of external function symbols described in the export symbol section 24 (see FIG. 2) of the DLL 31 (S61). Then, the DLL input unit 11 sequentially registers the acquired name of the external function symbol in the symbol name 322 of the symbol management table 32 (S62). The DLL input unit 11 sets serial numbers in order from “1” to each symbol number 321 when setting the external function symbol name to the symbol name 322.

そして、コード生成部12は、シンボル番号321およびシンボル名称322が設定されたシンボル管理テーブル32の各レコードを、シンボル番号321の小さい順に読み出す(S63)。そして、コード生成部12は、読み出したレコード毎(すなわち、外部関数シンボル毎)に、所定のアルゴリズム(または、所定のテンプレート)に従って、ラッパライブラリ34の構成要素であるラッパコードを生成する。以下、ラッパコードの生成処理を説明する。   Then, the code generation unit 12 reads each record of the symbol management table 32 in which the symbol number 321 and the symbol name 322 are set, in ascending order of the symbol number 321 (S63). The code generation unit 12 generates a wrapper code that is a component of the wrapper library 34 according to a predetermined algorithm (or a predetermined template) for each read record (that is, for each external function symbol). Hereinafter, the wrapper code generation processing will be described.

コード生成部12は、DLLのロードイメージ選択コードを作成する(S64)。そして、コード生成部12は、呼び出し関数のアドレス計算コードを作成する(S65)。そして、コード生成部12は、アドレス計算コードにより算出されたアドレスを用いて関数を呼び出す関数呼び出しコードを生成する(S66)。S64からS66により、コード生成部12は、ラッパコードを生成し、記憶部30に記憶する。なお、ラッパコードの処理については、後述する。   The code generation unit 12 creates a DLL load image selection code (S64). Then, the code generation unit 12 creates an address calculation code for the calling function (S65). Then, the code generation unit 12 generates a function call code that calls a function using the address calculated by the address calculation code (S66). From S64 to S66, the code generation unit 12 generates a wrapper code and stores it in the storage unit 30. The processing of the wrapper code will be described later.

そして、コード生成部12は、シンボル管理テーブル32の当該レコードのラッパコード領域ポインタ324に、記憶部30に記憶したラッパコードの先頭アドレス(格納場所)を設定する(S67)。   Then, the code generation unit 12 sets the start address (storage location) of the wrapper code stored in the storage unit 30 in the wrapper code area pointer 324 of the record in the symbol management table 32 (S67).

そして、コード生成部12は、シンボル管理テーブル32のアドレス323の設定を行なう。すなわち、コード生成部12は、S63で読み出したレコードが最初のレコードか(シンボル番号321が「1」のレコードか)否かを判別する(S68)。最初のレコードの場合(S68:YES)、コード生成部12は、当該最初のレコードのアドレス323に「00000000」を設定する(S69)。   Then, the code generation unit 12 sets the address 323 of the symbol management table 32. That is, the code generation unit 12 determines whether or not the record read in S63 is the first record (the record whose symbol number 321 is “1”) (S68). In the case of the first record (S68: YES), the code generation unit 12 sets “00000000” to the address 323 of the first record (S69).

一方、最初のレコードでない場合(S68:NO)、コード生成部12は、当該レコードの直前のレコードのアドレス323に設定された値を読み出す。そして、コード生成部12は、直前のレコードのアドレス323の値に、S64からS66において生成した直前のレコードのパッラコードのサイズを加算する。そして、コード生成部12は、加算した値を当該レコードのアドレス323に設定する(S70)。なお、直前のレコードは、本実施形態では、当該レコードのレコード番号321から「1」を引いたレコード番号321のレコードである。   On the other hand, if it is not the first record (S68: NO), the code generation unit 12 reads the value set in the address 323 of the record immediately before the record. Then, the code generation unit 12 adds the size of the parallax code of the immediately preceding record generated in S64 to S66 to the value of the address 323 of the immediately preceding record. Then, the code generation unit 12 sets the added value to the address 323 of the record (S70). In the present embodiment, the immediately preceding record is a record having a record number 321 obtained by subtracting “1” from the record number 321 of the record.

そして、コード生成部12は、シンボル管理テーブル32を読み出し、未処理のレコード(ラッパコードを生成していないレコード)が存在するか否かを判別する(S71)。未処理のレコードが存在する場合(S71:YES)、コード生成部12は、S63に戻りシンボル管理テーブル32の次のレコードの処理を行う。一方、未処理のレコードが存在しない場合(S71:NO)、後述する出力部13の処理を行う。   Then, the code generation unit 12 reads the symbol management table 32 and determines whether or not there is an unprocessed record (a record for which no wrapper code is generated) (S71). If there is an unprocessed record (S71: YES), the code generation unit 12 returns to S63 and processes the next record in the symbol management table 32. On the other hand, when there is no unprocessed record (S71: NO), processing of the output unit 13 described later is performed.

以上説明した図6の処理を、図2に示すDLL31を例に具体的に説明する。   The processing of FIG. 6 described above will be specifically described by taking the DLL 31 shown in FIG. 2 as an example.

まず、DLL入力部11は、DLL31の外部関数シンボルの一覧を取得し、図3に示すシンボル管理テーブル32を作成する(S61、S62)。なお、この時点では、アドレス323、ラッパコード領域ポインタ324は空欄である。   First, the DLL input unit 11 acquires a list of external function symbols of the DLL 31 and creates the symbol management table 32 shown in FIG. 3 (S61, S62). At this time, the address 323 and the wrapper code area pointer 324 are blank.

そして、コード生成部12は、シンボル管理テーブル32の最初のレコードの関数func_Aのラッパコードを生成し記憶部30に記憶する(S63〜S66)。そして、コード生成部12は、ラッパコードの格納場所の先頭アドレス)を、関数func_Aのラッパコード領域ポインタ324に設定する(S67)。そして、現在処理中の「関数func_A」は、最初のレコードであるため(S68:YES)、コード生成部12は、シンボル管理テーブル32のアドレス323に「00000000」を設定する(S69)。   Then, the code generation unit 12 generates a wrapper code of the function func_A of the first record in the symbol management table 32 and stores it in the storage unit 30 (S63 to S66). Then, the code generation unit 12 sets the wrapper code storage location start address) in the wrapper code area pointer 324 of the function func_A (S67). Since “function func_A” currently being processed is the first record (S68: YES), the code generation unit 12 sets “00000000” in the address 323 of the symbol management table 32 (S69).

次に、コード生成部12は、シンボル管理テーブル32を読み出し、未処理のレコードである関数func_Bの処理を行なう(S71:YES)。コード生成部12は、関数func_Aの処理と同様に、ラッパコードを生成し、ラッパコード領域ポインタに格納場所を設定する(S63〜S67)。そして、関数func_Bのレコードは最初のレコードでないため(S68:NO)、コード生成部12は、1つ上のレコード(関数func_A)のアドレス323の値「00000000」に、生成された関数func_Aのラッパコードのサイズ(ここでは、「00000100」(16進数)とする)を加算した値「00000100」を、アドレス323に設定する。そして、コード生成部12は、シンボル管理テーブル32を読み出し、次(未処理)のレコードがないため図6に示す処理を終了する。   Next, the code generation unit 12 reads the symbol management table 32 and performs processing of the function func_B which is an unprocessed record (S71: YES). Similar to the processing of the function func_A, the code generation unit 12 generates a wrapper code and sets a storage location in the wrapper code area pointer (S63 to S67). Since the record of the function func_B is not the first record (S68: NO), the code generator 12 sets the wrapper “of the function func_A generated to the value“ 00000000 ”of the address 323 of the record (function func_A) one level higher. A value “00000100” obtained by adding the code size (here, “00000100” (hexadecimal)) is set in the address 323. Then, the code generation unit 12 reads the symbol management table 32 and terminates the process illustrated in FIG. 6 because there is no next (unprocessed) record.

次に、ラッパコード生成部10の出力部13の処理について説明する。   Next, processing of the output unit 13 of the wrapper code generation unit 10 will be described.

図7は、ラッパコード生成部10の出力部13の処理フローを示したものである。出力部13は、図6の処理の後に、シンボル管理テーブル32にもとづいて、名称対応テーブル33およびラッパライブラリ34を出力する。   FIG. 7 shows a processing flow of the output unit 13 of the wrapper code generation unit 10. The output unit 13 outputs the name correspondence table 33 and the wrapper library 34 based on the symbol management table 32 after the processing of FIG.

まず、出力部13は、名称対応テーブル33(図4参照)を出力する(S71)。すなわち、出力部13は、図6のS61において読み出したDLL31の名称と、当該DLL31から生成されるラッパライブラリ名称とを、名称対応テーブル33に設定する。なお、本実施形態では、図4に示すように、DLL31の名称(sub.dll)の先頭に「W」を付加した名称(Wsub.dll)を、ラッパライブラリの名称とする。   First, the output unit 13 outputs the name correspondence table 33 (see FIG. 4) (S71). That is, the output unit 13 sets the name of the DLL 31 read in S61 of FIG. 6 and the wrapper library name generated from the DLL 31 in the name correspondence table 33. In the present embodiment, as shown in FIG. 4, the name (Wsub.dll) with “W” added to the head of the DLL 31 name (sub.dll) is used as the name of the wrapper library.

そして、出力部13は、ラッパライブラリの出力に先立って、ラッパライブラリの各セクションのサイズを算出する(S72)。すなわち、出力部13は、テキストセクション、データセクション、および、エクスポートシンボルセクションのサイズを算出する。なお、テキストセクションのサイズは、シンボル管理テーブル32に登録されている全ての外部関数シンボルのラッパコードのサイズの合計である。   Then, the output unit 13 calculates the size of each section of the wrapper library prior to the output of the wrapper library (S72). That is, the output unit 13 calculates the sizes of the text section, data section, and export symbol section. The size of the text section is the sum of the sizes of the wrapper codes of all the external function symbols registered in the symbol management table 32.

データセクションのサイズは、各ラッパコードが使用するグローバル変数領域のデータサイズの合計である。なお、本実施形態では、DLL31のロードイメージの管理用に36(16進数で20)バイトが必要であるものとする。なお、ロードイメージは、メモリにローディングされたロードモジュールである。   The size of the data section is the total data size of the global variable area used by each wrapper code. In the present embodiment, it is assumed that 36 (20 in hexadecimal) bytes are required for managing the load image of the DLL 31. The load image is a load module loaded in the memory.

エクスポートシンボルセクションのサイズは、外部関数シンボル名称と、当該外部関数シンボルのアドレスとを書き出すために必要な大きさである。本実施形態では、64(16進数で40)バイトが必要であるものとする。   The size of the export symbol section is a size necessary for writing the external function symbol name and the address of the external function symbol. In this embodiment, it is assumed that 64 (hexadecimal 40) bytes are required.

そして、出力部13は、以下の処理により、例えば、図8に示すようなラッパライブラリ34を出力する。   And the output part 13 outputs the wrapper library 34 as shown in FIG. 8, for example by the following processes.

まず、出力部13は、ヘッダセクション(図8:81)を出力する(S73)。すなわち、出力部13は、S72で算出した各セクションのサイズを記述したヘッダセクションを出力する。   First, the output unit 13 outputs a header section (FIG. 8: 81) (S73). That is, the output unit 13 outputs a header section describing the size of each section calculated in S72.

そして、出力部13は、テキストセクション(図8:82)を出力する(S74)。すなわち、出力部13は、シンボル管理テーブル32のラッパコード領域ポインタ324でポインタされている各ラッパコードを記憶部30から順次読み出し、テキストセクションとして出力する。なお、図示する例では、関数func_Aと、関数func_Bの2つのラッパコード821、822がテキストセクションに記述されている。   Then, the output unit 13 outputs the text section (FIG. 8: 82) (S74). That is, the output unit 13 sequentially reads each wrapper code pointed by the wrapper code area pointer 324 of the symbol management table 32 from the storage unit 30 and outputs it as a text section. In the illustrated example, two wrapper codes 821 and 822 of a function func_A and a function func_B are described in the text section.

そして、出力部13は、データセクション(図8:83)を出力する(S75)。データセクションのサイズは、ラッパコード固有の値であり、図示する例では前述した36(16進数で20)バイトとする。   Then, the output unit 13 outputs the data section (FIG. 8: 83) (S75). The size of the data section is a value unique to the wrapper code, and is 36 (hexadecimal 20) bytes described above in the illustrated example.

そして、出力部13は、エクスポートシンボルセクション(図8:84)を出力する(S76)。すなわち、出力部13は、シンボル管理テーブル32のシンボル名称322およびアドレス323に設定されたデータを順次エクスポートシンボルセクションに出力する。そして、出力部13は、各セクションを出力することにより図8に示すようなラッパライブラリ34を生成し、記憶部30に記憶する(S77)。   Then, the output unit 13 outputs the export symbol section (FIG. 8: 84) (S76). That is, the output unit 13 sequentially outputs the data set in the symbol name 322 and the address 323 of the symbol management table 32 to the export symbol section. Then, the output unit 13 generates a wrapper library 34 as shown in FIG. 8 by outputting each section, and stores it in the storage unit 30 (S77).

次に、ラッパライブラリ生成装置1の呼び出しコード生成部20の処理を説明する。   Next, processing of the calling code generation unit 20 of the wrapper library generation device 1 will be described.

図9は、呼び出しコード生成部20の処理フローである。まず、呼び出しコード生成部20は、記憶部30に記憶された呼び出しプログラム35を読み出し解析する(S91)。そして、呼び出しコード生成部20は、呼び出しプログラム35の中で、DLLの関数の呼び出しに対する外部宣言を特定し、修正する(S92)。すなわち、呼び出しコード生成部20は、DLL31を呼び出しているコード(記述)を、ラッパライブラリ34を呼び出すように変更する。そして、コード生成部20は、呼び出しプログラム35の識別子である引数を1つ追加する。なお、呼び出しコード生成部20は、名称対応テーブル33を参照して、呼び出し先を変更するラッパライブラリの名称を取得する。   FIG. 9 is a processing flow of the calling code generation unit 20. First, the calling code generation unit 20 reads and analyzes the calling program 35 stored in the storage unit 30 (S91). Then, the call code generation unit 20 identifies and corrects the external declaration for the call of the DLL function in the call program 35 (S92). That is, the call code generation unit 20 changes the code (description) that calls the DLL 31 so as to call the wrapper library 34. Then, the code generation unit 20 adds one argument that is an identifier of the calling program 35. The call code generation unit 20 refers to the name correspondence table 33 and acquires the name of the wrapper library whose call destination is to be changed.

そして、呼び出しコード生成部20は、識別子取得関数の定義を生成し、呼び出しプログラム35の所定の部分に追加する(S93)。識別子取得関数は、呼び出しプログラム35を識別するための識別子(識別情報)を返す関数である。この識別子には、例えば、呼び出しプログラム35が動作する実行環境が識別子を提供している場合、当該識別子を利用することができる。   Then, the call code generation unit 20 generates a definition of the identifier acquisition function and adds it to a predetermined part of the call program 35 (S93). The identifier acquisition function is a function that returns an identifier (identification information) for identifying the calling program 35. For example, when the execution environment in which the calling program 35 operates provides an identifier, the identifier can be used.

また、識別子には、例えば、呼び出しプログラムが異なれば異なるメモリ領域を占め、呼び出しプログラムが同じなら常に同じメモリ領域を示す変数のアドレスを利用することができる。   Further, for example, the identifier can occupy a different memory area if the calling program is different, and an address of a variable indicating the same memory area can be used whenever the calling program is the same.

そして、呼び出しコード生成部20は、呼び出しプログラム35の中から、DLL31の関数の呼び出しコード(例えば、call文)を特定する。そして、呼び出しコード生成部20は、特定した呼び出しコードの直前に、S93で生成した識別子取得関数の呼び出しコード(例えば、call文)を追加する(S94)。そして、呼び出しコード生成部20は、S92からS94で変更した変更後の呼び出しプログラム36を出力し、記憶部30に記憶する(S95)。   Then, the call code generation unit 20 specifies a call code (for example, a call statement) of the function of the DLL 31 from the call program 35. Then, the call code generation unit 20 adds the call code (for example, call statement) of the identifier acquisition function generated in S93 immediately before the identified call code (S94). Then, the calling code generation unit 20 outputs the changed calling program 36 changed from S92 to S94, and stores it in the storage unit 30 (S95).

次に、呼び出しプログラム35、および、当該呼び出しプログラム35に図9に示す処理を実行した変更後の呼び出しプログラム36を説明する。   Next, the calling program 35 and the calling program 36 after the change in which the processing shown in FIG.

図10は、呼び出しプログラム35の一例を示したものである。図示する呼び出しプログラム35は、DLLに含まれる関数func_Aを呼び出す関数呼出メソッド10aと、関数func_Aに対する外部宣言10bとを有する。   FIG. 10 shows an example of the calling program 35. The call program 35 shown in the figure has a function call method 10a for calling a function func_A included in a DLL and an external declaration 10b for the function func_A.

図11は、変更後の呼び出しプログラム36の一例を示したものである。図示する呼び出しプログラム35は、関数func_Aを呼び出す関数呼出メソッド11aと、func_Aに対する外部宣言11bと、識別子取得関数11cと、を有する。   FIG. 11 shows an example of the calling program 36 after the change. The call program 35 shown in the figure has a function call method 11a for calling the function func_A, an external declaration 11b for func_A, and an identifier acquisition function 11c.

呼び出しコード生成部20は、関数func_Aの外部宣言(図11:11b)において、ラッパライブラリ111を呼び出すように変更する。また、呼び出しコード生成部20は、関数func_Aの外部宣言において、呼び出しプログラム35の識別子である引数112を1つ追加する。なお、図示する例では、追加する引数は32ビット整数型としている。   The call code generation unit 20 changes the function func_A to call the wrapper library 111 in the external declaration (FIG. 11: 11b). In addition, the call code generation unit 20 adds one argument 112 that is an identifier of the call program 35 in the external declaration of the function func_A. In the illustrated example, the argument to be added is a 32-bit integer type.

また、呼び出しコード生成部20は、識別子取得関数11cを生成する。また、呼び出しコード生成部20は、関数呼出メソッド11aにおいて、関数 func_Aの呼び出しコードの直前に、識別子取得関数11cを呼び出すCall文113を追加する。これにより、変更後の呼び出しプログラム36は、識別子取得関数11cを呼び出すことにより取得したプログラムの識別子を、関数func_Aの追加した引数の値とする。   In addition, the call code generation unit 20 generates an identifier acquisition function 11c. In addition, in the function call method 11a, the call code generation unit 20 adds a Call statement 113 that calls the identifier acquisition function 11c immediately before the call code of the function func_A. As a result, the changed calling program 36 uses the identifier of the program acquired by calling the identifier acquisition function 11c as the value of the argument added to the function func_A.

以上説明したラッパコード生成部10、および、呼び出しコード生成部20の処理によりラッパライブラリ34および変更後の呼び出しプログラム36が生成される。変更後の呼び出しプログラム36は、図13に示すような仮想マシン上で実行され、生成されたラッパライブラリ34を呼び出す。以下に変更後の呼び出しプログラム36の実行時に呼び出されたラッパライブラリ34の処理を説明する。   The wrapper library 34 and the changed calling program 36 are generated by the processing of the wrapper code generation unit 10 and the calling code generation unit 20 described above. The changed calling program 36 is executed on the virtual machine as shown in FIG. 13 and calls the generated wrapper library 34. The processing of the wrapper library 34 called when the changed calling program 36 is executed will be described below.

図12は、ロードイメージ選択コードの処理フローである。なお、ロードイメージ選択コードは、外部関数シンボル毎に作成されるラッパコードの中の、図6のS64で生成されるコードである。また、ラッパコードは、ラップ対象の外部関数シンボルに対して、変更後の読み出しプログラム36を識別するための識別子を引数として追加したインタフェースを有する。   FIG. 12 is a processing flow of the load image selection code. The load image selection code is a code generated in S64 of FIG. 6 in the wrapper code created for each external function symbol. The wrapper code has an interface in which an identifier for identifying the read program 36 after the change is added as an argument to the external function symbol to be wrapped.

まず、ロードイメージ選択コードは、呼び出された変更後の読み出しプログラム36の識別子を取得し、当該識別子に対するDLL31のロードイメージがプロセスに作成済みか否かを判別する(S121)。なお、DLL31のロードイメージを作成した識別子については、後述するS124の処理により登録されているものとする。   First, the load image selection code acquires the identifier of the read program 36 after the change that has been called, and determines whether a load image of the DLL 31 corresponding to the identifier has been created in the process (S121). Note that the identifier that created the load image of the DLL 31 is registered by the process of S124 described later.

DLL31のロードイメージが作成されていない場合(S121:NO)、ロードイメージ選択コードは、DLL31をメモリに展開し(S122)、再配置する(S123)ことにより、ロードイメージを作成する。そして、ロードイメージ選択コードは、作成したロードイメージと、当該識別子とを対応付けて登録(記憶)する(S124)。   When the load image of the DLL 31 is not created (S121: NO), the load image selection code develops the DLL 31 in the memory (S122) and rearranges it (S123), thereby creating the load image. The load image selection code registers (stores) the created load image and the identifier in association with each other (S124).

一方、DLL31のロードイメージが既に作成済みの場合(121:YES)、ロードイメージ選択コードは、当該ロードイメージを取得する(S125)。なお、DLL31のメモリへの展開(S122)および再配置(S123)については、非特許文献1に詳しく述べられている。   On the other hand, when the load image of the DLL 31 has already been created (121: YES), the load image selection code acquires the load image (S125). Note that the deployment of the DLL 31 to the memory (S122) and the rearrangement (S123) are described in detail in Non-Patent Document 1.

次に、図6のS65において生成される呼び出し関数のアドレス計算コードは、DLL31のエクスポートシンボルセクション(図2参照)を参照し、当該ラッパコードの外部関数シンボルのの仮想相対アドレスを取得する。そして、取得した仮想相対アドレスとロードイメージの先頭アドレスとから、実際の関数アドレスを算出する。   Next, the address calculation code of the calling function generated in S65 of FIG. 6 refers to the export symbol section (see FIG. 2) of DLL 31, and acquires the virtual relative address of the external function symbol of the wrapper code. Then, an actual function address is calculated from the acquired virtual relative address and the head address of the load image.

そして、図6のS66において生成される関数呼び出しコードは、アドレス計算コードが算出した実際の関数アドレスを用いて、DLL31のロードイメージ中の関数の呼び出しを行なう。   The function call code generated in S66 of FIG. 6 calls a function in the load image of the DLL 31 using the actual function address calculated by the address calculation code.

以上、本発明の一実施形態について説明した。   The embodiment of the present invention has been described above.

本実施形態では、ラッパライブラリ生成装置1は既存のDLL31を解析し、当該DLL31のラッパライブラリ34を生成する。また、ラッパライブラリ生成装置1は既存の呼び出しプログラム35から、ラッパライブラリ34を呼び出す変更後の呼び出しプログラム36を生成する。この変更後の呼び出しプログラム36を実行することにより、ラッパライブラリ34が呼び出され、変更後の呼び出しプログラム36毎にDLL31のロードイメージを作成することができる。   In the present embodiment, the wrapper library generation device 1 analyzes an existing DLL 31 and generates a wrapper library 34 for the DLL 31. Further, the wrapper library generating apparatus 1 generates a changed calling program 36 that calls the wrapper library 34 from the existing calling program 35. By executing the call program 36 after the change, the wrapper library 34 is called and a load image of the DLL 31 can be created for each call program 36 after the change.

また、ラッパライブラリ34は、アプリケーションプログラム(呼び出しプログラム)毎にDLL31のロードイメージを作成する。これにより、1つのプロセス内で複数のアプロケーションプログラムが動作する実行環境であっても、所定のアプリケーションプログラムの処理が他のアプリケーションプログラムの処理に影響を及ぼすことを防止することができる。   The wrapper library 34 creates a load image of the DLL 31 for each application program (calling program). Thereby, even in an execution environment in which a plurality of allocation programs operate in one process, it is possible to prevent the processing of a predetermined application program from affecting the processing of other application programs.

また、ラッパライブラリ生成装置1がラッパライブラリ34および変更後の呼び出しプログラム36を自動生成することにより、1つのプロセス内で複数のアプリケーションプログラムが動作する実行環境においても、既存のシステムのリソース(DLL31、呼出プログラム35)を有効活用することができる。   In addition, the wrapper library generation device 1 automatically generates the wrapper library 34 and the changed calling program 36, so that even in an execution environment in which a plurality of application programs operate in one process, the resources (DLL 31,. The calling program 35) can be used effectively.

なお、本発明は上記の実施形態に限定されるものではなく、その要旨の範囲内で数々の変形が可能である。   In addition, this invention is not limited to said embodiment, Many deformation | transformation are possible within the range of the summary.

例えば、上記実施形態では、ラッパライブラリ生成装置1が、あらかじめラッパライブラリ34および変更後の呼び出しプログラム36を生成する。しかしながら、本発明は、呼び出しプログラム35の実行時に、動的にラッパライブラリ34および変更後の呼び出しプログラム36を生成してもよい。この場合、図1に示すラッパライブラリ生成装置1の各機能は、図13に示す仮想マシンの実行管理部623において実装される。以下に、実行管理部623の処理について説明する。   For example, in the above embodiment, the wrapper library generation device 1 generates the wrapper library 34 and the changed calling program 36 in advance. However, the present invention may dynamically generate the wrapper library 34 and the changed calling program 36 when the calling program 35 is executed. In this case, each function of the wrapper library generation device 1 shown in FIG. 1 is implemented in the execution management unit 623 of the virtual machine shown in FIG. Below, the process of the execution management part 623 is demonstrated.

図14は、実行管理部623の処理フローを示したものである。まず、実行管理部623は、現在の処理対象の命令がDLL31で定義される関数の呼び出しか否かを判定する(S141)。DLL31の呼び出しでない場合(S141:NO)、実行管理部623は、一般的なコード生成処理を実行する(S145)。   FIG. 14 shows a processing flow of the execution management unit 623. First, the execution management unit 623 determines whether the current instruction to be processed is a function call defined in the DLL 31 (S141). If it is not a call to the DLL 31 (S141: NO), the execution management unit 623 executes a general code generation process (S145).

一方、DLL31の呼び出しの場合(S141:YES)、実行管理部623は、入力手段904や、実行時オプションや、ファイルなどの手段により入力されたユーザの指示を受け付け、ラッパコードを生成するか否かを判別する(S142)。ラッパコード生成指示を受け付けた場合(S142:YES)、実行管理部623は、識別子取得関数呼び出しコードを生成する(S143)。なお、S143の処理は、呼び出しコード生成部20が図9のS93において識別子取得関数コードを生成する処理と同様である。そして、実行管理部623は、ラッパコードを生成する(S144)。なお、S144の処理は、コード生成部12が、図6のS64からS66においてラッパコードを生成する処理と同様である。一方、ラッパコード生成指示を受け付けない場合(S142:NO)、実行管理部623は、一般的なコード生成処理を行う(S145)。   On the other hand, when the DLL 31 is called (S141: YES), the execution management unit 623 receives a user instruction input by the input unit 904, a runtime option, a file, or the like, and generates a wrapper code. Is determined (S142). When a wrapper code generation instruction is received (S142: YES), the execution management unit 623 generates an identifier acquisition function call code (S143). Note that the process of S143 is the same as the process in which the call code generation unit 20 generates the identifier acquisition function code in S93 of FIG. Then, the execution management unit 623 generates a wrapper code (S144). Note that the processing in S144 is the same as the processing in which the code generation unit 12 generates the wrapper code in S64 to S66 in FIG. On the other hand, when a wrapper code generation instruction is not accepted (S142: NO), the execution management unit 623 performs a general code generation process (S145).

なお、S142のラッパコードを生成する否かの処理を省略して、全てのDLL31をラップの対象にすることもできる。また、呼び出しプログラム35の実行前に、ラッパコード生成部10があらかじめラッパライブラリ34を作成し、S144のラッパコード生成処理を省略することもできる。   Note that it is possible to omit all of the DLL 31 as a wrap target by omitting the process of whether or not to generate the wrapper code in S142. Further, before the execution of the calling program 35, the wrapper code generation unit 10 can create the wrapper library 34 in advance, and the wrapper code generation process of S144 can be omitted.

また、上記実施形態では、DLLを呼び出すプログラム毎に、DLL全体のロードイメージを作成する。しかしながら、本発明は、DLLを呼び出すプログラム毎に、ロードイメージの一部を作成することとしてもよい。   In the above embodiment, a load image of the entire DLL is created for each program that calls the DLL. However, the present invention may create a part of the load image for each program that calls the DLL.

すなわち、DLLの一部の領域が1つのプロセス内で動作する複数のプログラム間で共有可能な構成の場合、ラッパライブラリは、プログラム間で共有不可能な領域のみのロードイメージをプログラム毎に作成することとしてもよい。   That is, when a part of the DLL area is configured to be sharable among a plurality of programs operating in one process, the wrapper library creates a load image of only the area that cannot be shared between programs for each program. It is good as well.

図15は、ロードイメージ選択コードの処理フローである。なお、上記実施形態におけるロードイメージ選択コードの処理フロー(図12参照)に相当する処理である。なお、ここでは、DLL31のテキストセクション22はプログラム間で共有可能な領域(以下、「共有部分」)であって、データセクション23はプログラム間で共有不可能な領域(以下、「非共有部分」)とする。   FIG. 15 is a processing flow of the load image selection code. This process corresponds to the process flow (see FIG. 12) of the load image selection code in the above embodiment. Here, the text section 22 of the DLL 31 is an area that can be shared between programs (hereinafter, “shared part”), and the data section 23 is an area that cannot be shared between programs (hereinafter, “unshared part”). ).

まず、ロードイメージ選択コードは、テキストセクション22(共有部分)のロードイメージが作成済みか否かを判定する(S151)。テキストセクション22のロードイメージが作成済みの場合(S151:YES)、ロードイメージ選択コードは、当該ロードイメージを取得する(S152)。一方、テキストセクション22のロードイメージが未作成の場合(S151:NO)、ロードイメージ選択コードは、テキストセクションをメモリに展開してロードイメージを作成し、当該ロードイメージを記録する(S153)。   First, the load image selection code determines whether or not a load image of the text section 22 (shared part) has been created (S151). When the load image of the text section 22 has been created (S151: YES), the load image selection code acquires the load image (S152). On the other hand, when the load image of the text section 22 has not been created (S151: NO), the load image selection code develops the text section in the memory to create a load image, and records the load image (S153).

そして、ロードイメージ選択コードは、変更後の読み出しプログラム36の識別子を取得し、当該識別子に対する非共有部分のロードイメージがプロセスに作成済みか否かを判別する(S154)。作成済みの場合(S154:YES)、ロードイメージ選択コードは、当該ロードイメージを取得する(S155)。一方、非共有部分のロードイメージが未作成の場合(S154:NO)、ロードイメージ選択コードは、非共有部分をメモリへ展開し(S156)、再配置を行う(S157)。そして、ロードイメージ選択コードは、作成したロードイメージと、当該識別子とを対応付けて登録(記憶)する(S158)。そして、ロードイメージ選択コードは、アドレステーブルの先頭テーブルを、間接参照用のベースレジスタにロードする(S159)。   Then, the load image selection code obtains the identifier of the read program 36 after the change, and determines whether or not the load image of the non-shared part corresponding to the identifier has been created in the process (S154). If it has been created (S154: YES), the load image selection code acquires the load image (S155). On the other hand, when the load image of the non-shared part has not been created (S154: NO), the load image selection code expands the non-shared part into the memory (S156) and rearranges it (S157). The load image selection code registers (stores) the created load image and the identifier in association with each other (S158). Then, the load image selection code loads the head table of the address table into the base register for indirect reference (S159).

次に、DLL31のテキストセクション22が非共有部分の場合のロードイメージ選択コードの処理を説明する。   Next, the processing of the load image selection code when the text section 22 of the DLL 31 is a non-shared part will be described.

図16は、テキストセクションが非共有部分の場合の、ロードイメージ選択コードの処理フローである。図16に示す処理フローは、以下の点において図15に示す処理フローと異なる。すなわち、データのアドレステーブルの作成(S163)が追加されている点が、図15に示す処理フローと異なる。また、図15のS153に相当するS164の処理において、テキストセクションをメモリに展開するだけでなく、テキストセクションのデータの参照部分をデータのアドレステーブルを用いた間接参照に修正する点が異なる。これにより、テキストセクションを位置独立コードに修正することができ、プロセス内で動作する複数のプログラム間で共有可能なコードとなる。また、S163で作成したアドレステーブルは、非共有部分となる。そのため、S168において、データのアドレステーブルをメモリに展開し、アドレステーブルの再配置を行う点が異なる。   FIG. 16 is a processing flow of the load image selection code when the text section is a non-shared part. The processing flow shown in FIG. 16 differs from the processing flow shown in FIG. 15 in the following points. That is, the point that the creation of the data address table (S163) is added is different from the processing flow shown in FIG. Further, in the process of S164 corresponding to S153 in FIG. 15, not only the text section is expanded in the memory, but also the reference portion of the data in the text section is modified to indirect reference using the data address table. As a result, the text section can be corrected to position independent code, and the code can be shared among a plurality of programs operating in the process. The address table created in S163 is a non-shared part. Therefore, in S168, the data address table is expanded in the memory, and the address table is rearranged.

図1は、本発明の一実施形態が適用されたラッパライブラリ生成装置の概略構成図である。FIG. 1 is a schematic configuration diagram of a wrapper library generation apparatus to which an embodiment of the present invention is applied. 図2は、ダイナミックリンクライブラリの一例を示す図である。FIG. 2 is a diagram illustrating an example of a dynamic link library. 図3は、シンボル管理テーブルの一例を示す図である。FIG. 3 is a diagram illustrating an example of the symbol management table. 図4は、名称対応テーブルの一例を示す図である。FIG. 4 is a diagram illustrating an example of the name correspondence table. 図5は、ラッパライブラリ生成装置のハードウェア構成を示す図である。FIG. 5 is a diagram illustrating a hardware configuration of the wrapper library generation device. 図6は、DLL入力部およびコード生成部の処理フローを示す図である。FIG. 6 is a diagram illustrating a processing flow of the DLL input unit and the code generation unit. 図7は、出力部の処理フローを示す図である。FIG. 7 is a diagram illustrating a processing flow of the output unit. 図8は、ラッパライブラリの一例を示す図である。FIG. 8 is a diagram illustrating an example of a wrapper library. 図9は、呼び出しコード生成部の処理フローを示す図である。FIG. 9 is a diagram illustrating a processing flow of the calling code generation unit. 図10は、呼び出しプログラムの一例を示す図である。FIG. 10 is a diagram illustrating an example of a calling program. 図11は、変更後の呼び出しプログラムの一例を示す図である。FIG. 11 is a diagram illustrating an example of the calling program after the change. 図12は、ロードイメージ選択コードの処理フローを示す図である。FIG. 12 is a diagram illustrating a processing flow of the load image selection code. 図13は、仮想マシンのソフトウェア構成の一例を示す図である。FIG. 13 is a diagram illustrating an example of a software configuration of a virtual machine. 図14は、プログラム実行時にラッパコードを生成する場合の処理フローを示す図である。FIG. 14 is a diagram showing a processing flow when a wrapper code is generated during program execution. 図15は、ロードイメージの一部を作成する場合の第1のロードイメージ選択コードの処理フローを示す図である。FIG. 15 is a diagram showing a processing flow of the first load image selection code when a part of the load image is created. 図16は、ロードイメージの一部を作成する場合の第2のロードイメージ選択コードの処理フローを示す図である。FIG. 16 is a diagram showing a processing flow of the second load image selection code when a part of the load image is created.

符号の説明Explanation of symbols

1:ラッパライブラリ生成装置、10:ラッパコード生成部、11:DLL入力部、12:コード生成部、13:出力部、20:呼び出しコード生成部、30:記憶部、31:ダイナミックリンクライブラリ、32:シンボル管理テーブル、33:名称対応テーブル、34:ラッパライブラリ、35:呼び出しプログラム、36:変更後呼び出しプログラム   1: wrapper library generation device, 10: wrapper code generation unit, 11: DLL input unit, 12: code generation unit, 13: output unit, 20: call code generation unit, 30: storage unit, 31: dynamic link library, 32 : Symbol management table, 33: Name correspondence table, 34: Wrapper library, 35: Call program, 36: Call program after change

Claims (8)

ダイナミックリンクライブラリを呼び出すためのダイナミックリンクライブラリ呼び出しコード生成方法であって、
情報処理装置は、演算処理部と記憶部とを有し、
前記演算処理部は、
前記記憶部に記憶された前記ダイナミックリンクライブラリを読み出す第1の読み出しステップと、
前記読み出したダイナミックリンクライブラリに記述された関数にもとづいて、アプリケーションプログラム毎に前記ダイナミックリンクライブラリのロードイメージを作成するラッパライブラリを生成する生成ステップと、
前記記憶部に記憶された前記アプリケーションプログラムを読み出す第2の読み出しステップと、
前記アプリケーションプログラムにおいて、前記ダイナミックリンクライブラリを呼び出すコードを特定し、当該ダイナミックリンクライブラリの呼び出しコードを、前記生成したラッパライブラリを呼び出すコードに変更する変更ステップと、を行うこと
を特徴とするダイナミックリンクライブラリ呼び出しコード生成方法。
A dynamic link library call code generation method for calling a dynamic link library,
The information processing apparatus includes an arithmetic processing unit and a storage unit,
The arithmetic processing unit includes:
A first reading step of reading the dynamic link library stored in the storage unit;
A generation step of generating a wrapper library for creating a load image of the dynamic link library for each application program based on the function described in the read dynamic link library;
A second reading step of reading the application program stored in the storage unit;
In the application program, the dynamic link library is characterized in that: a code for calling the dynamic link library is specified, and a change step for changing the call code of the dynamic link library to a code for calling the generated wrapper library is performed. Call code generation method.
請求項1記載のダイナミックリンクライブラリ呼び出しコード生成方法であって、
前記生成ステップにおいて生成されるラッパライブラリは、
前記ダイナミックリンクライブラリの各領域の中から前記アプリケーションプログラム間で共有不可能な領域を特定し、当該共有不可能な領域のみのロードイメージを前記アプリケーションプログラム毎に作成すること
を特徴とするダイナミックリンクライブラリ呼び出しコード生成方法。
The dynamic link library call code generation method according to claim 1,
The wrapper library generated in the generating step is
A dynamic link library that identifies an area that cannot be shared among the application programs from each area of the dynamic link library and creates a load image of only the non-shareable area for each application program Call code generation method.
請求項1記載のダイナミックリンクライブラリ呼び出しコード生成方法であって、
前記生成ステップにおいて生成されるラッパライブラリは、
前記ダイナミックリンクライブラリのテキスト記述部が、前記アプリケーション間で共有不可能な場合、前記テキスト記述部のコードを前記アプリケーション間で共有可能なコードに修正し、前記テキスト記述部以外の前記アプリケーション間で共有不可能な領域のみのロードイメージを、前記アプリケーションプログラム毎に作成すること
を特徴とするダイナミックリンクライブラリ呼び出しコード生成方法。
The dynamic link library call code generation method according to claim 1,
The wrapper library generated in the generating step is
If the text description part of the dynamic link library is not sharable between the applications, the code of the text description part is modified to a code that can be shared between the applications, and is shared between the applications other than the text description part. A dynamic link library call code generation method, wherein a load image of only an impossible area is created for each application program.
請求項1記載のダイナミックリンクライブラリ呼び出しコード生成方法であって、
前記生成ステップにおいて生成されるラッパライブラリは、
前記アプリケーションプログラムが使用するメモリ領域のアドレス毎に、前記ロードイメージを作成すること
を特徴とするダイナミックリンクライブラリ呼び出しコード生成方法。
The dynamic link library call code generation method according to claim 1,
The wrapper library generated in the generating step is
A dynamic link library call code generation method, wherein the load image is created for each address of a memory area used by the application program.
請求項1記載のダイナミックリンクライブラリ呼び出しコード生成方法であって、
前記演算処理部は、
前記アプリケーションプログラムを前記記憶部から読み出し、実行する実行ステップを、さらに行い、
前記実行ステップの実行時に、前記第1の読出しステップ、前記生成ステップ、および、前記変更ステップを行うこと
を特徴とするダイナミックリンクライブラリ呼び出しコード生成方法。
The dynamic link library call code generation method according to claim 1,
The arithmetic processing unit includes:
The execution step of reading and executing the application program from the storage unit is further performed,
A dynamic link library call code generation method comprising: performing the first read step, the generation step, and the change step when executing the execution step.
請求項5記載のダイナミックリンクライブラリ呼び出しコード生成方法であって、
前記演算処理部は、
前記生成ステップの実行指示を受け付ける受け付けステップを、さらに行い、
前記実行ステップにおいて、前記実行指示を受け付けた場合に、前記生成ステップを行うこと、
を特徴とするダイナミックリンクライブラリ呼び出しコード生成方法。
The dynamic link library call code generation method according to claim 5,
The arithmetic processing unit includes:
Further performing a receiving step of receiving an instruction to execute the generating step;
Performing the generation step when the execution instruction is received in the execution step;
A dynamic link library call code generation method characterized by the above.
情報処理装置がダイナミックリンクライブラリの呼び出しコードを生成する呼び出しコード生成プログラムであって、
前記情報処理装置は、演算処理部と記憶部とを有し、
前記演算処理部に、
前記記憶部に記憶された前記ダイナミックリンクライブラリを読み出す第1の読み出しステップ、
前記読み出したダイナミックリンクライブラリに記述された関数にもとづいて、アプリケーションプログラム毎に前記ダイナミックリンクライブラリのロードイメージを作成するラッパライブラリを生成する生成ステップ、
前記記憶部に記憶された前記アプリケーションプログラムを読み出す第2の読み出しステップ、および、
前記アプリケーションプログラムにおいて、前記ダイナミックリンクライブラリを呼び出すコードを特定し、当該ダイナミックリンクライブラリの呼び出しコードを、前記生成したラッパライブラリを呼び出すコードに変更する変更ステップ、を実行させること
を特徴とする呼び出しコード生成プログラム。
An information processing device is a call code generation program for generating a call code of a dynamic link library,
The information processing apparatus includes an arithmetic processing unit and a storage unit,
In the arithmetic processing unit,
A first reading step of reading the dynamic link library stored in the storage unit;
A generation step of generating a wrapper library for creating a load image of the dynamic link library for each application program based on the function described in the read dynamic link library;
A second reading step of reading the application program stored in the storage unit; and
In the application program, a code for calling the dynamic link library is specified, and a change step for changing the call code of the dynamic link library to a code for calling the generated wrapper library is executed. program.
ダイナミックリンクライブラリを呼び出すためのダイナミックリンクライブラリ呼び出しコード生成装置であって、
前記ダイナミックリンクライブラリと、前記ダイナミックリンクライブラリを呼び出すアプロケーションプログラムと、を記憶する記憶手段と、
前記ダイナミックリンクライブラリに記述された関数にもとづいて、前記アプリケーションプログラム毎に前記ダイナミックリンクライブラリのロードイメージを作成するラッパライブラリを生成する生成ステップと、
前記アプリケーションプログラムを前記記憶手段から読み出し、当該アプリケーションプログラムにおいて、前記ダイナミックリンクライブラリを呼び出すコードを特定し、特定したダイナミックリンクライブラリの呼び出しコードを、前記生成したラッパライブラリを呼び出すコードに変更する変更手段と、を有すること
を特徴とするダイナミックリンクライブラリ呼び出しコード生成装置。
A dynamic link library call code generation device for calling a dynamic link library,
Storage means for storing the dynamic link library and an allocation program for calling the dynamic link library;
A generation step of generating a wrapper library for creating a load image of the dynamic link library for each application program based on a function described in the dynamic link library;
A change unit that reads the application program from the storage unit, identifies a code that calls the dynamic link library in the application program, and changes the call code of the identified dynamic link library to a code that calls the generated wrapper library; And a dynamic link library call code generation device.
JP2004302542A 2004-10-18 2004-10-18 Dynamic link library calling code generation method, program, and apparatus Pending JP2006113935A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2004302542A JP2006113935A (en) 2004-10-18 2004-10-18 Dynamic link library calling code generation method, program, and apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2004302542A JP2006113935A (en) 2004-10-18 2004-10-18 Dynamic link library calling code generation method, program, and apparatus

Publications (1)

Publication Number Publication Date
JP2006113935A true JP2006113935A (en) 2006-04-27

Family

ID=36382392

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2004302542A Pending JP2006113935A (en) 2004-10-18 2004-10-18 Dynamic link library calling code generation method, program, and apparatus

Country Status (1)

Country Link
JP (1) JP2006113935A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2008113291A1 (en) * 2007-03-20 2008-09-25 Huawei Technologies Co., Ltd. Method and system for calling functions
JP2010009149A (en) * 2008-06-24 2010-01-14 Fujitsu Ltd Dynamic library loading method and device
CN102402455A (en) * 2010-09-14 2012-04-04 北大方正集团有限公司 Method and device for calling dynamic link library (DLL)
CN112905378A (en) * 2021-03-03 2021-06-04 广州虎牙科技有限公司 Crash information analysis method and device, electronic equipment and readable storage medium

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2008113291A1 (en) * 2007-03-20 2008-09-25 Huawei Technologies Co., Ltd. Method and system for calling functions
JP2010009149A (en) * 2008-06-24 2010-01-14 Fujitsu Ltd Dynamic library loading method and device
CN102402455A (en) * 2010-09-14 2012-04-04 北大方正集团有限公司 Method and device for calling dynamic link library (DLL)
CN112905378A (en) * 2021-03-03 2021-06-04 广州虎牙科技有限公司 Crash information analysis method and device, electronic equipment and readable storage medium
CN112905378B (en) * 2021-03-03 2024-03-08 广州虎牙科技有限公司 Crash information analysis method, device, electronic equipment and readable storage medium

Similar Documents

Publication Publication Date Title
JP5167589B2 (en) Application server device and virtual machine program
JP6198939B2 (en) Method for loading driver and embedded device
US6944846B2 (en) Algorithm for localization of a JAVA application using reflection API and a custom class loader
US20050160415A1 (en) Method and system for improving performance of Java virtual machine
US8984497B2 (en) Source code converting, method program, and systems for first programming language to a code in a second programming language
TWI291098B (en) Method and system for data optimization and protection in DSP firmware
JP2010086410A (en) Memory protection method, information processing apparatus, memory protection program and recording medium with memory protection program recorded thereon
JP5496792B2 (en) Code conversion program, method and system
JP5489884B2 (en) Instruction execution device, instruction execution method, and instruction execution program
JP2006113935A (en) Dynamic link library calling code generation method, program, and apparatus
US7636914B1 (en) System and method for providing context to operator overloading
CN113849245B (en) Application program running method, computing device and storage medium
CN115576560A (en) Hot reloading method, device, equipment and medium for dynamic loader
KR101670916B1 (en) Method for storing function and system device using the same
US8694975B2 (en) Programming system in multi-core environment, and method and program of the same
KR101140522B1 (en) System and Method for Managing Object
JP2003241967A (en) Program execution device, its method and program executed therein
JPWO2020158347A1 (en) Information processing equipment, methods and programs
JP2000122876A (en) Information processor
JP2006048186A (en) Language processing system protecting generated code of dynamic compiler
KR101281954B1 (en) Method of incremental linking for embedded system
WO2015083234A1 (en) Function call table generating device, program execution device, and execution program
JP2011118830A (en) Multitasking system and program
JP6103972B2 (en) Program generation method, program execution method, program execution device, and program execution program
JP2016081097A (en) Programmable controller system, support device thereof and programmable controller