Subject: How to strip a gnu-win32-built dll
From: [email-masked] (Geoffrey Noer)

23 Apr 1997 01:05:29 -0700
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Content-Type: text
Original-To: [email-masked]
Original-Cc: [email-masked] (Geoffrey Noer)
X-Mailer: ELM [version 2.4 PL23]
Original-Sender: [email-masked]

Hello again,

As many of you know, stripping a dll with debugging information results in
a bad executable.  I believe this is because strip just removes the .stab
and .stabstr sections, leaving empty space that's not allowed.

Here's a workaround that will work in beta 18 (and may well work in beta 17
as well).  The process is to use objcopy to remove the debugging info and
then again to adjust the VMA of the .reloc section to where the .stab
section used to be.

Strip needs to be modified so it will adjust the VMAs for any sections
following the removed ones.  I doubt this will be done in time for beta 18.

bash% objdump --headers cygwin.dll
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00042c00  10001000  00042b64  00000400  2**2
                  CONTENTS, ALLOC, LOAD, CODE
  1 .bss          00001508  10044000  00000000  00000000  2**2
                  ALLOC
  2 .data         00001000  10046000  00000f64  00043000  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  3 .edata        00004a00  10047000  00004850  00044000  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  4 .idata        00001600  1004c000  00001560  00048a00  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  5 .stab         00006a00  1004e000  000068e8  0004a000  2**2
                  CONTENTS, DEBUGGING, NEVER_LOAD
  6 .stabstr      00004400  10055000  0000429a  00050a00  2**0
                  CONTENTS, DEBUGGING, NEVER_LOAD
  7 .reloc        00003600  1005a000  00003558  00054e00  2**2
                  CONTENTS, ALLOC, LOAD, DATA

bash% objcopy --strip-debug cygwin.dll
bash% objdump --headers cygwin.dll
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00042c00  10001000  00042b64  00000400  2**2
                  CONTENTS, ALLOC, LOAD, CODE
  1 .bss          00001508  10044000  00000000  00000000  2**2
                  ALLOC
  2 .data         00001000  10046000  00000f64  00043000  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  3 .edata        00004a00  10047000  00004850  00044000  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  4 .idata        00001600  1004c000  00001560  00048a00  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  5 .reloc        00003600  1005a000  00003558  0004a000  2**2
                  CONTENTS, ALLOC, LOAD, DATA

(NOTE: this is an invalid image!  Now change the VMA of the .reloc
section which fixes it)

bash% objcopy --adjust-section-vma .reloc=0x1004e000 cygwin.dll
bash% objdump --headers cygwin.dll
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00042c00  10001000  00042b64  00000400  2**2
                  CONTENTS, ALLOC, LOAD, CODE
  1 .bss          00001508  10044000  00000000  00000000  2**2
                  ALLOC
  2 .data         00001000  10046000  00000f64  00043000  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  3 .edata        00004a00  10047000  00004850  00044000  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  4 .idata        00001600  1004c000  00001560  00048a00  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  5 .reloc        00003600  1004e000  00003558  0004a000  2**2
                  CONTENTS, ALLOC, LOAD, DATA

-- 
Geoffrey Noer
[email-masked]
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".