From nobody Thu Oct 20 15:04:29 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MtW8t10V2z4fXwp; Thu, 20 Oct 2022 15:04:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MtW8t0Hkyz42jN; Thu, 20 Oct 2022 15:04:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666278270; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gaAPGUWiknuBrr2J1eqYJIzPoYYPAlWF/ZvalUaQhEo=; b=ypeJ1juYrXN1oQHYX4cVw1I/ciTGQhKbG0FO3N4BpCtB5lJ+KN+chkCoYzJV+UIJNQJsx/ iUmu8PVWetAxe+fNBuJYU2vUZGResGL6k0Cv+2FIxDXg9A8QOfAegbTyT6Ar2dNFLd0J7X Q7PRYH0zD3PRbsPAI8Ugmxul0ZFtY3IzY6wdYYZAdsuzx+nISZnYjzH9R6pfDh+IASL8Ih DvOlSXBKnu11ruN3HNoCO1LernleG8RhRX+ovcDpelELxyLaWcMYT1P3KGQ2LeXANiBPgE 3lS1vwWkeHDvT+5NXkGbLqrO2s7ttVRVaDQpHpomSgDQFR/TRLM+VeZoaRvNow== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MtW8s6PNzzvGK; Thu, 20 Oct 2022 15:04:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29KF4TEH090712; Thu, 20 Oct 2022 15:04:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29KF4TBD090711; Thu, 20 Oct 2022 15:04:29 GMT (envelope-from git) Date: Thu, 20 Oct 2022 15:04:29 GMT Message-Id: <202210201504.29KF4TBD090711@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: a9b24e4dc28a - main - riscv: fix relocation handling for R_RISCV_64 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a9b24e4dc28abfe668038e4c053d77b6dd4dce19 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666278270; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gaAPGUWiknuBrr2J1eqYJIzPoYYPAlWF/ZvalUaQhEo=; b=JrwE9sRkw/7z2ncQeZ6tJXN9O5QJ+8+nAFw77ql/KyH5xPJBrBCJi3q1MkBcv8mksVwz16 mt59lCphi2VvKT89kbq99c3stATnjp2uDIPL3ieVroYnRJa0duUcprsdqhPvOwdUZ5mdB4 U688JtTAgcCXy0W6wW+XlAKER62Vr+fJRLdUxuN7tVMFBDgEiKOEMdP5lkK+RgTN2mMHZu weC0gtZ2wZqmAc5i5O2Paptl/pE5KtS0dZ491n0o+eCQPrYkgaWerIESqWJjfc0sdibrG5 R7QcU/t32U5o+1oWwM87GjyRh16d4FEbd9INrhtQsgrVXXFDvwyhCGVkq3Kz0Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666278270; a=rsa-sha256; cv=none; b=aO/BiYXo7l420Bn8h6xY3EtUji1tMRLizXnUXKac1jpSD6kwuh/k5fYySEDgc34xs/RpPJ viLbUt/zynzoQMv2vaYmfYDbcFVlwa7LhQPP3fDpK2OaKiYy086quLlIApSa7stPvO3tb8 Wj/znCAyfFvRabEO4kg9au1Qja0ZpTrE3t9LdSj63eKwi/VbdrTDdlbfCsSxVzIP+72tRy nDRLQ9VN4pBphQwJCKk8b3rC+X5UpG2OykpL3qWDpRC+i2g3BOYef3jVxiCgcVe0bhvdOX k++sKoRBf4ZwuN7rCAbWTcpGQfm696NaxRX8V1Oj3Q5Ue1vKw7F2hyP54bnFXA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=a9b24e4dc28abfe668038e4c053d77b6dd4dce19 commit a9b24e4dc28abfe668038e4c053d77b6dd4dce19 Author: Mitchell Horne AuthorDate: 2022-10-20 14:56:59 +0000 Commit: Mitchell Horne CommitDate: 2022-10-20 15:01:29 +0000 riscv: fix relocation handling for R_RISCV_64 It requires the addend. In practice this doesn't seem to be a problem, since relocations of this type are all with an addend of zero. Obviously, we still want to handle this correctly if that ever changes. Reviewed by: markj MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D37039 --- sys/riscv/riscv/elf_machdep.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sys/riscv/riscv/elf_machdep.c b/sys/riscv/riscv/elf_machdep.c index 68c7afb4d09f..b3d8ac54a36d 100644 --- a/sys/riscv/riscv/elf_machdep.c +++ b/sys/riscv/riscv/elf_machdep.c @@ -340,15 +340,25 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data, break; case R_RISCV_64: + error = lookup(lf, symidx, 1, &addr); + if (error != 0) + return (-1); + + before64 = *where; + *where = addr + addend; + if (debug_kld) + printf("%p %c %-24s %016lx -> %016lx\n", where, + (local ? 'l' : 'g'), reloctype_to_str(rtype), + before64, *where); + break; + case R_RISCV_JUMP_SLOT: error = lookup(lf, symidx, 1, &addr); if (error != 0) return (-1); - val = addr; before64 = *where; - if (*where != val) - *where = val; + *where = addr; if (debug_kld) printf("%p %c %-24s %016lx -> %016lx\n", where, (local ? 'l' : 'g'), reloctype_to_str(rtype),