public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Reinhard Meyer <u-boot@emk-elektronik.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC] [PATCH V2] arm: arm926ejs: use ELF relocations
Date: Tue, 05 Oct 2010 13:01:31 +0200	[thread overview]
Message-ID: <4CAB058B.2090800@emk-elektronik.de> (raw)
In-Reply-To: <4CAB02A8.1010200@gmail.com>

Dear Graeme Russ,
>> .globl _rel_dyn_start_ofs
>> _rel_dyn_start_ofs:
>> 	.word __rel_dyn_start - _start
>> .globl _rel_dyn_end_ofs
>> _rel_dyn_end_ofs:
>> 	.word __rel_dyn_end - _start
>> .globl _dynsym_start_ofs
>> _dynsym_start_ofs:
>> 	.word __dynsym_start - _start
>>
>> get the values to "C".
> 
> Odd, is x86 different:
> 
> extern ulong _i386boot_rel_dyn_start;
> extern ulong _i386boot_rel_dyn_end;
> 
> void board_init_f (ulong stack_limit)
> {
> ...
> 	Elf32_Rel *rel_dyn_start = (Elf32_Rel *)&_i386boot_rel_dyn_start;
> 	Elf32_Rel *rel_dyn_end = (Elf32_Rel *)&_i386boot_rel_dyn_end;
> ...

It can be done that way, too! But above assembly code provides
relative offsets already, in "C" it would turn a bit uglier ;)
(TODO later)

> Provided you only use local variables (i.e. stored on the stack) the code
> might be relocatable anyway (the jump from asm to C will hopefully be
> relative). If you run the code at another address you will need to
> calculate the load offset and adjust rel_dyn_start and rel_dyn_end
> accordingly (see recent x86 patch series)

Probably. That adjustment is inherent, since offsets are used!

> 
> [snip]
> 
>> Is an entry in _dynsym really 16 bytes long?

My Questions was that Albert shifts "r_info" 4 times (= divide by 16)
to index into the _dynsym table, implying dynsym has 16 byte entries.
I see that it has - in elf.h. OK

> 
> Yes, it is an Elf32_Rel struct - see include/elf.h in the U-Boot tree
> 
> typedef struct
> {
> 	Elf32_Addr	r_offset;	/* offset of relocation */
> 	Elf32_Word	r_info;		/* symbol table index and type */
> } Elf32_Rel;

I will use the struct now.

> 	/* Perform relocation adjustments */
> 	re_src = (Elf32_Rel *)(rel_dyn_start + ((gd_t *)gdp)->load_off);
> 	re_end = (Elf32_Rel *)(rel_dyn_end + ((gd_t *)gdp)->load_off);

Using relative offsets the loop is a bit different...

Reinhard

  reply	other threads:[~2010-10-05 11:01 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-05  6:31 [U-Boot] [RFC] [PATCH V2] arm: arm926ejs: use ELF relocations Albert Aribaud
2010-10-05  6:45 ` Wolfgang Denk
2010-10-05  7:05   ` Reinhard Meyer
2010-10-05  7:23     ` Reinhard Meyer
2010-10-05  7:52       ` Reinhard Meyer
2010-10-05  8:33         ` Heiko Schocher
2010-10-05  8:41           ` Albert ARIBAUD
2010-10-05  9:00             ` Heiko Schocher
2010-10-05  9:10               ` Reinhard Meyer
2010-10-05  9:15                 ` Heiko Schocher
2010-10-05  9:19                   ` Reinhard Meyer
2010-10-05  9:29                     ` Heiko Schocher
2010-10-05  9:33                       ` Reinhard Meyer
2010-10-05  9:39                         ` Reinhard Meyer
2010-10-05 10:11                           ` Albert ARIBAUD
2010-10-05 10:36                             ` Reinhard Meyer
2010-10-05 10:49                               ` Graeme Russ
2010-10-05 11:01                                 ` Reinhard Meyer [this message]
2010-10-05 11:18                                   ` Albert ARIBAUD
2010-10-05 10:33                         ` Albert ARIBAUD
2010-10-05 10:40                           ` Wolfgang Denk
2010-10-05 11:10                             ` Albert ARIBAUD
2010-10-05 11:17                               ` Reinhard Meyer
2010-10-05 11:46                                 ` Albert ARIBAUD
2010-10-05 13:18                                   ` Reinhard Meyer
2010-10-05 13:24                                     ` Graeme Russ
2010-10-05 13:36                                     ` Albert ARIBAUD
2010-10-05 14:06                                       ` Reinhard Meyer
2010-10-05 11:43                               ` Wolfgang Denk
2010-10-05 10:20         ` Albert ARIBAUD
2010-10-05  8:27     ` Wolfgang Denk
2010-10-05  8:38       ` Reinhard Meyer
2010-10-05  8:50         ` Albert ARIBAUD
2010-10-05  8:59           ` Reinhard Meyer
2010-10-05  7:07   ` Wolfgang Denk
2010-10-05  7:40 ` Heiko Schocher
2010-10-05  8:32   ` Albert ARIBAUD
2010-10-05  8:02 ` Wolfgang Denk
2010-10-05  9:25 ` Heiko Schocher
2010-10-05  9:32   ` Albert ARIBAUD
2010-10-05 12:07   ` Heiko Schocher
2010-10-05 12:52 ` Heiko Schocher

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=4CAB058B.2090800@emk-elektronik.de \
    --to=u-boot@emk-elektronik.de \
    --cc=u-boot@lists.denx.de \
    /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