aboutsummaryrefslogtreecommitdiff
path: root/ld/ld.texi
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2023-05-16 16:04:58 +0100
committerNick Clifton <nickc@redhat.com>2023-05-16 16:04:58 +0100
commitd1792f72bf92ac06be7a4785567e2c7bf78c0496 (patch)
treef403f96a40e2ab64a16c2406321faa9bb0a686cb /ld/ld.texi
parent0e759f232b6def277d4ae3f2d8bccfe6e34d6034 (diff)
downloadgdb-d1792f72bf92ac06be7a4785567e2c7bf78c0496.zip
gdb-d1792f72bf92ac06be7a4785567e2c7bf78c0496.tar.gz
gdb-d1792f72bf92ac06be7a4785567e2c7bf78c0496.tar.bz2
Document how to use the linker to create a resource only DLL.
PR 30359 * ld.texi (WIN32): Document how to create a resource only DLL.
Diffstat (limited to 'ld/ld.texi')
-rw-r--r--ld/ld.texi33
1 files changed, 33 insertions, 0 deletions
diff --git a/ld/ld.texi b/ld/ld.texi
index fdcc8c5..252a0ac 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -8556,6 +8556,39 @@ archive. The cygwin and mingw ports of @command{ld} have specific
support for creating such libraries provided with the
@samp{--out-implib} command-line option.
+@item Resource only DLLs
+It is possible to create a DLL that only contains resources, ie just a
+@samp{.rsrc} section, but in order to do so a custom linker script
+must be used. This is because the built-in default linker scripts
+will always create @samp{.text} amd @samp {.idata} sections, even if
+there is no input to go into them.
+
+The script should look like this, although the @code{OUTPUT_FORMAT}
+should be changed to match the desired format.
+
+@example
+OUTPUT_FORMAT(pei-i386)
+SECTIONS
+@{
+ . = SIZEOF_HEADERS;
+ . = ALIGN(__section_alignment__);
+ .rsrc __image_base__ + __section_alignment__ : ALIGN(4)
+ @{
+ KEEP (*(.rsrc))
+ KEEP (*(.rsrc$*))
+ @}
+ /DISCARD/ : @{ *(*) @}
+@}
+@end example
+
+With this script saved to a file called, eg @file{rsrc.ld}, a command
+line like this can be used to create the resource only DLL
+@file{rsrc.dll} from an input file called @file{rsrc.o}:
+
+@smallexample
+ld -dll --subsystem windows -e 0 -s rsrc.o -o rsrc.dll -T rsrc.ld
+@end smallexample
+
@item exporting DLL symbols
@cindex exporting DLL symbols
The cygwin/mingw @command{ld} has several ways to export symbols for dll's.