From patchwork Mon Mar 30 17:42:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Dasmohapatra X-Patchwork-Id: 38659 Return-Path: X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by sourceware.org (Postfix) with ESMTPS id 3A695385B836 for ; Mon, 30 Mar 2020 17:42:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3A695385B836 Received: from noise.collabora.co.uk (unknown [IPv6:2a00:5f00:102:0:c0a7:51ff:feaf:e642]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id C12B32966B8; Mon, 30 Mar 2020 18:42:15 +0100 (BST) From: =?utf-8?q?Vivek_Das=C2=A0Mohapatra?= To: vivek@etla.org, libc-alpha@sourceware.org Subject: [RFC][PATCH 1/6] Define a new DT_FLAGS_1 flag DF_1_UNIQUE for ld, readelf et al Date: Mon, 30 Mar 2020 18:42:02 +0100 Message-Id: <89aad18e25212713ce8a05848e184df9301ca238.1585587351.git.vivek@collabora.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-Spam-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Mar 2020 17:42:18 -0000 --- include/elf/common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/elf/common.h b/include/elf/common.h index 6741c34a00..afea0973b9 100644 --- a/include/elf/common.h +++ b/include/elf/common.h @@ -1095,6 +1095,7 @@ #define DF_1_KMOD 0x10000000 #define DF_1_WEAKFILTER 0x20000000 #define DF_1_NOCOMMON 0x40000000 +#define DF_1_UNIQUE 0x80000000 /* Flag values for the DT_FLAGS entry. */ #define DF_ORIGIN (1 << 0) From patchwork Mon Mar 30 17:42:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Dasmohapatra X-Patchwork-Id: 38660 Return-Path: X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by sourceware.org (Postfix) with ESMTPS id 54836385DC08 for ; Mon, 30 Mar 2020 17:42:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 54836385DC08 Received: from noise.collabora.co.uk (unknown [IPv6:2a00:5f00:102:0:c0a7:51ff:feaf:e642]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id ED601291A2E; Mon, 30 Mar 2020 18:42:15 +0100 (BST) From: =?utf-8?q?Vivek_Das=C2=A0Mohapatra?= To: vivek@etla.org, libc-alpha@sourceware.org Subject: [RFC][PATCH 2/6] Handle DF_1_UNIQUE in ld Date: Mon, 30 Mar 2020 18:42:03 +0100 Message-Id: <01252aa43e79fd6ef92fc8dafe19193b334fae8b.1585587351.git.vivek@collabora.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-Spam-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Mar 2020 17:42:18 -0000 --- ld/emultempl/elf.em | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ld/emultempl/elf.em b/ld/emultempl/elf.em index bb7e537530..3d63917313 100644 --- a/ld/emultempl/elf.em +++ b/ld/emultempl/elf.em @@ -787,6 +787,8 @@ fragment < X-Patchwork-Id: 38661 Return-Path: X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by sourceware.org (Postfix) with ESMTPS id 7AE8C385DC0D for ; Mon, 30 Mar 2020 17:42:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7AE8C385DC0D Received: from noise.collabora.co.uk (unknown [IPv6:2a00:5f00:102:0:c0a7:51ff:feaf:e642]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 24E9A2966C4; Mon, 30 Mar 2020 18:42:16 +0100 (BST) From: =?utf-8?q?Vivek_Das=C2=A0Mohapatra?= To: vivek@etla.org, libc-alpha@sourceware.org Subject: [RFC][PATCH 3/6] Document DF_1_UNIQUE in the man page and ld help output Date: Mon, 30 Mar 2020 18:42:04 +0100 Message-Id: <736af5b6e404f4b65c00a6f4914c8f2830bb81af.1585587351.git.vivek@collabora.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-Spam-Status: No, score=-33.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Mar 2020 17:42:18 -0000 --- ld/ld.texi | 7 +++++++ ld/lexsup.c | 2 ++ 2 files changed, 9 insertions(+) diff --git a/ld/ld.texi b/ld/ld.texi index 9f562935be..af7dfcbb41 100644 --- a/ld/ld.texi +++ b/ld/ld.texi @@ -1271,6 +1271,13 @@ Specify that the dynamic loader should modify its symbol search order so that symbols in this shared library interpose all other shared libraries not so marked. +@item unique +When generating a shared library or other dynamically loadable ELF object +mark it as one that should only ever be loaded once, and only in the main +namespace (when using @code{dlmopen}). This is primarily used to mark +fundamental libraries such as libc, libpthread et al which cannot function +correctly unless they are the sole instances of themselves. + @item lazy When generating an executable or shared library, mark it to tell the dynamic linker to defer function call resolution to the point when diff --git a/ld/lexsup.c b/ld/lexsup.c index 2597e2d630..3876b922f4 100644 --- a/ld/lexsup.c +++ b/ld/lexsup.c @@ -1806,6 +1806,8 @@ elf_shlib_list_options (FILE *file) fprintf (file, _("\ -z interpose Mark object to interpose all DSOs but executable\n")); fprintf (file, _("\ + -z unique Mark DSO to be loaded at most once, and only in the main namespace\n")); + fprintf (file, _("\ -z lazy Mark object lazy runtime binding (default)\n")); fprintf (file, _("\ -z loadfltr Mark object requiring immediate process\n")); From patchwork Mon Mar 30 17:42:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Dasmohapatra X-Patchwork-Id: 38663 Return-Path: X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by sourceware.org (Postfix) with ESMTPS id 8343A385DC10 for ; Mon, 30 Mar 2020 17:42:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8343A385DC10 Received: from noise.collabora.co.uk (unknown [IPv6:2a00:5f00:102:0:c0a7:51ff:feaf:e642]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 48CCE2966DD; Mon, 30 Mar 2020 18:42:16 +0100 (BST) From: =?utf-8?q?Vivek_Das=C2=A0Mohapatra?= To: vivek@etla.org, libc-alpha@sourceware.org Subject: [RFC][PATCH 4/6] Handle DF_1_UNIQUE in readelf Date: Mon, 30 Mar 2020 18:42:05 +0100 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-Spam-Status: No, score=-27.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Mar 2020 17:42:19 -0000 --- binutils/readelf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/binutils/readelf.c b/binutils/readelf.c index eb41e10dae..ed1d757623 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -10349,6 +10349,11 @@ process_dynamic_section (Filedata * filedata) printf (" NOCOMMON"); val ^= DF_1_NOCOMMON; } + if (val & DF_1_UNIQUE) + { + printf (" UNIQUE"); + val ^= DF_1_UNIQUE; + } if (val != 0) printf (" %lx", val); puts (""); From patchwork Mon Mar 30 17:42:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Dasmohapatra X-Patchwork-Id: 38664 Return-Path: X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by sourceware.org (Postfix) with ESMTPS id 1E548385BF86 for ; Mon, 30 Mar 2020 17:42:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1E548385BF86 Received: from noise.collabora.co.uk (unknown [IPv6:2a00:5f00:102:0:c0a7:51ff:feaf:e642]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 6D0CA2966DF; Mon, 30 Mar 2020 18:42:16 +0100 (BST) From: =?utf-8?q?Vivek_Das=C2=A0Mohapatra?= To: vivek@etla.org, libc-alpha@sourceware.org Subject: [RFC][PATCH 5/6] Define DT_FLAGS_1 flag DF_1_UNIQUE for gold Date: Mon, 30 Mar 2020 18:42:06 +0100 Message-Id: <45e8321e79f1adaa08cc56efdc482034877691e1.1585587351.git.vivek@collabora.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-Spam-Status: No, score=-27.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Mar 2020 17:42:20 -0000 --- elfcpp/elfcpp.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/elfcpp/elfcpp.h b/elfcpp/elfcpp.h index 339faadaf3..7740fbe202 100644 --- a/elfcpp/elfcpp.h +++ b/elfcpp/elfcpp.h @@ -897,6 +897,7 @@ enum DF }; // Flags found in the DT_FLAGS_1 dynamic element. +// See also: include/elf/common.h enum DF_1 { @@ -913,7 +914,8 @@ enum DF_1 DF_1_INTERPOSE = 0x400, DF_1_NODEFLIB = 0x800, DF_1_NODUMP = 0x1000, - DF_1_CONLFAT = 0x2000 + DF_1_CONLFAT = 0x2000, + DF_1_UNIQUE = 0x80000000 }; // Version numbers which appear in the vd_version field of a Verdef From patchwork Mon Mar 30 17:42:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Dasmohapatra X-Patchwork-Id: 38665 Return-Path: X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by sourceware.org (Postfix) with ESMTPS id 1E02A385B836 for ; Mon, 30 Mar 2020 17:42:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1E02A385B836 Received: from noise.collabora.co.uk (unknown [IPv6:2a00:5f00:102:0:c0a7:51ff:feaf:e642]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 8F6082966E1; Mon, 30 Mar 2020 18:42:16 +0100 (BST) From: =?utf-8?q?Vivek_Das=C2=A0Mohapatra?= To: vivek@etla.org, libc-alpha@sourceware.org Subject: [RFC][PATCH 6/6] Implement and document DF_1_UNIQUE handling in gold Date: Mon, 30 Mar 2020 18:42:07 +0100 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-Spam-Status: No, score=-27.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Mar 2020 17:42:20 -0000 --- gold/layout.cc | 2 ++ gold/options.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/gold/layout.cc b/gold/layout.cc index be437f3900..d97ac57afc 100644 --- a/gold/layout.cc +++ b/gold/layout.cc @@ -5351,6 +5351,8 @@ Layout::finish_dynamic_section(const Input_objects* input_objects, flags |= elfcpp::DF_1_NOW; if (parameters->options().Bgroup()) flags |= elfcpp::DF_1_GROUP; + if (parameters->options().unique()) + flags |= elfcpp::DF_1_UNIQUE; if (flags != 0) odyn->add_constant(elfcpp::DT_FLAGS_1, flags); } diff --git a/gold/options.h b/gold/options.h index b2059d984c..de151642c7 100644 --- a/gold/options.h +++ b/gold/options.h @@ -1459,6 +1459,9 @@ class General_options DEFINE_bool(interpose, options::DASH_Z, '\0', false, N_("Mark object to interpose all DSOs but executable"), NULL); + DEFINE_bool(unique, options::DASH_Z, '\0', false, + N_("Mark DSO to be loaded at most once, and only in the main namespace"), + NULL); DEFINE_bool_alias(lazy, now, options::DASH_Z, '\0', N_("Mark object for lazy runtime binding"), NULL, true);