DLLTOOL(1)
β¨ dlltool (GNU Development Tools) β¨
β¨ NAME β¨
dlltool β okay so bestie, this whole tool is here to create files needed to build and use DLLs. That's the assignment. π
π SYNOPSIS π
Here's the exact invocation shape, no cap β code block stays untouched:
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]
[-y|--output-delaylib 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] [--add-stdcall-underscore]
[-k|--kill-at] [-A|--add-stdcall-alias]
[-p|--ext-prefix-alias prefix]
[-x|--no-idata4] [-c|--no-idata5]
[--use-nul-prefixed-import-tables]
[-I|--identify library-file-name] [--identify-strict]
[-i|--interwork]
[-n|--nodelete] [-t|--temp-prefix prefix]
[-v|--verbose]
[-h|--help] [-V|--version]
[--no-leading-underscore] [--leading-underscore]
[object-file ...]
π¦ DESCRIPTION π¦
dlltool reads its inputs, and those inputs can come from the -d and -b options as well as object files specified on the command line. Then it processes these inputs. If the -e option has been specified, it creates an exports file. If the -l option has been specified, it creates a library file. If the -z option has been specified, it creates a def file. And yes β any or all of the -e, -l and -z options can be present in one invocation of dlltool. Mix and match, bestie. π«Ά
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. Iconic behavior, honestly.
- First file: a
.deffile 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, ordlltoolcan be used to create it using the-zoption. In this casedlltoolwill 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.deffile it creates. - Second file: 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
-eoption todlltoolwhen it is creating or reading in a.deffile. - Third file: the library file that programs will link with in order to access the functions in the DLL (an
import library). This file can be created by giving the-loption todlltoolwhen it is creating or reading in a.deffile.
If the -y option is specified, dlltool generates a delay-import library that can be used instead of the normal import library to allow a program to link to the dll only as soon as an imported function is called for the first time. The resulting executable will need to be linked to the static delayimp library containing __delayLoadHelper2(), which in turn will import LoadLibraryA and GetProcAddress from kernel32. π§
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. π
Now, 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:
asm (".section .drectve");
asm (".ascii \"-export:my_func\"");
int my_func (void) { ... }
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:
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
dlltool may also be used to query an existing import library to determine the name of the DLL to which it is associated. See the description of the -I or --identify option. π
β¨ OPTIONS β¨
okay bestie, buckle up, here's every single flag and what it actually does π the command line options have these meanings:
-dfilename,--input-deffilename β names the.deffile that dlltool reads in and processes π-bfilename,--base-filefilename β names a base file to read in and process. The contents get added to the relocation section in the exports file that dlltool generates π-efilename,--output-expfilename β names the export file that dlltool creates-zfilename,--output-deffilename β names the.deffile that dlltool creates-lfilename,--output-libfilename β names the library file that dlltool creates-yfilename,--output-delaylibfilename β names the delay-import library file that dlltool creates β¨--export-all-symbolsβ treats every global and weak defined symbol it finds in the input object files as a symbol to export. There's a small list of symbols that are not exported by default β check--no-default-excludesfor that. You can add more to the do-not-export list with--exclude-symbolsπ«Ά--no-export-all-symbolsβ only exports symbols explicitly listed in an input.deffile or in.drectvesections in the input object files. This is the default behaviour, bestie. Those.drectvesections get created bydllexportattributes in the source code.--exclude-symbolslist β do not export the symbols in list. It's a list of symbol names separated by comma or colon characters π the symbol names should not contain a leading underscore. Only meaningful when--export-all-symbolsis used, iykyk.--no-default-excludesβ okay so when--export-all-symbolsis used, dlltool by default avoids exporting certain special symbols. The current list of symbols to avoid exporting isDllMain@12,DllEntryPoint@0,impure_ptr. You can use--no-default-excludesto go ahead and export these special symbols anyway π only meaningful when--export-all-symbolsis used.-Spath,--aspath β specifies the path, including the filename, of the assembler used to create the exports file π¦-foptions,--as-flagsoptions β specifies any specific command line options to pass to the assembler when building the exports file. This one works even if you're not using-Sβ¨ and heads up: it only takes one argument, so if it shows up more than once on the command line, later occurrences override earlier ones. So if you need to pass multiple options to the assembler, enclose them in double quotes, mmkay?-Dname,--dll-namename β specifies the name stored in the.deffile as the name of the DLL when the-eoption is used. If this option isn't present, the filename given to-egets used as the DLL name π-mmachine,-machinemachine β specifies the type of machine the library file should be built for. dlltool has a built-in default type depending on how it was created, but this option overrides that. Normally only useful when creating DLLs for an ARM processor, when the contents of the DLL are actually encoded using Thumb instructions πΈ-a,--add-indirectβ specifies that when dlltool creates the exports file it should add a section that allows the exported functions to be referenced without using the import library. Whatever the hell that means! π (the manpage said it, not me)-U,--add-underscoreβ specifies that when dlltool creates the exports file it should prepend an underscore to the names of all exported symbols β¨--no-leading-underscore,--leading-underscoreβ specifies whether a standard symbol should be forced to be prefixed, or not π--add-stdcall-underscoreβ specifies that when dlltool creates the exports file it should prepend an underscore to the names of exported stdcall functions. Variable names and non-stdcall function names are not modified. This one's useful when creating GNU-compatible import libs for third party DLLs built with MS-Windows tools π-k,--kill-atβ specifies that@<number>suffixes should be omitted from the names of stdcall functions that will be imported from the DLL. Useful when creating an import library for a DLL that exports stdcall functions but without the usual@<number>symbol name suffix π₯ This does not change the naming of symbols the import library provides to programs linked against it β only the entries in the import table (ie the.idatasection). Lowkey important distinction, don't forget it.-A,--add-stdcall-aliasβ specifies that when dlltool creates the exports file it should add aliases for stdcall symbols without@ <number>in addition to the symbols with@ <number>π-p,--ext-prefix-aliasprefix β causes dlltool to create external aliases for all DLL imports with the specified prefix. The aliases are created for both external and import symbols with no leading underscore π-x,--no-idata4β specifies that when dlltool creates the exports and library files it should omit the.idata4section. This is for compatibility with certain operating systems π§--use-nul-prefixed-import-tablesβ specifies that when dlltool creates the exports and library files it should prefix the.idata4and.idata5by zero an element. This emulates old gnu import library generation ofdlltool. By default this option is turned off β-c,--no-idata5β specifies that when dlltool creates the exports and library files it should omit the.idata5section. This is for compatibility with certain operating systems π¦-Ifilename,--identifyfilename β specifies that dlltool should inspect the import library indicated by filename and report, onstdout, the name(s) of the associated DLL(s). This can be done in addition to any other operations indicated by the other options and arguments. dlltool fails if the import library doesn't exist or isn't actually an import library π see also--identify-strict--identify-strictβ modifies the behavior of the--identifyoption so that an error is reported if filename is associated with more than one DLL π-i,--interworkβ specifies that dlltool should mark the objects in the library file and exports file it produces as supporting interworking between ARM and Thumb code πΈ-n,--nodeleteβ makes dlltool preserve the temporary assembler files it used to create the exports file. If this option is repeated, dlltool will also preserve the temporary object files it uses to create the library file π«Ά-tprefix,--temp-prefixprefix β makes dlltool use prefix when constructing the names of temporary assembler and object files. By default, the temp file prefix is generated from the pid β¨-v,--verboseβ make dlltool describe what it's doing π-h,--helpβ displays a list of command line options and then exits-V,--versionβ displays dlltool's version number and then exits@file β read command-line options from file. The options read are inserted in place of the original@file option. If file doesn't exist, or can't be read, then the option is treated literally, and not removed π Options in file are separated by whitespace. A whitespace character may be included in an option by surrounding the entire option in either single or double quotes. Any character (including a backslash) may be included by prefixing the character to be included with a backslash π the file may itself contain additional@file options β any such options will be processed recursively. It's giving inception, fr fr.
π SEE ALSO π
The Info pages for binutils. that's the whole vibe check, bestie π
π COPYRIGHT π
Copyright (c) 1991-2018 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License" π
okay that's the whole page, you ate that π
this was binutils-2.30, dated 2018-01-27 β iconic behavior from DLLTOOL(1), periodt π
π¦ where this page comes from
- nixpkgs unstable: djgpp 12.2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms