Linux DTrace development list
 help / color / mirror / Atom feed
From: Kris Van Hees <kris.van.hees@oracle.com>
To: Eugene Loh <eugene.loh@oracle.com>
Cc: Kris Van Hees <kris.van.hees@oracle.com>,
	dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [PATCH 3/6] bpf: implement additional relocation types
Date: Thu, 30 Jan 2025 18:14:55 -0500	[thread overview]
Message-ID: <Z5wH76ByPwuv4XRz@oracle.com> (raw)
In-Reply-To: <961b140b-e70e-4934-3b1c-b8d9ce799518@oracle.com>

On Thu, Jan 30, 2025 at 05:53:01PM -0500, Eugene Loh wrote:
> Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
> and an explanation in the commit msg what motivates this patch?

Sure, though I think it is actually quite obvious for anyone looking at the
documented BPF relocation types, and the relocations generated by gcc for
BPF code.

> On 1/28/25 01:31, Kris Van Hees wrote:
> > Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
> > ---
> >   include/port.h     | 6 ++++++
> >   libdtrace/dt_as.c  | 2 +-
> >   libdtrace/dt_cc.c  | 3 ++-
> >   libdtrace/dt_dis.c | 9 ++++++++-
> >   4 files changed, 17 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/port.h b/include/port.h
> > index 6ce8611e..0aadacb8 100644
> > --- a/include/port.h
> > +++ b/include/port.h
> > @@ -88,6 +88,12 @@ pid_t gettid(void);
> >   #ifndef R_BPF_64_64
> >   #define R_BPF_64_64		1
> >   #endif
> > +#ifndef R_BPF_64_ABS64
> > +#define R_BPF_64_ABS64		2
> > +#endif
> > +#ifndef R_BPF_64_ABS32
> > +#define R_BPF_64_ABS32		3
> > +#endif
> >   #ifndef R_BPF_64_32
> >   #define R_BPF_64_32		10
> >   #endif
> > diff --git a/libdtrace/dt_as.c b/libdtrace/dt_as.c
> > index a634b855..d3126f9a 100644
> > --- a/libdtrace/dt_as.c
> > +++ b/libdtrace/dt_as.c
> > @@ -492,7 +492,7 @@ fail:
> >   			case BPF_ST | BPF_MEM | BPF_DW:		/* stdw */
> >   			case BPF_ALU64 | BPF_MOV | BPF_K:	/* mov */
> >   			case BPF_ALU64 | BPF_ADD | BPF_K:	/* add */
> > -				rp->dofr_type = R_BPF_64_32;
> > +				rp->dofr_type = R_BPF_64_ABS32;
> >   				break;
> >   			case BPF_LD | BPF_IMM | BPF_DW:		/* lddw */
> >   				rp->dofr_type = R_BPF_64_64;
> > diff --git a/libdtrace/dt_cc.c b/libdtrace/dt_cc.c
> > index eebd923c..29cfbd84 100644
> > --- a/libdtrace/dt_cc.c
> > +++ b/libdtrace/dt_cc.c
> > @@ -1266,7 +1266,8 @@ dt_link_resolve(dtrace_hdl_t *dtp, dtrace_difo_t *dp)
> >   		if (rp->dofr_type == R_BPF_64_64) {
> >   			buf[ioff].imm = val & 0xffffffff;
> >   			buf[ioff + 1].imm = val >> 32;
> > -		} else if (rp->dofr_type == R_BPF_64_32)
> > +		} else if (rp->dofr_type == R_BPF_64_32 ||
> > +			   rp->dofr_type == R_BPF_64_ABS32)
> >   			buf[ioff].imm = (uint32_t)val;
> >   	}
> >   }
> > diff --git a/libdtrace/dt_dis.c b/libdtrace/dt_dis.c
> > index d983c099..b2e66754 100644
> > --- a/libdtrace/dt_dis.c
> > +++ b/libdtrace/dt_dis.c
> > @@ -639,6 +639,12 @@ dt_dis_rtab(const char *rtag, const dtrace_difo_t *dp, FILE *fp,
> >   		case R_BPF_64_32:
> >   			tstr = "R_BPF_INSN_DISP32";
> >   			break;
> > +		case R_BPF_64_ABS64:
> > +			tstr = "R_BPF_DATA_64";
> > +			break;
> > +		case R_BPF_64_ABS32:
> > +			tstr = "R_BPF_DATA_32";
> > +			break;
> >   		default:
> >   			tstr = "R_???";
> >   		}
> > @@ -853,7 +859,8 @@ dt_dis_difo(const dtrace_difo_t *dp, FILE *fp, const dt_ident_t *idp,
> >   		for (; cnt; cnt--, rp++) {
> >   			if (rp->dofr_offset < i * sizeof(uint64_t))
> >   				continue;
> > -			if (rp->dofr_offset == i * sizeof(uint64_t))
> > +			if (rp->dofr_offset >= i * sizeof(uint64_t) &&
> > +			    rp->dofr_offset < (i + 1) * sizeof(uint64_t))
> >   				rname = dt_difo_getstr(dp, rp->dofr_name);
> >   			break;

      reply	other threads:[~2025-01-30 23:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-28  6:31 [PATCH 3/6] bpf: implement additional relocation types Kris Van Hees
2025-01-30 22:53 ` Eugene Loh
2025-01-30 23:14   ` Kris Van Hees [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z5wH76ByPwuv4XRz@oracle.com \
    --to=kris.van.hees@oracle.com \
    --cc=dtrace-devel@oss.oracle.com \
    --cc=dtrace@lists.linux.dev \
    --cc=eugene.loh@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox