From patchwork Tue Nov 9 18:33:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 47313 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CB73B3858012 for ; Tue, 9 Nov 2021 18:45:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CB73B3858012 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1636483511; bh=ho5/nKVkJ+OLMal9M/tF4fWyZkMaVayDSCyeItPvaqw=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=PtB0kBDuJKZUVnGMLx2O76UGkDN4W8qPhuP7vhYzTo3Qno4aDrtM9jExfVy7kyS4k VwQpmt5Wytikg9wNPC6ZU/y+vRE+Ozt5z59MmZ3b3INWDKLX4Y/frVqC6JwB0XFxyC EYoH5f58d9o7uURJKG+lBr9bmg+JGtlfOARzQfT4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id 83204385801A for ; Tue, 9 Nov 2021 18:34:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 83204385801A Received: by mail-pl1-x632.google.com with SMTP id u17so83531plg.9 for ; Tue, 09 Nov 2021 10:34:23 -0800 (PST) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=ho5/nKVkJ+OLMal9M/tF4fWyZkMaVayDSCyeItPvaqw=; b=S0pmP5go1Xl7QXzsaNxrgJeuPHirWDaQrmbjEcSmzu/Lq//siovjaDphup6sUCkegz KWHeUaKcNUfGhxCcD35hzwKhmru01019mElS9KA1o+qcIjcT1TLP3PBDsIZjlEUdJC9v NkVorDkPOsizr2yuwFFoK2VLQdDBtkhH05yrASpytnv/hIAn2czmxA1JducgYLwAw7fx 5V/wYqyXLVmwq/dv3djKh8nJhnF5yvyZHCQxfa0/M64nuF9BdwxWdZeAyOYyzuy/we6M NYeKfQ/U7k5wTAHO893yubnZK53KcVv6V0RrWICa9ZjotW/rQo1frDNPVY2D9tJPLspp 4CEw== X-Gm-Message-State: AOAM530TM56Vkptfix1VIjOGfO4ymY+6PCLhYkzjqH+n25e6hUaSHo4f I0VCFxsNGHyyisc12SmZYnmDmIwfuL0N2Q== X-Google-Smtp-Source: ABdhPJwqIfwKv1lnMMi9H5JDtcultsf1kiBoqzVJmFyalRonnQjn61LQti9f/NqMxVDimQJk1BJmmA== X-Received: by 2002:a17:902:ea11:b0:141:c6c8:823a with SMTP id s17-20020a170902ea1100b00141c6c8823amr9333112plg.29.1636482862456; Tue, 09 Nov 2021 10:34:22 -0800 (PST) Received: from birita.. ([2804:431:c7cb:55a:94d0:2630:9b29:e621]) by smtp.gmail.com with ESMTPSA id ep15sm3761884pjb.3.2021.11.09.10.34.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Nov 2021 10:34:22 -0800 (PST) To: libc-alpha@sourceware.org, Florian Weimer Subject: [PATCH v5 15/22] elf: Run constructors if executable has a soname of a dependency Date: Tue, 9 Nov 2021 15:33:40 -0300 Message-Id: <20211109183347.2943786-16-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211109183347.2943786-1-adhemerval.zanella@linaro.org> References: <20211109183347.2943786-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Cc: John Mellor-Crummey Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" The DSO constructor should not be ignored if the main executable has the SONAME set to a dependency. It fixes the case where (using the scripts/dso-ordering-test.py definition): {}->a->b->c;soname({})=c Where the constructors should return c>b>a>{}= 0); assert (nsid < GL(dl_nns)); + /* Special case: trying to map itself. */ + if (name[0] == '\0') + return GL(dl_ns)[nsid]._ns_loaded; + /* Look for this name among those already loaded. */ for (l = GL(dl_ns)[nsid]._ns_loaded; l; l = l->l_next) { /* If the requested name matches the soname of a loaded object, use that object. Elide this check for names that have not - yet been opened. */ - if (__glibc_unlikely ((l->l_faked | l->l_removed) != 0)) + yet been opened or the executable itself. */ + if (__glibc_unlikely ((l->l_faked | l->l_removed) != 0 + || l->l_type == lt_executable)) continue; if (!_dl_name_match_p (name, l)) { diff --git a/elf/dso-sort-tests-1.def b/elf/dso-sort-tests-1.def index 5f7f18ef27..2228910c0d 100644 --- a/elf/dso-sort-tests-1.def +++ b/elf/dso-sort-tests-1.def @@ -50,7 +50,10 @@ output: e>d>c>b>a>{}a->b->c;soname({})=c -output: b>a>{}b>a>{}a->b->c;soname({})=a +output: c>b>a>{}