From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31532 invoked by alias); 4 Feb 2008 10:42:14 -0000 Received: (qmail 31522 invoked by uid 22791); 4 Feb 2008 10:42:13 -0000 X-Spam-Check-By: sourceware.org Received: from py-out-1112.google.com (HELO py-out-1112.google.com) (64.233.166.176) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 04 Feb 2008 10:41:56 +0000 Received: by py-out-1112.google.com with SMTP id d37so3724410pye.29 for ; Mon, 04 Feb 2008 02:41:54 -0800 (PST) Received: by 10.140.188.10 with SMTP id l10mr4413439rvf.6.1202121713841; Mon, 04 Feb 2008 02:41:53 -0800 (PST) Received: by 10.141.164.11 with HTTP; Mon, 4 Feb 2008 02:41:53 -0800 (PST) Message-ID: <3e004f8e0802040241y28fcbce6jef6bdff06611480@mail.gmail.com> Date: Mon, 04 Feb 2008 10:42:00 -0000 From: "robert song" To: gcc-help@gcc.gnu.org Subject: Problem about mips .data section MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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-02/txt/msg00020.txt.bz2 Hello, everyone. I have met a problem when I used mips gcc to compile a simple test file. The file defines two variables as bellow. const char *h_errlist[] = { "Resolver Error 0 (no error)", "Unknown host", /* 1 HOST_NOT_FOUND */ "Host name lookup failure", /* 2 TRY_AGAIN */ "Unknown server error", /* 3 NO_RECOVERY */ "No address associated with name", /* 4 NO_ADDRESS */ }; int h_nerr = { sizeof h_errlist / sizeof h_errlist[0] }; I found that with the -fdata-sections option, the size of the data section in the library genereated by the file has changed. The results are as bellow. without -fdata-sections: 00010d20 : 10d20: 00000005 00000000 00000000 00000000 ................ 00010d30 : 10d30: 00000c24 00000c40 00000c50 00000c6c ...$...@...P...l 10d40: 00000c84 00000000 00000000 00000000 ................ with -fdata-sections: 00010d30 : 10d30: 00000c30 00000c4c 00000c5c 00000c78 ...0...L...\...x 10d40: 00000c90 .... 00010d44 : 10d44: 00000005 00000000 00000000 ............ I tested it with the compilers of other architectures, and found that they all keep the same size. I have totally no idea how the mips gcc compiler acts with the .data section. BTW, my gcc version : 4.1.1 binutils version:2.17.50 glibc:2.5 Thank you for your help! Best Regards, robert