From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id iOMJELuxjGjaoAEAWB0awg (envelope-from ) for ; Fri, 01 Aug 2025 08:23:23 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=google header.b=ZwLIFdCp; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 2D23E1E102; Fri, 1 Aug 2025 08:23:23 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-9.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 19DF11E091 for ; Fri, 1 Aug 2025 08:23:22 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 45E203858CDA for ; Fri, 1 Aug 2025 12:23:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 45E203858CDA Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=google header.b=ZwLIFdCp Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 1289D3858D20 for ; Fri, 1 Aug 2025 12:20:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1289D3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1289D3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1754050857; cv=none; b=LQ9KlzsHpET1m+6Iw+lApZnFQyBNy4Iyo3PFbw1LecUL3IlLyiRmzRVFHMSVpdsEYNBYbgDNCF1EqK6yKrpR+jPlHsJT4t1ZmwJZj0sBvmIgIfSfpRgz+3L3Qz4eAP8Jbhe+HHrXYNnYR103ghCazOYXIKjQ4ZOPsCjNb4kkDGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1754050857; c=relaxed/simple; bh=CJP0TcOrOoe5N73G53EVXNCKGGOwGhj6v3BFoK5kTEI=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=YIvs+hLMHUfyYyymeKLGpQcqd9L95Pemd52aQb1BEa/mt+NSf+qudQ2ymwJCDYjRfFdTZsWnYLmh/llE13v3PgSSupKZX2PJ8vBLsJOpZb2mQ6obFJN16Hcvu+puF0LzixF9tmh4rbqOZVWng1YCRNor68zcSMegQZ35j+iObo8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1289D3858D20 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3b77b8750acso1228988f8f.0 for ; Fri, 01 Aug 2025 05:20:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1754050856; x=1754655656; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:cc :content-language:references:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=6jgF5QXQnl8kR9ByUoXpzjmp2TlUgHA4sySv9b3/mn0=; b=ZwLIFdCp1Ug3tINvYR23X/uF3qUQzwTfcfU+76xUp8W+twA0W/RiXOgMtG2O+S5Wwz oQcTfzP5bELkaRUm2I4kdGjVbeZWDggnBpdcJlwWTk2YxByNmi0s/Ay/mPUd+dIbJ+YQ Q/m4oTz8233jLaNFLXwrmHTMBU7jIhobQsb2DhITGhCaL88BT6QA+HDIz1pfchpKCr+9 6MyplsAYY1OHqPQCcMlejKge8Me3MjvgkQ+VKv+qcdKwe4tv91hzZjSTU2sQeYEqik2Z RgRsvQT9vhgCHwAfg7YKbQa+sQb9QmcfwNXcPtW0N2f6zMAU5BFnET1CqwzQuytAP6jb x0Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754050856; x=1754655656; h=content-transfer-encoding:in-reply-to:autocrypt:from:cc :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6jgF5QXQnl8kR9ByUoXpzjmp2TlUgHA4sySv9b3/mn0=; b=g4C3XbphYctuk8uep1F3V5RbdfhYGv0jSNXFew7nzmzzaGTCYddaUYQO2kBNXhGXnf y/w5Fykd+yFQx1FmC6Nt2ySeYiyDTJ7ZyNe86ceylVq8Dk3PWLvpGwfVssGuQZIoFAkG kaCzxMtqbsUf1XcU2WOEYZZmw2iCH39tURvUT73lds4wOZGZm01SH6CHMsJm2MXbSgKm FwAsHq+p84Jf2Fs8KIrYX+lM/tyDRdvTV9ZmsgRaaR3VF4xew7tV9/WvAtqPcNfO+OoI ApwENQKZY7FMQ/zvfiZJbl2A7hvh7rjcNIcpXDi7PXPY70xXxE+bLt3Mcy32ojwJUkzG TV6w== X-Gm-Message-State: AOJu0YzhK0jHrvGRaqU7Of+T68cxGr6QxfhilLUkNcACuJ8QwXH8+vPT u9jRhuP+L1HFPbrlocHK6Elys1LdtQhB2xJNaNHmFoCXo2AlspfMO49JCZjYmYKH02YccoPa8aG Wgec= X-Gm-Gg: ASbGncs4wHJVIMEaeU4HoyKUlZLBGICGrR3yr04WMKVbT7PjY4UUrQYYcslyZ5OxMPP SPmOjT2oJ0TfvuTYBuy2K7cvT5wBuBWmoRfHbgWg9IRSoNDDQqtDEubwnw8JKvEQuhIREqAfbBe 3Efb3yesEt11R4c7dKn3f/gm8c6s1tYAcct2IVyQFByaPA7VkpVfWzu6hGiY/N2WourvWHUbmBS QxbdwkH+uU6qzzOEJV5i21DMCyQi33eib9ztHux3eovGmbls8sDl+/ZZR/aKCzKE0eWOYbIunAO JwjofPAOHZLXvcd94kI66kevuX1yTC9EsUJOJim/fySoZ4jtsSgl2MSRwn6NpyGBVmC0S1x79AV zoHLACljpcGrOjXR79nOqktu6TEwBfd6Q8dAiFYwtGKNYyIjesh0+mISVDeld+wCccZziWfCdvA B9nSEawoA= X-Google-Smtp-Source: AGHT+IELiI+FaNOVPDmuvy3Z1lpYBzDVpAEOJrSu5Z1PV9EojIIM9irp0i58uoHRIQ4/2K7QPFKMZA== X-Received: by 2002:a05:6000:2dc2:b0:3b7:908e:e4ac with SMTP id ffacd0b85a97d-3b79d42097dmr4679869f8f.2.1754050855650; Fri, 01 Aug 2025 05:20:55 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-31f63ee0e0fsm7243703a91.17.2025.08.01.05.20.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 Aug 2025 05:20:55 -0700 (PDT) Message-ID: Date: Fri, 1 Aug 2025 14:20:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 02/44] bfd: add intelgt target to BFD To: Tankut Baris Aktemur , Markus Metzger References: <20250801-upstream-intelgt-mvp-v3-0-59ce0f87075b@intel.com> <20250801-upstream-intelgt-mvp-v3-2-59ce0f87075b@intel.com> Content-Language: en-US Cc: gdb-patches@sourceware.org, binutils@sourceware.org From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <20250801-upstream-intelgt-mvp-v3-2-59ce0f87075b@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 01.08.2025 11:37, Tankut Baris Aktemur wrote: > --- a/bfd/config.bfd > +++ b/bfd/config.bfd > @@ -198,6 +198,7 @@ fido*) targ_archs=bfd_m68k_arch ;; > hppa*) targ_archs=bfd_hppa_arch ;; > i[3-7]86) targ_archs=bfd_i386_arch ;; > ia16) targ_archs=bfd_i386_arch ;; > +intelgt) targ_archs=bfd_intelgt_arch ;; > kvx) targ_archs=bfd_kvx_arch ;; > loongarch*) targ_archs=bfd_loongarch_arch ;; > m6811*|m68hc11*) targ_archs="bfd_m68hc11_arch bfd_m68hc12_arch bfd_m9s12x_arch bfd_m9s12xg_arch" ;; > @@ -705,12 +706,12 @@ case "${targ}" in > ;; > x86_64-*-linux-*) > targ_defvec=x86_64_elf64_vec > - targ_selvecs="i386_elf32_vec iamcu_elf32_vec x86_64_elf32_vec i386_pei_vec x86_64_pe_vec x86_64_pei_vec" > + targ_selvecs="i386_elf32_vec iamcu_elf32_vec x86_64_elf32_vec i386_pei_vec x86_64_pe_vec x86_64_pei_vec intelgt_elf64_vec" > want64=true > ;; > x86_64-*-mingw* | x86_64-*-pe | x86_64-*-pep | x86_64-*-cygwin) > targ_defvec=x86_64_pe_vec > - targ_selvecs="x86_64_pe_vec x86_64_pei_vec x86_64_pe_big_vec x86_64_elf64_vec i386_pe_vec i386_pei_vec i386_elf32_vec iamcu_elf32_vec pdb_vec" > + targ_selvecs="x86_64_pe_vec x86_64_pei_vec x86_64_pe_big_vec x86_64_elf64_vec i386_pe_vec i386_pei_vec i386_elf32_vec iamcu_elf32_vec pdb_vec intelgt_elf64_vec intelgt_legacy_elf64_vec" > want64=true > targ_underscore=no > ;; I'm not convinced of forcing this as secondary target onto (about) everyone. > @@ -781,7 +782,13 @@ case "${targ}" in > targ_defvec=i386_elf32_vec > targ_selvecs="i386_msdos_vec i386_aout_vec" > ;; > - Please don't remove the (visually) separating blank lines; instead add a new one yourself. > +#ifdef BFD64 > + intelgt-*-elf) > + targ_defvec=intelgt_elf64_vec > + targ_selvecs="intelgt_elf64_vec" Why would targ_selvecs need to hold what targ_defvec already has? > --- /dev/null > +++ b/bfd/elf64-intelgt.c > @@ -0,0 +1,195 @@ > +/* Intel(R) Graphics Technology-specific support for ELF > + Copyright (C) 2022-2025 Free Software Foundation, Inc. > + > + This file is part of BFD, the Binary File Descriptor library. > + > + This program is free software; you can redistribute it and/or modify > + it under the terms of the GNU General Public License as published by > + the Free Software Foundation; either version 3 of the License, or > + (at your option) any later version. > + > + This program is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + GNU General Public License for more details. > + > + You should have received a copy of the GNU General Public License > + along with this program; if not, write to the Free Software > + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, > + MA 02110-1301, USA. */ > + > +#include "sysdep.h" > +#include "bfd.h" > +#include "libbfd.h" > +#include "elf-bfd.h" > + > +#include "elf/common.h" > +#include "elf/intelgt.h" > + > +#define MINUS_ONE (~ (bfd_vma) 0) > + > +#define INTELGT_ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) What's wrong with ARRAY_SIZE()? > +static bool > +elf64_intelgt_elf_object_p (bfd *abfd) > +{ > + return bfd_default_set_arch_mach (abfd, bfd_arch_intelgt, bfd_mach_intelgt); > +} > + > +/* Map BFD relocs to the IntelGT relocs. */ > +struct elf_reloc_map > +{ > + bfd_reloc_code_real_type bfd_reloc_val; > + unsigned char elf_reloc_val; > +}; > + > +static const struct elf_reloc_map elf64_intelgt_reloc_map[] = > +{ > + { BFD_RELOC_64, R_ZE_SYM_ADDR }, > + { BFD_RELOC_32, R_ZE_SYM_ADDR_32 }, > + { BFD_RELOC_ZE_SYM_ADDR32_HI, R_ZE_SYM_ADDR32_HI }, > + { BFD_RELOC_ZE_PER_THREAD_PAYLOAD_OFFSET_32, > + R_PER_THREAD_PAYLOAD_OFFSET_32 }, > +}; > + > +static reloc_howto_type elf64_intelgt_howto_table[] = > +{ > + HOWTO (R_ZE_NONE, /* type */ > + 0, /* rightshift */ > + 0, /* size (0 = byte, 1 = short, 2 = long) */ > + 0, /* bitsize */ > + false, /* pc_relative */ > + 0, /* bitpos */ > + complain_overflow_dont,/* complain_on_overflow */ > + NULL, /* special_function */ > + "R_ZE_NONE", /* name */ > + false, /* partial_inplace */ > + 0, /* src_mask */ > + 0, /* dst_mask */ > + false), /* pcrel_offset */ > + HOWTO (R_ZE_SYM_ADDR, /* type */ > + 0, /* rightshift */ > + 2, /* size (0 = byte, 1 = short, 2 = long) */ > + 64, /* bitsize */ > + false, /* pc_relative */ > + 0, /* bitpos */ > + complain_overflow_unsigned, /* complain_on_overflow */ > + bfd_elf_generic_reloc, /* special_function */ > + "R_ZE_SYM_ADDR", /* name */ > + false, /* partial_inplace */ > + MINUS_ONE, /* src_mask */ Based on the arch apparently using RELA relocations, src_mask shouldn't be non-zero anywhere aiui. > + MINUS_ONE, /* dst_mask */ While for a 64-bit reloc this looks right, ... > + false), /* pcrel_offset */ > + HOWTO (R_ZE_SYM_ADDR_32, /* type */ > + 0, /* rightshift */ > + 2, /* size (0 = byte, 1 = short, 2 = long) */ > + 32, /* bitsize */ > + false, /* pc_relative */ > + 0, /* bitpos */ > + complain_overflow_unsigned, /* complain_on_overflow */ > + bfd_elf_generic_reloc, /* special_function */ > + "R_ZE_SYM_ADDR_32", /* name */ > + false, /* partial_inplace */ > + MINUS_ONE, /* src_mask */ > + MINUS_ONE, /* dst_mask */ ... I don't think it's right here. I'm also unconvinced of the use of complain_overflow_unsigned, when ... > + false), /* pcrel_offset */ > + HOWTO (R_ZE_SYM_ADDR32_HI, /* type */ > + 32, /* rightshift */ > + 2, /* size (0 = byte, 1 = short, 2 = long) */ > + 32, /* bitsize */ > + false, /* pc_relative */ > + 0, /* bitpos */ > + complain_overflow_unsigned, /* complain_on_overflow */ > + bfd_elf_generic_reloc, /* special_function */ > + "R_ZE_SYM_ADDR32_HI", /* name */ > + false, /* partial_inplace */ > + MINUS_ONE, /* src_mask */ > + MINUS_ONE, /* dst_mask */ > + false), /* pcrel_offset */ ... the other half of the address can be represented this way. > --- a/binutils/readelf.c > +++ b/binutils/readelf.c > @@ -124,6 +124,7 @@ > #include "elf/kvx.h" > #include "elf/lm32.h" > #include "elf/iq2000.h" > +#include "elf/intelgt.h" > #include "elf/m32c.h" > #include "elf/m32r.h" > #include "elf/m68k.h" > @@ -2395,6 +2396,10 @@ dump_relocations (Filedata * filedata, > case EM_AMDGPU: > rtype = elf_amdgpu_reloc_type (type); > break; > + > + case EM_INTELGT: > + rtype = elf_intelgt_reloc_type (type); > + break; > } > > if (rtype == NULL) > @@ -15589,6 +15594,8 @@ is_32bit_abs_reloc (Filedata * filedata, unsigned int reloc_type) > return reloc_type == 1; /* R_XTENSA_32. */ > case EM_Z80: > return reloc_type == 6; /* R_Z80_32. */ > + case EM_INTELGT: > + return reloc_type == 2; /* R_ZE_SYM_ADDR_32 */ Not sure here as well, when this can be the lower half of a 64-bit address. > --- /dev/null > +++ b/include/elf/intelgt.h > @@ -0,0 +1,39 @@ > +/* Copyright (C) 2022-2025 Free Software Foundation, Inc. > + > + This file is part of BFD, the Binary File Descriptor library. > + > + This program is free software; you can redistribute it and/or modify > + it under the terms of the GNU General Public License as published by > + the Free Software Foundation; either version 3 of the License, or > + (at your option) any later version. > + > + This program is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + GNU General Public License for more details. > + > + You should have received a copy of the GNU General Public License > + along with this program; if not, write to the Free Software > + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, > + MA 02110-1301, USA. */ > + > +/* This file holds definitions specific to the IntelGT ABI. */ > + > +#ifndef __INTELGT_H_ > +#define __INTELGT_H_ > + > +#include "elf/reloc-macros.h" > + > +START_RELOC_NUMBERS (elf_intelgt_reloc_type) > + RELOC_NUMBER (R_ZE_NONE, 0) > + /* 64-bit address. */ > + RELOC_NUMBER (R_ZE_SYM_ADDR, 1) > + /* 32-bit address or lower 32-bit of a 64-bit address. */ > + RELOC_NUMBER (R_ZE_SYM_ADDR_32, 2) > + /* Higher 32bits of a 64-bit address. */ > + RELOC_NUMBER (R_ZE_SYM_ADDR32_HI, 3) > + /* 32-bit field of payload offset of per-thread data. */ > + RELOC_NUMBER (R_PER_THREAD_PAYLOAD_OFFSET_32, 4) Why is this not R_ZE_PER_THREAD_PAYLOAD_OFFSET_32? Jan