From patchwork Wed Jul 31 20:02:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 815667 Delivered-To: patch@linaro.org Received: by 2002:a5d:4acf:0:b0:367:895a:4699 with SMTP id y15csp900822wrs; Wed, 31 Jul 2024 13:03:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXRgvOCZ6AHOda7JjX9CBH7qy2RpwALS/ceaUC49v/CllszB74jZ01OnkDljzz5ZiQxghP+LbIb0E61AbxKeBky X-Google-Smtp-Source: AGHT+IH0yRDKrMebdLrIHNWSnsSS/u1Ldk/UOtqSEMJXdvjgaCTjCybpu8LTt/AR40sqS1PVgW7E X-Received: by 2002:a05:6830:3611:b0:709:3772:8c31 with SMTP id 46e09a7af769-7096b8771edmr169280a34.31.1722456223850; Wed, 31 Jul 2024 13:03:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1722456223; cv=pass; d=google.com; s=arc-20160816; b=gABjU0ly7y+qWe8jeETniHQaR+JlmAOX3eI2dhE5LixeGVNB3L3DLwuEoOWE1ooenr 8lOh3ubhiWVkqN4urGp8Sw19Ij4L91k7XG4xsGqyVGAJsDCJOCSJlelIk9TCYhTFDWsA /Lm6k2s9XBsM3vXqYbepRIQ6Vi+zs5U1viA0fFaMu2CuHTGGvns9Bk+pwbxEdJBMNFhW TOTRLY2KHCVSU46YLL2LS1SCiogcjQ3wBjvaWyp2TkPjEv9dgq/txVMoQrMuIIl1gI74 H0QaHLZWPdnaEGTSu7+lBGGBG0RuK5CSZuyirm0wFHLNkVJy+uBy8mCH2pSKv1ApdlGp LK5g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=Fgt9d5LP1LprzxcdzicBf+tjVmYkCVud6ErtxvVCba8=; fh=zKuAMb1nXEL7zl6xmPyPzNI9yuHu1VXmLp48x4QMXiI=; b=JR203YSL3NACkxyBa/qugjW/6duqZt/JB/Ukyd3e5ViAy6ZuQt9mKQ+2Por47MIwiu /PbNCw/K9UsDi3TAhkEdP20no8C5RxerFnhldPOBNs0MkJjl79pzWo5bhv6vVb7ZAZKl P3YWBTs1z8fgrJ0QzdpqjQRUwmLXlqIKW53xABdwHM6R7QcXxkFIqJMKRobWS/Y3fa/q O8J/gqydIILYkaTX1Gpgdiwgz8OCOvlFfw0+gAl3PdpkcTnk2dzYuVg/sTw0L2VPZ/vN TfQnnIvngC/mQXkhJEGi2Jlq4DcWcd03N8g/sMhFhiXoCAOKHlGvgBvGcqgBx5FlEp88 inig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TSCP7Kjs; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id af79cd13be357-7a1d74655f1si1601162385a.499.2024.07.31.13.03.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 13:03:43 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TSCP7Kjs; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6A1493858416 for ; Wed, 31 Jul 2024 20:03:43 +0000 (GMT) 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 589B13858283 for ; Wed, 31 Jul 2024 20:03:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 589B13858283 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 589B13858283 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::632 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722456208; cv=none; b=xk37XJ5l1dxBPM5RImBLOBcwR4IHQ65LoucU/kCizQMD/vbxVPFUFKOQ2EgoJJsqq2qfxXl1YpXSuY5qqtFm5HH+hC2Dtv7K0bJb8erUWUZaoIoBWxKwo4Wjtl/i9P33ICRKIRbX/hNnoSOUBILHRUBumktjxFfxi9GuNQV91B0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722456208; c=relaxed/simple; bh=5jiJmsfvQMHb7PuaooYFabjo3SJSxld3HJVCtpZR2ls=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=G3+ETeFFvalsvnl1U7APzaPC2D+omoFMATnX2iqjWicBpuvpXbPfpiPHsk6R3EFiTO8y61LytxT5Oo6a5LVzL6wgxvu1j7s4Gx8Z09owqB/vSWfwhJ8jz1yBeudxVTjH9A8Kfx/GNftBHw7UzBxSYgzuy+XwcKWhuH/VPMDlc3Q= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1fd9e70b592so42803825ad.3 for ; Wed, 31 Jul 2024 13:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722456203; x=1723061003; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Fgt9d5LP1LprzxcdzicBf+tjVmYkCVud6ErtxvVCba8=; b=TSCP7KjsaaPMO/FJGfugZB3tkes/rg1skOS+wnmI+Tpg0gfpcllFny6TeK39ZhRvHv wDx5lRY7UGOaD15LxzX5avVG/ONifCo5eKAI9hLgWEwE3tK1hKv9Stkq6vELsrElrXZF eKFtJodly4Vll69HR6yzZYvfbYa6dDm2x6OoZZa2imacOG8BrTrYKtgCDgUluIXUend6 Na1uRRTJ/xF/bWHYCzIis+gkLZojkdUxijTAWW8e7SFc2TpTAtV62pWOxkLKfHbC1wCx 9oHron2w7r3P7wKnr857MJsrqMZTAf2AMmR7YOSc+2iOaO7nnHA01DvzaXe+aj7IDeVx Vy/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722456203; x=1723061003; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Fgt9d5LP1LprzxcdzicBf+tjVmYkCVud6ErtxvVCba8=; b=DXXqSZlql1VN7NB8pe28UxnlG8IDcYEzxQNt/g7siatokfRDhlhhfWnEnfLfHBNjOG xXqD461IBAlAJgm6b8mZC/FgMN2uafGaz4p+DNFyVJI8hAJCvD9iY/ndCvvlpG1mUhzK 41n+CpKXv0s18J96y2FVX0+AtGe2mxeyNHo96pNfdMINlTcHPtZXYsRTt0zaoWIVcfJ9 Uyq6yj9ZstzaceX01QzpX1HO4Zy5hUs7ir9dvaU9GSvnzHCzydaver7JnYK0REijXl9i AJoppYlPtZtordNouyTQ5ovZ/UFr4Ipo9E8oeH0EHYfDNP6FneWUKi0Vy/pxKgrDFRlr PJSg== X-Gm-Message-State: AOJu0Yz2hFISuLaN5fZwrmRAeb63YYAU5cpEYDiSKlr8r3FizpHhqmSp ofd+0qRDwl5kVbliSVygjQQLAcsrCcX32WZl7theZEcI2njwP25C2BvyzNLjjZdddgGk2twOcUH z X-Received: by 2002:a17:903:28c3:b0:1fc:86cc:4254 with SMTP id d9443c01a7336-1ff4ceaefbcmr4207625ad.33.1722456203636; Wed, 31 Jul 2024 13:03:23 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:1944:b913:6070:fef0:3852]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7fbd8d4sm124106725ad.271.2024.07.31.13.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 13:03:22 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Stephen Roettger , Jeff Xu , Florian Weimer , Mike Hommey Subject: [PATCH v2 4/5] elf: Also parse gnu properties for static linked binaries Date: Wed, 31 Jul 2024 17:02:07 -0300 Message-ID: <20240731200307.2269811-5-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240731200307.2269811-1-adhemerval.zanella@linaro.org> References: <20240731200307.2269811-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patch=linaro.org@sourceware.org So the static binary can opt-out of memory sealing. Checked on x86_64-linux-gnu. --- elf/dl-support.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/elf/dl-support.c b/elf/dl-support.c index 8290a380f3..a02ae712b3 100644 --- a/elf/dl-support.c +++ b/elf/dl-support.c @@ -45,6 +45,7 @@ #include #include #include +#include #include extern char *__progname; @@ -336,6 +337,18 @@ _dl_non_dynamic_init (void) _dl_main_map.l_relro_size = ph->p_memsz; break; } + /* Process program headers again, but scan them backwards so + that PT_NOTE can be skipped if PT_GNU_PROPERTY exits. */ + for (const ElfW(Phdr) *ph = &_dl_phdr[_dl_phnum]; ph != _dl_phdr; --ph) + switch (ph[-1].p_type) + { + case PT_NOTE: + _dl_process_pt_note (&_dl_main_map, -1, &ph[-1]); + break; + case PT_GNU_PROPERTY: + _dl_process_pt_gnu_property (&_dl_main_map, -1, &ph[-1]); + break; + } call_function_static_weak (_dl_find_object_init);