Re: Can I control the output section for constant strings?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Pan ruochen" <panruochen@xxxxxxxxx> 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

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux