DLLTOOL(1)
π DLLTOOL(1) π
okay bestie, pull up a chair, because we're talking about dlltool β a lil GNU Development Tools icon that creates the files you need to build and use DLLs. she's from the GNU Development Tools crew and she is, lowkey, the backbone of your whole Windows-ish linking situation. π«Ά
β¨ NAME β¨
dlltool β create files needed to build and use DLLs
π 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 πΈ
so. dlltool reads its inputs, and those inputs can come from the -d and -b options plus any object files you hand her on the command line. she takes all of that in, does her lil processing thing, and then:
- 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 the slayest part? any or all of -e, -l and -z can show up in a single invocation of dlltool. one trip, three files, no cap. π
π¦ the three files you need for a DLL π¦
when you're creating a DLL, alongside the source for the DLL itself, you need three other files. and dlltool is literally right there to help you make them.
file #1: the .def file πΈ
this one specifies which functions are exported from the DLL, which functions the DLL imports, and so on. it's a text file, so you can write it by hand if you're feeling crafty β or you can let dlltool build it for you with the -z option. in that case, dlltool scans the object files you listed on the command line, hunting for the functions that have been specially marked as being exported, and drops entries for them into the .def file she creates.
to mark a function as exported from a DLL, it needs an -export:<name_of_function> entry in the .drectve section of the object file. in C you can do that with the asm() operator, like this:
asm (".section .drectve");
asm (".ascii \"-export:my_func\"");
int my_func (void) { ... }
file #2: the exports file π
this one gets 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 make it by giving the -e option to dlltool while she's creating or reading in a .def file.
file #3: the library file π
this is the one programs will link with in order to access the functions inside the DLL β aka the import library. you get it by giving the -l option to dlltool while she's creating or reading in a .def file.
π the delay-import situation π
if you specify the -y option, dlltool generates a delay-import library. you can use it instead of the normal import library, and it lets a program 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. iykyk π§
π₯ how she actually builds stuff π₯
here's the tea: dlltool builds the library file by hand, but she builds the exports file by creating temporary files containing assembler statements and then assembling those.
- the
-Scommand-line option lets you specify the path to the assembler thatdlltoolwill use π οΈ - the
-foption lets you pass specific flags to that assembler - the
-noption stopsdlltoolfrom deleting those temporary assembler files when she's done - and if
-nis specified twice, that also stops her from deleting the temporary object files she used to build the library π
π example time π
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
β one more thing β
dlltool may also be used to query an existing import library to figure out the name of the DLL it's associated with. peep the description of the -I or --identify option for that one. π
more parts incoming, bestie β do not go anywhere π
β¨ OPTIONS β¨
okay bestie, here's the whole menu of flags. every single one. grab a snack π
-dfilename,--input-deffilename β names the.deffile that dlltool should read in and process. that's the input, the source of truth, the blueprint π-bfilename,--base-filefilename β names a base file to read in and process. whatever's inside it gets added to the relocation section in the exports file dlltool generates. lowkey important.-efilename,--output-expfilename β names the export file dlltool should create. output vibes only β¨-zfilename,--output-deffilename β names the.deffile dlltool should create. yes, it makes one too. main character energy.-lfilename,--output-libfilename β names the library file dlltool should create. the moment you've all been waiting for π-yfilename,--output-delaylibfilename β names the delay-import library file dlltool should create. fancy.--deterministic-libraries,--non-deterministic-librariesβ when dlltool is making output libraries because of either--output-libor--output-delaylib, this picks whether timestamps, user ids and group ids are all set to zero (--deterministic-libraries) or whether you get the actual real timestamps, user ids and group ids (--non-deterministic-libraries). reproducible girlies, rise π«Ά--export-all-symbolsβ treat every global and weak defined symbol found in the input object files as a symbol to export. ngl there's a small list of symbols that don't get exported by default β that's the--no-default-excludesoption's whole deal. and 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.deffile, or in.drectvesections in the input object files. this is the default behaviour, periodt. those.drectvesections get created bydllexportattributes in the source code, iykyk.--exclude-symbolslist β don't 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 is only meaningful when--export-all-symbolsis used. π--no-default-excludesβ 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. use--no-default-excludesto go ahead and export these special symbols anyway. only meaningful when--export-all-symbolsis used, bestie.-Spath,--aspath β specifies the path, including the filename, of the assembler to use to create the exports file. π§-foptions,--as-flagsoptions β any specific command-line options you want passed to the assembler when building the exports file. this works even if you didn't use the-Soption. heads up: this option only takes one argument, and if it shows up more than once on the command line, the later occurrences override the earlier ones. so if you need to pass multiple options to the assembler, wrap them in double quotes. π-Dname,--dll-namename β the name to store in the.deffile as the name of the DLL when the-eoption is used. if you don't include this option, then the filename you gave to-egets used as the DLL's name.-mmachine,-machinemachine β 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 you're creating DLLs for an ARM processor and the DLL's contents are actually encoded using Thumb instructions. π¦-a,--add-indirectβ when dlltool creates the exports file, add a section that allows the exported functions to be referenced without using the import library. "whatever the hell that means!" β direct quote, the original manpage said it, not me π-U,--add-underscoreβ when dlltool creates the exports file, prepend an underscore to the names of all exported symbols.--no-leading-underscore,--leading-underscoreβ whether a standard symbol should be forced to be prefixed, or not. that's it, that's the whole thing.--add-stdcall-underscoreβ when dlltool creates the exports file, prepend an underscore to the names of exported stdcall functions. variable names and non-stdcall function names are not modified. this one's a lifesaver when you're creating GNU-compatible import libs for third party DLLs that were built with MS-Windows tools. π-k,--kill-atβ@<number>suffixes get omitted from the names of stdcall functions that will be imported from the DLL. super useful when you're making an import library for a DLL that exports stdcall functions but without the usual@<number>symbol name suffix.
important though: this does not change the naming of symbols provided by the import library to programs linked against it β only the entries in the import table (ie the .idata section). so don't @ me.
-A,--add-stdcall-aliasβ when dlltool creates the exports file, add aliases for stdcall symbols without@ <number>, in addition to the symbols with@ <number>. both, not either. π-p,--ext-prefix-aliasprefix β makes dlltool create external aliases for all DLL imports using the specified prefix. the aliases get created for both external and import symbols with no leading underscore.-x,--no-idata4β when dlltool creates the exports and library files, omit the".idata4"section. this is for compatibility with certain operating systems. β¨--use-nul-prefixed-import-tablesβ when dlltool creates 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 creates the exports and library files, omit the".idata5"section. again, this is for compatibility with certain operating systems. π§-Ifilename,--identifyfilename β dlltool should inspect the import library indicated by filename and report, on"stdout", the name(s) of the associated DLL(s). this can happen in addition to any other operations indicated by the other options and arguments. dlltool fails if the import library does not exist or is not actually an import library. also peep--identify-strictbelow. π--identify-strictβ modifies the behavior of the--identifyoption so that an error is reported if filename is associated with more than one DLL. no polyamory for your import libs, apparently π-i,--interworkβ 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. and if you repeat this option, dlltool will also preserve the temporary object files it uses to create the library file. messy workspace rights π₯-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β makes dlltool describe what it is doing. narration, bestie ποΈ-h,--helpβ displays a list of command-line options and then exits. classic.-V,--versionβ displays dlltool's version number and then exits. β@file β read command-line options from file. the options read get inserted in place of the original@file option. if file does not exist, or cannot be read, then the option will be treated literally, and not removed.
options inside 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. and plot twist β the file may itself contain additional @file options; any such options will be processed recursively. it's giving inception π
π SEE ALSO π
the Info pages for binutils. go read 'em, they're right there.
π COPYRIGHT π
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".
and that's the whole page, bestie π«Ά this came from binutils-2.45.50, dated 2025-12-09, and it lives at DLLTOOL(1). go build something iconic with it, you've got this πβ¨
π¦ where this page comes from
- ubuntu resolute: binutils-arm-none-eabi 2.45.50.20251209-1ubuntu1+23build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms