From patchwork Tue Dec 3 17:30:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Kilroy X-Patchwork-Id: 1203813 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107668-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="O0rgQg/J"; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="9TVgqmH5"; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="9TVgqmH5"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47S8Dd66Pgz9sP6 for ; Wed, 4 Dec 2019 04:32:01 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:references :in-reply-to:content-type:content-transfer-encoding :mime-version; q=dns; s=default; b=avcz+Y5K9U/FtalsQc+6avhAMmLoK gbMt6XDn6b4vdKwKQBY6btWh+yui+FBLYxe97fuYpf4kVuz3DA7YSGLyP5grKv9g jHNrrMMpolSDjYM04LnzIjOh0s2u/9/4GPbC+B7kDJnKFGa7hoyvSuuTcKuQyXJr p0isTuKq4uv9ho= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:references :in-reply-to:content-type:content-transfer-encoding :mime-version; s=default; bh=Zo6fqltnmZNeGeJILSZS7aDzb4k=; b=O0r gQg/JAGJ6PWcFnd56joF+qkUGwitQJY18LByJ+NDQ/zFsg3xdpJbTXQB1/iFacvc J1q1XZKb6V3TkMlkus8Ne7ySd6YBd1aXaTAYe8ZAqyg0jHzOauiEA6SWvPupT3pg aWLt6X4WtEtaHgZTLorS7iPagpCSll1C5qVRjV+8= Received: (qmail 16049 invoked by alias); 3 Dec 2019 17:30:49 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 15694 invoked by uid 89); 3 Dec 2019 17:30:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 spammy= X-HELO: EUR01-HE1-obe.outbound.protection.outlook.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OmpwN3zSYal3LWZWIw/KibZtwMicUmVROZNv+tR1HEM=; b=9TVgqmH5m69rpi++HfhFEUwhPmTbFBVRT1pGrdskyF1dQb/GNCX2X/3l5Cn70KnDFAOMGFKX0Z+cgxWE4nuow6FABPf3IAosV0oX4zotX374KVTapcwDbxPXaXJbXogxWkNoUwQkr9gVNVeVRKuHMnJkCstCvZniD+72VREHYqE= Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-CheckRecipientChecked: true X-CR-MTA-CID: cb046d7ce3c99d81 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SdLmGRqQXn9Rg8HtlGe3OqowBk6yNL6AKg66m1+qhDhxzTHN4KCTWihs3jlA6Hislfzjl8wLTFTreVeapLUr09kRLR6movv2l7KGBZIDx4v/bEiX9i46Fvhb79ihNONITIbHbfm46eMGy4IQevsjGQcAIcGqMD2OobMTCVvc8hq4OPAHOWyR2IR3jYyQQwNsUCOwlkufcT+o0UvJ/geEAMYq9NI+udofdNPjqICWw0QaHDQ6vZ11JQQk4y/SUSdQObg/4hsKtg90LmQNCL5likCWZKhj8/IrGIF2BKVCTZGDEvLMjGwxERn1C6gWWJTzCbLn8rS51QQ2gzz5qnLDPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OmpwN3zSYal3LWZWIw/KibZtwMicUmVROZNv+tR1HEM=; b=R5ScYTMUhzV6EBmy8oaun52550jPZS4JUGEnU+enp1QXHdYx8FhSaalcjs8XEkQbzzfzjfUlDTY5vNbenlXqH4hW+zkHMzzBjUQ6bokutMZIGLZiaPuj6jsgDFPHme7o1McNEpW1Cf0wCeHBawUfWYKgSD2DIlmyVi5YR3Fn4VfZZWuGCHhsy2j/fdK4JARSjMWfjFyD2rQxefkTH8HXOofCIYmEB0/iN+FUqbYlrzEm0JvxgiTzvFtBlinibjrev8UOiqNvjuKLBa5YPkvY/atkTShkaKkKklF04vzre6rzaQUBCbocMmsboCx2Jq0tAO4U+fs05SrDjeK/lnOGBQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OmpwN3zSYal3LWZWIw/KibZtwMicUmVROZNv+tR1HEM=; b=9TVgqmH5m69rpi++HfhFEUwhPmTbFBVRT1pGrdskyF1dQb/GNCX2X/3l5Cn70KnDFAOMGFKX0Z+cgxWE4nuow6FABPf3IAosV0oX4zotX374KVTapcwDbxPXaXJbXogxWkNoUwQkr9gVNVeVRKuHMnJkCstCvZniD+72VREHYqE= From: David Kilroy To: "libc-alpha@sourceware.org" CC: nd Subject: [PATCH v3 1/3] elf: Allow dlopen of filter object to work [BZ #16272] Date: Tue, 3 Dec 2019 17:30:10 +0000 Message-ID: <1575394197-18006-2-git-send-email-david.kilroy@arm.com> References: <1575394197-18006-1-git-send-email-david.kilroy@arm.com> In-Reply-To: <1575394197-18006-1-git-send-email-david.kilroy@arm.com> Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=David.Kilroy@arm.com; x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:2657;OLM:2657; X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(136003)(39860400002)(396003)(376002)(346002)(366004)(199004)(189003)(99286004)(102836004)(6306002)(6436002)(4326008)(478600001)(14454004)(2906002)(386003)(50226002)(36756003)(186003)(6916009)(2616005)(6506007)(305945005)(76176011)(52116002)(86362001)(81156014)(25786009)(26005)(71190400001)(6486002)(71200400001)(256004)(81166006)(2501003)(14444005)(7736002)(3846002)(8676002)(8936002)(446003)(11346002)(44832011)(316002)(66476007)(6512007)(30864003)(66556008)(66446008)(64756008)(66946007)(2351001)(5660300002)(6116002)(5640700003)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB4001; H:AM0PR08MB4068.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: LMgO/mYoJBfMt2z67b3jKG54ewsP5hVNTSc3h1lze23TuBwduM90YPUEqzUBuXzN8mxeCzVGp+KjfEBg+mvLYrfwABX9g3W1nl78+yfSydJDUYFkf+nfNc5IdG6Rkk68oABDy/iOjk7uKo0BTQ1C3Hk3D5npoJY5SvIApYZiQzcaO3wnZVAQMrsQiT2AdFJPmF/JBZtR40z6mfxnaJWFxZjDIRPXrocPqmUC+YbtrY5La8Z1ppZMUMJIgWEe7rWrRS9DIfZ12eu4OfuuWlN2vmPHkgGeBo+3/8Yo+ZQA5WThgHf+F9lGD3NVueCMY3pp7HmSgvJQY4/uxknDh5ueyTN/edBn1jT99EkiNjNwq36+cqCwlwg5xV9C+K58VjZBnxz7Y9apoGd2CHhaeVhEDU35eFbCNwy8jeTNA1BvGGbNhBwm9Ctxp+RsE/9dXsy6TSZNxytDs0dlw2+ORJD2XQF1aTf+y8eg8qvz9RfokC4= x-ms-exchange-transport-forked: True MIME-Version: 1.0 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=David.Kilroy@arm.com; X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT051.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 0c2cd21b-7cc0-4d24-21eb-08d7781672dd There are two fixes that are needed to be able to dlopen filter objects. First _dl_map_object_deps cannot assume that map will be at the beginning of l_searchlist.r_list[], as filtees are inserted before map. Secondly dl_open_worker needs to ensure that filtees get relocated. In _dl_map_object_deps: * avoiding removing relocatiion dependencies of map by setting l_reserved to 0 and otherwise processing the rest of the search list. * ensure that map remains at the beginning of l_initfini - the list of things that need initialisation (and destruction). Do this by splitting the copy up. This may not be required, but matches the initialization order without dlopen. Modify dl_open_worker to relocate the objects in new->l_inifini. new->l_initfini is constructed in _dl_map_object_deps, and lists the objects that need initialization and destruction. Originally the list of objects in new->l_next are relocated. All of these objects should also be included in new->l_initfini (both lists are populated with dependencies in _dl_map_object_deps). We can't use new->l_prev to pick up filtees, as during a recursive dlopen from an interposed malloc call, l->prev can contain objects that are not ready for relocation. Add tests to verify that symbols resolve to the filtee implementation when filter objects are used, both as a normal link and when dlopen'd. Tested by running the testsuite on x86_64. --- elf/Makefile | 12 ++++++++++-- elf/dl-deps.c | 35 ++++++++++++++++++++++++++--------- elf/dl-open.c | 11 +++++++---- elf/tst-filterobj-dlopen.c | 39 +++++++++++++++++++++++++++++++++++++++ elf/tst-filterobj-flt.c | 24 ++++++++++++++++++++++++ elf/tst-filterobj-lib.c | 24 ++++++++++++++++++++++++ elf/tst-filterobj-lib.h | 18 ++++++++++++++++++ elf/tst-filterobj.c | 36 ++++++++++++++++++++++++++++++++++++ 8 files changed, 184 insertions(+), 15 deletions(-) create mode 100644 elf/tst-filterobj-dlopen.c create mode 100644 elf/tst-filterobj-flt.c create mode 100644 elf/tst-filterobj-lib.c create mode 100644 elf/tst-filterobj-lib.h create mode 100644 elf/tst-filterobj.c diff --git a/elf/Makefile b/elf/Makefile index 0debea7..69f11c7 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -199,7 +199,8 @@ tests += restest1 preloadtest loadfail multiload origtest resolvfail \ tst-debug1 tst-main1 tst-absolute-sym tst-absolute-zero tst-big-note \ tst-unwind-ctor tst-unwind-main tst-audit13 \ tst-sonamemove-link tst-sonamemove-dlopen tst-dlopen-tlsmodid \ - tst-dlopen-self tst-auditmany tst-initfinilazyfail tst-dlopenfail + tst-dlopen-self tst-auditmany tst-initfinilazyfail tst-dlopenfail \ + tst-filterobj tst-filterobj-dlopen # reldep9 tests-internal += loadtest unload unload2 circleload1 \ neededtest neededtest2 neededtest3 neededtest4 \ @@ -292,7 +293,8 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \ tst-auditmanymod4 tst-auditmanymod5 tst-auditmanymod6 \ tst-auditmanymod7 tst-auditmanymod8 tst-auditmanymod9 \ tst-initlazyfailmod tst-finilazyfailmod \ - tst-dlopenfailmod1 tst-dlopenfaillinkmod tst-dlopenfailmod2 + tst-dlopenfailmod1 tst-dlopenfaillinkmod tst-dlopenfailmod2 \ + tst-filterobj-flt tst-filterobj-lib # Most modules build with _ISOMAC defined, but those filtered out # depend on internal headers. modules-names-tests = $(filter-out ifuncmod% tst-libc_dlvsym-dso tst-tlsmod%,\ @@ -1627,3 +1629,9 @@ $(objpfx)tst-dlopenfailmod1.so: \ $(shared-thread-library) $(objpfx)tst-dlopenfaillinkmod.so LDFLAGS-tst-dlopenfaillinkmod.so = -Wl,-soname,tst-dlopenfail-missingmod.so $(objpfx)tst-dlopenfailmod2.so: $(shared-thread-library) + +LDFLAGS-tst-filterobj-flt.so = -Wl,--filter=$(objpfx)tst-filterobj-lib.so +$(objpfx)tst-filterobj: $(objpfx)tst-filterobj-flt.so | $(objpfx)tst-filterobj-lib.so +$(objpfx)tst-filterobj-dlopen: $(libdl) | $(objpfx)tst-filterobj-lib.so +$(objpfx)tst-filterobj.out: $(objpfx)tst-filterobj-lib.so +$(objpfx)tst-filterobj-dlopen.out: $(objpfx)tst-filterobj-lib.so diff --git a/elf/dl-deps.c b/elf/dl-deps.c index c29b988..bb85c83 100644 --- a/elf/dl-deps.c +++ b/elf/dl-deps.c @@ -550,13 +550,14 @@ Filters not supported with LD_TRACE_PRELINKING")); } /* Maybe we can remove some relocation dependencies now. */ - assert (map->l_searchlist.r_list[0] == map); struct link_map_reldeps *l_reldeps = NULL; if (map->l_reldeps != NULL) { - for (i = 1; i < nlist; ++i) + for (i = 0; i < nlist; ++i) map->l_searchlist.r_list[i]->l_reserved = 1; + /* Avoid removing relocation dependencies of the main binary. */ + map->l_reserved = 0; struct link_map **list = &map->l_reldeps->list[0]; for (i = 0; i < map->l_reldeps->act; ++i) if (list[i]->l_reserved) @@ -581,16 +582,32 @@ Filters not supported with LD_TRACE_PRELINKING")); } } - for (i = 1; i < nlist; ++i) + for (i = 0; i < nlist; ++i) map->l_searchlist.r_list[i]->l_reserved = 0; } - /* Sort the initializer list to take dependencies into account. The binary - itself will always be initialize last. */ - memcpy (l_initfini, map->l_searchlist.r_list, - nlist * sizeof (struct link_map *)); - /* We can skip looking for the binary itself which is at the front of - the search list. */ + /* Sort the initializer list to take dependencies into account. Always + initialize the binary itself last. First, find it in the search list. */ + for (i = 0; i < nlist; ++i) + if (map->l_searchlist.r_list[i] == map) + break; + assert (i < nlist); + if (i > 0) + { + /* Copy the binary into position 0. */ + memcpy (l_initfini, &map->l_searchlist.r_list[i], + sizeof (struct link_map *)); + /* Copy the filtees. */ + memcpy (&l_initfini[1], map->l_searchlist.r_list, + i * sizeof (struct link_map *)); + /* Copy the remainder. */ + memcpy (&l_initfini[i + 1], &map->l_searchlist.r_list[i + 1], + (nlist - i - 1) * sizeof (struct link_map *)); + } + else + memcpy (l_initfini, map->l_searchlist.r_list, + nlist * sizeof (struct link_map *)); + _dl_sort_maps (&l_initfini[1], nlist - 1, NULL, false); /* Terminate the list of dependencies. */ diff --git a/elf/dl-open.c b/elf/dl-open.c index df9f29a..9996fe9 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -637,22 +637,25 @@ dl_open_worker (void *a) allows IFUNC relocations to work and it also means copy relocation of dependencies are if necessary overwritten. */ unsigned int nmaps = 0; - struct link_map *l = new; + unsigned int j = 0; + struct link_map *l = new->l_initfini[0]; do { if (! l->l_real->l_relocated) ++nmaps; - l = l->l_next; + l = new->l_initfini[++j]; } while (l != NULL); + /* Stack allocation is limited by the number of loaded objects. */ struct link_map *maps[nmaps]; nmaps = 0; - l = new; + j = 0; + l = new->l_initfini[0]; do { if (! l->l_real->l_relocated) maps[nmaps++] = l; - l = l->l_next; + l = new->l_initfini[++j]; } while (l != NULL); _dl_sort_maps (maps, nmaps, NULL, false); diff --git a/elf/tst-filterobj-dlopen.c b/elf/tst-filterobj-dlopen.c new file mode 100644 index 0000000..81eed0f --- /dev/null +++ b/elf/tst-filterobj-dlopen.c @@ -0,0 +1,39 @@ +/* Test for BZ16272, dlopen'ing a filter object. + Ensure that symbols from the filter object resolve to the filtee. + + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include "support/check.h" +#include "support/xdlfcn.h" + +static int do_test (void) +{ + void *lib = xdlopen ("tst-filterobj-flt.so", RTLD_LAZY); + char *(*fn)(void) = xdlsym (lib, "get_text"); + const char* text = fn (); + + printf ("%s\n", text); + + /* Verify the text matches what we expect from the filtee */ + TEST_COMPARE_STRING (text, "Hello from filtee (PASS)"); + + return 0; +} + +#include "support/test-driver.c" diff --git a/elf/tst-filterobj-flt.c b/elf/tst-filterobj-flt.c new file mode 100644 index 0000000..b4e10b2 --- /dev/null +++ b/elf/tst-filterobj-flt.c @@ -0,0 +1,24 @@ +/* Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include "tst-filterobj-lib.h" + +/* We never want to see the output of the filter object */ +const char *get_text (void) +{ + return "Hello from filter object (FAIL)"; +} diff --git a/elf/tst-filterobj-lib.c b/elf/tst-filterobj-lib.c new file mode 100644 index 0000000..07e2348 --- /dev/null +++ b/elf/tst-filterobj-lib.c @@ -0,0 +1,24 @@ +/* Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include "tst-filterobj-lib.h" + +/* This is the real implementation that wants to be called */ +const char *get_text (void) +{ + return "Hello from filtee (PASS)"; +} diff --git a/elf/tst-filterobj-lib.h b/elf/tst-filterobj-lib.h new file mode 100644 index 0000000..bed9bf8 --- /dev/null +++ b/elf/tst-filterobj-lib.h @@ -0,0 +1,18 @@ +/* Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +const char *get_text (void); diff --git a/elf/tst-filterobj.c b/elf/tst-filterobj.c new file mode 100644 index 0000000..d38eb9b --- /dev/null +++ b/elf/tst-filterobj.c @@ -0,0 +1,36 @@ +/* Test that symbols from filter objects are resolved to the filtee. + + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include "support/check.h" +#include "tst-filterobj-lib.h" + +static int do_test (void) +{ + const char* text = get_text (); + + printf ("%s\n", text); + + /* Verify the text matches what we expect from the filtee */ + TEST_COMPARE_STRING (text, "Hello from filtee (PASS)"); + + return 0; +} + +#include "support/test-driver.c" From patchwork Tue Dec 3 17:30:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Kilroy X-Patchwork-Id: 1203814 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107670-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="I5MdIDFi"; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="5YDB64tW"; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="5YDB64tW"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47S8Dp0Kcxz9sPL for ; Wed, 4 Dec 2019 04:32:09 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:references :in-reply-to:content-type:content-transfer-encoding :mime-version; q=dns; s=default; b=qzZfJLPUsyO3QRNXv1+wijcsOne3+ btdrND3l1EHg1YUWpySeu5NAAqTjy5QIL5SuMAfGsFMmo8eFP/ftWwBfsTBmB4av Np9anQ/RCQgJyuCyUjl8bbKmV6h0Dtyhb0ga2EAbhWTDQTnMZ0w+IvKeraJR1tro GvmXnMM3GU9dtU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:references :in-reply-to:content-type:content-transfer-encoding :mime-version; s=default; bh=z74xZ3kBXhejYzh0pzq3DmnLXFY=; b=I5M dIDFi1JMjB2lAohnESyyvoVmKSfKhpe0HD0xseOK4WHECs8RCdNqXkl//4q8OKWV P5EpDexZJzOkOv05jBFQX+/cl72cNiihG5qJNkuvkPDvqR5N7zuAVIPR/AbOLBox HPJu/bNDGpr2FSU8zxW+TIT4UaIDazet13fQpHWw= Received: (qmail 16163 invoked by alias); 3 Dec 2019 17:30:56 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 15669 invoked by uid 89); 3 Dec 2019 17:30:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.0 required=5.0 tests=AWL, BAYES_00, FORGED_SPF_HELO, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 spammy= X-HELO: EUR01-DB5-obe.outbound.protection.outlook.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9H9O+XtCay8hCLI7vMna1/i3HZSdUw1h4yR8ZYmLve0=; b=5YDB64tWs8HA4bOCq/f/ghyn3FFm47xNnMDpf38DO8ySQ2QigbYVvb2QyKauvOvCDHqDcVdkY59VhlYRCKuqmoiyZYYl4lYcOYBeVigmT992hN2ckIdZhscH8lVAcIkgbaYmNfHsO7AmIDlENdCCQLDHPNfZzaWsGkcbA8YnK7o= Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-CheckRecipientChecked: true X-CR-MTA-CID: b5a7b96ff383b61c X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OoBcdohWe9f30Ys0/5+Uzi9sLGT54KSN5xl4bVr5S0JFpwT2AGSQZf0/w4RZRgyEADmWv2vj4/NstoiYmkfWiEQEyfzRRVYunFODoT6e5W0m5zZAGKXov8SK6UZIHxFLLoV2VDb8hmBoZsm9f+i0d2YIUx9Xp2J3yY8Y0FQtQZdxrcrQKlPV9hEBGzMxsuzuQ/7b4ARDfIOD4pKrCUvLPx4/wAEb0rS3S1zPN/zs0jfzVZsYuLxOnWFrOmrvPRHabUDjS2bgZmHcSu9R+o3zTox2NZiWT1lzYteSCWu3mwGlB6V1qu4J015d5jMMX0wrHCvPVAoy1V/rFkkc4txL9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9H9O+XtCay8hCLI7vMna1/i3HZSdUw1h4yR8ZYmLve0=; b=Ekf1kEiWWLISfsIeKgWZYZMS1sYDrNiQlsDc8Un45O+m/5Atec80BjMvlGQeKLLOcHDMsCnBFBjbkzMTh/H/yKU8mA7M3BgnmOBLntTBrabjTe1e3M75cknB851s1a7pfHeTCsuT7QC9A6vUwB+pzMLSesgiSEFWaIcLWMTKjLNV0dZSOKpLorympXOV+jIQ3IqEDPawnaYfDjdjHSvzTfjiz5lKXYGVftO0AlW4jGhidpq368Umd/CDwufczQijkv17bT2SwV3BMYEikHZ8O0bhMrQU4agb+P+VmcwhoHPJEyd6oXrkkyH2e5mldN4sB/JTHbLRZ4as7tJcD2L9Dw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9H9O+XtCay8hCLI7vMna1/i3HZSdUw1h4yR8ZYmLve0=; b=5YDB64tWs8HA4bOCq/f/ghyn3FFm47xNnMDpf38DO8ySQ2QigbYVvb2QyKauvOvCDHqDcVdkY59VhlYRCKuqmoiyZYYl4lYcOYBeVigmT992hN2ckIdZhscH8lVAcIkgbaYmNfHsO7AmIDlENdCCQLDHPNfZzaWsGkcbA8YnK7o= From: David Kilroy To: "libc-alpha@sourceware.org" CC: nd Subject: [PATCH v3 2/3] elf: avoid redundant sort in dlopen Date: Tue, 3 Dec 2019 17:30:11 +0000 Message-ID: <1575394197-18006-3-git-send-email-david.kilroy@arm.com> References: <1575394197-18006-1-git-send-email-david.kilroy@arm.com> In-Reply-To: <1575394197-18006-1-git-send-email-david.kilroy@arm.com> Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=David.Kilroy@arm.com; x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:4125;OLM:4125; X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(136003)(39860400002)(396003)(376002)(346002)(366004)(199004)(189003)(99286004)(102836004)(6436002)(4326008)(478600001)(14454004)(2906002)(386003)(50226002)(36756003)(186003)(6916009)(2616005)(6506007)(305945005)(76176011)(52116002)(86362001)(81156014)(25786009)(26005)(71190400001)(6486002)(71200400001)(256004)(81166006)(2501003)(14444005)(7736002)(3846002)(8676002)(8936002)(446003)(11346002)(44832011)(316002)(4744005)(66476007)(6512007)(66556008)(66446008)(64756008)(66946007)(2351001)(5660300002)(6116002)(5640700003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB4001; H:AM0PR08MB4068.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: ihBQL5joMI34yQaOAsyJQLygMiMBbjKzD4Rwl5HSQZoQDqaxwzq/P9cF3X4flHapDr1F57luDxar7XgiWbdIdfZ9GzwgxOSxlxVkZiJBWrByflpRBSnv/MBIv/KvAkQINHeCzJTAxmKU77VqsKLw4gbDMZq48d1sGdTOgwkpykhtZ/Eo8nEYC/X1ZyY5C1dA6XRmhJJbWM5wcybifmNNx6Rjl8HFh0yFVdqjsAlfoxXUzXVS5MEKjugfd2ogGA2JYzlRu5aaMF77CDYsANYbM3zrubOdUFT/hbF7VS/o2fYQg0bSFu4mmw5IMFK1l2pbyA2KrM/2lxvlBITjWegVH9jUqKvW1+XUu4I1NP8Jofm0kC4dJ2dxrMZMBtZ/w+k3KIWK+qn40PN6RC1SSIcabSWKlF+TFcEXJS5f1hwKSnw8qrGtxUu94VVbmXTLS4ol x-ms-exchange-transport-forked: True MIME-Version: 1.0 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=David.Kilroy@arm.com; X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 5e1584c4-d8de-49c0-f21e-08d77816731d l_initfini is already sorted by dependency in _dl_map_object_deps(), so avoid sorting again in dl_open_worker(). Tested by running the testsuite on x86_64. Reviewed-by: Adhemerval Zanella --- elf/dl-open.c | 1 - 1 file changed, 1 deletion(-) diff --git a/elf/dl-open.c b/elf/dl-open.c index 9996fe9..c4d09c7c 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -658,7 +658,6 @@ dl_open_worker (void *a) l = new->l_initfini[++j]; } while (l != NULL); - _dl_sort_maps (maps, nmaps, NULL, false); int relocation_in_progress = 0; From patchwork Tue Dec 3 17:30:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Kilroy X-Patchwork-Id: 1203812 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107669-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="cfGmm1YB"; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="aX6PNbD8"; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="aX6PNbD8"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47S8DR6tKnz9sP6 for ; Wed, 4 Dec 2019 04:31:51 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:references :in-reply-to:content-type:content-transfer-encoding :mime-version; q=dns; s=default; b=gCCzMVjAHNq0LsbWiEOKSp6x3KW1c Xh18Ie9BXm7wZrLnk37kegbDLJZCSk8SkvzPqPk9xlcMcMorTL64oJU1foSZgEAf ZnJLJFlb8N56M1vR9jVnlMsJlxOrOK6/bl9gUVwfdoGjno6pMWG/PEWSEUm7GiC5 jS+RRzY/wQVPyI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:references :in-reply-to:content-type:content-transfer-encoding :mime-version; s=default; bh=zFYzBGPAFAo12u5B+/SWmhEQVus=; b=cfG mm1YB8DSKsTOrLEX+/4QVcZTZe4Vs3+6QuOcKut3yKGpDNgthM3v6HVIW/WuK0zn LhQdVjF1SffRXtZzY1qQVqC0JvKsd5K+A1Sq/IMPGcQWdVnQbkZAP7Aun3ltST/6 Nwh08V/iuKWVfDYSe5mrOXxs66xNxxYN/NUvbk9Y= Received: (qmail 16081 invoked by alias); 3 Dec 2019 17:30:51 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 15677 invoked by uid 89); 3 Dec 2019 17:30:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1792 X-HELO: EUR03-AM5-obe.outbound.protection.outlook.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F2xr7vPj26LCgS8MuKGYrADsk0rWP02s/9tbwORzgRU=; b=aX6PNbD8EZRI8gKxgUrgs1/jNWU5UVsxl3kFlYA73YKQriSMjZe5cILqF+syAUHP4QHDpZ2YEPRQ2YDNG0vcd9BJvDDK9oUvvwwyMWXW1FPwzLozpUMISrLyKR6pXZ0jrm2KeFEniygxvXTJTHwLsI3d5TPms0QV1Hhh4BCskUU= Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-CheckRecipientChecked: true X-CR-MTA-CID: 70c1bc5f82f0bafe X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dby4fmdS7ohvyedsRXloGPI16SlQabrOnn0W7Kt/2oYeWuXEMFv5AVD153lZLtAFHcC/5w235rGo7DawgiER6vzSyxdHHfs1mBRKpebOptFdHxs4YkpUVEZ+qoA+h39bYz92hXDd59HUl0NF0l2+VlNIVVsOss/HrvgNf5TVpQLd80COXCCQuWgKYrpxVFko52XA2FwxUh95OOfT1D2Y8wxPHpu0C9udFd6MiHx0F3t6OxHuQ07kyb8s0JGm8sVNaGSyki7QlRsCX2PowvjPKomfjKJxLohSBmOANumbU5soj23lKV+bDOOMMdmDhP3jEjk7jJGgZy6TjIjm5zYKHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F2xr7vPj26LCgS8MuKGYrADsk0rWP02s/9tbwORzgRU=; b=TDqoTnXJaw+MvrtS8dd6zmuUGvMELLsLZhzhOCh+HGn0SScstKRkYSTJTqDYVPP/n+Bx6mMX/dVpmkox5es7tdSUZwmdfZMCXTCHE7ObtUzM9AVWhdeVXFdMB+zUSF9KTyw6/z7DJyPoKVdCbOGDaXxmPoavU8Gm2KBQSwJtqIzsi2Y3+1xP+aLrAY/MHgt96+nbuaQIZeGPG4AHUMA8S155vFzWi4SFnOUtwTODongc1aB8+XOK+iyAKlVSiYcvWtJPon9Sk9wrOOHSB7kIAVVg1JaNUIhFC+F9ZdE71c1SuqElhQFFuUR2Txy7VTvxUhefdU8sILGEI+q2iDvS8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F2xr7vPj26LCgS8MuKGYrADsk0rWP02s/9tbwORzgRU=; b=aX6PNbD8EZRI8gKxgUrgs1/jNWU5UVsxl3kFlYA73YKQriSMjZe5cILqF+syAUHP4QHDpZ2YEPRQ2YDNG0vcd9BJvDDK9oUvvwwyMWXW1FPwzLozpUMISrLyKR6pXZ0jrm2KeFEniygxvXTJTHwLsI3d5TPms0QV1Hhh4BCskUU= From: David Kilroy To: "libc-alpha@sourceware.org" CC: nd Subject: [PATCH v3 3/3] elf: avoid stack allocation in dl_open_worker Date: Tue, 3 Dec 2019 17:30:11 +0000 Message-ID: <1575394197-18006-4-git-send-email-david.kilroy@arm.com> References: <1575394197-18006-1-git-send-email-david.kilroy@arm.com> In-Reply-To: <1575394197-18006-1-git-send-email-david.kilroy@arm.com> Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=David.Kilroy@arm.com; x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:7691;OLM:7691; X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(136003)(39860400002)(396003)(376002)(346002)(366004)(199004)(189003)(52314003)(99286004)(102836004)(6436002)(4326008)(478600001)(14454004)(2906002)(386003)(50226002)(36756003)(186003)(6916009)(2616005)(6506007)(305945005)(76176011)(52116002)(86362001)(81156014)(25786009)(26005)(71190400001)(6486002)(71200400001)(256004)(81166006)(2501003)(7736002)(3846002)(8676002)(8936002)(446003)(11346002)(44832011)(316002)(66476007)(6512007)(66556008)(66446008)(64756008)(66946007)(2351001)(5660300002)(6116002)(5640700003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB4001; H:AM0PR08MB4068.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: KEikf8pfv7E7SOemiz+xDlcDQzVlCdg7oqY3uMnQwF6tCVnzsTMHEvZcdoJIxpLF2tijDnVu2ygURuNaDZo8Qx/Gc2OLZupMkPPakHttQU4QLwNsNu3AWFr1Yt7vCFO2KrPmuvHzwKAg/Oe6tbzanl6gvA7BsWIkIX99upEuGCXlQGmcyIrFeT9c2PFo51JYwVLlR5o/TC7TCBXXmyy2aTxX4bZFJsqm3dssSBDcBVggR7T4vPf07Xo8t5wSc3s0lQOF4zu3bv28z+42ACXya//mS29jT38TOgIKM/48GF8VRXDlObpYmTGQqOM1o6+xW2Az2HkS7UqBTlpxAMIxPQ8Xez6PTSWh+V80wsMnqhCe3HgYzckiyfkLOdxG0BbcvunfBbdvchRRMcq0albi/5K/y32V7lW4pxHcREKjCISrpcdo9kqgjHbBzG55vl2S x-ms-exchange-transport-forked: True MIME-Version: 1.0 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=David.Kilroy@arm.com; X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT051.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 3b764e09-c08e-42e0-0392-08d77816735c As the sort was removed, there's no need to keep a separate map of links. Instead, when relocating objects iterate over l_initfini directly. This allows us to remove the loop copying l_initfini elements into map. We still need a loop to identify the first and last elements that need relocation. Tested by running the testsuite on x86_64. Reviewed-by: Adhemerval Zanella --- elf/dl-open.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/elf/dl-open.c b/elf/dl-open.c index c4d09c7c..eb36a91 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -636,25 +636,18 @@ dl_open_worker (void *a) /* Sort the objects by dependency for the relocation process. This allows IFUNC relocations to work and it also means copy relocation of dependencies are if necessary overwritten. */ - unsigned int nmaps = 0; + unsigned int first = UINT_MAX; + unsigned int last = 0; unsigned int j = 0; struct link_map *l = new->l_initfini[0]; do { if (! l->l_real->l_relocated) - ++nmaps; - l = new->l_initfini[++j]; - } - while (l != NULL); - /* Stack allocation is limited by the number of loaded objects. */ - struct link_map *maps[nmaps]; - nmaps = 0; - j = 0; - l = new->l_initfini[0]; - do - { - if (! l->l_real->l_relocated) - maps[nmaps++] = l; + { + if (first == UINT_MAX) + first = j; + last = j + 1; + } l = new->l_initfini[++j]; } while (l != NULL); @@ -669,9 +662,12 @@ dl_open_worker (void *a) them. However, such relocation dependencies in IFUNC resolvers are undefined anyway, so this is not a problem. */ - for (unsigned int i = nmaps; i-- > 0; ) + for (unsigned int i = last; i-- > first; ) { - l = maps[i]; + l = new->l_initfini[i]; + + if (l->l_real->l_relocated) + continue; if (! relocation_in_progress) {