From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by sourceware.org (Postfix) with ESMTPS id CEDC33858C2C for ; Tue, 4 Jan 2022 20:21:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CEDC33858C2C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=martin.st Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=martin.st Received: by mail-lj1-x231.google.com with SMTP id p7so61667328ljj.1 for ; Tue, 04 Jan 2022 12:21:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iVkcsNcUKwfXh+5nbwLEe/C+4ljz7ppZulLfi74eJD0=; b=CeftrZqeOveNUof6tntcsiLxJARwKFy6HgjJnOBwSrHLeJEncA4gPKr1NVHMURzkTS 1/+BYjB0Rc9jHSColL5P9nMvLGBeUHYKMQyN++wZyDPjujHw4ZMl9ze71OA4ybRe05KK rArq7m9DAg3Ff1oe+pehr0i9j4Rgr8HSCXzHLEjRfFf7irV/ABqbTSu5zOGuVJ//XGdV U+2iGmKH7nJrKQqF9eo/qEPKItETQanWwFe/Lgho8MEAF/HNzG8o4zzDwNLhqYXe5Ez0 5pStLk4LR/UP2ERxPz17y+2hld4Xdeu7QImnoMvpbQLUL0vZbthvfof/vqCm3IlqU6nE azrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iVkcsNcUKwfXh+5nbwLEe/C+4ljz7ppZulLfi74eJD0=; b=0hdSejnzBOvQxVkATMfFoz5ee9jBdOo8KVFC8M++H04W60pgHiVTWz+FBx+UeNtRCj t+uLZ0E1S+mzJpGGB/Iz9BuuYBZF8Rn4iVR1BNwZZ+CePtzGdOfPQCFGjJ5FvOSYpEP3 UUftOm8ndw37In72LP9pzzZN2i88IHd6yKvHmGcpr8UjTJlXq/AiKv1lPWFupR7qCZ8y zF2RA8KkbQtNxDSL79C1clHh+xlysswU/vEfHYEInOBRys5427OWncRNEfFNkiiZzU0S iFIM63U2Z/LzEDhdx9yjSHXKPMDRaH/+KdF+Q6zJACIrk9+WmRukmHvQKZlc3YU0LYaF Hr7w== X-Gm-Message-State: AOAM531QNuOdvh50aRDEjJ6I0qOZxGqYMHvHUvsylobMgr1zdeZApHLU 9JoaXbAEcNbuJAYubiBWNxuDI1b9+6zl08FG X-Google-Smtp-Source: ABdhPJzVFVfELwI9ARaeTK7swMJ9k0yHSPmLBGV25SUbDRjDZ5AuGwgXf0SNfSa7AAo7za/BDhxtkg== X-Received: by 2002:a2e:b8cd:: with SMTP id s13mr31984909ljp.136.1641327713698; Tue, 04 Jan 2022 12:21:53 -0800 (PST) Received: from localhost.localdomain (dsl-tkubng21-58c01c-243.dhcp.inet.fi. [88.192.28.243]) by smtp.gmail.com with ESMTPSA id s29sm4005088lfc.227.2022.01.04.12.21.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jan 2022 12:21:53 -0800 (PST) From: =?UTF-8?q?Martin=20Storsj=C3=B6?= To: binutils@sourceware.org Subject: [PATCH] dlltool: Use the dll name as unique object file prefix instead of getpid() Date: Tue, 4 Jan 2022 22:21:53 +0200 Message-Id: <20220104202153.1007004-1-martin@martin.st> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jan 2022 20:21:56 -0000 This makes the output deterministic without requiring the caller to pass --temp-prefix. This also avoids potential prefix clashes, if building multiple import libraries that later are merged into one single import library (which is done for a number of umbrella libraries in mingw-w64-crt). Signed-off-by: Martin Storsjö --- binutils/dlltool.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/binutils/dlltool.c b/binutils/dlltool.c index 8c1ddd61f63..83f30676f77 100644 --- a/binutils/dlltool.c +++ b/binutils/dlltool.c @@ -3930,9 +3930,6 @@ main (int ac, char **av) } } - if (!tmp_prefix) - tmp_prefix = prefix_encode ("d", getpid ()); - for (i = 0; mtable[i].type; i++) if (strcmp (mtable[i].type, mname) == 0) break; @@ -3992,6 +3989,22 @@ main (int ac, char **av) optind++; } + if (!tmp_prefix) + { + if (dll_name) + { + tmp_prefix = xmalloc (strlen (dll_name) + 2); + sprintf (tmp_prefix, "%s_", dll_name); + for (i = 0; tmp_prefix[i]; i++) + if (!ISALNUM (tmp_prefix[i])) + tmp_prefix[i] = '_'; + } + else + { + tmp_prefix = prefix_encode ("d", getpid ()); + } + } + mangle_defs (); if (exp_name) -- 2.25.1