public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "Jose E. Marchesi" <jose.marchesi@oracle.com>
To: Cupertino Miranda <cupertino.miranda@oracle.com>
Cc: binutils@sourceware.org, nickc@redhat.com, elena.zannoni@oracle.com
Subject: Re: [PATCH] bpf: Added linker support for R_BPF_64_NODYLD32.
Date: Mon, 08 Jan 2024 19:45:25 +0100	[thread overview]
Message-ID: <877ckj7jga.fsf@oracle.com> (raw)
In-Reply-To: <877ckk6sg9.fsf@oracle.com> (Cupertino Miranda's message of "Mon, 08 Jan 2024 10:16:22 +0000")


Hi Cuper.
OK, thanks.

> Hi Jose,
>
> Thanks for your review.
> I realized I missed to update the macro for the relocation where the
> properties like size, overflow check, (etc.) are defined.
> I have added the comment near the relocation macro definition.
>
> Sending the patch for review once again.
>
> Regards,
> Cupertino
>
> From bb8afde9a8f17d42393067c3a667bec1f08b252a Mon Sep 17 00:00:00 2001
> From: Cupertino Miranda <cupertino.miranda@oracle.com>
> Date: Wed, 20 Dec 2023 12:24:03 +0000
> Subject: [PATCH] bpf: Added linker support for R_BPF_64_NODYLD32.
>
> This patch adds linker support to patch R_BPF_64_NODYLD32 relocations.
> The implementation was based on comments and code in LLVM, as the GNU
> toolchain does not uses this relocation type.
> ---
>  bfd/bpf-reloc.def | 17 ++++++++++-------
>  bfd/elf64-bpf.c   |  1 +
>  2 files changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/bfd/bpf-reloc.def b/bfd/bpf-reloc.def
> index 7e7497892fa..42ba1a169ea 100644
> --- a/bfd/bpf-reloc.def
> +++ b/bfd/bpf-reloc.def
> @@ -90,17 +90,20 @@
>  
>    /* R_BPF_64_NODYLD32 is not used by GNU tools - but it is generated by LLVM.
>       We provide an entry here so that tools like strip can safely handle BPF
> -     binaries generated by other tools.  */
> +     binaries generated by other tools.
> +     R_BPF_64_NODYLD32 should be fixed at linker like a R_BPF_64_ABS32.
> +     The difference to ABS32 is that LLVM execution engine does not resolve
> +     R_BPF_64_NODYLD32 relocations.  */
>    BPF_HOWTO (R_BPF_64_NODYLD32,	/* type */
>  	 0,			/* rightshift */
> -	 0,			/* size */
> -	 0,			/* bitsize */
> +	 4,			/* size */
> +	 32,			/* bitsize */
>  	 false,			/* pc_relative */
>  	 0,			/* bitpos */
> -	 complain_overflow_dont, /* complain_on_overflow */
> +	 complain_overflow_bitfield, /* complain_on_overflow */
>  	 bpf_elf_generic_reloc, /* special_function */
>  	 "R_BPF_64_NODYLD32",	/* name */
>  	 false,			/* partial_inplace */
> -	 0,			/* src_mask */
> -	 0,			/* dst_mask */
> -	 false)			/* pcrel_offset */
> +	 0xffffffff,		/* src_mask */
> +	 0xffffffff,		/* dst_mask */
> +	 true)			/* pcrel_offset */
> diff --git a/bfd/elf64-bpf.c b/bfd/elf64-bpf.c
> index c932a4024ba..0bffe2c5717 100644
> --- a/bfd/elf64-bpf.c
> +++ b/bfd/elf64-bpf.c
> @@ -276,6 +276,7 @@ bpf_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
>            }
>  	case R_BPF_64_ABS64:
>  	case R_BPF_64_ABS32:
> +	case R_BPF_64_NODYLD32:
>  	  {
>  	    addend = bfd_get (howto->bitsize, input_bfd, where);
>  	    relocation += addend;

  reply	other threads:[~2024-01-08 18:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-20 13:23 Cupertino Miranda
2024-01-03 10:34 ` Jose E. Marchesi
2024-01-08 10:16   ` Cupertino Miranda
2024-01-08 18:45     ` Jose E. Marchesi [this message]
2024-01-08 20:45       ` Cupertino Miranda

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=877ckj7jga.fsf@oracle.com \
    --to=jose.marchesi@oracle.com \
    --cc=binutils@sourceware.org \
    --cc=cupertino.miranda@oracle.com \
    --cc=elena.zannoni@oracle.com \
    --cc=nickc@redhat.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).