From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id C93DA3881D35 for ; Tue, 22 Aug 2023 11:26:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C93DA3881D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692703562; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ugH3l83zO5KCEWB3I0ytzNXEW4OMYE7PEeL8D41zr3M=; b=DK/E7Z4MhQExD1/PKhCwNcIu/YgorP66LbF4h7lKOi8Dx4e/Om5MRBmlT9uI8xSfKw7bu+ hQwG+bNN3/VDZoU/oktblB8VG1fQ58rORNusvKQ1BiqZXL20TXiF/zz2K0ml3xOrRlS8X3 rZo86nOsiLFzmMGcDDQ0mrJhr5KTL/s= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-228-iOOy_zM0O0qJjMbtH2Zh5g-1; Tue, 22 Aug 2023 07:25:59 -0400 X-MC-Unique: iOOy_zM0O0qJjMbtH2Zh5g-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0973C1C05EC9; Tue, 22 Aug 2023 11:25:59 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C5592026D76; Tue, 22 Aug 2023 11:25:58 +0000 (UTC) From: Florian Weimer To: Andreas Schwab Cc: Florian Weimer via Libc-alpha Subject: Re: [PATCH v3 1/2] elf: Do not run constructors for proxy objects References: Date: Tue, 22 Aug 2023 13:25:57 +0200 In-Reply-To: (Andreas Schwab's message of "Tue, 22 Aug 2023 13:14:43 +0200") Message-ID: <87cyzf2u9m.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: * Andreas Schwab: > On Aug 22 2023, Florian Weimer via Libc-alpha wrote: > >> diff --git a/elf/dl-init.c b/elf/dl-init.c >> index 5b0732590f..fefd471851 100644 >> --- a/elf/dl-init.c >> +++ b/elf/dl-init.c >> @@ -25,6 +25,10 @@ >> static void >> call_init (struct link_map *l, int argc, char **argv, char **env) >> { >> + /* Do not run constructors for proxy objects. */ >> + if (l != l->l_real) >> + return; >> + >> /* If the object has not been relocated, this is a bug. The >> function pointers are invalid in this case. (Executables do not >> need relocation, and neither do proxy objects.) */ > > Now that we know that l == l->l_real, the following assertion does not > need to indirect through l_real any more. Thanks, makes sense. Okay to push with that change? @@ -25,10 +25,14 @@ static void call_init (struct link_map *l, int argc, char **argv, char **env) { + /* Do not run constructors for proxy objects. */ + if (l != l->l_real) + return; + /* If the object has not been relocated, this is a bug. The function pointers are invalid in this case. (Executables do not need relocation, and neither do proxy objects.) */ - assert (l->l_real->l_relocated || l->l_real->l_type == lt_executable); + assert (l->l_relocated || l->l_type == lt_executable); if (l->l_init_called) /* This object is all done. */ Florian