Re: [PATCH 2/8] ARM: aarch64: Fix get_runtime_offset after relocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 22, 2019 at 01:14:23PM -0700, Andrey Smirnov wrote:
> On Thu, Aug 22, 2019 at 5:52 AM Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> wrote:
> >
> > get_runtime_offset shall return the offset between the address we are
> > running at and the address we are linked at. This value obviously
> > changes when we relocate the binary. cf3b09737b tried to avoid using
> > R_AARCH64_RELATIVE relocations, but in fact this is exactly what the
> > function needs to work. Consider barebox starting at 0x10000000
> > when we are linked at 0x0 then get_runtime_offset() should return
> > 0x10000000 before relocate_to_current_adr(), but afterwards it should
> > return 0x0.
> >
> > This patch brings back the previously removed "a" flag. Since gcc5
> > doesn't put the values of R_AARCH64_RELATIVE fixup'd relocations
> > into the binary but zeroes instead, we help ourselves by basing
> > get_runtime_offset on an address which actually is zero. With
> > CONFIG_RELOCATABLE=y the binary is always linked to 0x0, so _text
> > is initially zero.
> >
> 
> This paragraph might be worth putting in the comment as well to
> document some cleverness that is still required to deal with GCC5.

Makes sence. Added this:

/*
 * With older gcc versions (gcc5) function pointers will not be filled
 * into the binary during compile time and instead rely on relocation
 * during runtime. In the binary we'll always have 0x0 here. We deliberately
 * use _text here since that is 0x0 and is correct without relocation.
 */

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux