DLLTOOL(1)

πŸ“¦
version 2.44 Β· 3 versions
, in debian trixie

πŸ’– DLLTOOL πŸ’–

dlltool β€” GNU Development Tools β€” the girl who makes the files you need to build and use DLLs πŸ¦‹


✨ NAME ✨

dlltool β€” create files needed to build and use DLLs

okay so literally the whole point: it makes the files. the files you need. to build DLLs. and to use them. that's her. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

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]
        [--deterministic-libraries] [--non-deterministic-libraries]
        [object-file ...]

look at her. look at all those flags. main character energy fr fr πŸ‘‘


🌸 DESCRIPTION 🌸

okay so bestie, here's the tea. dlltool reads its inputs β€” and those inputs can come from the -d and -b options, and from object files you just drop right there on the command line. iconic behavior. then she processes all of it, and:

  • if you gave her -e, she creates an exports file πŸ’–
  • if you gave her -l, she creates a library file πŸŽ€
  • if you gave her -z, she creates a def file ✨

and listen β€” any or all of -e, -l and -z can be present in one single invocation of dlltool. she can multitask. she contains multitudes. πŸ’…


so when you're creating a DLL, along with the source for the DLL itself, you need three other files. and dlltool is here to help with the creation of those files. let's go through them one by one, no skips, because the way that all three of these matter is real.

1. the .def file πŸ“

the first file is a .def file. it specifies which functions are exported from the DLL, which functions the DLL imports, and so on. it's a text file β€” you can absolutely just write it by hand, or you can let dlltool create it for you using the -z option. in that case, dlltool will scan the object files specified on its command line, looking for those functions that have been specially marked as being exported, and she'll put entries for them in the .def file she creates. πŸ¦‹

2. how to mark a function as exported ✨

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. you can do this in C by using the asm() operator:

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

int my_func (void) { ... }

there she is. chef's kiss. 😭

3. the exports file πŸŽ€

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. it's a binary file, and you can create it by giving the -e option to dlltool when she's creating or reading in a .def file. πŸ’–

4. the library 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 (an import library). you create this one by giving the -l option to dlltool when she's creating or reading in a .def file. πŸ‘‘

5. delay-import libraries, the plot twist 🌈

if you specify the -y option, 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. and here's the important bit: 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. don't forget that part, she will not work otherwise bestie πŸ’€


now, the mechanics. how does she actually do it. 🧚

dlltool builds the library file by hand β€” but she builds the exports file by creating temporary files containing assembler statements and then assembling those. so:

  • -S lets you specify the path to the assembler that dlltool will use
  • -f lets you pass specific flags to that assembler
  • -n can be used to prevent dlltool from deleting those temporary assembler files when she's done
  • and if -n is specified twice, that will prevent dlltool from deleting the temporary object files she used to build the library

two -ns. double the no-delete. iykyk. πŸ™ˆ


⭐ EXAMPLE ⭐

here's 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

copy it. run it. slay. 🫢


πŸ” ONE MORE THING πŸ”

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. πŸ’œ

not me leaving you on a cliffhanger about --identify β€” the options are coming up next, bestie, stay with me πŸ’–

✨ OPTIONS ✨

okay bestie, here's the whole menu of flags πŸ’… every single one, no skips, let's gooo

The command-line options have the following meanings:

  • -d filename, --input-def filename β€” tells dlltool which .def file to read in and process πŸ“–
  • -b filename, --base-file filename β€” names a base file to read in and process. The contents of this file get added to the relocation section in the exports file that dlltool generates. lowkey crucial 🫢
  • -e filename, --output-exp filename β€” names the export file that dlltool should create.
  • -z filename, --output-def filename β€” names the .def file that dlltool should create.
  • -l filename, --output-lib filename β€” names the library file that dlltool should create. ✨
  • -y filename, --output-delaylib filename β€” names the delay-import library file that dlltool should create.
  • --deterministic-libraries, --non-deterministic-libraries β€” when you're making output libraries in response to either the --output-lib or --output-delaylib options, this decides whether any timestamps, user ids and group ids created get the value of zero (--deterministic-libraries) or the actual timestamps, user ids and group ids (--non-deterministic-libraries). reproucible-builds girlies, this one's for you πŸ’–
  • --export-all-symbols β€” treat all global and weak defined symbols found in the input object files as symbols to be exported. There's a small list of symbols that don't get exported by default; peep the --no-default-excludes option for that. And you can add to the list of symbols to not export by using the --exclude-symbols option.
  • --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, no cap. The .drectve sections are created by dllexport attributes in the source code.
  • --exclude-symbols list β€” 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. This only means anything when --export-all-symbols is used.
  • --no-default-excludes β€” when --export-all-symbols is used, it'll by default avoid exporting certain special symbols. The current list of symbols to avoid exporting is DllMain@12, DllEntryPoint@0, impure_ptr. You can use the --no-default-excludes option to go ahead and export these special symbols anyway. This is only meaningful when --export-all-symbols is used. πŸ™ˆ
  • -S path, --as path β€” specifies the path, including the filename, of the assembler to be used to create the exports file.
  • -f options, --as-flags options β€” specifies any specific command-line options to pass to the assembler when building the exports file. This option works even if the -S option isn't used. It only takes one argument, and if it shows up more than once on the command line, then later occurrences override earlier ones. So if you need to pass multiple options to the assembler, wrap them in double quotes. fr fr, remember the quotes πŸŽ€
  • -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 isn't present, then the filename you gave to the -e option gets used as the name of the DLL.
  • -m machine, -machine machine β€” 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. This is 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 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 all exported symbols.
  • --no-leading-underscore, --leading-underscore β€” specifies whether standard symbol should be forced to be prefixed, or not.
  • --add-stdcall-underscore β€” specifies that when dlltool is creating 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 option is useful when creating GNU-compatible import libs for third party DLLs that were 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. This is useful when creating an import library for a DLL which exports stdcall functions but without the usual @<number> symbol name suffix.
heads up bestie: this does not change the naming of symbols provided by the import library to programs linked against it, but only the entries in the import table (ie the .idata section).
  • -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>.
  • -p, --ext-prefix-alias prefix β€” 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 is creating the exports and library files it should omit the .idata4 section. This is for compatibility with certain operating systems.
  • --use-nul-prefixed-import-tables β€” specifies that when dlltool is creating the exports and library files it should prefix the .idata4 and .idata5 by zero an element. This emulates old gnu import library generation of dlltool. By default this option is turned off.
  • -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.
  • -I filename, --identify filename β€” specifies that dlltool should inspect the import library indicated by filename and report, on stdout, the name(s) of the associated DLL(s). This can be performed 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 --identify option, such 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 that 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 then dlltool will also preserve the temporary object files it uses to create the library file. πŸ—‚οΈ
  • -t prefix, --temp-prefix prefix β€” 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 is doing. main character energy, narrating its own life 🎬
  • -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 will be 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. πŸŒ€


🌈 SEE ALSO 🌈

The Info pages for binutils.


Copyright (c) 1991-2025 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 thing bestie, you ate that πŸ’…βœ¨ this was binutils-2.44, dated 2025-03-28, and yeah it's page DLLTOOL(1) β€” go build something iconic πŸ¦‹πŸ’–

πŸ“¦ where this page comes from