DLLTOOL(1)
π DLLTOOL(1) π
okay bestie, welcome to the manual page for dlltool, part of the GNU Development Tools situation β¨ (the manual name is literally DLLTOOL(1), iykyk). she's a binutils girlie and she makes files. so many files. let's get into it π
β¨ NAME β¨
dlltool β Create files needed to build and use DLLs.
that's it. that's the whole vibe. she builds the scaffolding so your DLL can exist π
πΈ 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]
[--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] [-kβͺ--kill-at]
[-Aβͺ--add-stdcall-alias]
[-pβͺ--ext-prefix-alias prefix]
[-xβͺ--no-idata4] [-cβͺ--no-idata5] [-iβͺ--interwork]
[-nβͺ--nodelete] [-tβͺ--temp-prefix prefix]
[-vβͺ--verbose]
[-hβͺ--help] [-Vβͺ--version]
[object-file ...]
look at her. so many options. she's thriving π
π¦ DESCRIPTION π¦
okay so here's the tea π. dlltool reads its inputs, and those inputs can come from the -d and -b options, plus object files you just drop on the command line. then she processes all of that, 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 literally any or all of -e, -l and -z can show up in one single invocation of dlltool. she's a multitasker, no cap π
π the three files situation π
so when you're creating a DLL, along with the source for the DLL itself, you need three other files. dlltool can help with creating all of them, and honestly? she wants to π₯Ί
file one: 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 create it by hand like a brave little soldier, or dlltool can create it for you using the -z option. in that case dlltool scans the object files you specified on her command line, looking for the functions that have been specially marked as being exported, and she puts entries for them into the .def file she creates. queen behavior β¨
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. and you can do that in C by using the asm() operator, like this:
asm (".section .drectve");
asm (".ascii \"-export:my_func\"");
int my_func (void) { ... }
see? iconic. it's giving "I annotate my own object files" π
file two: the exports file π₯
this is the second file you need for DLL creation. it 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 (so, not something you hand-edit, bestie, don't even try), and you can create it by giving the -e option to dlltool when she's creating or reading in a .def file.
file three: the library file π
this is the file that programs will link with in order to access the functions in the DLL. you create it by giving the -l option to dlltool when she's creating or reading in a .def file. simple as π«Ά
π how she actually does it π
here's the fun part: dlltool builds the library file by hand, but she builds the exports file by creating temporary files containing assembler statements and then assembling those. very DIY of her π
- the
-Scommand line option specifies the path to the assembler she'll use π οΈ - the
-foption passes specific flags to that assembler π© - the
-noption stopsdlltoolfrom deleting those temporary assembler files when she's done ποΈβ - and if
-nis specified twice, that also preventsdlltoolfrom 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
chef's kiss. no notes. ate and left no crumbs ππ₯
π OPTIONS π
the command line options have the following meanings:
-d filename,--input-def filenameβ Specifies the name of a.deffile to be read in and processed. π-b filename,--base-file filenameβ Specifies the name of a base file to be read in and processed. The contents of this file will be added to the relocation section in the exports file generated bydlltool. π§©-e filename,--output-exp filenameβ Specifies the name of the export file to be created bydlltool. π€-z filename,--output-def filenameβ Specifies the name of the.deffile to be created bydlltool. π-l filename,--output-lib filenameβ Specifies the name of the library file to be created bydlltool. π--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 are not exported by default β see the--no-default-excludesoption for that. And you can add to the list of symbols to NOT export by using the--exclude-symbolsoption. π₯--no-export-all-symbolsβ Only export symbols explicitly listed in an input.deffile, or in.drectvesections in the input object files. This is the default behaviour. The.drectvesections are created bydllexportattributes in the source code. π―--exclude-symbols listβ Do not export the symbols in list. This is 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, it will by default avoid exporting certain special symbols. The current list of symbols to avoid exporting isDllMain@12,DllEntryPoint@0,impure_ptr. You may use the--no-default-excludesoption to go ahead and export these special symbols anyway. This is only meaningful when--export-all-symbolsis 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 be passed to the assembler when building the exports file. This option will work even if the-Soption is not used. It only takes one argument, and if it occurs more than once on the command line, then later occurrences will override earlier occurrences. So if you need to pass multiple options to the assembler, enclose them in double quotes, bestie π£οΈ-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. If this option is not present, then the filename given to the-eoption will be used as the name of the DLL. π·οΈ-m machine,-machine machineβ Specifies the type of machine for which the library file should be built.dlltoolhas a built in default type, depending on how she was created, but this option can override 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 whendlltoolis creating the exports file she 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 whendlltoolis creating the exports file she should prepend an underscore to the names of the exported functions. β-k,--kill-atβ Specifies that whendlltoolis creating the exports file she should not append the string@ <number>. These numbers are called ordinal numbers and they represent another way of accessing the function in a DLL, other than by name. π’-A,--add-stdcall-aliasβ Specifies that whendlltoolis creating the exports file she should add aliases for stdcall symbols without@ <number>, in addition to the symbols with@ <number>. πͺ-p,--ext-prefix-alias prefixβ Causesdlltoolto 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 whendlltoolis creating the exports and library files she should omit the".idata4"section. This is for compatibility with certain operating systems. π«-c,--no-idata5β Specifies that whendlltoolis creating the exports and library files she should omit the".idata5"section. This is for compatibility with certain operating systems. π«-i,--interworkβ Specifies thatdlltoolshould mark the objects in the library file and exports file that she produces as supporting interworking between ARM and Thumb code. π€-n,--nodeleteβ Makesdlltoolpreserve the temporary assembler files she used to create the exports file. If this option is repeated, thendlltoolwill also preserve the temporary object files she uses to create the library file. ποΈ-t prefix,--temp-prefix prefixβ Makesdlltooluse prefix when constructing the names of temporary assembler and object files. By default, the temp file prefix is generated from the pid. π€-v,--verboseβ Makedlltooldescribe what she is doing. she'll tell you everything, she's an open book π’-h,--helpβ Displays a list of command line options and then exits. π-V,--versionβ Displaysdlltool's version number and then exits. π·οΈ
π SEE ALSO π
The Info pages for binutils.
that's the whole list, bestie. go read the Info pages, they're right there πβ¨
π COPYRIGHT π
Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 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.1 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 so real talk for a sec: that license bit means you can copy, distribute and/or modify this doc under the GNU Free Documentation License, Version 1.1 or any later version from the FSF β no Invariant Sections, no Front-Cover Texts, no Back-Cover Texts. the full license copy lives in the section called ``GNU Free Documentation License''. periodt. π
and that's the whole page!! this was binutils-2.15.97, dated 2005-04-20, and it's the DLLTOOL(1) manual. ty for coming to my ted talk, go build some DLLs, mwah ππβ¨π¦
π¦ where this page comes from
- debian bookworm: binutils-h8300-hms 2.16.1-10+b2
- ubuntu jammy: binutils-h8300-hms 2.16.1-10build1
- ubuntu noble: binutils-h8300-hms 2.16.1-10build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms