public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@google.com>
To: "Pan ruochen" <panruochen@gmail.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: Can I control the output section for constant strings?
Date: Fri, 15 Aug 2008 14:27:00 -0000	[thread overview]
Message-ID: <m3vdy2e4r1.fsf@google.com> (raw)
In-Reply-To: <af0faace0808140015i546d9a41o85d2adb4575273f0@mail.gmail.com> (Pan ruochen's message of "Thu\, 14 Aug 2008 15\:15\:30 +0800")

"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

      reply	other threads:[~2008-08-15 14:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-14  9:31 Pan ruochen
2008-08-15 14:27 ` Ian Lance Taylor [this message]

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=m3vdy2e4r1.fsf@google.com \
    --to=iant@google.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=panruochen@gmail.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).