From patchwork Fri Dec 16 02:13:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Harmstone X-Patchwork-Id: 33836 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp723739wrn; Thu, 15 Dec 2022 18:14:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf5MrF3UzHy9hO5CvnxIo/1gjiOR5X8UpoVDRv0k4ZBx4qx6HM8YHa2+oXJqVd3F2bTXTFyb X-Received: by 2002:a05:6402:4512:b0:45c:835c:c6ef with SMTP id ez18-20020a056402451200b0045c835cc6efmr21263881edb.32.1671156865495; Thu, 15 Dec 2022 18:14:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671156865; cv=none; d=google.com; s=arc-20160816; b=A0k9twU8QrJEBce1pVrGWB4+w8W0U0BXkFrtIPcAlaHJ5dvKV4eUdgJhNYc4kIaleO uvJTr+RfedH0ZNwiJDMsFZPNRDKNA5bCHMRnHED3JNOCXciF675HNvXfWmOQ9b6ujwYO Yq3XbmFQmiEh3Giep5IBYgHy3jApD1198PWRtH3KPIJWhM1RRPgbnReHipga2mFLHb82 QCgEtx2+AVx8g3vuMmUSHl4eD8K7t3Veknd6Bomdhx2QyONpRXIn9zivtsSQxnH+zeim lDPDgEbKmBjsNcgmHu/QZjScLPlKzeKGdFv1JwcIabdmLdfhOz6TwMiM8IhzowstQUVT zMew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:delivered-to; bh=RF+1W25QIo9y42E4xQl4Y4zUBqY/NC8+ZiWYZ01DBxY=; b=xd04gq1dmHTmI03kkwJIvfR7x8nq8b/jzlnyU1HGE0qffYx6AIULKNWRQj62jVRzV4 JutlMWkrzAgq2/rFClC3YGede3adFrxyrsEvKbaXg0GsowkmI+WTxOw9OK1ZUbgqwG1C dGr6llSy58dano4aMOWd4qSnrWuL0zMNsrShNFtWC3wlMKchNEKYRPB42/D87Ox6CjcA mcRW97u/Ys8gbEfjhNW92YbvuxDEOqACrnd+62Jo68LeU42twMbyD10EoyqsqmwYO1Ff sJ9De6yVFt01I8wUpg0/5m6bgMkHRXGO+f8+JZVOHEX4+70v/IO8bHyfE8vKrI9sRB/A 9oOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20210112 header.b=kHnJbdiv; 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" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id v12-20020a056402348c00b00461eb5cdcdcsi1250974edc.23.2022.12.15.18.14.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 18:14:25 -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=fail header.i=@gmail.com header.s=20210112 header.b=kHnJbdiv; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 55954382A234 for ; Fri, 16 Dec 2022 02:14:24 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id 7EE29382D3EB for ; Fri, 16 Dec 2022 02:14:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7EE29382D3EB Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=harmstone.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-x336.google.com with SMTP id ja17so936678wmb.3 for ; Thu, 15 Dec 2022 18:14:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=RF+1W25QIo9y42E4xQl4Y4zUBqY/NC8+ZiWYZ01DBxY=; b=kHnJbdivEGtseWBz9YHkLm1C2MK/hrE9FXEmmDVcNZkt5/AUSTgP7uilUduQeH4+ap Vh/UPz9MiMEIxq2mroSEkmv3zShqknFNqll6D5tWwycRG0izdUoOMYFsHSFKBOOZ2Rzv OIBcM2ImXYhT6DxsEnShVAW07TYMttwZe09Q+rDQVGwlHdY63vME4Uii7m9xrqs8OxvH jgUYVl2kUURDOfHRYOLFVtmcNELaDnDJdj2FjR9AExX8GNFwMc+cCh4QIdXNV3zILAXM 8YrVPtQ7fy6hj9y/ygUsHCGYEKlPgK0ge52AxEhfCs0QcBs7eoBsqdXgOElN6lNIaTuE Q4ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=RF+1W25QIo9y42E4xQl4Y4zUBqY/NC8+ZiWYZ01DBxY=; b=asfkKtkip8xTzqM1lT1MGAMFia/GXvuga8albTxdjpJjcPs00wJkV5HwRnF3FbJ8VB obVhmfJcw1fayr6e1VpO79w87xR73uR+vqWO+2xKnjQZiFE6F6yY2dZFwlPDO50dsZW6 afSDFEFx1VoZBKVn6n4XIJJAyYoLIC0XLSDeT4GhkTX/P/3LVwvKqwFJ8C4wd6/55R3i ugn+JePFxls3uVRZA0Hf8xGLu3wHuxaXjhlVlaiD9jDQKXU3unEQjc739CSt7K0mE+ua 7p1bmNZhnS6On6Oi2tuU3IUrv/BtFgqfLFLB+gNpx6X5oi6unxi172RDOedCiAemKW6e rZCw== X-Gm-Message-State: ANoB5pk6d46zFVBGBcH4Ksi8B0dBe+rPfZcGpe0SEoix3KrhTkyY72Uz knHryK+07ZLt7O3LCc47Qp7+cJhJd6A= X-Received: by 2002:a05:600c:2042:b0:3d2:3ae8:885b with SMTP id p2-20020a05600c204200b003d23ae8885bmr6868622wmg.28.1671156843781; Thu, 15 Dec 2022 18:14:03 -0800 (PST) Received: from beren.harmstone.com ([2a02:8010:64ea:0:8eb8:7eff:fe53:9d5f]) by smtp.gmail.com with ESMTPSA id s4-20020a5d5104000000b0024207ed4ce0sm883149wrt.58.2022.12.15.18.14.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 18:14:03 -0800 (PST) From: Mark Harmstone To: binutils@sourceware.org, wej22007@outlook.com, zac.walker@linaro.org Cc: Mark Harmstone Subject: [PATCH 1/5] Fix size of external_reloc for pe-aarch64 Date: Fri, 16 Dec 2022 02:13:56 +0000 Message-Id: <20221216021400.22309-1-mark@harmstone.com> X-Mailer: git-send-email 2.37.4 MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URI_TRY_3LD 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.29 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 Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752334981192209810?= X-GMAIL-MSGID: =?utf-8?q?1752334981192209810?= This patch series finishes off the work by Jedidiah Thompson, and adds support for creating aarch64 PE images. This should be essentially complete: I've used this to create a "hello world" Windows program in asm, and (with GCC patches) a UEFI program in C. I think the only things missing are the .secidx relocation, which is needed for PDBs, and the SEH pseudos used for C++ exceptions. This first patch fixes the size of RELSZ; I'm not sure why it was 14 in the first place. This is the size of the "Base Relocation Block" in https://learn.microsoft.com/en-us/windows/win32/debug/pe-format, and AFAIK should be 10 for everything. --- bfd/coff-aarch64.c | 4 ---- include/coff/aarch64.h | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/bfd/coff-aarch64.c b/bfd/coff-aarch64.c index 2c3e225a222..0faa75c63d2 100644 --- a/bfd/coff-aarch64.c +++ b/bfd/coff-aarch64.c @@ -188,10 +188,6 @@ coff_aarch64_rtype_lookup (unsigned int code) #define bfd_pe_print_pdata NULL #endif -/* Handle include/coff/aarch64.h external_reloc. */ -#define SWAP_IN_RELOC_OFFSET H_GET_32 -#define SWAP_OUT_RELOC_OFFSET H_PUT_32 - /* Return TRUE if this relocation should appear in the output .reloc section. */ diff --git a/include/coff/aarch64.h b/include/coff/aarch64.h index 100e08f18ef..b670f28bd3e 100644 --- a/include/coff/aarch64.h +++ b/include/coff/aarch64.h @@ -54,11 +54,10 @@ struct external_reloc char r_vaddr[4]; char r_symndx[4]; char r_type[2]; - char r_offset[4]; }; #define RELOC struct external_reloc -#define RELSZ 14 +#define RELSZ 10 /* ARM64 relocations types. */