public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] Document how to use the linker to create a resource only DLL.
@ 2023-05-16 15:05 Nick Clifton
  0 siblings, 0 replies; only message in thread
From: Nick Clifton @ 2023-05-16 15:05 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d1792f72bf92ac06be7a4785567e2c7bf78c0496

commit d1792f72bf92ac06be7a4785567e2c7bf78c0496
Author: Nick Clifton <nickc@redhat.com>
Date:   Tue May 16 16:04:58 2023 +0100

    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.

Diff:
---
 ld/ChangeLog |  5 +++++
 ld/ld.texi   | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/ld/ChangeLog b/ld/ChangeLog
index 788410a026a..ae1b34af0c0 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,8 @@
+2023-05-16  Nick Clifton  <nickc@redhat.com>
+
+	PR 30359
+	* ld.texi (WIN32): Document how to create a resource only DLL.
+
 2023-05-16  Nick Clifton  <nickc@redhat.com>
 
 	* ld.texi (-Ur): Clarify the actions of this option.
diff --git a/ld/ld.texi b/ld/ld.texi
index fdcc8c50e4d..252a0ac9c3f 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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-16 15:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-16 15:05 [binutils-gdb] Document how to use the linker to create a resource only DLL Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).