public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "Frédéric Rivière" <frederic.riviere@microej.com>
To: Nick Clifton <nickc@redhat.com>
Cc: binutils@sourceware.org
Subject: Re: load of in-place relocation addend in AArch64
Date: Wed, 6 Dec 2023 16:02:39 +0100	[thread overview]
Message-ID: <54acf602-44ed-4bc8-8652-5feb450195ee@microej.com> (raw)
In-Reply-To: <2747d24e-1331-4970-8660-421f4479dc62@redhat.com>

Hi Nick,

Thanks for the quick reply.

My compiler generates REL relocations because I was just naively 
following the official AArch64 ABI.

I understand that RELA is more easy to manage since there is no need to 
retrieve the source section for getting the addend.

However, I believe that ld AArch64 should not support REL entries at all 
(with a clear error message) instead of silently generating a wrong 
object file.

Finally, I just updated my compiler to generate RELA and now it works fine.

Best regards,

--Frédéric

On 12/6/2023 12:14 PM, Nick Clifton wrote:
> Hi Frédéric,
>
>> My compiler generates REL relocations with an in-place addend but the 
>> addend is not taken into account for computing the final relocated 
>> symbol address (S+A).
>
> Is there any particular reason for this ?
>
> Ie, if your compiler generated RELA relocations then all of your problems
> with the binutils should go away...
>
>> So it seems the that I'm the first one that generates REL relocations 
>> for AArch64 target.
>
> True.
>
>> However, I don't see any limitation on using REL relocations in the 
>> AARCH64 ABI.
>
> Correct.  There are - in theory - allowed.
>
>> I would appreciate any comment/feedback that would help me 
>> understanding the reasons behind that.
>
> As a general rule RELA relocations are preferable in that they
> are simpler - it is easier to extract the addend - and in theory
> they have the possibility to express a wider range of addends
> than would be available to REL relocations.
>
> Have you tried modifying the AArch64 code in the BFD library to
> support REL relocations ?  In theory all that you need to do is
> to change a few lines in bfd/elfnn-aarch64.c:
>
>   #define elf_backend_may_use_rel_p      0
>
> and maybe:
>
>   #define elf_backend_may_use_rela_p     1
>   #define elf_backend_default_use_rela_p 1
>   #define elf_backend_rela_normal     1
>
> In practice I am pretty sure that there will be assumptions of RELA
> relocs elsewhere in the AArch64 specific code, so I doubt it will be
> as simple as I have suggested.
>
> Cheers
>   Nick

	





  reply	other threads:[~2023-12-06 15:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-06  8:08 Frédéric Rivière
2023-12-06 11:14 ` Nick Clifton
2023-12-06 15:02   ` Frédéric Rivière [this message]
2023-12-06 15:31     ` Nick Clifton
2023-12-06 16:56       ` Frédéric Rivière
2023-12-07 17:16         ` Nick Clifton
2023-12-11  7:51           ` Frédéric Rivière
2024-03-28  7:10             ` Fangrui Song

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=54acf602-44ed-4bc8-8652-5feb450195ee@microej.com \
    --to=frederic.riviere@microej.com \
    --cc=binutils@sourceware.org \
    --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).