From patchwork Sat Oct 8 02:57:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: linted X-Patchwork-Id: 1687680 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=uclibc-ng.org (client-ip=89.238.66.15; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=Fq53w1pi; dkim-atps=neutral Received: from helium.openadk.org (helium.openadk.org [89.238.66.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Mkqbr1qDRz20Zg for ; Sat, 8 Oct 2022 13:57:42 +1100 (AEDT) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id 74A7435208EF; Sat, 8 Oct 2022 04:57:33 +0200 (CEST) Authentication-Results: helium.openadk.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=Fq53w1pi; dkim-atps=neutral Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by helium.openadk.org (Postfix) with ESMTPS id D00983520673 for ; Sat, 8 Oct 2022 04:57:28 +0200 (CEST) Received: by mail-pj1-f42.google.com with SMTP id b15so5818454pje.1 for ; Fri, 07 Oct 2022 19:57:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=U0AVmslnKg4f8vNJ9+fiZKQ41TMWYLoJpHmBrqKSlkw=; b=Fq53w1pin6Yipv1NTX4lBJdSf6WTxCvFWo1qGo5M2ISXg+QOazak26kc12E9Hqn4rE gzBF0lLMtv91SuaLfR50rAkYGnMVAM21xUSXWl9wAj7+dWE+QUURBlh5EwL0e2e+036R VhRBATgmeMF13nEvW7/whQ6nkdzu/e2PchkSfvxRMGw51V16DQDUiUgxiJ+TRSemcxZm Nw/mSxPf36TWNAKP35XDRXBPXIkGQBpJP2Ihgk7276Q8RywhLJp6h8GQNKl1XBLwQqo/ kgW0oMuZpU3/669QwO9CrIBJrdGvhAW1ZPtNyDeVA+9Qvicvtqgx+C9fANcjJJ0dWbDU 7cQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=U0AVmslnKg4f8vNJ9+fiZKQ41TMWYLoJpHmBrqKSlkw=; b=MY+K9Bax10HXRMfpGxp+KJV1lbVTf3PWhrG6oBH6miiQP10vwbLLhU0lp2lKZcsAor JhH1lt5OKDi6een0VyairV/B4v1khMBGndsUDMPxvAWmKxj7gfgfo59eemt0t6vQXvgP l1F0iSH+TTefrM0ixftL3tGbxh5ozkxFCGPhKycIMiqKuNpXRUsZP5MtavAkg8Xie4nR TO7OvHfzmWxnOjbE0KNh2UtwEza5RSCH6/xHYtYwB6ZBtxfzWuztTz8J7E4HcJ/TrT2K 6RMtz67LgmsFJXuWRd10ORmW2LgJiIgcPnY5At3XcpEY2iDy70JJGQx9zR8gUmZ9HmsL U47A== X-Gm-Message-State: ACrzQf3SNTvKCrSFy3xBC1c3u3Nt1v1N2iAhssJ3sgq2DJHX+tzyKnhE 5hD0fgIft9m+T434hEeNka3F4TBSmxSKHm34jGClaxOG8d4= X-Google-Smtp-Source: AMsMyM6e2GvBbXO9tsWv0XQaM0qnbmGlg0XU2ad/nY3gVJ/dh4uOB/wvFYWzSxdyHW2xpEJFN6xqlAH6U9HU0wmK5a4= X-Received: by 2002:a17:90b:38cc:b0:202:e0e8:e802 with SMTP id nn12-20020a17090b38cc00b00202e0e8e802mr8703887pjb.121.1665197846449; Fri, 07 Oct 2022 19:57:26 -0700 (PDT) MIME-Version: 1.0 From: linted Date: Fri, 7 Oct 2022 22:57:00 -0400 Message-ID: To: devel@uclibc-ng.org Message-ID-Hash: HZHK5CBTRNMTK3LDFFDCJQS2TKDA7G7C X-Message-ID-Hash: HZHK5CBTRNMTK3LDFFDCJQS2TKDA7G7C X-MailFrom: linted90@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list Subject: [uclibc-ng-devel] [PATCH] static pie support for ppc List-Id: uClibc-ng Development Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Hello, Attached is the patch for ppc to support static pie. --- From e49f829f923f6004ceacd547abb3179e9af4ac3e Mon Sep 17 00:00:00 2001 From: linted Date: Fri, 7 Oct 2022 22:49:12 -0400 Subject: [PATCH] Static pie support for ppc Modified config files and crt1.S to support static pie elf generation. Signed-off-by: linted --- extra/Configs/Config.in | 2 +- libc/sysdeps/linux/powerpc/crt1.S | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) pointer */ + lwzu r3, 0(r1) /* restore r3 */ + addi r1, r1, 4 /* update stack pointer */ + li r5, 0 /* zero r5 */ +#endif #endif /* Set up the small data pointer in r13. */ #ifdef __PIC__ From e49f829f923f6004ceacd547abb3179e9af4ac3e Mon Sep 17 00:00:00 2001 From: linted Date: Fri, 7 Oct 2022 22:49:12 -0400 Subject: [PATCH] Static pie support for ppc Modified config files and crt1.S to support static pie elf generation. Signed-off-by: linted --- extra/Configs/Config.in | 2 +- libc/sysdeps/linux/powerpc/crt1.S | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in index dd1beaadc..1c41d77ff 100644 --- a/extra/Configs/Config.in +++ b/extra/Configs/Config.in @@ -326,7 +326,7 @@ config STATIC_PIE default n depends on DOPIC && !UCLIBC_FORMAT_FDPIC_ELF && \ (TARGET_arm || TARGET_i386 || TARGET_x86_64 || TARGET_aarch64 || \ - TARGET_mips || TARGET_xtensa) + TARGET_mips || TARGET_xtensa || TARGET_powerpc) config ARCH_HAS_NO_SHARED bool diff --git a/libc/sysdeps/linux/powerpc/crt1.S b/libc/sysdeps/linux/powerpc/crt1.S index 3f5d056c0..3ac32636c 100644 --- a/libc/sysdeps/linux/powerpc/crt1.S +++ b/libc/sysdeps/linux/powerpc/crt1.S @@ -40,6 +40,9 @@ #ifndef __UCLIBC_CTOR_DTOR__ .weak _init .weak _fini +#endif +#ifdef L_rcrt1 + .type reloc_static_pie,%function #endif .type main,%function .type __uClibc_main,%function @@ -61,6 +64,22 @@ _start: # ifdef PPC_HAS_SECUREPLT mr 30,31 # endif +#ifdef L_rcrt1 + stwu r3, -4(r1) /* Save r3 */ + stwu r9, -16(r1) /* Save r9 */ + bcl 20,31,2f /* Jump to label 2 */ +2: mflr r3 /* Load lr into r3 */ + addis r3, r3, _DYNAMIC-2b@ha /* Add high half of _DYNAMIC to r3 */ + addi r3,r3,_DYNAMIC-2b@l /* Add low half of _DYNAMIC */ + lwz r4, 0(r31) /* load _DYNAMIC from the GOT */ + subf r3, r4, r3 /* sub _DYNAMIC@got and it's actual address */ + bl reloc_static_pie /* Call reloc_static_pie */ + lwzu r9, 0(r1) /* restore r9 */ + addi r1, r1, 16 /* update stack pointer */ + lwzu r3, 0(r1) /* restore r3 */ + addi r1, r1, 4 /* update stack pointer */ + li r5, 0 /* zero r5 */ +#endif #endif /* Set up the small data pointer in r13. */ #ifdef __PIC__ -- 2.34.1