public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] ARM: Incorrect ROM protection range?
Date: Thu, 24 Feb 2011 08:33:25 +0100	[thread overview]
Message-ID: <4D6609C5.3040203@denx.de> (raw)
In-Reply-To: <4D660030.409@free.fr>

Hello Albert,

Albert ARIBAUD wrote:
> Le 24/02/2011 07:06, Po-Yu Chuang a ?crit :
>> Hi all,
>>
>> I am using relocation fixed a320evb (arm) u-boot.
>>
>> I noticed something weird about the output of
>> command flinfo.
>>
>> The size of u-boot.bin is 129156 (0x1F884), but the
>> protected range is only 0 ~ 0x1bfff.
>>
>> I guess that it is because u-boot protects _start ~ __bss_start,
>> but there are some other things in u-boot.bin after __bss_start,
>> e.g. .rel.dyn section and .dynsym section
> 
> You're most probable right about this -- this size error has to be 
> fixed. All reasers please see the 'BTW' at the end of my post.
> 
>> That is quite strange.
>> According to arch/arm/cpu/arm920t/u-boot.lds,
>> .rel.dyn and .dynsym sections should be placed before __bss_start.
>> However, objdump shows that they are not at where they should be.
>>
>> Do I understand correctly?
> 
> Not quite. Actually, relocation sections should start from the same
> location as BSS -- they are overlaid at the same location, and this is 
> voluntary.
> 
> The relocation sections are only needed and useful before relocation, 
> where BSS should not be used anyway.
> 
> BSS only exists after relocation, where relocation tables are no more 
> useful.
> 
> Thus, to minimize RAM and FLASH footprints, the two are overlaid at the 
> same location.
> 
>> Does anybody have similar situation?
> 
> Just about all people who use ARM U-Boot since the overlay was 
> introduced. :)
> 
>> 0001bf1c g       .bss   00000000 __bss_start
> 
>> 0001bf1c g       .rel.dyn       00000000 __rel_dyn_start
> 
>> 0001f73c g       .dynsym        00000000 __dynsym_start
>> 0001f73c g       .rel.dyn       00000000 __rel_dyn_end
> 
> This is normal as far as layout is concerned: BSS and .rel.dyn start at 
> the same offset, and .dynsym follows .rel.dyn.
> 
> You're right that U-Boot protection should cover the whole of U-Boot, 
> including the relocation tables. I *think* protection uses a monitor 
> length define for this. Can you verify this point, and check what your 
> "monitor length" define amounts to? Maybe it does not cover the 
> relocation tables any more.

The bin length is calculated in arch/arm/lib/board.c, but it seems
to me not correct ... :-(

in board_init_f():

gd->mon_len = _bss_end_ofs;

that seems correct to me, but later in board_init_r()

monitor_flash_len = _bss_start_ofs;

which is used for example in ./drivers/mtd/cfi_flash.c for protecting
the flash sectors ... so this should be fixed.

> BTW,
> 
> Would it not be better to compute the actual image size rather than rely 
> on a define?
> 
> In the U-Boot image itself, knowing the image size could be achieved in 
> ARM by using a general _end symbol that would be set after the last 
> image output section, so _end-_start would equal the image size.

we have such a "_end" in u-boot.lds files.

> For code other than the U-Boot image itself (loaders, utilities), a 'du 
> -b u-boot.bin | cut -f 1' should be ok, provided the image is built 
> first, which I think is already the case.
> 
> Amicalement,

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

  parent reply	other threads:[~2011-02-24  7:33 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-24  6:06 [U-Boot] ARM: Incorrect ROM protection range? Po-Yu Chuang
2011-02-24  6:52 ` Albert ARIBAUD
2011-02-24  7:07   ` Wolfgang Denk
2011-02-24  7:11   ` Po-Yu Chuang
2011-02-24  7:33   ` Heiko Schocher [this message]
2011-02-24  7:40     ` Po-Yu Chuang
2011-02-24  8:07       ` Albert ARIBAUD
2011-02-24  9:39         ` Wolfgang Denk
2011-02-24 11:58           ` Albert ARIBAUD
2011-02-24 12:58             ` Po-Yu Chuang
2011-02-24 13:13               ` Albert ARIBAUD
2011-02-24 13:41                 ` Wolfgang Denk
2011-02-24 16:01                   ` Albert ARIBAUD
2011-02-24 18:38                     ` Wolfgang Denk
2011-02-24 18:47                       ` Albert ARIBAUD
2011-02-24 20:17                         ` Wolfgang Denk
2011-02-25  2:41                           ` Po-Yu Chuang
2011-02-25  6:34                             ` Albert ARIBAUD
2011-02-25  7:15                               ` Wolfgang Denk
2011-02-25  8:00                                 ` Po-Yu Chuang
2011-03-01  8:31                                   ` Po-Yu Chuang
2011-03-01 12:22                                     ` Albert ARIBAUD
2011-03-02  2:56                                       ` Po-Yu Chuang

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=4D6609C5.3040203@denx.de \
    --to=hs@denx.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