From patchwork Mon Jan 1 11:53:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 184157 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp3926059dyb; Mon, 1 Jan 2024 03:53:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFxf82CNPs76ZgCodGDWQVLlWjhO1gcioH7tmEljFW4k7QeFZcX9+48aEHG4HhfBfBDQ01m X-Received: by 2002:a05:622a:5a89:b0:427:f260:486 with SMTP id fz9-20020a05622a5a8900b00427f2600486mr12619240qtb.63.1704110008626; Mon, 01 Jan 2024 03:53:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704110008; cv=pass; d=google.com; s=arc-20160816; b=em/9D4PZqO+nHlS7rn/Ct1p3RW9eGGbSZ6W1TtkbEBYLaZPXhYFsuFL0Br81bYndLu oZnPIxCfMalcEZUq9JlFM96pbUeVBbT01AHfeedy4meWQbiKhCbWevtuoFKPxDS1nFer Q8472w6iOvBx3I12dXAOYAcgDqZMzrdcwtRAgjTIJw4682jz2+MhDTxDvs71hI2mMBiO acXzu7zxgoIP7OXMwH5ijFql1gDkey7aUAONDGEfBhhfJQmwmUgUI77pSNF30TdVqgSY S931LK/z69p+sxsbtttwj7TcHlMwRq25OWX8zUl81vX7T4HJ+nlblBxPCUC94S1gfseN 3Kbw== 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:message-id:date:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=+pQNSWATafGw8Ze/HIshlOWeZDHl5NhC1II+sghQP8U=; fh=Xqqbql4Did+W9ZzqM7xwA/K7NbjwTHR7CWXqQlfUhgo=; b=z7PC0CdTyggX79Qh/oCc3XHiCeGOYEO1b5auiPNcE6H7+N+WlBU6pD+IlTxd71CuoM zf6GriLAZyQAW64DaZkCX6ky078dlE2RqysIvpY2GvaNhlda2CSQ7kn6l5d9kCtYWBuH j8BBBkr4ozLTBth9ieDg/BeK4QRaxvhW2EvwFcSFEGm61oVJ557v7ti5YOURqPlA3yox YuINrPpewwlvZrnFZmR5oTPQPHSbf811xZqeC6OCBKwBbjASEsZwLRt/JjUyzW0s+Jc1 EdYyjh5aeFVXAT3qPqkQDWOGhOAyH0COSVN2snBVao7pOuW8vR3a63OwcJV7P2NCF3tz Re5g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bccIxo6o; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id bp35-20020a05622a1ba300b004277efe2614si24711228qtb.463.2024.01.01.03.53.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 03:53:28 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bccIxo6o; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 317C23858420 for ; Mon, 1 Jan 2024 11:53:28 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by sourceware.org (Postfix) with ESMTPS id 79D093858D35 for ; Mon, 1 Jan 2024 11:53:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 79D093858D35 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 79D093858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704109998; cv=none; b=Y0788M2v2QMA+ilM8TXclxkzeJxoqwUTYm8xMP4GKwEf38pH/89FJ9G6yplx8d6RJb1Q5Yf3rKNCe4wXmB1NLEA59q+u0WYXHWQz+Ef/JQxn+2yUD0ahlJ5137SuFnI+y600L9qX24vYuPzNi76aW3h5qVWV7DWUwKbnTtw+fpo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704109998; c=relaxed/simple; bh=HxK8nJbT1glNtP8FDkkl6NeJXMYLlru6hiwAMRH/i+g=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ZQwDv9RFCnLEjaUp2DlBhBRF4CktJx/aqEnAF9z8Hm4gpFxRR8HRxM4ijrjomGCOpHmYY0gsufOaxfyX4vysQufgqi7kSddOpYcubG6+ynXpvT6SzPA1gg2mnRVu0E4RJKa90ZCEaQH3dtWqWZzTqpmspIwu3nkbMKhTUwi4anw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-50e7e1ddaddso6473314e87.3 for ; Mon, 01 Jan 2024 03:53:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704109991; x=1704714791; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=+pQNSWATafGw8Ze/HIshlOWeZDHl5NhC1II+sghQP8U=; b=bccIxo6oj9ri/b4VyA5dgMHc2xStvalOd6b7kvBSmeH+Zc6OPwkAG9V+8SIULzO2vW SDEydinI07Zpw0RA9amAzRepLLpfkG8AKVa4uhE+6M/rhXIDfwaeOZEgvSMu4c5ksziS JUpbLhIzKkQkhUOOSzDP4kZA0WcU0B0hwYK9zZgXw47kh5YfrecAXVFObeqdSDJlROXX mpP589b1GIMQb56zxL1ty7DRxGAvyMdZm4QcEivMukS8u3PJvJZpw3AXNxsaJxnHEuCR uXBRYEoUHrz5McBeLXfacAZjvvbEYhkqXAUWth4hwmP/83ebZJCYkL8dwToi+Jh3NxUl BeQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704109991; x=1704714791; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+pQNSWATafGw8Ze/HIshlOWeZDHl5NhC1II+sghQP8U=; b=vytUIGa4DWMEFr697S2rGCWatis58pBWQeFTqB7rqNy669YfPsXNyn2SzkJS6goJOC 2DcNx8WCKUGQVUEoeVBmqxkQsYAOPx9j8FY4/JOvWFN8uxA4mMsFvjEUsqgJuZRfNHqL +TTIAmojjWqB9cjHg4P6I1kNucDcEQR8zGefql9Xd9WmSdVMrusKBdOEfFKWJ2mT4BFE gfiGyrzwfgu4h7dqFgWIYUBnfaRG/CAoSbn2IjbPYdNMb4rZde2q6SvU+Bc+ZMVvPRB7 icjsONRlqLQBUCiZnIH59yxxM5F8ElgB5YL+6MpYfS2E7JfRtSMlGGaoZCyKLCyXqtei Ncgw== X-Gm-Message-State: AOJu0Yzcplm3n053OW+TsCOh5C6F30exf23zxLHx/rw6oRNzEqmTd/Aj K6Itg3K1fnBKCq/vzaGeEUh0iFZXFwU= X-Received: by 2002:a05:6512:3b8f:b0:50e:7c9b:85da with SMTP id g15-20020a0565123b8f00b0050e7c9b85damr5519935lfv.76.1704109991043; Mon, 01 Jan 2024 03:53:11 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:b32f:8da1:ad5a:e55a:5cb0]) by smtp.gmail.com with ESMTPSA id h14-20020a19ca4e000000b0050e84a3d75bsm1737801lfj.254.2024.01.01.03.53.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 03:53:10 -0800 (PST) From: Sergey Bugaev To: binutils@sourceware.org, bug-hurd@gnu.org Subject: [PATCH binutils] Add support for the aarch64-gnu target (GNU/Hurd on AArch64) Date: Mon, 1 Jan 2024 14:53:09 +0300 Message-ID: <20240101115309.614317-1-bugaevc@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 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, T_SCC_BODY_TEXT_LINE 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786888856343770933 X-GMAIL-MSGID: 1786888856343770933 Also recognized are aarch64-*-gnu tagrets, e.g. aarch64-pc-gnu or aarch64-unknown-gnu. The ld/emulparams/aarch64gnu.sh file is (for now) identical to aarch64fbsd.sh, or to aarch64linux.sh with Linux-specific logic removed; and mainly different from the generic aarch64elf.sh in that it does not set EMBEDDED=yes. Coupled with a corresponding GCC patch, this produces a toolchain that can sucessfully build working binaries targeting aarch64-gnu. Signed-off-by: Sergey Bugaev --- bfd/config.bfd | 2 +- gas/configure.tgt | 1 + ld/configure.tgt | 5 +++++ ld/emulparams/aarch64gnu.sh | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 ld/emulparams/aarch64gnu.sh diff --git a/bfd/config.bfd b/bfd/config.bfd index 4106924e..9f3d4d46 100644 --- a/bfd/config.bfd +++ b/bfd/config.bfd @@ -284,7 +284,7 @@ case "${targ}" in targ_selvecs="aarch64_elf64_be_vec aarch64_elf32_le_vec aarch64_elf32_be_vec arm_elf32_le_vec arm_elf32_be_vec" want64=true ;; - aarch64-*-linux* | aarch64-*-netbsd* | aarch64-*-nto*) + aarch64-*-linux* | aarch64-*-netbsd* | aarch64-*-nto* | aarch64-*-gnu*) targ_defvec=aarch64_elf64_le_vec targ_selvecs="aarch64_elf64_be_vec aarch64_elf32_le_vec aarch64_elf32_be_vec arm_elf32_le_vec arm_elf32_be_vec aarch64_pei_le_vec aarch64_pe_le_vec" want64=true diff --git a/gas/configure.tgt b/gas/configure.tgt index 3a582ef4..15c1ed3d 100644 --- a/gas/configure.tgt +++ b/gas/configure.tgt @@ -134,6 +134,7 @@ case ${generic_target} in case ${cpu}-${os} in aarch64*-linux-gnu_ilp32) arch=aarch64:32 ;; esac ;; + aarch64*-*-gnu*) fmt=elf em=gnu ;; aarch64*-*-netbsd*) fmt=elf em=nbsd;; aarch64*-*-nto*) fmt=elf;; aarch64*-*-openbsd*) fmt=elf;; diff --git a/ld/configure.tgt b/ld/configure.tgt index afd43032..211a2dee 100644 --- a/ld/configure.tgt +++ b/ld/configure.tgt @@ -116,6 +116,11 @@ aarch64-*-linux*) targ_emul=aarch64linux targ_extra_libpath="aarch64linuxb aarch64linux32 aarch64linux32b armelfb_linux_eabi armelf_linux_eabi" targ_extra_emuls="aarch64elf aarch64elf32 aarch64elf32b aarch64elfb armelf armelfb $targ_extra_libpath" ;; +# This has to come after aarch64-*-linux* for aarch64-*-linux-gnu to hit the Linux branch. +aarch64-*-gnu*) + targ_emul=aarch64gnu + targ_extra_emuls="aarch64elf aarch64elfb armelf armelfb" + ;; aarch64-*-haiku*) targ_emul=aarch64haiku targ_extra_emuls="aarch64elf aarch64elf32 aarch64elf32b aarch64elfb armelf armelfb armelf_haiku $targ_extra_libpath" ;; diff --git a/ld/emulparams/aarch64gnu.sh b/ld/emulparams/aarch64gnu.sh new file mode 100644 index 00000000..0bcab7a4 --- /dev/null +++ b/ld/emulparams/aarch64gnu.sh @@ -0,0 +1,37 @@ +ARCH=aarch64 +MACHINE= +NOP=0x1f2003d5 + +SCRIPT_NAME=elf +ELFSIZE=64 +OUTPUT_FORMAT="elf64-littleaarch64" +BIG_OUTPUT_FORMAT="elf64-bigaarch64" +LITTLE_OUTPUT_FORMAT="elf64-littleaarch64" +NO_REL_RELOCS=yes + +TEMPLATE_NAME=elf +EXTRA_EM_FILE=aarch64elf + +GENERATE_SHLIB_SCRIPT=yes +GENERATE_PIE_SCRIPT=yes + +MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" +COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" +SEPARATE_GOTPLT=24 +IREL_IN_PLT= + +TEXT_START_ADDR=0x400000 + +DATA_START_SYMBOLS='PROVIDE (__data_start = .);'; + +# AArch64 does not support .s* sections. +NO_SMALL_DATA=yes + +OTHER_BSS_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__bss_start__ = .${CREATE_SHLIB+)};" +OTHER_BSS_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}_bss_end__ = .${CREATE_SHLIB+)}; ${CREATE_SHLIB+PROVIDE (}__bss_end__ = .${CREATE_SHLIB+)};" +OTHER_END_SYMBOLS="${CREATE_SHLIB+PROVIDE (}__end__ = .${CREATE_SHLIB+)};" + +OTHER_SECTIONS='.note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }' +ATTRS_SECTIONS='.ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) }' +# Ensure each PLT entry is aligned to a cache line. +PLT=".plt ${RELOCATING-0} : ALIGN(16) { *(.plt)${RELOCATING+${IREL_IN_PLT+ *(.iplt)}} }"