From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id CDD843858D37; Thu, 3 Feb 2022 15:31:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CDD843858D37 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: dllfixdbg: don't overwrite input DLL X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: 96646006a7d9a4376255a25a2cbaad8502751c2a X-Git-Newrev: 7ae91f3b560a365193142191627214b3a734b0f5 Message-Id: <20220203153118.CDD843858D37@sourceware.org> Date: Thu, 3 Feb 2022 15:31:18 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Feb 2022 15:31:18 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D7ae91f3b560= a365193142191627214b3a734b0f5 commit 7ae91f3b560a365193142191627214b3a734b0f5 Author: Corinna Vinschen Date: Thu Feb 3 16:19:54 2022 +0100 Cygwin: dllfixdbg: don't overwrite input DLL =20 Change dllfixdbg to keep the input DLL intact and just generate a new DLL matching the debug file. Fix Makefile rule accordingly. The result is, cygwin0.dll is the original DLL created with full debug sections and stays that way throughout the build process. Only new-cygwin1.dll will become the stripped DLL matching with the file containing the debug sections cygwin1.dbg. This is ok, because commit ba02fef995ac ("Cygwin: Makefile.am: fix DLL build rule") made new-cygwin1.dll the DLL to be installed. =20 Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/Makefile.am | 7 ++----- winsup/cygwin/dllfixdbg | 14 ++++++++------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/winsup/cygwin/Makefile.am b/winsup/cygwin/Makefile.am index 28c143434..265b6bf69 100644 --- a/winsup/cygwin/Makefile.am +++ b/winsup/cygwin/Makefile.am @@ -639,11 +639,8 @@ $(PRE_DLL_NAME): $(LDSCRIPT) dllfixdbg libdll.a $(VERS= ION_OFILES) $(LIBSERVER)\ $(newlib_build)/libc/libc.a \ -lgcc -lkernel32 -lntdll -Wl,-Map,cygwin.map =20 -$(DBG_DLL_NAME): $(PRE_DLL_NAME) - $(AM_V_GEN)$(srcdir)/dllfixdbg $(OBJDUMP) $(OBJCOPY) $(PRE_DLL_NAME) $(DB= G_DLL_NAME) - -$(NEW_DLL_NAME): $(PRE_DLL_NAME) $(DBG_DLL_NAME) - $(AM_V_GEN)ln -f $(PRE_DLL_NAME) $@ +$(DBG_DLL_NAME) $(NEW_DLL_NAME): $(PRE_DLL_NAME) + $(AM_V_GEN)$(srcdir)/dllfixdbg $(OBJDUMP) $(OBJCOPY) $(PRE_DLL_NAME) $(DB= G_DLL_NAME) $(NEW_DLL_NAME) =20 # cygwin import library toolopts=3D--cpu=3D@target_cpu@ --ar=3D@AR@ --as=3D@AS@ --nm=3D@NM@ --objc= opy=3D@OBJCOPY@ diff --git a/winsup/cygwin/dllfixdbg b/winsup/cygwin/dllfixdbg index 1ae64a1ef..e9e35aed1 100755 --- a/winsup/cygwin/dllfixdbg +++ b/winsup/cygwin/dllfixdbg @@ -13,11 +13,13 @@ my $strip =3D $ARGV[0] eq '-s'; shift if $strip; my $objdump =3D shift; my @objcopy =3D ((shift)); -my $dll =3D shift; -my $dbg =3D shift; -xit 0, @objcopy, '-R', '.gnu_debuglink_overlay', '--add-gnu-debuglink=3D/d= ev/null', '--only-keep-debug', $dll, $dbg; -xit 0, @objcopy, '-g', '--keep-section=3D.gnu_debuglink_overlay', '--add-g= nu-debuglink=3D' . $dbg, $dll; -open(OBJDUMP, '-|', "$objdump --headers $dll"); +my $pre_dll =3D shift; +my $dbg_dll =3D shift; +my $new_dll =3D shift; +my $verbose =3D shift; +xit 0, @objcopy, '-R', '.gnu_debuglink_overlay', '--add-gnu-debuglink=3D/d= ev/null', '--only-keep-debug', $pre_dll, $dbg_dll; +xit 0, @objcopy, '-g', '--keep-section=3D.gnu_debuglink_overlay', '--add-g= nu-debuglink=3D' . $dbg_dll, $pre_dll, $new_dll; +open(OBJDUMP, '-|', "$objdump --headers $new_dll"); my %section; while () { my ($idx, $name, $size, $vma, $lma, $fileoff, $algn) =3D /^\s*(\d+)\s+= (\.\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s*$/; @@ -55,7 +57,7 @@ for my $k (sort {$section{$a}{-idx} <=3D> $section{$b}{-i= dx}} keys %section) { } =20 warn "$0: ERROR final VMA (" . sprintf("0x%08x", $vma) . ") not on 64K bou= ndary\n" if $vma !=3D align($vma, 64 * 1024); -push(@objcopy, $dll, @ARGV); +push(@objcopy, $new_dll, @ARGV); xit 1, @objcopy; sub align { my $n =3D $_[0];