mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* arm: Question on linker script and start/end variables
@ 2016-03-07 16:37 Renaud Barbier
  2016-03-08  7:22 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Renaud Barbier @ 2016-03-07 16:37 UTC (permalink / raw)
  To: barebox

I have a ARM-based board for which we have a running barebox.

In the low level code, when running from flash, I would like to get the
start and end address of a section. For instance, &__barebox_cmd_start
and &__barebox_cmd_end.

For both I am getting 0 unless I am running from memory.

Even assigning these addresses to variables always returns 0.

This is not an issue on PPC platforms.

All my tests and research to get the correct address on ARM has led to
no positive results.

Has anybody an explanation why these addresses cannot be obtained on ARM
platforms?

Cheers,
Renaud






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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: arm: Question on linker script and start/end variables
  2016-03-07 16:37 arm: Question on linker script and start/end variables Renaud Barbier
@ 2016-03-08  7:22 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2016-03-08  7:22 UTC (permalink / raw)
  To: Renaud Barbier; +Cc: barebox

On Mon, Mar 07, 2016 at 04:37:14PM +0000, Renaud Barbier wrote:
> I have a ARM-based board for which we have a running barebox.
> 
> In the low level code, when running from flash, I would like to get the
> start and end address of a section. For instance, &__barebox_cmd_start
> and &__barebox_cmd_end.
> 
> For both I am getting 0 unless I am running from memory.
> 
> Even assigning these addresses to variables always returns 0.
> 
> This is not an issue on PPC platforms.
> 
> All my tests and research to get the correct address on ARM has led to
> no positive results.
> 
> Has anybody an explanation why these addresses cannot be obtained on ARM
> platforms?

It doesn't work for two reasons. First of all the program is not running
at the address it is linked at. barebox on ARM is linked as position
independent executable (-pie) to address 0x0. Usually when called from the
SoC ROM the binary will run at another address though. This means that
pointers to global variables that are stored in the binary will point to
0x0 + offset in the binary. To use the variables we have to add the
offset between 0x0 and the address we are really running to the pointer.
The second reason comes with linker generated variables like
__bss_start. These are set to 0x0 in the binary. They need to be fixed
up during runtime using the dynsym table, see relocate_to_current_adr().
I don't know a way to access these in C. In barebox we have the ld_var
macro which uses assembly to access the linker generated variables. Note
that you can't access arbitrary variables, to access __barebox_cmd_start
you have to add the variable to arch/arm/lib/runtime-offset.S.

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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-03-08  7:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-07 16:37 arm: Question on linker script and start/end variables Renaud Barbier
2016-03-08  7:22 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox