From patchwork Mon Jan 16 13:29:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 44146 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1191964wrn; Mon, 16 Jan 2023 05:30:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXv1z+YS2x7DLpRZyHHdsBOAIh8IIlhP7VPAi9QNVqgGt5F5mnPC1LEQ8FE7Qd3KxYZF1tp7 X-Received: by 2002:a17:907:10d0:b0:85e:f910:71b6 with SMTP id rv16-20020a17090710d000b0085ef91071b6mr19111257ejb.51.1673875814090; Mon, 16 Jan 2023 05:30:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673875814; cv=none; d=google.com; s=arc-20160816; b=Ht4KUjBiPL4bC1lv0TaNWZBlO3K36Idhma77RnUYVYwiH7MWgfzpvnY6FMFNxRLp3G 0cl3iCK52w2VEXXBnD7iGVe6LOi+6i2S1UxWlxfaii8cJWlWcuG6qTMb2O7Cl9Wdydye G6VfnTmlDobL9t+Z3DRXDKW+fcDKp5d07FOF7ZL5BQPdLJcTi3wzY5EgS7pZCi3aUGiu L0FR3Q/4bAo7tLHkoajCSgc8tPV1hscqf7ApDtpUTWmvlFC6ftPD1UbTjl4j65rYSysv uM1A2B/KxJNBck7Dufuy6aFI2PT9nH3ImZ9AM4KAkb/7PhDcH1hXCVh15+Ip02bCt0Er Ij0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=tpnIshYFPOnkRsybS9qwewwOl/p9oBJ+jEwSnIy1kpY=; b=Adr9ZUospYKkwtUGHzQZHtr0VjrPsXuion/f16nJCQX4C1NdQEHsBwHDNHKUOS2887 DW15YqZWU9OFZ3662d0hg3L2iYdffp+gb2XgAUW99sCKc/AZu4D9lKEgakLUh3qNV+xk khcYN6aJGt/kMJQIru0G5a67WyuoDwO33frQiT4lfb2jCbsL+Dna+y2IcKKcIbv1wpYr LS0XOTPYSZIdO0PDREDS8ZeJnYRRxObrcOVyvEjtFO2qOAVJPALTTE6h+vYHMxS3TkoF 7ZRfqVoHTeW/dyDt0N5WNinncTOR7wUC7W5kKup7ysIFz6txPddM/seEivJ5WWdeihQ2 6yJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=rlN8Xhcm; 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=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id dr2-20020a170907720200b0087073de5aa3si3365676ejc.371.2023.01.16.05.30.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Jan 2023 05:30:14 -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=@sourceware.org header.s=default header.b=rlN8Xhcm; 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=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DA95D3858C2B for ; Mon, 16 Jan 2023 13:30:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DA95D3858C2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673875812; bh=tpnIshYFPOnkRsybS9qwewwOl/p9oBJ+jEwSnIy1kpY=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=rlN8XhcmK0GyTKrmBTFMQU0EV905s+43jgsg6JUsP/4jwem5Hg1nycw5Tg/S5PSI6 5eOPwbJQ1gP3R9MwvoQAfRAokMMeDFGEP5WAB+w6EeGaHALzvRAohFMevcTm1Ft6sG +CpJ0U2Priu7KuI2h/R993sQCWrD7TeKrML7q2Yw= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by sourceware.org (Postfix) with ESMTPS id BFBDC3858D32 for ; Mon, 16 Jan 2023 13:29:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BFBDC3858D32 Received: by mail-pl1-x62f.google.com with SMTP id d3so30314463plr.10 for ; Mon, 16 Jan 2023 05:29:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=tpnIshYFPOnkRsybS9qwewwOl/p9oBJ+jEwSnIy1kpY=; b=V1QrWkn4Gcim01jEQfUDi7+PzknJGKVXI+eKaL20HgqzAzm9aaIEybEO+IRzHpQNmx 0WTXT8GeytgsHRFpBGzsLgkkMCExBERlOVu/ZFV7MuvbM9tDDVM2J0vYzBk5Dm2qyzsz iPR9uKgrvm4Jrnpbj0g6fW89T/G837rKK1y8ZTsFERaFrlaayLrp53JBszO/Ve29iIq8 90ABMSI0qCKANe4jB0rjPQvNKG6gIN5gUHIIpWMwKL88iFRAW0cQ2ZNOo6V9WTwRePDi +xdqu/uhaV6VcGouUAp4KXKFHFjobME6jXScjW5FTtassZARWlJeCqCbC5LrWsZjqvX7 WotQ== X-Gm-Message-State: AFqh2krIkNR5DR2h55bXLPOXqhHxilEbcfK985Wzf58A8ZxquluwWsk5 PM1Wa1BNtgAXpb++pCSbNpOv2Y5Eq8s= X-Received: by 2002:a05:6a20:d006:b0:af:c491:c7d2 with SMTP id hu6-20020a056a20d00600b000afc491c7d2mr84589158pzb.29.1673875797794; Mon, 16 Jan 2023 05:29:57 -0800 (PST) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:303a:c9dc:cd1d:96a1]) by smtp.gmail.com with ESMTPSA id q18-20020a170902bd9200b00186b7443082sm19336954pls.195.2023.01.16.05.29.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Jan 2023 05:29:57 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id EC08F1140A04; Mon, 16 Jan 2023 23:59:54 +1030 (ACDT) Date: Mon, 16 Jan 2023 23:59:54 +1030 To: binutils@sourceware.org Cc: Mark Harmstone Subject: Correct ld-pe/aarch64.d test output Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3035.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: 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: , X-Patchwork-Original-From: Alan Modra via Binutils From: Alan Modra Reply-To: Alan Modra 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?1755186005936127303?= X-GMAIL-MSGID: =?utf-8?q?1755186005936127303?= "foo" is at 0x2010. This corrects the expected output for .long and .word referencing foo, showing a problem with relocation handling. Mark, the relocation special functions you added look like they only work for gas. They are also used by the linker when linking to another output format (which may not be supported by aarch64), and by objdump, eg. gas/testsuite/gas/aarch64/inst-directive. I've been poking at them over the last few days, and realized I don't know enough about what exactly goes into the addend fields stored in aarch64-pe relocatable object files to be able to fix the problems. Is is really a sensible addend with no symbol value confounding? Someone with access to existing aarch64-pe assemblers and linkers will need to do some digging, particularly in the case where a relocation is emitted against defined symbols like "foo" in ld-pe/aarch64a.s. I've also been looking again at bfd_perform_relocation and bfd_install_relocation. These functions grew the way they are to be compatible with old COFF and AOUT object file formats emitted by other linkers, and no one has been game to remove the hacks. One possibility that I may look into implementing is a flag in the reloc howto that asks for sane behaviour. * testsuite/ld-pe/aarch64.d: Correct expected output. diff --git a/ld/testsuite/ld-pe/aarch64.d b/ld/testsuite/ld-pe/aarch64.d index cc3daf9e9cd..eea52e10fe2 100644 --- a/ld/testsuite/ld-pe/aarch64.d +++ b/ld/testsuite/ld-pe/aarch64.d @@ -10,41 +10,41 @@ Disassembly of section .text: 0000000000002010 : 2010: 12345678 and w24, w19, #0xfffff003 2014: 12345678 and w24, w19, #0xfffff003 - 2018: 00002000 udf #8192 - 201c: 00002000 udf #8192 + 2018: 00002010 udf #8208 + 201c: 00002010 udf #8208 2020: 00002220 udf #8736 2024: 00002220 udf #8736 - 2028: 00002001 udf #8193 - 202c: 00002001 udf #8193 + 2028: 00002011 udf #8209 + 202c: 00002011 udf #8209 2030: 00002221 udf #8737 2034: 00002221 udf #8737 - 2038: 00001fff udf #8191 - 203c: 00001fff udf #8191 + 2038: 0000200f udf #8207 + 203c: 0000200f udf #8207 2040: 0000221f udf #8735 2044: 0000221f udf #8735 2048: 9abcdef0 .inst 0x9abcdef0 ; undefined 204c: 12345678 and w24, w19, #0xfffff003 2050: 9abcdef0 .inst 0x9abcdef0 ; undefined 2054: 12345678 and w24, w19, #0xfffff003 - 2058: 00002000 udf #8192 + 2058: 00002010 udf #8208 205c: 00000000 udf #0 - 2060: 00002000 udf #8192 + 2060: 00002010 udf #8208 2064: 00000000 udf #0 2068: 00002220 udf #8736 206c: 00000000 udf #0 2070: 00002220 udf #8736 2074: 00000000 udf #0 - 2078: 00002001 udf #8193 + 2078: 00002011 udf #8209 207c: 00000000 udf #0 - 2080: 00002001 udf #8193 + 2080: 00002011 udf #8209 2084: 00000000 udf #0 2088: 00002221 udf #8737 208c: 00000000 udf #0 2090: 00002221 udf #8737 2094: 00000000 udf #0 - 2098: 00001fff udf #8191 + 2098: 0000200f udf #8207 209c: 00000000 udf #0 - 20a0: 00001fff udf #8191 + 20a0: 0000200f udf #8207 20a4: 00000000 udf #0 20a8: 0000221f udf #8735 20ac: 00000000 udf #0