From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20299 invoked by alias); 15 Aug 2008 14:25:09 -0000 Received: (qmail 20280 invoked by uid 22791); 15 Aug 2008 14:25:07 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 15 Aug 2008 14:24:28 +0000 Received: from wpaz9.hot.corp.google.com (wpaz9.hot.corp.google.com [172.24.198.73]) by smtp-out.google.com with ESMTP id m7FEOGoY027835; Fri, 15 Aug 2008 15:24:17 +0100 Received: from smtp.corp.google.com (spacemonkey2.corp.google.com [192.168.120.114]) by wpaz9.hot.corp.google.com with ESMTP id m7FEO5SD012738 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 15 Aug 2008 07:24:06 -0700 Received: from localhost.localdomain.google.com (69-36-227-135.cust.layer42.net [69.36.227.135] (may be forged)) (authenticated bits=0) by smtp.corp.google.com (8.13.8/8.13.8) with ESMTP id m7FEO2DN012851 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 15 Aug 2008 07:24:04 -0700 To: "Pan ruochen" Cc: gcc-help@gcc.gnu.org Subject: Re: Can I control the output section for constant strings? References: From: Ian Lance Taylor Date: Fri, 15 Aug 2008 14:27:00 -0000 In-Reply-To: (Pan ruochen's message of "Thu\, 14 Aug 2008 15\:15\:30 +0800") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-08/txt/msg00150.txt.bz2 "Pan ruochen" 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