DLLTOOL(1)
π DLLTOOL(1) π
ok so bestie, welcome to dlltool β a lil GNU Development Tools girlie whose whole job is making the files you need to build and use DLLs. no cap. let's get into it β¨
πΈ 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]
[object-file ...]
β¨ DESCRIPTION β¨
ok so picture this: dlltool reads its inputs, and those inputs can come from the -d and -b options, plus any object files you drop on the command line. it then does its lil processing thing, and:
- if you passed
-e, it creates an exports file π«Ά - if you passed
-l, it creates a library file π - if you passed
-z, it creates a def file β¨
and the gag is, any or all of -e, -l and -z can show up in one single invocation of dlltool. iconique. multiple slays at once, we love to see it.
so when you're creating a DLL, alongside the source for the DLL itself, you lowkey need three other files. and bestie, dlltool is literally here to help you make them. π
the first file is a .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 β you can absolutely hand-write it, or you can let dlltool create it for you with the -z option. in that case, dlltool scans the object files you specified on its command line, looking for those functions that have been specially marked as being exported, and then it drops entries for them into the .def file it creates. π¦
ok so 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 using the asm() operator, like this:
asm (".section .drectve");
asm (".ascii \"-export:my_func\"");
int my_func (void) { ... }
the second file you need 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's creating or reading in a .def file. π
the third file you need for DLL creation is the library file that programs will link with in order to access the functions in the DLL β aka an import library. you can create this one by giving the -l option to dlltool when it's creating or reading in a .def file. β
ok now if you specify the -y option, dlltool generates a delay-import library that you can use instead of the normal import library. this 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 π
so here's the tea on how it actually builds stuff: dlltool builds the library file by hand, but it builds the exports file by creating temporary files containing assembler statements and then assembling those. and guess what, you get knobs for that:
-Son the command line lets you specify the path to the assembler thatdlltoolwill use π§-flets you pass specific flags to that assembler-ncan be used to preventdlltoolfrom deleting these temporary assembler files when it's done- and if
-nis specified twice, that will preventdlltoolfrom deleting the temporary object files it used to build the library π
ok bestie here's a whole example of creating a DLL from a source file dll.c AND 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
no notes, she ate. π₯
and one more lil 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 for that. π
heads up bestie, this is only part 1 of the page β there's more coming, don't go anywhere π
π OPTIONS π
okay bestie, here's what every single command line option actually means. no gatekeeping, no skipping, we're doing all of them π
-d filename,--input-def filenameβ names the.deffile that dlltool should read in and process. that's the input, the source of truth, the moment.-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 dlltool is gonna create. this is the output, the glow-up result β¨-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. delayed, but make it fashion π¦--export-all-symbolsβ treats every global and weak defined symbol found in the input object files as a symbol to be exported. there's a small list of symbols that are NOT exported by default β peep--no-default-excludesfor that tea. and if you wanna add more symbols to the do-not-export pile, that's what--exclude-symbolsis for.--no-export-all-symbolsβ only exports symbols that are explicitly listed in an input.deffile, or in.drectvesections in the input object files. this is the default behaviour, bestie, so if you didn't ask for anything else, this is what you're getting. and those.drectvesections? they're created bydllexportattributes in the source code. iconic.--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 does anything meaningful when--export-all-symbolsis being used, so don't come for it otherwise π--no-default-excludesβ when--export-all-symbolsis used, dlltool will by default avoid exporting certain special symbols. the current list of symbols it avoids exporting isDllMain@12,DllEntryPoint@0,impure_ptr. you can use the--no-default-excludesoption to go ahead and export these special symbols anyway. again: this is only meaningful when--export-all-symbolsis used.-S path,--as pathβ specifies the path, including the filename, of the assembler that's gonna be used to create the exports file.-f options,--as-flags optionsβ specifies any specific command line options to be passed to the assembler when building the exports file. this one works even if you didn't use the-Soption, so it's lowkey independent like that. it 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, okay? okay π«Ά-D name,--dll-name nameβ specifies the name to be stored in the.deffile as the name of the DLL when the-eoption is used. and if you don't use this option? then the filename you gave to-egets used as the name of the DLL instead. no biggie.-m machine,-machine machineβ specifies the type of machine the library file should be built for. dlltool has a built in default type that depends on how it was created, but this option overrides that. this is normally only useful when you're 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 allows the exported functions to be referenced without using the import library. whatever the hell that means! π (that's the manpage's words, not mine, I'm just the messenger)-U,--add-underscoreβ when dlltool is creating the exports file, it should prepend an underscore to the names of all exported symbols. little underscore, big difference.--no-leading-underscore,--leading-underscoreβ specifies whether a standard symbol should be forced to be prefixed, or not. pick your fighter.--add-stdcall-underscoreβ 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 one's useful when you're creating GNU-compatible import libs for third party DLLs that were built with MS-Windows tools. slay for interop π-k,--kill-atβ when dlltool is creating the exports file, it should not append the string@ <number>. those numbers are called ordinal numbers, and they represent another way of accessing the function in a DLL, other than by name. so yeah, you're killing the@.-A,--add-stdcall-aliasβ when dlltool is creating the exports file, it should add aliases for stdcall symbols without@ <number>, in addition to the symbols with@ <number>. both. and. periodt.-p,--ext-prefix-alias prefixβ makes dlltool create external aliases for all DLL imports with the specified prefix. the aliases get created for both external and import symbols with no leading underscore.-x,--no-idata4β when dlltool is creating the exports and library files, it should omit the.idata4section. this exists for compatibility with certain operating systems, so don't touch it unless you know you need it.--use-nul-prefixed-import-tablesβ 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β when dlltool is creating the exports and library files, it should omit the.idata5section. again: this is for compatibility with certain operating systems.-I filename,--identify filenameβ tells dlltool to 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, so it stacks. dlltool fails if the import library does not exist or is not actually an import library. see also--identify-strict.--identify-strictβ modifies the behaviour of the--identifyoption, such that an error is reported if filename is associated with more than one DLL. one DLL only, bestie, we're monogamous here.-i,--interworkβ tells dlltool to 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. double hoarding, double the vibes π-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 giving commentary, it's giving narrator energy π-h,--helpβ displays a list of command line options and then exits. classic.-V,--versionβ displays dlltool's version number and then exits.@fileβ reads command-line options from file. the options that get read are inserted in place of the original@fileoption. if file does not exist, or cannot 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. and the file may itself contain additional @file options β any such options will be processed recursively. it's files all the way down π
π SEE ALSO π
the Info pages for binutils. go read 'em, they're right there.
π COPYRIGHT π
Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 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 was binutils-2.21.1, dated 2011-06-27, and it's DLLTOOL(1) β you read the entire thing, no skimming, I'm so proud of you. go forth and build your DLLs, main character π¦β¨
π¦ where this page comes from
- ubuntu jammy: binutils-msp430 2.22~msp20120406-5.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms