From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.86_2) id 1hkpqI-0003FQ-EO for mharc-grub-devel@gnu.org; Tue, 09 Jul 2019 09:07:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41332) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkkEh-0005ZX-7o for grub-devel@gnu.org; Tue, 09 Jul 2019 03:08:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkkEg-0001f9-7T for grub-devel@gnu.org; Tue, 09 Jul 2019 03:08:23 -0400 Received: from m9a0001g.houston.softwaregrp.com ([15.124.64.66]:44283) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hkkEg-0001TO-0m for grub-devel@gnu.org; Tue, 09 Jul 2019 03:08:22 -0400 Received: FROM m9a0001g.houston.softwaregrp.com (15.121.0.191) BY m9a0001g.houston.softwaregrp.com WITH ESMTP FOR grub-devel@gnu.org; Tue, 9 Jul 2019 07:08:20 +0000 Received: from M4W0335.microfocus.com (2002:f78:1193::f78:1193) by M9W0068.microfocus.com (2002:f79:bf::f79:bf) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Tue, 9 Jul 2019 07:06:46 +0000 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (15.124.8.10) by M4W0335.microfocus.com (15.120.17.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10 via Frontend Transport; Tue, 9 Jul 2019 07:06:46 +0000 Received: from BY5PR18MB3283.namprd18.prod.outlook.com (10.255.139.203) by BY5PR18MB3282.namprd18.prod.outlook.com (10.255.138.79) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2052.18; Tue, 9 Jul 2019 07:06:45 +0000 Received: from BY5PR18MB3283.namprd18.prod.outlook.com ([fe80::b587:8197:fcb2:bcd8]) by BY5PR18MB3283.namprd18.prod.outlook.com ([fe80::b587:8197:fcb2:bcd8%6]) with mapi id 15.20.2052.019; Tue, 9 Jul 2019 07:06:45 +0000 From: Chester Lin To: "grub-devel@gnu.org" Subject: Re: [PATCH] riscv: fix computation of pc-relative relocation offset Thread-Topic: [PATCH] riscv: fix computation of pc-relative relocation offset Thread-Index: AQHVNiTednw1hpTNo0WuoPz0B3ht0A== Date: Tue, 9 Jul 2019 07:06:45 +0000 Message-ID: <20190709070627.GA1465@linux-8mug> In-Reply-To: Accept-Language: zh-TW, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: DB6PR05CA0010.eurprd05.prod.outlook.com (2603:10a6:6:14::23) To BY5PR18MB3283.namprd18.prod.outlook.com (2603:10b6:a03:196::11) authentication-results: spf=none (sender IP is ) smtp.mailfrom=chester.lin@suse.com; x-originating-ip: [202.47.205.198] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 717ed119-1dd9-45fb-3d33-08d7043c008c x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:BY5PR18MB3282; x-ms-traffictypediagnostic: BY5PR18MB3282: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6430; x-forefront-prvs: 0093C80C01 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(7916004)(366004)(39860400002)(136003)(396003)(376002)(346002)(189003)(199004)(44832011)(66066001)(3846002)(476003)(7736002)(68736007)(25786009)(11346002)(14454004)(6116002)(486006)(2501003)(33656002)(2351001)(478600001)(71190400001)(2906002)(5660300002)(71200400001)(52116002)(81166006)(102836004)(66446008)(26005)(66946007)(6506007)(6512007)(256004)(66476007)(53546011)(64756008)(186003)(66556008)(81156014)(5640700003)(99286004)(9686003)(6436002)(8676002)(386003)(53936002)(6246003)(305945005)(73956011)(229853002)(316002)(86362001)(6916009)(6486002)(33716001)(1076003)(8936002); DIR:OUT; SFP:1102; SCL:1; SRVR:BY5PR18MB3282; H:BY5PR18MB3283.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: suse.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: izCTo+N6OvZEUOd7C0FEXCLKIWWCqEZS52WRkBr3pmZ/jaGWl8rfxOz67cEtjZBrj85NXSbMyVCP4MBqDZwca6o2g3xQYLzO5ewL3MNOcBLpwWbITMcMIwsR5rETrzKQKBwitV394l5+bg0xRE14wnKB+3SpGsq3zFg+ZgWGTeRSYCVWU4XSwaadT3gaLEDC9AlgcKUGlTlf5FDB6OZG/rUVnxzg6g8QMWInPfEU4v+M0FXCwDyn4orlDDzZvf7ProU1h2Ja1ttZyTZ4+2RVvlZdJ3G3Pf+KFd5JMlFtGYd83of4U1Kld7kix1d2MUaOVkOafazDGl4uy/vBA808sgzjAgX70js7WC3NkzmnTLSeHBjJfJnhdKJW0BVrerzeNWK01HvRgGvNNSOqWL/UJvSUuICsnZMizLejROlmB90= Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 717ed119-1dd9-45fb-3d33-08d7043c008c X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jul 2019 07:06:45.1842 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 856b813c-16e5-49a5-85ec-6f081e13b527 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: chester.lin@suse.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR18MB3282 X-OriginatorOrg: suse.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 15.124.64.66 X-Mailman-Approved-At: Tue, 09 Jul 2019 09:07:33 -0400 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jul 2019 07:08:24 -0000 On Wed, Jun 26, 2019 at 16:50:03 +0200, Andreas Schwab wrote: > The offset calculation was missing the relocation addend. >=20 > Signed-off-by: Andreas Schwab > --- > util/grub-mkimagexx.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c > index bc087c2b5..d16ec63a1 100644 > --- a/util/grub-mkimagexx.c > +++ b/util/grub-mkimagexx.c > @@ -1232,8 +1232,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct sectio= n_metadata *smd, > grub_uint32_t *t32 =3D (grub_uint32_t *) target; > grub_uint16_t *t16 =3D (grub_uint16_t *) target; > grub_uint8_t *t8 =3D (grub_uint8_t *) target; > - grub_int64_t off =3D (long)sym_addr - target_section_addr - offset > - - image_target->vaddr_offset; > + grub_int64_t off; > =20 > /* > * Instructions and instruction encoding are documented in the RISC-V > @@ -1243,6 +1242,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct sectio= n_metadata *smd, > */ > =20 > sym_addr +=3D addend; > + off =3D sym_addr - target_section_addr - offset - image_target->vaddr= _offset; > =20 > switch (ELF_R_TYPE (info)) > { This patch can fix a grub abort issue which randomly shows 'unaligned point= er' warnings on console. I tried this patch on QEMU v4.0.50 + grub-2.0.4-rc1. Tested-by: Chester Lin