From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 41205 invoked by alias); 8 Feb 2019 11:38:08 -0000 Mailing-List: contact cygwin-cvs-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cygwin-cvs-owner@cygwin.com Received: (qmail 41131 invoked by uid 9078); 8 Feb 2019 11:38:08 -0000 Date: Fri, 08 Feb 2019 11:38:00 -0000 Message-ID: <20190208113808.41128.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] forkables: use dynloaded dll's IndexNumber as dirname X-Act-Checkin: newlib-cygwin X-Git-Author: Michael Haubenwallner X-Git-Refname: refs/heads/master X-Git-Oldrev: 6dd415caf569aa49ea11d4ab0e837aa379c130b4 X-Git-Newrev: 8bbb3d3a23e4d3ab8e707168f1c6bd7b0e19f6df X-SW-Source: 2019-q1/txt/msg00143.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=8bbb3d3a23e4d3ab8e707168f1c6bd7b0e19f6df commit 8bbb3d3a23e4d3ab8e707168f1c6bd7b0e19f6df Author: Michael Haubenwallner Date: Thu Jan 12 10:03:52 2017 +0100 forkables: use dynloaded dll's IndexNumber as dirname Diff: --- winsup/cygwin/forkable.cc | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/winsup/cygwin/forkable.cc b/winsup/cygwin/forkable.cc index da45643..c569b0f 100644 --- a/winsup/cygwin/forkable.cc +++ b/winsup/cygwin/forkable.cc @@ -409,34 +409,17 @@ dll::nominate_forkable (PCWCHAR dirx_name) if (!*forkable_ntname) return; /* denominate */ - if (type < DLL_LOAD) - wcpcpy (next, modname); - else + if (type == DLL_LOAD) { - /* Avoid lots of extra directories for loaded dll's: - * mangle full path into one single directory name, - * just keep original filename intact. The original - * filename is necessary to serve as linked - * dependencies of dynamically loaded dlls. */ - PWCHAR lastpathsep = wcsrchr (ntname, L'\\'); - if (!lastpathsep) - { - forkable_ntname = NULL; - return; - } - *lastpathsep = L'\0'; - HANDLE fh = dll_list::ntopenfile (ntname, NULL, FILE_DIRECTORY_FILE); - *lastpathsep = L'\\'; - - FILE_INTERNAL_INFORMATION fii = { 0 }; - if (fh != INVALID_HANDLE_VALUE) - { - dll_list::read_fii (fh, &fii); - NtClose (fh); - } + /* Multiple dynamically loaded dlls can have identical basenames + * when loaded from different directories. But still the original + * basename may serve as linked dependency for another dynamically + * loaded dll. So we have to create a separate directory for the + * dynamically loaded dll - using the dll's IndexNumber as name. */ next += format_IndexNumber (next, -1, &fii.IndexNumber); - wcpcpy (next, lastpathsep); + next = wcpcpy (next, L"\\"); } + wcpcpy (next, modname); } /* Create the nominated hardlink for one indivitual dll,