From patchwork Mon Nov 15 18:37:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 47712 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 7A87E3857C71 for ; Mon, 15 Nov 2021 18:49:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A87E3857C71 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1637002168; bh=zalrArEzflFAZo2LG3BDFvI+Ei2zzI84iAlAFLSATuQ=; 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=K/+A1ccw4+ip/oEecfzvlIvn6/o5V98COyCP5XMN/S3h7yhbswzaOQrKA+xEE9GU3 g1Az3sAMLglaGzrkusrZM6Yoj2zcIK9Rgk2EL0cNbrfL/UawtiRSO0jqP/pGxiR4mM DRyWICYr9lsTXhX69vlPsqI1NpRg4z7fSJbaHesQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-vk1-xa30.google.com (mail-vk1-xa30.google.com [IPv6:2607:f8b0:4864:20::a30]) by sourceware.org (Postfix) with ESMTPS id 6DA203857805 for ; Mon, 15 Nov 2021 18:38:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6DA203857805 Received: by mail-vk1-xa30.google.com with SMTP id m19so4914104vko.12 for ; Mon, 15 Nov 2021 10:38:05 -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=zalrArEzflFAZo2LG3BDFvI+Ei2zzI84iAlAFLSATuQ=; b=xDqS2G/U53rlwnwNE2P1bo74tkN69SvQpm//CcTHP4Ss1/ZPsk6KtAX5Ejq2CDd/RA GUuR48GL4ooA3+x1ZtM8EV9G4W6zJ1piDkFruK5mvf228xSymfc7G4KbgaN8oP7bNnGw QgpSEMrE0FFt+X9HacbK3SB97QvTq7eSYxse9aHGqyZiwo+gWXi7WtOWe3XquuT/B92+ cFsXnTLd96RD5p58ukpOP25HC17DM2dDyIDSTgBoiDjsVnjCNuQU7DLq+u6XnY7eD+09 DBsHPdYfyYHn8ogzB5j2dpTJwvI9/PJtCov4+A6CjW/iEnFSQx0f2hzm9x8CmkiZ3a/A 9WEg== X-Gm-Message-State: AOAM533+JOQpsMakNpEw5LBhw4sjPibxEQHkGE/xvTRAz331UmGB5nm4 XEue/qF80n5ETvy48c3csJC58+QVH35pGw== X-Google-Smtp-Source: ABdhPJxA8jdxdahzMvicB1E06Qssff3dKnWwFZj7ZuGN2QAFuW0IVbLTEW8OVSZ/GSd6jJ4e3NR98w== X-Received: by 2002:a1f:e287:: with SMTP id z129mr61934771vkg.17.1637001484836; Mon, 15 Nov 2021 10:38:04 -0800 (PST) Received: from birita.. ([2804:431:c7ca:66dc:13f5:e2fb:5a0d:90]) by smtp.gmail.com with ESMTPSA id e7sm8976565vkn.20.2021.11.15.10.38.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 10:38:04 -0800 (PST) To: libc-alpha@sourceware.org, Florian Weimer Subject: [PATCH v6 15/20] elf: Run constructors if executable has a soname of a dependency Date: Mon, 15 Nov 2021 15:37:29 -0300 Message-Id: <20211115183734.531155-16-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211115183734.531155-1-adhemerval.zanella@linaro.org> References: <20211115183734.531155-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 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. An empty name correspond to + a NULL or "" argument for dlopen(), and it returns the head object + of the namespace. */ + 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>{}