* [PATCH 3/6] bpf: implement additional relocation types
@ 2025-01-28 6:31 Kris Van Hees
2025-01-30 22:53 ` Eugene Loh
0 siblings, 1 reply; 3+ messages in thread
From: Kris Van Hees @ 2025-01-28 6:31 UTC (permalink / raw)
To: dtrace, dtrace-devel
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;
--
2.45.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH 3/6] bpf: implement additional relocation types
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
0 siblings, 1 reply; 3+ messages in thread
From: Eugene Loh @ 2025-01-30 22:53 UTC (permalink / raw)
To: Kris Van Hees, dtrace, dtrace-devel
Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
and an explanation in the commit msg what motivates this patch?
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;
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH 3/6] bpf: implement additional relocation types
2025-01-30 22:53 ` Eugene Loh
@ 2025-01-30 23:14 ` Kris Van Hees
0 siblings, 0 replies; 3+ messages in thread
From: Kris Van Hees @ 2025-01-30 23:14 UTC (permalink / raw)
To: Eugene Loh; +Cc: Kris Van Hees, dtrace, dtrace-devel
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;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-30 23:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox