From patchwork Thu Oct 17 10:33:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Kilroy X-Patchwork-Id: 1178450 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-106056-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="OwB7+cx+"; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="xOo62zUT"; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="xOo62zUT"; 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 46v59s1Y8zz9sNx for ; Thu, 17 Oct 2019 21:33:52 +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=bNuZbDRNZ4IaM99ONhESEgwm4CsPF EDUEGBTqKuqQO5rtVhTJ8A5u5l+iXWtUtFSQ0wWdU9FNrP4GXRRrHSBMT5RA4G1/ WBZZNymMlsa+MXcBcG+Mxzc/WIy/njGS/oYwNGvwvwZBXM6y94buNv7OTQwT2XVg y8ezPsWGkctyWA= 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=+zRPO4PJsYnz0b9u7wZKOL6Xogs=; b=OwB 7+cx+tTzpThwmQ6He63un/MVV2AAkd4Zaoeq2mNvkd/G/8+1TjXFoPogOhR42SaL Q4pCfw1Dj2pIwV2sgxTzpzYpv2KZaaUX6foBJ1K2Q3RpXVSTxUkiwOh8ndYyPeX1 0gdjz6qIwtpSrG82LDOLtbR8AK5D4AuH6zIIkcN8= Received: (qmail 57483 invoked by alias); 17 Oct 2019 10:33:32 -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 57387 invoked by uid 89); 17 Oct 2019 10:33:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.7 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 autolearn=ham version=3.3.1 spammy= X-HELO: FRA01-PR2-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=jXWxBuP8vycZEqlYuWAe6+9AXBUfZSXXrwINPCu2bFQ=; b=xOo62zUTaXoDQ5QdF1PUXFECTOc7mMG+1lk0lG9jYLs7SysO4bQvbkbATF4UVuwggn9YdSZ313nH+KUWim5NhqxtT6iCwzFS0OtVQLow/u0Q2K8/Bz7QEyvhKbbeAE/uzKVojZDK0/Vl4cnvN9R9Nr2SfDbLqjNzDi1mDb3i4Ls= Authentication-Results: spf=temperror (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=none action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) X-CheckRecipientChecked: true X-CR-MTA-CID: bd68a76c02a4ea0d X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gleGEMcTNWao9raE6lYPOapYvmt6A3XOiGEFNQ3yIPEvgZOSkg4IurUXsksFZm/0UdGibzBSXLzvAdajpKJ9Gi+Fu7uByI+8IZFl26mISi92eSEaIlxN1SxDcZx121e8aY7dlN1iP3kWJ2p08uxMDB+pnzVrZQDU8NufwEyCp9HZyBZomNL2S1ZzYpKfgkcLDH5zj70Zgyp+tNJp+NEMfrN6jPFfbSIoXLBIhfPW12X4aUGtsv6p1RJ4pUudT93f8cfeRjl0r3+NHz2D9N8iUvAHtNTlUDsvcMt6gDzha2dgxdhb5jj6j2/pbOOCT7O/M8lM7KryhKOB/I4kyXUNxQ== 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=jXWxBuP8vycZEqlYuWAe6+9AXBUfZSXXrwINPCu2bFQ=; b=lm6JPpu4d+mcJFkYXRk3b58cDac2Ffv3YPBo7NMtoOOkFY3F6VWULg3tLvUItQAIgmIWpBsYPUk3tDGijPnTtUjXZy3/9+m8hzy1CMBeTOukoCAMepDJDtuTkEmQ/R6bb5DUw00cUNPnau2koXH/uL5lbayK41qzvo4LpxjXrGtb+4Ul4LVLN8fICXUZE83eFdBDm32ZUz8tnMi3QqjAlrAfuS8DL+3noj0tHoaU6sXeTzhRKkcWKVGFR26m8+tiLEz3uUN0Rpr1XY0wRZUz5EFSKbVFtEWlmS26XPhV2ghWyGcOYlauQqhn+ZMq5IKYcSdqIde0Zo71U5j4MjK+2g== 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=jXWxBuP8vycZEqlYuWAe6+9AXBUfZSXXrwINPCu2bFQ=; b=xOo62zUTaXoDQ5QdF1PUXFECTOc7mMG+1lk0lG9jYLs7SysO4bQvbkbATF4UVuwggn9YdSZ313nH+KUWim5NhqxtT6iCwzFS0OtVQLow/u0Q2K8/Bz7QEyvhKbbeAE/uzKVojZDK0/Vl4cnvN9R9Nr2SfDbLqjNzDi1mDb3i4Ls= From: David Kilroy To: "libc-alpha@sourceware.org" CC: nd Subject: [PATCH 1/3] elf: Allow dlopen of filter object to work [BZ #16272] Date: Thu, 17 Oct 2019 10:33:19 +0000 Message-ID: <4eae391688a6e42b0b75467de265c122e6402668.1571301957.git.david.kilroy@arm.com> References: In-Reply-To: Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=David.Kilroy@arm.com; X-MS-Exchange-PUrlCount: 1 x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:2657;OLM:2657; X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(376002)(366004)(136003)(39860400002)(396003)(346002)(189003)(199004)(7736002)(305945005)(6306002)(64756008)(30864003)(99286004)(478600001)(66946007)(36756003)(102836004)(66446008)(66556008)(6512007)(26005)(186003)(386003)(66476007)(11346002)(5640700003)(446003)(71200400001)(2501003)(44832011)(486006)(2616005)(5660300002)(476003)(52116002)(8676002)(71190400001)(66066001)(76176011)(4326008)(6506007)(6436002)(86362001)(8936002)(3846002)(25786009)(6116002)(118296001)(14454004)(81166006)(6916009)(6486002)(316002)(256004)(81156014)(14444005)(2906002)(50226002)(2351001)(2004002)(473944003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB5492; H:AM0PR08MB4068.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: CQybONN07IGjK01gEPCDxyAYEiapQGqwA7a+Iw9A/7WI9e2aSPRwUikeadKIop6YrWUijappAN/cbZheE9wD+dB3xQND9v8xERHwAly4FicUqIEdnxUq3jpR9wxEyFgM8UkO0s9WSN8xBiYqi43hUp1IMKsQYIw0TCyk6NqcQcXOmM14oco+EAeaKF0SVhoL0iP/PHxueEQPqAQQ5d311/yTOhwfEbaIDkcjBpikLAITEXvP5y/1UTsNalpPFi+T9YZe+eRBHALvN2ihGSUBhdW1EHZhwwBMg5FpOwtJNcj/m40dN32pnJB2F/yOP5iMMRsEgil2FxYJUK9gfvxqW3Y086fIDnWuuJYJuBJxyWxyjL3fgt/h3i4seGH9uuyzBIrRQaZcxucjVMqAbEAtq4qx+jcijdfDLA21cQcVussI7RjiDTIJhYfaethwFJYLqTai0551CHrMBqoZ/KlWlA== 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: AM5EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 1617d711-69fc-4a8a-5a05-08d752ed6d3b _dl_map_object_deps assumes that map will always be at the beginning of the search list in l_searchlist.r_list[]. This is not true if map is a filter object, in which case the filtees are inserted before map. Fix this by: * avoiding relocation dependencies of map by setting l_reserved to 0 and otherwise processing the rest of the search list. * ensuring 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. With that in place, the filtee objects are not getting relocations applied when dlopen is called. Modify dl_open_worker to attempt relocations on new->l_initfini instead of objects referenced by new->l_next (the filtees are in l_prev). 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 | 54 ++++++++++++++++++++++++++++++++++++++++++++++ elf/tst-filterobj-flt.c | 24 +++++++++++++++++++++ elf/tst-filterobj-lib.c | 24 +++++++++++++++++++++ elf/tst-filterobj-lib.h | 18 ++++++++++++++++ elf/tst-filterobj.c | 34 +++++++++++++++++++++++++++++ 8 files changed, 197 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 8f96299..55bed87 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -192,7 +192,8 @@ tests += restest1 preloadtest loadfail multiload origtest resolvfail \ tst-latepthread tst-tls-manydynamic tst-nodelete-dlclose \ 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-aout + tst-sonamemove-link tst-sonamemove-dlopen tst-dlopen-aout \ + tst-filterobj tst-filterobj-dlopen # reldep9 tests-internal += loadtest unload unload2 circleload1 \ neededtest neededtest2 neededtest3 neededtest4 \ @@ -279,7 +280,9 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \ tst-main1mod tst-libc_dlvsym-dso tst-absolute-sym-lib \ tst-absolute-zero-lib tst-big-note-lib tst-unwind-ctor-lib \ tst-audit13mod1 tst-sonamemove-linkmod1 \ - tst-sonamemove-runmod1 tst-sonamemove-runmod2 + tst-sonamemove-runmod1 tst-sonamemove-runmod2 \ + 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%,\ @@ -1553,3 +1556,8 @@ $(objpfx)tst-big-note-lib.so: $(objpfx)tst-big-note-lib.o $(objpfx)tst-unwind-ctor: $(objpfx)tst-unwind-ctor-lib.so CFLAGS-tst-unwind-main.c += -funwind-tables -DUSE_PTHREADS=0 + +LDFLAGS-tst-filterobj-flt.so=-Wl,--filter=$(objpfx)tst-filterobj-lib.so +CFLAGS-tst-filterobj-dlopen.c += -DPFX=\"$(objpfx)\" +$(objpfx)tst-filterobj: $(objpfx)tst-filterobj-flt.so | $(objpfx)tst-filterobj-lib.so +$(objpfx)tst-filterobj-dlopen: $(libdl) | $(objpfx)tst-filterobj-lib.so diff --git a/elf/dl-deps.c b/elf/dl-deps.c index c29b988..c177cef 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 a9fd4cb..7fcfdc0 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -305,22 +305,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..7c24a1d --- /dev/null +++ b/elf/tst-filterobj-dlopen.c @@ -0,0 +1,54 @@ +/* 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 +#include + +int main (int argc, const char**argv) +{ + void *lib = dlopen (PFX "tst-filterobj-flt.so", RTLD_LAZY); + int result = 1; + + if (lib != NULL) + { + char *(*fn)(void) = dlsym (lib, "get_text"); + + if (fn != NULL) + { + const char* text = fn (); + + printf ("%s\n", text); + + /* Verify the text matches what we expect from the filtee */ + result = strcmp (text, "Hello from filtee (PASS)") != 0; + } + else + { + fprintf (stderr, "No function\n"); + } + } + else + { + fprintf (stderr, "No library\n"); + } + + return result; +} diff --git a/elf/tst-filterobj-flt.c b/elf/tst-filterobj-flt.c new file mode 100644 index 0000000..ec84d4c --- /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..99d50fb --- /dev/null +++ b/elf/tst-filterobj.c @@ -0,0 +1,34 @@ +/* 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 +#include + +#include "tst-filterobj-lib.h" + +int main (int argc, const char**argv) +{ + const char* text = get_text (); + + printf ("%s\n", text); + + /* Verify the text matches what we expect from the filtee */ + return strcmp (text, "Hello from filtee (PASS)") != 0; +} From patchwork Thu Oct 17 10:33:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Kilroy X-Patchwork-Id: 1178451 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-106057-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="omZESVdj"; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="UuSnvrck"; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="UuSnvrck"; 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 46v5B22KZKz9sNx for ; Thu, 17 Oct 2019 21:34:02 +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=KeS4ePQHaU9EieHybJgHHWqH8y+RV peIVWoyqqB+BiGcjCh1IfAg7teF4NttdcOXQ63E1KlDvSZ7EljCZNTOxld3AVOP8 BN4WB2w5H8Ejr8SsodhmG2BRFKKnx6kk/C7AeGs2AkxyuR6z8Dz2UylmFu/ENe6N tJ86sTdGvyfN6o= 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=JzJ33/s4zD1nwvfnFuyCg3gVOj8=; b=omZ ESVdjknBufIBx5Dun5YX9lQcrSzWUk6TnlkoOIf9S2PoigzK/b5Aj5AwKbglNtha qJWVaSRnxkYXN5LEMMSU7CCbCmzZO94g/x8PRkKCbMOVnPXUICnDEOOhahzgezGl 8w+4Un8EgTtd+FsRLdpewYmfbra51Yn/LqgQXayU= Received: (qmail 57560 invoked by alias); 17 Oct 2019 10:33:32 -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 57474 invoked by uid 89); 17 Oct 2019 10:33:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.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 autolearn=ham version=3.3.1 spammy= 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=xcum8Zg9CSNnsbl8AxSTWmx4Wev2HJBiGCYHAg6Fitc=; b=UuSnvrckGlqpcsNv2S98OxFHqreFYS8iESn4c3jYvA1ennW0bA0rieSz3CE6OiSerXxbSlIA41nEk8sejV73JHOBFhFEt5MbP7d7GLla86gH6zeFkGrK1yyMTi6cqF6wdex45ct+0B7uKNfX61Dop/5EK/UWZXWij1xOGZ4vuio= Authentication-Results: spf=temperror (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=none action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) X-CheckRecipientChecked: true X-CR-MTA-CID: 42f480caedb36fba X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R3lfYOOd+c0O5bz9kBj5Rh7qdf7pGQOlbZRcXzje0cjQqCNeJi6CJbgBi0KyAGYGR4mGUNDHEXUvnTezS/cypGhBm52/Y6uuiqbFLfzpQOBFEqQPMvyE+SZ9OP9iXzAw1cflB/HbubyoTMFGUu0RWi3DhyP3ywREGAAE8kqMkD8rtbfGpBcF+530mC7sWVIsLxDTS5zoHatIfVPoIlTurV+aR9jzrZCME77W+f9jZhQDobPEglnoYk/dFdqVWPPcrg95eC0JsU+9YCMKAUDc+LyKj2l3gd85LhuSDPB7IP5QkkGgyxrp3wI4pqjG+pMk2pfKLG/6Vm/d+Q9ypZXjGw== 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=xcum8Zg9CSNnsbl8AxSTWmx4Wev2HJBiGCYHAg6Fitc=; b=P57y05FIlB+HB7eQ/9YOZrCgjluo+GBuaER3nCMZMKbCRnH6dUkMOsDfz9htmtt8nqWjCIqn49d5hkxc2Lfm72cPmFgMhuRMMDTVoIwpTgEV5/PLztlan6RwlFzcVX1sX0WsuH9KZwBan1OYX6VX2RQQUDFdmIQujTqepNOqOP+boalWfKCUg7G7aeDbmMGBwh67GkzQjH9Fu3VvZYzZgnPLbO8plgo5f08yYRXamlqjbIaRSCBW9qMLdQMTTANcIHW6CclecYb1i/rhkDktyXz11569EEy5EguHHx0MiGfCcL/jb3maji5Jt6Eol9S0SrYIJGYemulV+6NsTutCkQ== 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=xcum8Zg9CSNnsbl8AxSTWmx4Wev2HJBiGCYHAg6Fitc=; b=UuSnvrckGlqpcsNv2S98OxFHqreFYS8iESn4c3jYvA1ennW0bA0rieSz3CE6OiSerXxbSlIA41nEk8sejV73JHOBFhFEt5MbP7d7GLla86gH6zeFkGrK1yyMTi6cqF6wdex45ct+0B7uKNfX61Dop/5EK/UWZXWij1xOGZ4vuio= From: David Kilroy To: "libc-alpha@sourceware.org" CC: nd Subject: [PATCH 2/3] elf: avoid redundant sort in dlopen Date: Thu, 17 Oct 2019 10:33:19 +0000 Message-ID: <6809187033c7c9d0cc9689e1eb05a18bf0fd31c2.1571301957.git.david.kilroy@arm.com> References: In-Reply-To: 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)(376002)(366004)(136003)(39860400002)(396003)(346002)(189003)(199004)(7736002)(305945005)(64756008)(99286004)(478600001)(66946007)(36756003)(102836004)(66446008)(66556008)(6512007)(26005)(186003)(386003)(4744005)(66476007)(11346002)(5640700003)(446003)(71200400001)(2501003)(44832011)(486006)(2616005)(5660300002)(476003)(52116002)(8676002)(71190400001)(66066001)(76176011)(4326008)(6506007)(6436002)(86362001)(8936002)(3846002)(25786009)(6116002)(118296001)(14454004)(81166006)(6916009)(6486002)(316002)(256004)(81156014)(14444005)(2906002)(50226002)(2351001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB5492; H:AM0PR08MB4068.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: DKYhurZz/gzgIv1l66Y06FVJXLk0zz824SFffZ0BEA9Zb6Rl9BWdcCUz8iFczgotSHxrLvKf/hkZF8YtoSqQ02O4F6fe4KnaW0CjzUlLwTiKXw0U5k+eUNQGjz7OJayg7xFZTMUeuPnnC9tEVEEo2D1Y/leawsP5W650qjgTi64RtZAO6vWagp5EbWHtfKh7nfujgn2DvsrCkN+ylfwOFjzoskaSaB/Zyig0sav0S5vNwM7562YYloeQLerl7BMnJnpvq5J5qS5p3Sjnh1yJ6pYSY7m3fXHsW7g0zH+/c1cSJMz396lqKAj921AHXJhAwHNNuEFV5LERR1usCcl10HrbnFnhBhIYnmx1+UPnxb7R2oDBz9tBpf0ZxDoCp57UTiir8fzhn6xkOi1ncKRB+d0Cgz6DlloWWxFSw5UmNUo= 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: VE1EUR03FT028.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 757cc761-454c-4a36-9fd8-08d752ed6d73 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. --- elf/dl-open.c | 1 - 1 file changed, 1 deletion(-) diff --git a/elf/dl-open.c b/elf/dl-open.c index 7fcfdc0..25e8fb0 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -326,7 +326,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 Thu Oct 17 10:33:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Kilroy X-Patchwork-Id: 1178448 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-106054-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="SSU7hgCp"; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="v5tWoyzK"; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="v5tWoyzK"; 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 46v59Y1DZcz9sNx for ; Thu, 17 Oct 2019 21:33:36 +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=stmsJcgv19ByjBAv8GxK3seVi8n0o v6sORcxSMK6XE8V+Jd1EMhabWQBvz1Fy54Pxgh+4bkDf8bENLBKDC65JOG0KNy9m uzx/8PEd/T1CpQR1Mm+jZ2z2/IoLpiKCTxEnpBVvjoHOn2xx/kQAFXPr16mXKtIh 9lHoXRgtfTyCss= 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=q0rDELknA2yfHOfU289Dn65X7Yo=; b=SSU 7hgCp2VGP7FPN8nT8Yl25wxhSB7p5bjRek0FyreoFM5RYFaWlfvO3FBxwvZmWfLA lQMw+jhLkHAn5RSo851oWQhlRorOkMGWtMo3shjFOGiCxyEsiro854pXn2YNI/HS 4z6TrBvcSCMIvWbQAmzzyqOMt4eYv8dIAgctLrEI= Received: (qmail 57126 invoked by alias); 17 Oct 2019 10:33:30 -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 57109 invoked by uid 89); 17 Oct 2019 10:33:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, FORGED_SPF_HELO, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= 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=03g3Eo+7UTtbwzPTbP1GJ1Kqvt6lXYmJurQApX5TCmc=; b=v5tWoyzK6Jk1e6QpJEc2ikHefbilcZBb6hFIFEpMy/rz81y/UJhC1FqeNqIUSaD2yIOtw/AA+6g6+yoZBhMGD/OUfaYlPbujgDA6wMw/Jrtg/rVZOaDkCBvIjscl7JvMbbaPfSbCyc21+e80cubsDzHul2BxRGQx83/3Ok6TEOc= Authentication-Results: spf=fail (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=none action=none header.from=arm.com; Received-SPF: Fail (protection.outlook.com: domain of arm.com does not designate 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: d0c2eb45bd27eaca X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JdPyHhOk5bHnRxGCniArTKbgFlbZD6Rkn83NV7uZEbq6XC4Ujy3YpeiUPM5NVGctIvUGg1tems355qeUpBc3VuG59+Tq6MbtgcwIpkBj4qZ0iQ6MPnovEroR/RzKhPYcmzVjRybutz8EOX/di9EQRCkDLWUWG4jsVb4PwlWcD2D1nUYzv6sORNvvfM8xyaCc3j3SCj1qC/W3JbmBpj5vdSOyzaIl57g/w/Iuroswo4Z2cgETITxPGXyUyU0xUAi4HZbHsxQU2MnmajVfPWVWfm7yMEOvi8avfbWjCwpdhbeskBrwega7L2ubxhe4XEe1m1hQ/FnrL92EHXDCn6accA== 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=03g3Eo+7UTtbwzPTbP1GJ1Kqvt6lXYmJurQApX5TCmc=; b=b3TkBym3UBjyOUwsel/+1kbZcHlfu1gM0MNXYcJcOqTk5RjdvaCpwcTMYsS4M2OWn5F48iZqxr15PGE60V07bbgbwEC4IkMedQlyj2Qp0J2OI+5YbwAQP+mcWe8BeIYLTJkrWJ4yPsXYKIef6cTadIrII/r/t15bsiY9xSFSiTzKpBzlt17biSM7R3MLzr1SHqS5XNNCakTij+enO+6CvnXkesfDld3Rf3E76rTEM5MRv2f2fOja/1AchKKvGqW6KxHeA4KgJ9JjHbHGxGjzDP7NN7bHmI9xSx1GH4Lek2J0GbUEBedgY/qcad5WZqQa/70hOnzLzgd3Hr7X4G9vfQ== 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=03g3Eo+7UTtbwzPTbP1GJ1Kqvt6lXYmJurQApX5TCmc=; b=v5tWoyzK6Jk1e6QpJEc2ikHefbilcZBb6hFIFEpMy/rz81y/UJhC1FqeNqIUSaD2yIOtw/AA+6g6+yoZBhMGD/OUfaYlPbujgDA6wMw/Jrtg/rVZOaDkCBvIjscl7JvMbbaPfSbCyc21+e80cubsDzHul2BxRGQx83/3Ok6TEOc= From: David Kilroy To: "libc-alpha@sourceware.org" CC: nd Subject: [PATCH 3/3] elf: avoid stack allocation in dl_open_worker Date: Thu, 17 Oct 2019 10:33:19 +0000 Message-ID: <42c95e0805f33efa9c7bd6c8d14997df312a787c.1571301957.git.david.kilroy@arm.com> References: In-Reply-To: Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=David.Kilroy@arm.com; x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:6790;OLM:6790; X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(376002)(366004)(136003)(39860400002)(396003)(346002)(189003)(199004)(7736002)(305945005)(64756008)(99286004)(478600001)(66946007)(36756003)(102836004)(66446008)(66556008)(6512007)(26005)(186003)(386003)(66476007)(11346002)(5640700003)(446003)(71200400001)(2501003)(44832011)(486006)(2616005)(5660300002)(476003)(52116002)(8676002)(71190400001)(66066001)(76176011)(4326008)(6506007)(6436002)(86362001)(8936002)(3846002)(25786009)(6116002)(118296001)(14454004)(81166006)(6916009)(6486002)(316002)(256004)(81156014)(2906002)(50226002)(2351001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB5492; H:AM0PR08MB4068.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: 12f6DR9VCojUufO9vFLtOMoyRDLDc+ei6NDJblYc5DPzYmrH4tKVbLu4VIzeJXAP6CfkBZ/5Rt/i5Y1oGlzJO/w19/ggIEL3Qkmj5aGAhSOcEdj3IgSQcNZyw5FqfcWN3+GoQBjYAg8B7in4ig1DKdeQawUbJUTDkQBPka5bfegdbpkOo+NGJamZThc8t9NJnGplk0501J0uNKH1ws8dEvbRI85A9KWl2ifOouNJHl9aMecUoiA6Uh7F2mWaqE4LV8fJJx3IEFvmJjpV5FdMCX9WxTqv1TL8Q7Fp0A3jeT7mPNIBuYhDFl7TF31QIUdSTaMXggomZ4RAU32ATV/H25gP+moI/OlpC1mK35b0pBOAUccvSbxyuPeqUf72m6e2ttLDPF2qr1Lba7/AtiETKtL/NRJAg8wl3OrJcWNBpc4= 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: DB5EUR03FT028.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 3be147f4-468b-43ba-9c15-08d752ed6da9 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. --- 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 25e8fb0..d96921a 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -304,34 +304,30 @@ 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); int relocation_in_progress = 0; - 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) {