* [PATCH] riscv: fix computation of pc-relative relocation offset
@ 2019-06-26 14:50 Andreas Schwab
2019-07-09 7:06 ` Chester Lin
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2019-06-26 14:50 UTC (permalink / raw)
To: grub-devel
The offset calculation was missing the relocation addend.
Signed-off-by: Andreas Schwab <schwab@suse.de>
---
util/grub-mkimagexx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c
index bc087c2b5..d16ec63a1 100644
--- a/util/grub-mkimagexx.c
+++ b/util/grub-mkimagexx.c
@@ -1232,8 +1232,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd,
grub_uint32_t *t32 = (grub_uint32_t *) target;
grub_uint16_t *t16 = (grub_uint16_t *) target;
grub_uint8_t *t8 = (grub_uint8_t *) target;
- grub_int64_t off = (long)sym_addr - target_section_addr - offset
- - image_target->vaddr_offset;
+ grub_int64_t off;
/*
* Instructions and instruction encoding are documented in the RISC-V
@@ -1243,6 +1242,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd,
*/
sym_addr += addend;
+ off = sym_addr - target_section_addr - offset - image_target->vaddr_offset;
switch (ELF_R_TYPE (info))
{
--
2.22.0
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] riscv: fix computation of pc-relative relocation offset
2019-06-26 14:50 [PATCH] riscv: fix computation of pc-relative relocation offset Andreas Schwab
@ 2019-07-09 7:06 ` Chester Lin
2019-07-11 12:41 ` Daniel Kiper
0 siblings, 1 reply; 3+ messages in thread
From: Chester Lin @ 2019-07-09 7:06 UTC (permalink / raw)
To: grub-devel@gnu.org
On Wed, Jun 26, 2019 at 16:50:03 +0200, Andreas Schwab wrote:
> The offset calculation was missing the relocation addend.
>
> Signed-off-by: Andreas Schwab <schwab@suse.de>
> ---
> util/grub-mkimagexx.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c
> index bc087c2b5..d16ec63a1 100644
> --- a/util/grub-mkimagexx.c
> +++ b/util/grub-mkimagexx.c
> @@ -1232,8 +1232,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd,
> grub_uint32_t *t32 = (grub_uint32_t *) target;
> grub_uint16_t *t16 = (grub_uint16_t *) target;
> grub_uint8_t *t8 = (grub_uint8_t *) target;
> - grub_int64_t off = (long)sym_addr - target_section_addr - offset
> - - image_target->vaddr_offset;
> + grub_int64_t off;
>
> /*
> * Instructions and instruction encoding are documented in the RISC-V
> @@ -1243,6 +1242,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd,
> */
>
> sym_addr += addend;
> + off = sym_addr - target_section_addr - offset - image_target->vaddr_offset;
>
> switch (ELF_R_TYPE (info))
> {
This patch can fix a grub abort issue which randomly shows 'unaligned pointer'
warnings on console. I tried this patch on QEMU v4.0.50 + grub-2.0.4-rc1.
Tested-by: Chester Lin <clin@suse.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] riscv: fix computation of pc-relative relocation offset
2019-07-09 7:06 ` Chester Lin
@ 2019-07-11 12:41 ` Daniel Kiper
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Kiper @ 2019-07-11 12:41 UTC (permalink / raw)
To: Chester Lin; +Cc: grub-devel@gnu.org
On Tue, Jul 09, 2019 at 07:06:45AM +0000, Chester Lin wrote:
> On Wed, Jun 26, 2019 at 16:50:03 +0200, Andreas Schwab wrote:
> > The offset calculation was missing the relocation addend.
> >
> > Signed-off-by: Andreas Schwab <schwab@suse.de>
> > ---
> > util/grub-mkimagexx.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c
> > index bc087c2b5..d16ec63a1 100644
> > --- a/util/grub-mkimagexx.c
> > +++ b/util/grub-mkimagexx.c
> > @@ -1232,8 +1232,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd,
> > grub_uint32_t *t32 = (grub_uint32_t *) target;
> > grub_uint16_t *t16 = (grub_uint16_t *) target;
> > grub_uint8_t *t8 = (grub_uint8_t *) target;
> > - grub_int64_t off = (long)sym_addr - target_section_addr - offset
> > - - image_target->vaddr_offset;
> > + grub_int64_t off;
> >
> > /*
> > * Instructions and instruction encoding are documented in the RISC-V
> > @@ -1243,6 +1242,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd,
> > */
> >
> > sym_addr += addend;
> > + off = sym_addr - target_section_addr - offset - image_target->vaddr_offset;
> >
> > switch (ELF_R_TYPE (info))
> > {
>
> This patch can fix a grub abort issue which randomly shows 'unaligned pointer'
> warnings on console. I tried this patch on QEMU v4.0.50 + grub-2.0.4-rc1.
>
> Tested-by: Chester Lin <clin@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Daniel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-11 12:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-26 14:50 [PATCH] riscv: fix computation of pc-relative relocation offset Andreas Schwab
2019-07-09 7:06 ` Chester Lin
2019-07-11 12:41 ` Daniel Kiper
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.