This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: section placement q
Andrew Morton wrote:
>
> void __attribute__ ((__section__ (".some_section"))) foo(void)
> {
> bar("hello, world\n");
> }
>
> The string goes into .rodata. We'd like it in <where?>
i don't know where you'd like to have it, but it _must_ default to
.rodata (for obvious reasons -- the pointer might stick around)
> We either need a way of telling the compiler to divert '.rodata', or a
> construct like:
>
> foo()
> {
> char *p;
>
> p = __attribute__ ((__section__ (".some_section"))) "hello";
> }
fwiw what i once did was:
--- /img/linux-2.3.40pre1/include/linux/init.h Thu Jan 13 18:13:33 2000
+++ linux-2.3.40pre1as/include/linux/init.h Thu Feb 17 03:46:25 2000
@@ -73,6 +73,7 @@ extern struct kernel_param __setup_start
#define __exitdata __attribute__ ((unused, __section__ (".data.exit")))
#define __initsetup __attribute__ ((unused,__section__ (".setup.init")))
#define __init_call __attribute__ ((unused,__section__ (".initcall.init")))
+#define __initstr(s) ({static const char __attribute__((__section__(".rodata.init"))) __is[] = s; __is; })
/* For assembly routines */
#define __INIT .section ".text.init","ax"
and marked all strings as necessary. Saved a few dozen kb, but was
ugly enough that i decided it wasn't worth maintaining.
i can't see much that the compiler could help with here...