Go to the first, previous, next, last section, table of contents.



DLLÀ» ¸¸µé°í »ç¿ëÇϴµ¥ ÇÊ¿äÇÑ ÆÄÀÏÀ» ¸¸µé±â

dlltool may be used to create the files needed to build and use dynamic link libraries (DLLs).
dlltoolÀº µ¿Àû ¸µÅ© ¶óÀ̺귯¸®(DLL)À» ¸¸µé°í »ç¿ëÇϴµ¥ ÇÊ¿äÇÑ ÆÄÀÏÀ» ¸¸µç´Ù.

Warning: dlltool is not always built as part of the binary utilities, since it is only useful for those targets which support DLLs.
°æ°í: dlltoolÀº DLLÀ» Áö¿øÇϴ Ÿ°Ù¿¡¼­¸¸ »ç¿ëÇϱ⠶§¹®¿¡ ÄÄÆÄÀϽà »ý¼ºµÇÁö ¾ÊÀ» ¼ö ÀÖ´Ù.


dlltool [-d|--input-def def-file-name]
        [-b|--base-file base-file-name]
        [-e|--output-exp exports-file-name]
        [-z|--output-def def-file-name]
        [-l|--output-lib library-file-name]        
        [--export-all-symbols] [--no-export-all-symbols]
        [--exclude-symbols list]
        [--no-default-excludes]
        [-S|--as path-to-assembler] [-f|--as-flags options]
        [-D|--dllname name] [-m|--machine machine]
        [-a|--add-indirect] [-U|--add-underscore] [-k|--kill-at]
        [-A|--add-stdcall-alias]
        [-x|--no-idata4] [-c|--no-idata5] [-i|--interwork]
        [-n|--nodelete] [-v|--verbose] [-h|--help] [-V|--version]
        [object-file ...]

dlltool reads its inputs, which can come from the `-d' and `-b' options as well as object files specified on the command line. It then processes these inputs and if the `-e' option has been specified it creates a exports file. If the `-l' option has been specified it creates a library file and if the `-z' option has been specified it creates a def file. Any or all of the -e, -l and -z options can be present in one invocation of dlltool.

When creating a DLL, along with the source for the DLL, it is necessary to have three other files. dlltool can help with the creation of these files.

dlltoolÀº ¸í·ÉÇà°ú `-d', `-b' ¿É¼ÇÀ¸·Î ÀÔ·ÂÀ» ¹Þ´Â´Ù. ÀÔ·ÂÀ» ó¸®ÇÑ ÈÄ, `-e' ¿É¼ÇÀ» »ç¿ëÇϸé ÀͽºÆ÷Æ® ÆÄÀÏÀ» ¸¸µç´Ù. `-l' ¿É¼ÇÀº ¶óÀ̺귯¸® ÆÄÀÏ(.lib ÆÄÀÏ)À», `-z' ¿É¼ÇÀº def ÆÄÀÏÀ» ¸¸µç´Ù. -e, -l, -z ¿É¼ÇÀº °°ÀÌ »ç¿ëÇÒ ¼ö ÀÖ´Ù.

DLL ÆÄÀÏÀ» ¸¸µé ¶§ DLLÀ» À§ÇÑ ¼Ò½º ¿Ü¿¡ 3 ÆÄÀÏÀÌ ÇÊ¿äÇÏ´Ù. dlltool´Â ÀÌ ÆÄÀÏÀ» ¸¸µå´Â °ÍÀ» µµ¿ÍÁØ´Ù.

The first file is a `.def' file which specifies which functions are exported from the DLL, which functions the DLL imports, and so on. This is a text file and can be created by hand, or dlltool can be used to create it using the `-z' option. In this case dlltool will scan the object files specified on its command line looking for those functions which have been specially marked as being exported and put entries for them in the .def file it creates.

In order to mark a function as being exported from a DLL, it needs to have an `-export:<name_of_function>' entry in the `.drectve' section of the object file. This can be done in C by using the asm() operator:
ù¹ø° ÆÄÀÏÀº DLLÀÌ ¾î¶² ÇÔ¼ö¸¦ ÀͽºÆ÷Æ®ÇÏ°í ÀÓÆ÷Æ®ÇÏ´ÂÁö¸¦ ¼³¸íÇÏ´Â `.def' ÆÄÀÏÀÌ´Ù. ÀÌ´Â ÀÏ¹Ý ÅؽºÆ® ÆÄÀÏ·Î `-z' ¿É¼ÇÀ¸·Î ¸¸µé ¼ö ÀÖ´Ù. ÀÌ °æ¿ì dlltool´Â ¸í·ÉÇà¿¡ ÁÖ¾îÁø ¿ÀºêÁ§Æ® ÆÄÀϵ鿡¼­ ¸í½ÃÀûÀ¸·Î ÀͽºÆ÷Æ®µÇ´Â ÇÔ¼ö¸¦ ã¾Æ .def ÆÄÀÏ¿¡ Æ÷ÇÔÇÑ´Ù.

DLL¿¡¼­ ÇÔ¼ö°¡ ÀͽºÆ÷Æ®µÊÀ» ¸í½ÃÀûÀ¸·Î ¾Ë±â±â À§Çؼ­ ¿ÀºêÁ§Æ® ÆÄÀÏÀÇ `.drectve' ¼½¼Ç¿¡ `-export:<name_of_function>' Ç׸ñÀÌ ÇÊ¿äÇÏ´Ù. ÀÌ´Â ´ÙÀ½°ú °°ÀÌ C¿¡¼­ asm() ¿¬»êÀÚ¸¦ »ç¿ëÇÏ¿© °¡´ÉÇÏ´Ù.

  asm (".section .drectve");  
  asm (".ascii \"-export:my_func\"");

  int my_func (void) { ... }

The second file needed for DLL creation is an exports file. This file is linked with the object files that make up the body of the DLL and it handles the interface between the DLL and the outside world. This is a binary file and it can be created by giving the `-e' option to dlltool when it is creating or reading in a .def file.

The third file needed for DLL creation is the library file that programs will link with in order to access the functions in the DLL. This file can be created by giving the `-l' option to dlltool when it is creating or reading in a .def file.
DLLÀ» ¸¸µå´Âµ¥ ÇÊ¿äÇÑ µÎ¹ø° ÆÄÀÏÀº ÀͽºÆ÷Æ® ÆÄÀÏÀÌ´Ù. ÀÌ ÆÄÀÏÀº DLLÀ» ÀÌ·ç´Â ¿ÀºêÁ§Æ® ÆÄÀÏ°ú ¸µÅ©µÇ¾î DLL°ú ¿ÜºÎ »çÀÌÀÇ ÀÎÅÍÆäÀ̽º¸¦ ´Ù·é´Ù. ÀÌ´Â ÀÌÁø ÆÄÀÏÀÌ°í, .def ÆÄÀÏÀ» ¸¸µé°Å³ª ÀÐÀ» ¶§ `-e' ¿É¼ÇÀ¸·Î ¸¸µé ¼ö ÀÖ´Ù.

¼¼¹ø° ÆÄÀÏÀº DLL ÇÔ¼ö¿¡ Á¢±ÙÇϱâ À§Çؼ­ ¸µÅ©µÇ´Â ÇÁ·Î±×·¥ÀÎ ¶óÀ̺귯¸® ÆÄÀÏÀÌ´Ù. ÀÌ ÆÄÀÏÀº .def ÆÄÀÏÀ» ¸¸µé°Å³ª ÀÐÀ» ¶§ `-l' ¿É¼ÇÀ¸·Î ¸¸µé ¼ö ÀÖ´Ù.

dlltool builds the library file by hand, but it builds the exports file by creating temporary files containing assembler statements and then assembling these. The `-S' command line option can be used to specify the path to the assembler that dlltool will use, and the `-f' option can be used to pass specific flags to that assembler. The `-n' can be used to prevent dlltool from deleting these temporary assembler files when it is done, and if `-n' is specified twice then this will prevent dlltool from deleting the temporary object files it used to build the library.

Here is an example of creating a DLL from a source file `dll.c' and also creating a program (from an object file called `program.o') that uses that DLL:
dlltoolÀº Á÷Á¢ ¶óÀ̺귯¸® ÆÄÀÏÀ» ¸¸µéÁö¸¸, ÀͽºÆ÷Æ® ÆÄÀÏÀº ¾î¼Àºí¸® ¹®ÀåÀ» ´ãÀº Àӽà ÆÄÀÏÀ» ¸¸µé°í À̸¦ ¾î¼ÀºíÇÏ¿© ¸¸µç´Ù. `-S' ¿É¼ÇÀº »ç¿ëÇÒ ¾î¼Àºí·¯ÀÇ °æ·Î¸¦ ÁöÁ¤ÇÏ°í, `-f' ¿É¼ÇÀº ¾î¼Àºí·¯¿¡ ÁÙ ¿É¼ÇÀ» ÁöÁ¤ÇÑ´Ù. `-n'Àº Àӽà ¾î¼Àºí¸® ÆÄÀÏÀ» »èÁ¦ÇÏÁö ¾Ê°Ô ÇÏ°í, `-n'À» µÎ¹ø »ç¿ëÇÏ¸é ¶óÀ̺귯¸® ÆÄÀÏÀ» ¸¸µå´Âµ¥ »ç¿ëÇÑ Àӽà ÆÄÀϵéÀ» »èÁ¦ÇÏÁö ¾Ê´Â´Ù.

´ÙÀ½Àº `dll.c'·Î DLLÀ» ¸¸µé°í, ÀÌ DLLÀ» »ç¿ëÇÏ´Â (`program.o'¶ó´Â ¿ÀºêÁ§Æ® ÆÄÀÏ¿¡¼­) ÇÁ·Î±×·¥À» ¸¸µå´Â ¿¹ÀÌ´Ù.

  gcc -c dll.c
  dlltool -e exports.o -l dll.lib dll.o
  gcc dll.o exports.o -o dll.dll
  gcc program.o dll.lib -o program

The command line options have the following meanings:

¸í·ÉÇà ¿É¼ÇµéÀº ´ÙÀ½°ú °°´Ù.

-d filename
--input-def filename
Specifies the name of a .def file to be read in and processed.
Àаí ó¸®ÇÒ .def ÆÄÀÏ À̸§À» ÁöÁ¤ÇÑ´Ù.
-b filename
--base-file filename
Specifies the name of a base file to be read in and processed. The contents of this file will be added to the relocation section in the exports file generated by dlltool.
Àаí ó¸®ÇÒ º£À̽º ÆÄÀÏ À̸§À» ÁöÁ¤ÇÑ´Ù. ÆÄÀÏ ³»¿ëÀº dlltoolÀÌ »ý¼ºÇÏ´Â ÀͽºÆ÷Æ® ÆÄÀÏÀÇ Àç¹èÄ¡ ¼½¼Ç¿¡ Ãß°¡µÈ´Ù.
-e filename
--output-exp filename
Specifies the name of the export file to be created by dlltool.
»ý¼ºÇÒ ÀͽºÆ÷Æ® ÆÄÀÏ À̸§À» ÁöÁ¤ÇÑ´Ù.
-z filename
--output-def filename
Specifies the name of the .def file to be created by dlltool.
»ý¼ºÇÒ .def ÆÄÀÏ À̸§À» ÁöÁ¤ÇÑ´Ù.
-l filename
--output-lib filename
Specifies the name of the library file to be created by dlltool.
»ý¼ºÇÒ ¶óÀ̺귯¸® ÆÄÀÏ À̸§À» ÁöÁ¤ÇÑ´Ù.
--export-all-symbols
Treat all global and weak defined symbols found in the input object files as symbols to be exported. There is a small list of symbols which are not exported by default; see the --no-default-excludes option. You may add to the list of symbols to not export by using the --exclude-symbols option.
ÀÔ·Â ¿ÀºêÁ§Æ® ÆÄÀÏÀÇ ¸ðµç Á¤ÀÇµÈ Àü¿ª ½Éº¼°ú ¾àÇÑ ½Éº¼À» ÀͽºÆ÷Æ®ÇÑ´Ù. ±âº»À¸·Î ÀͽºÆ÷Æ®µÇÁö ¾Ê´Â ½Éº¼µéÀÌ Á¶±Ý ÀÖ´Ù. --no-default-excludes¸¦ Âü°íÇ϶ó. --exclude-symbols ¿É¼ÇÀ» »ç¿ëÇÏ¿© Ãß°¡·Î ½Éº¼µéÀ» ÀͽºÆ÷Æ®ÇÏÁö ¾Ê°Ô ÇÒ ¼ö ÀÖ´Ù.
--no-export-all-symbols
Only export symbols explicitly listed in an input .def file or in `.drectve' sections in the input object files. This is the default behaviour. The `.drectve' sections are created by `dllexport' attributes in the source code.
¸í½ÃÀûÀ¸·Î .def ÆÄÀÏÀ̳ª ÀÔ·Â ¿ÀºêÁ§Æ® ÆÄÀÏÀÇ `.drectve' ¼½¼Ç¿¡ ÁöÁ¤µÈ ½Éº¼¸¸ ÀͽºÆ÷Æ®ÇÑ´Ù. ÀÌ´Â ±âº» ÇൿÀÌ´Ù. `.drectve' ¼½¼ÇÀº ¼Ò½º Äڵ忡¼­ `dllexport' ¼Ó¼ºÀ¸·Î ¸¸µç´Ù.
--exclude-symbols list
Do not export the symbols in list. This is a list of symbol names separated by comma or colon characters. The symbol names should not contain a leading underscore. This is only meaningful when --export-all-symbols is used.
listÀÇ ½Éº¼µéÀ» ÀͽºÆ÷Æ®ÇÏÁö ¾Ê´Â´Ù. ¸ñ·Ï¿¡¼­ ½Éº¼ À̸§Àº `,'³ª `:'À¸·Î ±¸ºÐµÈ´Ù. ½Éº¼ À̸§Àº ¾Õ¿¡ `_'À» Æ÷ÇÔÇÒ ¼ö ¾ø´Ù. ÀÌ ¿É¼ÇÀº --export-all-symbolsÀ» »ç¿ëÇßÀ» ¶§¸¸ Àǹ̰¡ ÀÖ´Ù.
--no-default-excludes
When --export-all-symbols is used, it will by default avoid exporting certain special symbols. The current list of symbols to avoid exporting is `DllMain@12', `DllEntryPoint@0', `impure_ptr'. You may use the --no-default-excludes option to go ahead and export these special symbols. This is only meaningful when --export-all-symbols is used.
--export-all-symbols¸¦ »ç¿ëÇÏ¸é ±âº»À¸·Î ¾î¶² Ưº°ÇÑ ½Éº¼Àº ÀͽºÆ÷Æ®ÇÏÁö ¾Ê´Â´Ù. ÀÌ ¸ñ·ÏÀº ÇöÀç `DllMain@12', `DllEntryPoint@0', `impure_ptr'ÀÌ´Ù. --no-default-excludes ¿É¼ÇÀ¸·Î À̵é±îÁöµµ ÀͽºÆ÷Æ®ÇÒ ¼ö ÀÖ´Ù. ÀÌ ¿É¼ÇÀº --export-all-symbolsÀ» »ç¿ëÇßÀ» ¶§¸¸ Àǹ̰¡ ÀÖ´Ù.
-S path
--as path
Specifies the path, including the filename, of the assembler to be used to create the exports file.
ÀͽºÆ÷Æ® ÆÄÀÏÀ» ¸¸µé ¶§ »ç¿ëÇÏ´Â ¾î¼Àºí·¯ÀÇ (ÆÄÀϸíÀ» Æ÷ÇÔÇÑ) °æ·Î¸¦ ÁöÁ¤ÇÑ´Ù.
-f switches
--as-flags switches
Specifies any specific command line switches to be passed to the assembler when building the exports file. This option will work even if the `-S' option is not used. This option only takes one argument, and if it occurs more than once on the command line, then later occurrences will override earlier occurrences. So if it is necessary to pass multiple switches to the assembler they should be enclosed in double quotes.
ÀͽºÆ÷Æ® ÆÄÀÏÀ» ¸¸µé ¶§ ¾î¼Àºí·¯¿¡ ÁÖ¾îÁú ¿É¼ÇÀ» ÁöÁ¤ÇÑ´Ù. ÀÌ ¿É¼ÇÀº `-S' ¿É¼ÇÀÌ ¾ø¾îµµ °¡´ÉÇÏ´Ù. ÀÌ ¿É¼ÇÀº ¿ÀÁ÷ ÇÑ ¾Æ±Ô¸ÕÆ®¸¸ ¹Þ´Â´Ù. ¿É¼ÇÀ» ¿©·¯¹ø »ç¿ëÇÏ¸é ³ªÁß °ÍÀÌ ¾ÕÀÇ °ÍÀ» ´ëüÇÑ´Ù. ±×·¡¼­ ¾î¼Àºí·¯¿¡ ¿©·¯ ¿É¼ÇÀ» ³Ñ°ÜÁÖ·Á¸é ½Öµû¿ÈÇ¥·Î ¹­¾îÁà¾ß ÇÑ´Ù.
-D name
--dll-name name
Specifies the name to be stored in the .def file as the name of the DLL when the `-e' option is used. If this option is not present, then the filename given to the `-e' option will be used as the name of the DLL.
`-e' ¿É¼ÇÀ» »ç¿ëÇÒ ¶§ .def ÆÄÀÏ¿¡ ÀúÀåÇÒ DLL À̸§À» ÁöÁ¤ÇÑ´Ù. ÀÌ ¿É¼ÇÀ» »ç¿ëÇÏÁö ¾ÊÀ¸¸é `-e' ¿É¼Ç¿¡ ÁÖ¾îÁø À̸§ÀÌ DLL À̸§ÀÌ µÈ´Ù.
-m machine
-machine machine
Specifies the type of machine for which the library file should be built. dlltool has a built in default type, depending upon how it was created, but this option can be used to override that. This is normally only useful when creating DLLs for an ARM processor, when the contents of the DLL are actually encode using THUMB instructions.
¶óÀ̺귯¸® ÆÄÀÏÀÌ ¸¸µé¾îÁú ÄÄÇ»ÅÍ Å¸ÀÔÀ» ÁöÁ¤ÇÑ´Ù. dlltoolÀº ÄÄÆÄÀÏ ¶§ °áÁ¤µÇ´Â ±âº» ŸÀÔÀÌ ÀÖÁö¸¸, ÀÌ ¿É¼ÇÀ¸·Î ´ëüÇÒ ¼ö ÀÖ´Ù. º¸Åë DLLÀÇ ³»¿ëÀÌ THUMB ¸í·É¾î·Î µÈ, ARM ÇÁ·Î¼¼¼­¸¦ À§ÇÑ DLLÀ» »ý¼ºÇÒ ¶§¸¸ À¯¿ëÇÏ´Ù.
-a
--add-indirect
Specifies that when dlltool is creating the exports file it should add a section which allows the exported functions to be referenced without using the import library. Whatever the hell that means!
ÀͽºÆ÷Æ® ÆÄÀÏÀ» ¸¸µé ¶§, ÀÓÆ÷Æ® ¶óÀ̺귯¸® ¾øÀÌ ÀͽºÆ÷Æ®µÈ ÇÔ¼ö¸¦ ÂüÁ¶ÇÒ ¼ö ÀÖ°Ô ÇÏ´Â ¼½¼ÇÀ» Ãß°¡ÇÑ´Ù. µµ´ëü ÀÌ°Ô ¹«½¼ ¸»À̾ß!
-U
--add-underscore
Specifies that when dlltool is creating the exports file it should prepend an underscore to the names of the exported functions.
ÀͽºÆ÷Æ® ÆÄÀÏÀ» ¸¸µé ¶§, ÀͽºÆ÷Æ®µÇ´Â ÇÔ¼ö À̸§ ¾Õ¿¡ `_'À» ºÙÀδÙ.
-k
--kill-at
Specifies that when dlltool is creating the exports file it should not append the string `@ <number>'. These numbers are called ordinal numbers and they represent another way of accessing the function in a DLL, other than by name.
ÀͽºÆ÷Æ® ÆÄÀÏÀ» ¸¸µé ¶§, À̸§ µÚ¿¡ `@ <number>'À» ºÙÀδÙ. ÀÌ ¼ýÀÚ´Â ordinal number¶ó Çϸç, DLL ÇÔ¼ö¸¦ À̸§ ¿ÜÀÇ ¹æ¹ýÀ¸·Î Á¢±ÙÇÒ ¶§ ¾²ÀδÙ.
-A
--add-stdcall-alias
Specifies that when dlltool is creating the exports file it should add aliases for stdcall symbols without `@ <number>' in addition to the symbols with `@ <number>'.
ÀͽºÆ÷Æ® ÆÄÀÏÀ» ¸¸µé ¶§, `@ <number>'¸¦ °¡Áø ½Éº¼¿¡ `@ <number>'ÀÌ ¾ø´Â stdcall ½Éº¼À» À§ÇÑ º°¸íÀ» ºÙÀδÙ.
-x
--no-idata4
Specifies that when dlltool is creating the exports and library files it should omit the .idata4 section. This is for compatibility with certain operating systems.
ÀͽºÆ÷Æ® ÆÄÀÏ°ú ¶óÀ̺귯¸® ÆÄÀÏÀ» ¸¸µé ¶§, .idata4 ¼½¼ÇÀ» »ý·«ÇÑ´Ù. ÀÌ´Â ¾î¶² ¿î¿µÃ¼Á¦¿¡¼­ ȣȯ¼ºÀ» À§ÇÑ °ÍÀÌ´Ù.
-c
--no-idata5
Specifies that when dlltool is creating the exports and library files it should omit the .idata5 section. This is for compatibility with certain operating systems.
ÀͽºÆ÷Æ® ÆÄÀÏ°ú ¶óÀ̺귯¸® ÆÄÀÏÀ» ¸¸µé ¶§, .idata5 ¼½¼ÇÀ» »ý·«ÇÑ´Ù. ÀÌ´Â ¾î¶² ¿î¿µÃ¼Á¦¿¡¼­ ȣȯ¼ºÀ» À§ÇÑ °ÍÀÌ´Ù.
-i
--interwork
Specifies that dlltool should mark the objects in the library file and exports file that it produces as supporting interworking between ARM and THUMB code.
ARM°ú THUMB Äڵ带 °áÇÕÇϱâ À§ÇØ »ý¼ºµÈ ¶óÀ̺귯¸® ÆÄÀÏ°ú ÀͽºÆ÷Æ® ÆÄÀÏ¿¡¼­ °´Ã¼¿¡ Ç¥½Ã¸¦ ÇÑ´Ù.
-n
--nodelete
Makes dlltool preserve the temporary assembler files it used to create the exports file. If this option is repeated then dlltool will also preserve the temporary object files it uses to create the library file.
ÀͽºÆ÷Æ® ÆÄÀÏÀ» ¸¸µå´Âµ¥ ¾²ÀÎ Àӽà ¾î¼Àºí¸® ÆÄÀÏÀ» º¸Á¸ÇÑ´Ù. ÀÌ ¿É¼ÇÀÌ ¹Ýº¹µÇ¸é ¶óÀ̺귯¸® ÆÄÀÏÀ» ¸¸µå´Âµ¥ »ç¿ëÇÑ Àӽà °´Ã¼µéµµ º¸Á¸ÇÑ´Ù.
-v
--verbose
Make dlltool describe what it is doing.
dlltoolÀÌ ÇÏ°í ÀÖ´Â ÀÛ¾÷À» Ãâ·ÂÇÑ´Ù.
-h
--help
Displays a list of command line options and then exits.
¸í·ÉÇà ¿É¼ÇÀ» °£´ÜÈ÷ ¼³¸íÇÏ°í Á¾·áÇÑ´Ù.
-V
--version
Displays dlltool's version number and then exits.
dlltoolÀÇ ¹öÀüÀ» Ãâ·ÂÇÏ°í Á¾·áÇÑ´Ù.


Go to the first, previous, next, last section, table of contents.