public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Pedro Falcato" <pedro.falcato@gmail.com>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: devel@edk2.groups.io, jake@nvidia.com,
	 "rebecca@bsdio.com" <rebecca@bsdio.com>,
	"gaoliming@byosoft.com.cn" <gaoliming@byosoft.com.cn>,
	 "bob.c.feng@intel.com" <bob.c.feng@intel.com>,
	"yuwei.chen@intel.com" <yuwei.chen@intel.com>,
	 "ardb+tianocore@kernel.org" <ardb+tianocore@kernel.org>
Subject: Re: [edk2-devel] [PATCH] BaseTools/GenFw: Change opcode when converting ADR to ADRP
Date: Fri, 27 Oct 2023 15:10:01 +0100	[thread overview]
Message-ID: <CAKbZUD30++dPZK0WK8jV9G88=cAKehJVsBnkB8dfSARDvK4AoA@mail.gmail.com> (raw)
In-Reply-To: <CAMj1kXH3OP1rPsMtcfSqmB_z=wG=yijq+sH5YQz2a2a3cwc32w@mail.gmail.com>

On Fri, Oct 27, 2023 at 2:47 PM Ard Biesheuvel <ardb@kernel.org> wrote:
>
> Hello all,
>
> Apologies for the late response.
>
> On Fri, 27 Oct 2023 at 14:44, Jake Garver via groups.io
> <jake=nvidia.com@groups.io> wrote:
> >
> > Thanks for your response, Pedro.
> >
> > I chased this as a toolchain bug originally, but concluded that the ADR indeed works before GenFw rewrites it.  But I see your point regarding the relocation statement.
> >
> > As requested, below is the disassembled function along with relocations.  This was generated from the dll using "aarch64-linux-gnu-objdump -r -D".  The ADR in question is at 2ffc.
> >
>
> Can you double check the object file? I suspect this is a linker
> relaxation not a compiler issue.
>
> > This code was generated by the current version of the GCC 10.x toolchain on Ubuntu20.  So, if we're concluding this is a toolchain issue, then it's with a fairly "stock" toolchain.
> >
> > 0000000000002fec <fdt_path_offset>:
> >     2fec:   a9b97bfd stp   x29, x30, [sp, #-112]!
> >     2ff0:   910003fd mov   x29, sp
> >     2ff4:   a90363f7 stp   x23, x24, [sp, #48]
> >     2ff8:   aa0003f8 mov   x24, x0
> >     2ffc:   10020020 adr   x0, 7000 <_cont+0xe98>
> > 2ffc: R_AARCH64_ADR_GOT_PAGE  __stack_chk_guard
>
> The nasty thing with relying on --emit-relocs is that they get out of
> sync. R_AARCH64_ADR_GOT_PAGE is documented as applying to ADRP only,
> so this code is non-compliant one way or the other.

I was narrowing it down to this, but _ADR_GOT_PAGE does not seem to be
relaxable as ADRP -> ADR, per the ABI spec (see "Large GOT
Indirection". "PC-relative addressing" only applies to
_ADR_PREL_PG_HI21...)
Maybe it's just not a documented relaxation? Or does it relax as
_ADR_GOT_PAGE -> _ADR_PREL_PG_HI21 -> _ADR_PREL_LO21 without updating
internal relocation info?

>
> There are other relaxations that also confuse GenFw when the static
> relocs don't get updated accordingly.

Wonderful that you can confirm this is probably a linker --emit-relocs
issue. So, if this proves to be the case:
Acked-by: Pedro Falcato <pedro.falcato@gmail.com>

but please rewrite the commit message so that it's clear that this is
an --emit-relocs toolchain bug.

-- 
Pedro


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110209): https://edk2.groups.io/g/devel/message/110209
Mute This Topic: https://groups.io/mt/102202314/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



      parent reply	other threads:[~2023-10-27 14:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-26 15:31 [edk2-devel] [PATCH] BaseTools/GenFw: Change opcode when converting ADR to ADRP Jake Garver via groups.io
2023-10-26 18:46 ` Pedro Falcato
2023-10-27 12:44   ` Jake Garver via groups.io
2023-10-27 13:46     ` Ard Biesheuvel
2023-10-27 14:09       ` Jake Garver via groups.io
2023-10-27 14:12         ` Pedro Falcato
2023-10-27 14:13         ` Ard Biesheuvel
2023-10-27 14:26           ` Pedro Falcato
2023-10-27 14:43             ` Ard Biesheuvel
2023-10-27 15:52               ` Jake Garver via groups.io
2023-11-02 11:47                 ` Jake Garver via groups.io
2023-11-02 12:47                   ` Pedro Falcato
2023-12-06 16:51                     ` Jake Garver via groups.io
2023-12-12  9:22                       ` Ard Biesheuvel
2023-12-13 14:57                         ` Jake Garver via groups.io
2023-12-13 17:31                           ` Ard Biesheuvel
2023-12-13 18:01                             ` Pedro Falcato
2023-12-13 19:47                               ` Jake Garver via groups.io
2023-12-19 23:29                                 ` Jake Garver via groups.io
2023-12-20  7:34                                   ` Ard Biesheuvel
2023-10-27 14:10       ` Pedro Falcato [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-list 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='CAKbZUD30++dPZK0WK8jV9G88=cAKehJVsBnkB8dfSARDvK4AoA@mail.gmail.com' \
    --to=devel@edk2.groups.io \
    /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