[DTrace-devel] [PATCH] Fix relocations of 64-bit values

Eugene Loh eugene.loh at oracle.com
Tue Jun 15 11:30:36 PDT 2021


Reviewed-by: Eugene Loh <eugene.loh at oracle.com>

On 6/15/21 1:58 PM, Kris Van Hees wrote:
> The R_BPF_64_64 relocation in the final linking was truncating 64-bit
> values to 32-bits.
>
> Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> ---
>   libdtrace/dt_cc.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/libdtrace/dt_cc.c b/libdtrace/dt_cc.c
> index 9bf6ba09..a39c701b 100644
> --- a/libdtrace/dt_cc.c
> +++ b/libdtrace/dt_cc.c
> @@ -2395,7 +2395,7 @@ dt_link_resolve(dtrace_hdl_t *dtp, dtrace_difo_t *dp)
>   		dt_ident_t	*idp = dt_dlib_get_sym(dtp, name);
>   		uint_t		ioff = rp->dofr_offset /
>   				       sizeof(struct bpf_insn);
> -		uint32_t	val;
> +		uint64_t	val;
>   
>   		if (idp == NULL)			/* not found */
>   			continue;
> @@ -2418,10 +2418,10 @@ dt_link_resolve(dtrace_hdl_t *dtp, dtrace_difo_t *dp)
>   		}
>   
>   		if (rp->dofr_type == R_BPF_64_64) {
> -			buf[ioff].imm = val;
> -			buf[ioff + 1].imm = 0;
> +			buf[ioff].imm = val & 0xffffffff;
> +			buf[ioff + 1].imm = val >> 32;
>   		} else if (rp->dofr_type == R_BPF_64_32)
> -			buf[ioff].imm = val;
> +			buf[ioff].imm = (uint32_t)val;
>   	}
>   }
>   



More information about the DTrace-devel mailing list