* Can I control the output section for constant strings?
@ 2008-08-14 9:31 Pan ruochen
2008-08-15 14:27 ` Ian Lance Taylor
0 siblings, 1 reply; 2+ messages in thread
From: Pan ruochen @ 2008-08-14 9:31 UTC (permalink / raw)
To: gcc-help
Hi All
For the following code:
|----------------------------------------------------|
| #define __init __attribute__((section(".init"))) |
| int __init foo_init(void) |
| { |
| ... |
| printf("foo_init\n"); |
| ... |
| } |
|----------------------------------------------------|
I want gcc to put the constant string "foo_init\n" into the section
.init as well, instead of the section .rodata. And for other functions
which are not marked as __init, the constant strings are put defaultly.
Can I do this? And how?
-------------
Best Regards,
PRC
Aug 14, 2008
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Can I control the output section for constant strings?
2008-08-14 9:31 Can I control the output section for constant strings? Pan ruochen
@ 2008-08-15 14:27 ` Ian Lance Taylor
0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2008-08-15 14:27 UTC (permalink / raw)
To: Pan ruochen; +Cc: gcc-help
"Pan ruochen" <panruochen@gmail.com> writes:
> For the following code:
> |----------------------------------------------------|
> | #define __init __attribute__((section(".init"))) |
> | int __init foo_init(void) |
> | { |
> | ... |
> | printf("foo_init\n"); |
> | ... |
> | } |
> |----------------------------------------------------|
> I want gcc to put the constant string "foo_init\n" into the section
> .init as well, instead of the section .rodata. And for other functions
> which are not marked as __init, the constant strings are put defaultly.
> Can I do this? And how?
static const char foo_init_string[] __attribute__((section(".init"))) =
"foo_init\n";
...
printf(foo_init_string);
I don't think there is any way to make this happen automatically.
Ian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-08-15 14:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-14 9:31 Can I control the output section for constant strings? Pan ruochen
2008-08-15 14:27 ` Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).