From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 489703858D28; Sat, 5 Feb 2022 09:48:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 489703858D28 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: drop dllfixdbg script X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: 44d870417997fdd0501f6baf7fccaed00e25602f X-Git-Newrev: c3efc81658bf0423edf6f6e07824f745c08e9ec7 Message-Id: <20220205094823.489703858D28@sourceware.org> Date: Sat, 5 Feb 2022 09:48:23 +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: Sat, 05 Feb 2022 09:48:23 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Dc3efc81658b= f0423edf6f6e07824f745c08e9ec7 commit c3efc81658bf0423edf6f6e07824f745c08e9ec7 Author: Corinna Vinschen Date: Sat Feb 5 10:41:35 2022 +0100 Cygwin: drop dllfixdbg script =20 On second thought, we don't actually need this script. Express the entire action as sufficiently simple Makefile rule. =20 Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/Makefile.am | 26 +++++++++++++-- winsup/cygwin/dllfixdbg | 80 -------------------------------------------= ---- 2 files changed, 24 insertions(+), 82 deletions(-) diff --git a/winsup/cygwin/Makefile.am b/winsup/cygwin/Makefile.am index ff177454a..ad38fb220 100644 --- a/winsup/cygwin/Makefile.am +++ b/winsup/cygwin/Makefile.am @@ -639,8 +639,30 @@ $(PRE_DLL_NAME): $(LDSCRIPT) libdll.a $(VERSION_OFILES= ) $(LIBSERVER)\ $(newlib_build)/libc/libc.a \ -lgcc -lkernel32 -lntdll -Wl,-Map,cygwin.map =20 -$(DBG_DLL_NAME) $(NEW_DLL_NAME): dllfixdbg $(PRE_DLL_NAME) - $(AM_V_GEN)$(srcdir)/dllfixdbg $(OBJDUMP) $(OBJCOPY) $(PRE_DLL_NAME) $(DB= G_DLL_NAME) $(NEW_DLL_NAME) $(V) +# create cygwin1.dbg file +$(DBG_DLL_NAME): $(PRE_DLL_NAME) + $(AM_V_GEN)$(OBJCOPY) -R .gnu_debuglink_overlay \ + --add-gnu-debuglink=3D/dev/null \ + --only-keep-debug \ + $(PRE_DLL_NAME) \ + $(DBG_DLL_NAME) + +# create stripped, temporary DLL, append .gnu_debuglink section, move +# .gnu_debuglink section in place of .gnu_debuglink_overlay placeholder +# section and store result in new-cygwin1.dll +$(NEW_DLL_NAME): $(PRE_DLL_NAME) $(DBG_DLL_NAME) + $(AM_V_GEN)TMP_DLL_NAME=3D$$( mktemp --suffix=3D.dll ) && \ + $(OBJCOPY) -g \ + --keep-section=3D.gnu_debuglink_overlay \ + --add-gnu-debuglink=3D$(DBG_DLL_NAME) \ + $(PRE_DLL_NAME) $${TMP_DLL_NAME} && \ + vma=3D$$( objdump --headers $${TMP_DLL_NAME} | \ + awk '/.gnu_debuglink_overlay/{print $$4;}' ) && \ + $(OBJCOPY) -R .gnu_debuglink_overlay \ + --change-section-address .gnu_debuglink=3D0x$${vma} \ + --set-section-flag .gnu_debuglink=3Dcontents,readonly,debug,noload \ + $${TMP_DLL_NAME} $(NEW_DLL_NAME) && \ + rm $${TMP_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 deleted file mode 100755 index 669ea92dd..000000000 --- a/winsup/cygwin/dllfixdbg +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/perl -# -# This file is part of Cygwin. -# -# This software is a copyrighted work licensed under the terms of the -# Cygwin license. Please consult the file "CYGWIN_LICENSE" for -# details. -# -use integer; -use strict; - -sub xit { - my ( $execit, $cmdline, $verbose ) =3D @_; - print "+ ", join (' ', @$cmdline), "\n" if ($verbose); - if ($execit) { - exec @{$cmdline} or die "$0: couldn't exec @{$cmdline}[0] - $!\n"; - } else { - system @{$cmdline} and die "$0: couldn't exec @{$cmdline}[0] - $!\n"; - } -} - -my $objdump =3D shift; # path to objdump -my $objcopy =3D shift; # path to objcopy -my $pre_dll =3D shift; # name of input DLL, usually cygwin0.dll -my $dbg_dll =3D shift; # name of debug section file, usually cygwin1.dbg -my $new_dll =3D shift; # name of stripped DLL, usually new-cygwin1.dll -my $verbose =3D shift; # verbose flag, taken from Makefile's $(V) - -# Create cygwin1.dbg file -my @create_dbgfile =3D ( $objcopy, - '-R', - '.gnu_debuglink_overlay', - '--add-gnu-debuglink=3D/dev/null', - '--only-keep-debug', - $pre_dll, - $dbg_dll ); -&xit (0, \@create_dbgfile, $verbose); -# Create stripped new-cygwin1.dll -# The .gnu_debuglink section gets appended -my @create_stripped_dll =3D ( $objcopy, - '-g', - '--keep-section=3D.gnu_debuglink_overlay', - '--add-gnu-debuglink=3D' . $dbg_dll, - $pre_dll, - $new_dll ); -&xit (0, \@create_stripped_dll, $verbose); -# Fixup .gnu_debuglink section -my @fixup_debuglink =3D ( $objcopy ); -open (OBJDUMP, '-|', "$objdump --headers $new_dll"); -my $overlay_vma; -while () { - # Fetch line and split - my ($idx, $name, $size, $vma, $lma, $fileoff, $algn) - =3D /^\s*(\d+)\s+(\.\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s*$= /; - # skip section flag lines - next if !defined ($idx); - # If we see a .gnu_debuglink_overlay section, use its section vma - # as vma of the .gnu_debuglink section. - if ($name eq '.gnu_debuglink_overlay') { - $overlay_vma =3D $vma; - # remove .gnu_debuglink_overlay section - push (@fixup_debuglink, - '-R', - '.gnu_debuglink_overlay'); - # move .gnu_debuglink to .gnu_debuglink_overlay section slot - push (@fixup_debuglink, - '--change-section-address', - '.gnu_debuglink=3D0x' . $overlay_vma); - # fix up section flags - push (@fixup_debuglink, - '--set-section-flag', - '.gnu_debuglink=3Dcontents,readonly,debug,noload'); - } -} -close OBJDUMP; -# If we didn't find a .gnu_debuglink_overlay section, bail out -defined ($overlay_vma) or die "$0: no .gnu_debuglink_overlay section!\n"; - -push (@fixup_debuglink, $new_dll); -&xit (1, \@fixup_debuglink, $verbose);