All of lore.kernel.org
 help / color / mirror / Atom feed
From: Albert ARIBAUD <albert.aribaud@free.fr>
To: u-boot@lists.denx.de
Subject: [U-Boot] Most ARM CPU's have buggy clear_bss?
Date: Fri, 29 Oct 2010 14:08:52 +0200	[thread overview]
Message-ID: <4CCAB954.5050506@free.fr> (raw)
In-Reply-To: <4CCAB659.5010309@ahsoftware.de>

Le 29/10/2010 13:56, Alexander Holler a ?crit :
> Am 29.10.2010 11:19, schrieb Albert ARIBAUD:
>> Hi all,
>>
>> Le 29/10/2010 10:50, Alexander Holler a ?crit :
>>> Hello again,
>>>
>>> I'm leaving the problem description below, what fixed it all here was to
>>> add -fPIC to the CFLAGS to instruct the compiler to generate relocatable
>>> code (again).
>>>
>>> This flag was replaced in commit 92d5ecba47feb9961c3b7525e947866c5f0d2de5
>>
>> Did you reach tis commit by dissecting?
>
> No, I just used gitk and/or git gui blame to search when -fPIC disappeared.

Hmm... Git blame just lest you know what commit changed a line last, 
which is not enough to make sure that the change was the root cause.

>>> with -pie in LDFLAGS, which I don't understand (does not mean I have
>>> much experience how the compiler and linker are working in regard to
>>> relocatable code).
>>>
>
>> That needs some more analysis.
>>
>> -fPIC without GOT relocation does nothing good, and with it, does not
>> enough -- hence the ELF relocation patches replacing -fPIC with -pie,
>> which is *intended* for relocating executables. these two machanisms are
>> not meant to be used together.
>>
>> Can you be more specific about this:
>
> Adding
>
> printf("nand_chip: %p\n",&nand_chip[0]);
>
> to nand_init() in drivers/mtd/nand.c
>
> a non relocated address will be printed without -fPIC. After adding
> -fPIC to the CFLAGS the address is relocated. U-Boot fails there first
> because nand_chip[0] contains function pointers which are used while
> scanning the NAND.

Weird: I introduced -pie precisely because it relocates pointers in data 
structures while -fPIC does not -- I'd hit the issue myself. I assume I 
can test this with an OpenRD board, which has NAND also.

> And because they aren't relocated, but only the
> relocated BSS will be cleared, the following code in nand_set_defaults()
> in drivers/mtd/nand/nand_base.c will not initialize cmdfunc
>
>            if (chip->cmdfunc == NULL)
>                   chip->cmdfunc = nand_command;
>
> with the result that chip->cmdfunc is called later which just points to
> somewhere (because the not relocated BSS isn't cleared).

Hmm... What do you mean by "a non relocated BSS ins't cleared" ? AFAICT, 
the start.S code clears the relocated BSS. Are we in a case where you 
prevent part of the relocation process, such as by using 
CONFIG_SKIP_RELOCATE_UBOOT?

> I'm having this problem with both gcc 4.3.4 and gcc 4.5.1 (along with
> binutils 2.20.1). I'm compiling native.
>
> I've got the idea to add -fPIC while staring add the assembler output of
> nand.c, trying to understand whats happening.
>
> I could send another mail to the list, when I've checked what happens
> when I'm cross-compiling using the ELDK (I think the ELDK uses 4.2.x),
> attaching 4 times nand.s (4.3.4.non-working, 4.5.1.non-working,
> 4.5.1.fPIC.working, 4.2.x.currently_unknown).
>
> nand.s is about 55kB, don't know if I should send about 200k in one mail
> to ml.

Providing the location on the Net of the toolchains will be enough, 
(along with which version of nand.c you're using if that matters).

> Regards,
>
> Alexander

Amicalement,
-- 
Albert.

  reply	other threads:[~2010-10-29 12:08 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-27  7:26 [U-Boot] Most ARM CPU's have buggy clear_bss? Darius Augulis
2010-10-27  8:01 ` Sughosh Ganu
2010-10-27  8:22   ` Darius Augulis
2010-10-27  8:54     ` Sughosh Ganu
2010-10-27  8:58       ` Darius Augulis
2010-10-27  9:09         ` Sughosh Ganu
2010-10-27 10:10           ` Darius Augulis
2010-10-27 10:40             ` Wolfgang Denk
2010-10-27 10:59               ` Darius Augulis
2010-10-27 11:41                 ` Wolfgang Denk
2010-10-27 15:12 ` Eric Cooper
2010-10-27 18:11   ` Darius Augulis
2010-10-28  5:50     ` Heiko Schocher
2010-10-28  6:09       ` Reinhard Meyer
2010-10-28  6:17         ` Heiko Schocher
2010-10-28  6:20           ` Reinhard Meyer
2010-10-28  6:23             ` Reinhard Meyer
2010-10-28  6:35               ` Heiko Schocher
2010-10-28  6:14 ` Heiko Schocher
2010-10-28  6:36   ` Reinhard Meyer
2010-10-28  6:56     ` Darius Augulis
2010-10-28  8:36       ` Wolfgang Denk
2010-10-28  8:31     ` Wolfgang Denk
2010-10-28  8:39   ` Wolfgang Denk
2010-10-28  8:53     ` Heiko Schocher
2010-10-28 10:23     ` Alexander Holler
2010-10-28 11:16       ` Reinhard Meyer
2010-10-28 11:38         ` Wolfgang Denk
2010-10-28 11:55           ` Reinhard Meyer
2010-10-29  9:29           ` Albert ARIBAUD
2010-10-28 11:46         ` [U-Boot] CONFIG_SKIP_RELOCATE_UBOOT still used? Alexander Holler
2010-10-29  9:32           ` Albert ARIBAUD
2010-10-29 11:32             ` Alexander Holler
2010-10-29 11:43               ` Albert ARIBAUD
2010-10-29 11:48                 ` Wolfgang Denk
2010-10-28  9:03 ` [U-Boot] Most ARM CPU's have buggy clear_bss? Alexander Holler
2010-10-28  9:31   ` Alexander Holler
2010-10-29  8:50     ` Alexander Holler
2010-10-29  9:19       ` Albert ARIBAUD
2010-10-29 11:56         ` Alexander Holler
2010-10-29 12:08           ` Albert ARIBAUD [this message]
2010-10-29 12:31             ` Alexander Holler
2010-10-29 13:37               ` Albert ARIBAUD
2010-10-29 13:50                 ` Alexander Holler
2010-10-29 14:04                   ` Albert ARIBAUD
2010-10-29 14:37                 ` Alexander Holler
2010-10-29 14:44                   ` Wolfgang Denk
2010-10-29 14:50                     ` Alexander Holler
2010-10-29 14:50                   ` Reinhard Meyer
2010-10-29 14:58                     ` Alexander Holler
2010-10-29 14:54                   ` Albert ARIBAUD
2010-10-29 15:05                     ` Alexander Holler
2010-10-29 15:23                       ` Albert ARIBAUD
2010-10-29 15:32                         ` Alexander Holler
2010-10-29 15:38                           ` Albert ARIBAUD
2010-10-29 16:56                             ` Alexander Holler

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=4CCAB954.5050506@free.fr \
    --to=albert.aribaud@free.fr \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.