From: noer AT cygnus DOT com (Geoffrey Noer) Subject: How to strip a gnu-win32-built dll 23 Apr 1997 01:05:29 -0700 Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <199704222059.NAA06950.cygnus.gnu-win32@cirdan.cygnus.com> Content-Type: text Original-To: gnu-win32 AT cygnus DOT com Original-Cc: noer AT cygnus DOT com (Geoffrey Noer) X-Mailer: ELM [version 2.4 PL23] Original-Sender: owner-gnu-win32 AT cygnus DOT com 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 noer AT cygnus DOT com - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".