DLLTOOL(1)

πŸ“¦ version 2.47, in arch rolling

πŸ’– NAME πŸ’–

okay so bestie, this is dlltool, straight out of the GNU Development Tools universe β€” manual page DLLTOOL(1), if you're keeping track πŸ’… β€” and its whole thing is: create files needed to build and use DLLs. periodt. ✨

🌸 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 ...]

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so 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, and:

  • 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

Any or all of the -e, -l and -z options can be present in one invocation of dlltool. multitasking icon behavior, honestly πŸ‘‘

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. 🫢

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:

          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 (an import library). This file can be created by giving the -l option to dlltool when it is creating or reading in a .def file.

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. 😭 this is a whole chain, but it's fine, we love a linked list of dependencies

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. keeping the temp files like souvenirs πŸŽ€

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, this is the main character section β€” every single flag, no skipping, fr fr. Here's what they all mean:

  • -d filename, --input-def filename β€” names the .def file that gets read in and processed. That's the input, the raw material, the starting point πŸ’…
  • -b filename, --base-file filename β€” names a base file to read in and process. Whatever's inside it gets added to the relocation section in the exports file that dlltool generates.
  • -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. Delayed slay ✨
  • --deterministic-libraries, --non-deterministic-libraries β€” when you're making output libraries in response to either --output-lib or --output-delaylib, you pick one: use the value of zero for any timestamps, user ids and group ids created (--deterministic-libraries), or use the actual timestamps, user ids and group ids (--non-deterministic-libraries). Reproducible build besties stay winning πŸŽ€
  • --export-all-symbols β€” treat every global and weak defined symbol in the input object files as a symbol to export. There's a tiny list of symbols that don't get exported by default β€” peep --no-default-excludes for that. You can add more symbols to the do-not-export list with --exclude-symbols.
  • --no-export-all-symbols β€” only export symbols that are explicitly listed in an input .def file or in .drectve sections in the input object files. This is the default behaviour, jsyk. Those .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. Only meaningful 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 --no-default-excludes to go ahead and export these special symbols anyway. Only meaningful when --export-all-symbols is used.
  • -S path, --as path β€” specifies the path, including the filename, of the assembler to use when creating the exports file.
  • -f options, --as-flags options β€” any specific command-line options to pass to the assembler when building the exports file. This works even if -S isn't used. It only takes one argument, and 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, wrap them in double quotes, okay? πŸ’–
  • -D name, --dll-name name β€” specifies the name stored in the .def file as the name of the DLL when the -e option is used. If this option isn't there, then the filename given to -e gets used as the DLL's name.
  • -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. 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 β€” when dlltool is creating the exports file, it should add a section that lets the exported functions be referenced without using the import library. Whatever the hell that means! 😭
  • -U, --add-underscore β€” when dlltool is creating the exports file, 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 β€” when dlltool is creating the exports file, prepend an underscore to the names of exported stdcall functions. Variable names and non-stdcall function names are not modified. Super 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 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.
Heads up bestie: 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 .idata section). Don't get it twisted πŸ’€
  • -A, --add-stdcall-alias β€” when dlltool is creating the exports file, 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 β€” when dlltool is creating the exports and library files, omit the .idata4 section. This is for compatibility with certain operating systems.
  • --use-nul-prefixed-import-tables β€” when dlltool is creating the exports and library files, 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 β€” when dlltool is creating the exports and library files, omit the .idata5 section. Again, for compatibility with certain operating systems.
  • -I filename, --identify filename β€” tells dlltool to inspect the import library indicated by filename and report, on stdout, 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 --identify, so that an error is reported if filename is associated with more than one DLL. Strict queen behaviour ✨
  • -i, --interwork β€” 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 you repeat this option, dlltool will also preserve the temporary object files it uses to create the library file. Nothing gets deleted, we hoard πŸŽ€
  • -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's doing. Narrator mode πŸ—£οΈ
  • -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 β€” and any such options get processed recursively. It's giving inception, fr fr 🌸


🌈 SEE ALSO 🌈

The Info pages for binutils. That's the plug, go read them πŸ’œ


Copyright (c) 1991-2026 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".


That's the whole page bestie, you ate it 🫢 This gorgeous lil doc is from binutils-2.47, dated 2026-08-31 β€” iconic, no cap πŸ’…βœ¨

πŸ“¦ where this page comes from