bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/30359] Create Resource-Only DLL


From: nickc at redhat dot com
Subject: [Bug ld/30359] Create Resource-Only DLL
Date: Wed, 19 Apr 2023 10:44:00 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=30359

--- Comment #3 from Nick Clifton <nickc at redhat dot com> ---
(In reply to Pali Rohár from comment #2)
> If adding empty import table and something in code .text sections is feature
> of the linker, it is somewhere documented?

No. :-(

> What it is doing and what is
> putting there (as those sections are not in any user supplied input file)?

The (builtin, default) linker script is the cause.

> And I'm interesting why it is doing, it is some requirement for some SW?
> Just I'm currious here.

The PE linker script automatically puts some constant values into the .text
section as markers between the normal code and the constructors and
destructors.  If you run "ld --verbose" you will see this in the details for
the .text section:

    ...
       LONG (-1); LONG (-1);
       KEEP (*(.ctors));
       KEEP (*(.ctor));
       KEEP (*(SORT_BY_NAME(.ctors.*)));
       LONG (0); LONG (0);
       /* See comment about __CTOR_LIST__ above.  The same reasoning
          applies here too.  */
       ___DTOR_LIST__ = .;
       __DTOR_LIST__ = .;
       LONG (-1); LONG (-1);
       KEEP (*(.dtors));
       KEEP (*(.dtor));
       KEEP (*(SORT_BY_NAME(.dtors.*)));
       LONG (0); LONG (0);
    ...

These markers are used by the execution startup code to help find the two
tables.


> And about objcopy --remove-section workaround, this is problematic because
> for automatization, it is needed to know what sections has to be removed -
> meaning ability to ask LD what additional section it added there.

  In which case, just use --only-section instead.  ie:

  $ objcopy --only-section=.rsrc test-rsrc.dll test-rsrc.3.dll
  $ objdump -h test-rsrc.3.dll
  test-rsrc.3.dll:     file format pei-i386

  Sections:
  Idx Name          Size      VMA       LMA       File off  Algn
    0 .rsrc         000000b8  10003000  10003000  00000200  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]