From patchwork Mon Dec 2 06:36:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 102205 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 178FC3858CDB for ; Mon, 2 Dec 2024 06:37:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 178FC3858CDB Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=h4zmNfdE X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-yw1-x112d.google.com (mail-yw1-x112d.google.com [IPv6:2607:f8b0:4864:20::112d]) by sourceware.org (Postfix) with ESMTPS id D8FF23858D26 for ; Mon, 2 Dec 2024 06:37:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D8FF23858D26 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D8FF23858D26 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::112d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1733121439; cv=none; b=QXeABzhNZ+AqhJrSf8riPBOpv+6vfwEdcC/vSTHts3plIb+a+H7H/fi3QxOAaRPg00+b7gTTduC1Po0OrwYflw8fGutd5w7FaSvsSGM+OVu1Z4a9Uh3SnRLll2BhtZhG7itPdlbWAhuGmw3HQRFsfH+KY/QDJse007KRNNbKSBg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1733121439; c=relaxed/simple; bh=NMp9m4t9lilCg/eDl4NY8HaDxSRz+/c/t0/9f8YIk/M=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=k7gESIbFEod4kf6HrKzcPPd1mf+4K50H6nkHE/D28Ej4DIQKCQGG9ACPGihpOcg2OH7ILTZl4e/GpUUXSh8lOLmDxTk0hTrwgXr5luHlj8PPjk7CjOZNXA2pkLWS8dt8Dy0lZOc8OJUTriAT6mVWLhx6p94FcRhPfZVBg2YF7OI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D8FF23858D26 Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-6ef6e339406so14425877b3.1 for ; Sun, 01 Dec 2024 22:37:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733121438; x=1733726238; darn=sourceware.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=pQq2CszcwfQWS5cCmaWqQM5KKnNzWKc/RxV7xG9P7aY=; b=h4zmNfdEO949IKKnjap7Ni12YajN0hcMx8puVcEoO2tWHugLCrKb/VKOYs51vBphAV 8TQXA0Nd23YQAiUkP6Ny2QBNKX2Usnb0r31U9r/LAIFgZPIMS5zHaDDR1SIp2f5hBXqg hIfnaSlHCxFZdi1SyZibLFhAfQlmMU0PgfVMAb1Znp+wxdkCiy0pRlUe4tr18BcPqgih ZjkjXhIbgIc5xCAEd8IdbhEHq9kncf0GdfHC4jqVIlLAg45Q5ryhkL125uhkXBw5FSOx iSLn4RC+NEbUGi5nzisYqrqWBHMFDUTOeIFo4e4hE5EPhbdMrfWJExFbNJV/two5XlkE cEDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733121438; x=1733726238; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pQq2CszcwfQWS5cCmaWqQM5KKnNzWKc/RxV7xG9P7aY=; b=SW0mHuTVYNzaZlrSNNFM5XhTB/pU1ByBXHuMvkbTtuS+zP2MqYlWgQbp5YgpAZDVGA MXMr1jVSawyArONV7lVYjot9JwMuTe7oToyikPgtOCsjNZ+Bt0BVCtHQu/tsXg/fwB07 ZSckVa4OcK6d+G87On1BuYbUAsLZs4cIuhtbnMzP0hP6r1WF9OSDh8cbWM9NlqPkCaPV 2kdVtTLuO6FiNtbgosmtPWWoJhtRNlleVjC0amugFx2iz3uQX5bx9NdlG9uiFJdwUHJi MesTiS3yHJpLsKgjjz+Ka/hSRn9EgoeFW58YDvl/JC230I8eZFCnUwvw6UOT/tKWUeZB cjqA== X-Forwarded-Encrypted: i=1; AJvYcCWzsKQsVGKwljYeixAbHv6mZTfl+hMS6VzDjpsmf5UlWPXb5oR51ZtflOSk33GZzuj7QPMC+PUQosgt@sourceware.org X-Gm-Message-State: AOJu0YxUjBsmhBp1jb5NOaHNZJvjXuGZTS/LkGzBKuH5ICcPCjDkcdSv bbPfgakmpS4wCOE0a95DgOinZC+BDd9UEBaQgp1m1kMUjUtrqeK1bBdEiyslXu9mqJ48Iju5v05 FDPSCohrGQz4XVC2AP4STLveKVqJQDS9fva3KnE1z X-Gm-Gg: ASbGncs7DsHZvoxkk0Djp5/jr9WA4E+D5WU+J/BYGZP7ec18gk03lypevZljlmffPcM AkfXuKq6wM60CqH2gQApkVlRXmz450qzy X-Google-Smtp-Source: AGHT+IHH5rxEUOrKCj05pxBBHz5VELP3i4Kv5a7ZPfxjlau9fHg0zThNEuQvftzJuXQQWHroaKbsv341VpQa+GtkzD0= X-Received: by 2002:a05:690c:4908:b0:6ef:8122:282f with SMTP id 00721157ae682-6ef81222ae5mr49220967b3.24.1733121438121; Sun, 01 Dec 2024 22:37:18 -0800 (PST) MIME-Version: 1.0 References: <20240527143803.3550703-1-hjl.tools@gmail.com> <20240527143803.3550703-2-hjl.tools@gmail.com> <87iks6kmn0.fsf@oldenburg.str.redhat.com> In-Reply-To: From: "H.J. Lu" Date: Mon, 2 Dec 2024 14:36:41 +0800 Message-ID: Subject: [PATCH] elf: Check PDE load address with non-empty text section To: Florian Weimer Cc: Noah Goldstein , GNU C Library , "Carlos O'Donell" X-Spam-Status: No, score=-3017.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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~patchwork=sourceware.org@sourceware.org On Mon, Dec 2, 2024 at 9:15 AM H.J. Lu wrote: > > On Sat, Nov 30, 2024 at 12:18 PM H.J. Lu wrote: > > > > On Sat, Nov 30, 2024, 12:52 AM Florian Weimer wrote: > >> > >> * H. J. Lu: > >> > >> > +ifneq (,$(load-address-ldflag)) > >> > +tests += \ > >> > + tst-pie-address \ > >> > + # tests > >> > +tests-pie += \ > >> > + tst-pie-address \ > >> > + # tests-pie > >> > +LDFLAGS-tst-pie-address += $(load-address-ldflag)=$(pde-load-address) > >> > +ifeq (yes,$(enable-static-pie)) > >> > +tests += \ > >> > + tst-pie-address-static \ > >> > + # tests > >> > +tests-static += \ > >> > + tst-pie-address-static \ > >> > + # tests-static > >> > +LDFLAGS-tst-pie-address-static += \ > >> > + $(load-address-ldflag)=$(pde-load-address) > >> > +endif > >> > +endif > >> > >> These tests fail on aarch64 and s390x for us: > >> > >> =====FAIL: elf/tst-pie-address.out===== > >> =====FAIL: elf/tst-pie-address.test-result===== > >> FAIL: elf/tst-pie-address > >> original exit status 139 > >> =====FAIL: elf/tst-pie-address-static.out===== > >> =====FAIL: elf/tst-pie-address-static.test-result===== > >> FAIL: elf/tst-pie-address-static > >> original exit status 132 > > > > > > Do they fail without -Ttext-segment=? My change doesn't > > touch dynamic PIE. If it fails, it may be due to glibc or ld bugs. > > > >> > >> The configure checks report this > >> > >> checking whether -fPIE is default... no > >> checking PDE load address... 0x0000000001000000 > > Somehow aarch64 got > > pde-load-address = > > in config.make. I will take a look. > Does this patch it for you? Check PDE load address with non-empty text section: .globl _start _start: .globl __start .byte 0 From abc2604d98bfcb28fc8fb4095c73140fe48e24e4 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 2 Dec 2024 14:22:46 +0800 Subject: [PATCH] elf: Check PDE load address with non-empty text section Check PDE load address with non-empty text section: .globl _start _start: .globl __start .byte 0 Signed-off-by: H.J. Lu --- configure | 1 + configure.ac | 1 + 2 files changed, 2 insertions(+) diff --git a/configure b/configure index 9bcf62dca5..0e42f21926 100755 --- a/configure +++ b/configure @@ -8122,6 +8122,7 @@ else case e in #( _start: .globl __start __start: + .byte 0 EOF if test $libc_cv_cc_pie_default = yes; then pde_ld_flags="-no-pie" diff --git a/configure.ac b/configure.ac index 895bd5267d..02339a0a4c 100644 --- a/configure.ac +++ b/configure.ac @@ -1774,6 +1774,7 @@ cat > conftest.S <