From: Arnd Bergmann <arnd@arndb.de>
To: Jean Delvare <khali@linux-fr.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: Questions on __initdata
Date: Sun, 4 Dec 2005 17:41:43 +0100 [thread overview]
Message-ID: <200512041741.43591.arnd@arndb.de> (raw)
In-Reply-To: <20051204151533.13df37c6.khali@linux-fr.org>
Am Sonntag 04 Dezember 2005 15:15 schrieb Jean Delvare:
> My tests (on i386) seem to suggest that "doesn't apply to uninitialized
> data" only holds for non-global variables. Tagging uninitialized global
> variables __initdata works, and moves the variables from .bss to .data.
> Is it correct? Does it work on all archs? If so, the comment above
> needs to be fixed.
Yes, your observation is correct. Note that newer gcc versions treat
data that is initialized to zero the same way as uninitialized data (by
putting it into .bss), but that should be independent of the architecture.
> I'm also slightly puzzled by the whole concept of __initdata static
> local variables. They only seem to make sense if the function itself is
> tagged __init. If so, isn't it redundant to tag the data __initdata?
No. If the function is tagged __init, it goes into the init section, but
static variable in it still go to .bss, so you have to flag them separately.
It would be nice if gcc could determine that automatically, but the
current __attribute__((section())) syntax does not allow that.
> As a side question, given that an uninitialized global variable being
> tagged __initdata will be moved from .bss to .data, will it become a
> truly uninitialized variable? Or will it automatically be initialized
> to 0 by the compiler as .bss is?
.bss is special in that it is not initialized by the compiler but by the
ELF loader, or case of the kernel, some very early kernel code.
Moving data from .bss to __initdata causes it to be initialized to
zero by the compiler and it becomes part of the object file.
> + *
> + * Uninitialized static local variables cannot be made "__initdata".
> *
As explained above, this sentence is wrong.
> *
> * Also note, that this data cannot be "const".
I think this sentence is wrong as well, can anyone clarify why you should
not be able to have const __initdata?
Arnd <><
next prev parent reply other threads:[~2005-12-04 16:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-04 14:15 Questions on __initdata Jean Delvare
2005-12-04 16:41 ` Arnd Bergmann [this message]
2005-12-05 20:37 ` Ralf Baechle
2005-12-06 13:32 ` Paweł Sikora
2005-12-06 13:48 ` Ralf Baechle
2005-12-06 4:42 ` Keith Owens
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=200512041741.43591.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=khali@linux-fr.org \
--cc=linux-kernel@vger.kernel.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