DLLTOOL(1)
π DLLTOOL(1) β GNU Development Tools π
okay bestie, welcome to dlltool, straight outta the GNU Development Tools manual, section 1 β¨ this is the girlie that builds the files you need to make and use DLLs, and she is lowkey a whole infrastructure queen π
β¨ 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 ...]
like, look at her. that's a lot of options and every single one of them is iconic π
π¦ DESCRIPTION π¦
so dlltool reads its inputs, okay? those inputs can come from the -d and -b options, plus any object files you drop on the command line π then it processes all of that, and:
- if you specified
-e, it creates an exports file β¨ - if you specified
-l, it creates a library file π - if you specified
-z, it creates a def file π
and here's the slay part: any or all of the -e, -l and -z options can be present in one single invocation of dlltool. one girl, three jobs, no complaints. π
π the three files situation
when you're creating a DLL, alongside the source for the DLL itself, you need three other files. dlltool can help with the creation of these files, because she's helpful like that π«Ά
file number one 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, so you can absolutely write it by hand if that's your vibe, or you can let dlltool create it for you using the -z option. when you do that, dlltool scans the object files you listed on its command line, looking for the functions that have been specially marked as being exported, and then puts entries for them in the .def file it creates. like a little detective with a clipboard π΅οΈββοΈ
so how do you 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. and you can do that in C by using the asm() operator:
asm (".section .drectve");
asm (".ascii \"-export:my_func\"");
int my_func (void) { ... }
yes bestie, that's backslash-escaped double quotes inside the string. it's giving "and I oop" but it's correct, don't touch it π
file number two needed for DLL creation is an 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 can create it by giving the -e option to dlltool when it is creating or reading in a .def file.
file number three needed for DLL creation is the library file that programs will link with in order to access the functions in the DLL β aka the import library π. you can create this one by giving the -l option to dlltool when it is creating or reading in a .def file.
β¨ the delay-import library moment β¨
if you specify the -y option, dlltool generates a delay-import library that can be used 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 β° (fashionably late, honestly, but make it functional).
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. chain of command, no cap π«‘
π how she actually builds stuff
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:
- the
-Scommand-line option can be used to specify the path to the assembler thatdlltoolwill use π§ - the
-foption can be used to pass specific flags to that assembler π³οΈ - the
-noption can be used to stopdlltoolfrom deleting these temporary assembler files when it is done ποΈ - and if
-nis specified twice, then that will also stopdlltoolfrom deleting the temporary object files it used to build the library π (double-n= double the hoarding, respect)
π example time π
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
look at her go. four lines. a whole DLL and a whole program. ate and left no crumbs π₯
π§ one more little trick
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 for the deets β she knows things and she tells you, iykyk π
β¨ OPTIONS β¨
okay bestie, here's the whole menu of command-line flags and what they actually mean. buckle up, there's a lot of them and they're all lowkey important π
-d filename,--input-def filenameβ names the.deffile that dlltool should read in and process. feed it the def file, it does the thing π«Ά-b filename,--base-file filenameβ names a base file for dlltool to read in and process. its contents get added into the relocation section of the exports file that dlltool generates. so like, extra relocation data, slotted right in β¨-e filename,--output-exp filenameβ names the export file dlltool is gonna create for you.-z filename,--output-def filenameβ names the.deffile dlltool is gonna create.-l filename,--output-lib filenameβ names the library file dlltool is gonna create.-y filename,--output-delaylib filenameβ names the delay-import library file dlltool is gonna create. it's giving "library but fashionably late" π--deterministic-libraries,--non-deterministic-librariesβ when you're making output libraries in response to either the--output-libor--output-delayliboptions, this decides what goes in the timestamps, user ids and group ids: either all zeros (--deterministic-libraries) or the actual real timestamps, user ids and group ids (--non-deterministic-libraries). pick your fighter π--export-all-symbolsβ treat every global and weak defined symbol found in the input object files as a symbol to be exported. yes, ALL of them, main character energy π. there is a small list of symbols that are not exported by default though β peep the--no-default-excludesoption for that. and you can add 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 of the input object files. this is the default behaviour, no cap. those.drectvesections get created bydllexportattributes in the source code.--exclude-symbols listβ do NOT export the symbols in list. list is a bunch of symbol names separated by commas or colons. heads up: the symbol names should not have a leading underscore. this only does anything meaningful when--export-all-symbolsis in play.--no-default-excludesβ when--export-all-symbolsis used, by default dlltool avoids exporting certain special symbols. the current list of symbols it avoids isDllMain@12,DllEntryPoint@0,impure_ptr. use--no-default-excludesto go ahead and export those special little guys anyway. only meaningful when--export-all-symbolsis used π«Ά-S path,--as pathβ specifies the path, filename included, of the assembler used to create the exports file.-f options,--as-flags optionsβ specifies any specific command-line options to pass to the assembler while building the exports file. works even if-Sisn't used, iconic. this option 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, wrap them in double quotes. fr fr, one arg only.-D name,--dll-name nameβ specifies the name stored in the.deffile as the name of the DLL, used when the-eoption is used. if this option isn't there, then whatever filename you gave to-ebecomes the DLL's name. periodt.-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 it's only really useful when you're creating DLLs for an ARM processor, where the DLL contents are actually encoded using Thumb instructions.-a,--add-indirectβ says that when dlltool is creating the exports file, it should add a section letting the exported functions be referenced without using the import library. whatever the hell that means! π-U,--add-underscoreβ says 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β says whether a standard symbol should be forced to be prefixed, or not.--add-stdcall-underscoreβ says 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, leave them alone π. this one's useful when you're creating GNU-compatible import libs for third party DLLs that were built with MS-Windows tools.-k,--kill-atβ says that@<number>suffixes should be omitted from the names of stdcall functions that'll be imported from the DLL. useful when you're creating an import library for a DLL that exports stdcall functions but without the usual@<number>symbol name suffix. important: this does not change the naming of the symbols the import library hands to programs linked against it β only the entries in the import table (ie the.idatasection). not me stressing the difference, but like, it matters π₯-A,--add-stdcall-aliasβ says that when dlltool is creating the exports file, it should add aliases for stdcall symbols without@ <number>in addition to the symbols with@ <number>. double the symbols, double the slay π-p,--ext-prefix-alias prefixβ 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β says that when dlltool is creating the exports and library files, it should omit the.idata4section. this is for compatibility with certain operating systems π¦--use-nul-prefixed-import-tablesβ says that when dlltool is creating the exports and library files, it should prefix the.idata4and.idata5by zero an element. this emulates the old gnu import library generation ofdlltool. by default this option is turned off.-c,--no-idata5β says that when dlltool is creating the exports and library files, it should omit the.idata5section. also for compatibility with certain operating systems β-I filename,--identify filenameβ says 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 behaviour of--identify, such that an error gets reported if filename is associated with more than one DLL.-i,--interworkβ says dlltool should mark the objects in the library file and exports file that it produces as supporting interworking between ARM and Thumb code. ARM girlies, this one's for you π§-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. keep those leftovers bestie π-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β makes dlltool describe what it is doing. it's narrating its own life, respect π-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 that get read are inserted in place of the original@fileoption. if file doesn't exist, or can't be read, then the option is treated literally and is not removed. options inside file are separated by whitespace. a whitespace character can be included in an option by surrounding the entire option in either single or double quotes π. any character (including a backslash) can be included by prefixing the character you want with a backslash. and plot twist β the file can itself contain additional@fileoptions, and any of those get processed recursively. it's files all the way down π₯
πΈ SEE ALSO πΈ
- The Info pages for binutils.
π COPYRIGHT π
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".
and that's the whole page bestie!! this is from binutils-2.47, dated 2026-09-19, and it's the DLLTOOL(1) man page π«Άβ¨ go build something iconic with it, ily π
π¦ where this page comes from
- ubuntu stonking: binutils-sh-elf 2.47+3build2 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms