mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH 1/5] ARM: Fix global_variable_offset() for aarch64
Date: Wed, 17 Jul 2019 09:18:03 +0200	[thread overview]
Message-ID: <20190717071803.opnegmgrtqbbv6si@pengutronix.de> (raw)
In-Reply-To: <CAHQ1cqHQRhR4jBCFn24aWb12UFABiiP3XbA2teF-MLL3fgxBXg@mail.gmail.com>

On Tue, Jul 16, 2019 at 06:28:17PM -0700, Andrey Smirnov wrote:
> On Tue, Jul 16, 2019 at 6:50 AM Sascha Hauer <s.hauer@pengutronix.de> wrote:
> >
> > Not all toolchains use pc relative addresses for global variables.
> > Apparently the gcc 8.3.0 YOCTO toolchain uses absolute addresses.
> 
> Just out of curiosity, can this behavior be changed with -mcmodel=tiny
> or maybe -mpc-relative-literal-loads ?

This doesn't seem to have any influence with one toolchain or the other.

BTW with this diff:

diff --git a/arch/arm/cpu/common.c b/arch/arm/cpu/common.c
index 4d957da1dc..65cf90f553 100644
--- a/arch/arm/cpu/common.c
+++ b/arch/arm/cpu/common.c
@@ -60,6 +60,14 @@ void pbl_barebox_break(void)
 	);
 }
 
+static noinline void _puthex_ll(unsigned long val)
+{
+	putc_ll('a');
+	putc_ll(':');
+	puthex_ll(val);
+	putc_ll('\n');
+}
+
 /*
  * relocate binary to the currently running address
  */
@@ -69,6 +77,8 @@ void relocate_to_current_adr(void)
 	unsigned long __maybe_unused *dynsym, *dynend;
 	void *dstart, *dend;
 
+	_puthex_ll((unsigned long)__rel_dyn_start);
+
 	/* Get offset between linked address and runtime address */
 	offset = get_runtime_offset();
 	offset_var = global_variable_offset();

This is what the two toolchains make from it (stripped some irrelevant instructions):

YOCTO:

0000000000003c38 <relocate_to_current_adr>:
    3c3c:       b0000100        adrp    x0, 24000 <__dtb_imx8mq_evk_start+0x5c40>
    3c48:       f943e013        ldr     x19, [x0, #1984]
    3c4c:       aa1303e0        mov     x0, x19
    3c50:       97ffffd1        bl      3b94 <_puthex_ll>

OSELAS:

0000000000003c20 <relocate_to_current_adr>:
    3c24:       b0000100        adrp    x0, 24000 <__dtb_imx8mq_evk_start+0x5c60>
    3c30:       911ee013        add     x19, x0, #0x7b8
    3c34:       aa1303e0        mov     x0, x19
    3c38:       97ffffd1        bl      3b7c <_puthex_ll>


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

      reply	other threads:[~2019-07-17  7:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-16 13:49 Sascha Hauer
2019-07-16 13:49 ` [PATCH 2/5] ARM: nxp-imx8mq-evk: Do setup_c() before accessing global variables Sascha Hauer
2019-07-16 13:49 ` [PATCH 3/5] ARM: phyCORE-i.MX8M SOM: " Sascha Hauer
2019-07-16 13:49 ` [PATCH 4/5] ARM: zii-imx8mq-dev: " Sascha Hauer
2019-07-16 13:49 ` [PATCH 5/5] ARM: access __boot_cpu_mode with a function Sascha Hauer
2019-07-17  1:28 ` [PATCH 1/5] ARM: Fix global_variable_offset() for aarch64 Andrey Smirnov
2019-07-17  7:18   ` Sascha Hauer [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-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=20190717071803.opnegmgrtqbbv6si@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /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