From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25841 invoked by alias); 17 Aug 2012 17:15:04 -0000 Received: (qmail 25712 invoked by uid 22791); 17 Aug 2012 17:15:01 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_BJ X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 17 Aug 2012 17:14:43 +0000 From: "tom.rini at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/54303] New: -fdata-sections -ffunction-sections and -fmerge-constants do not work well together Date: Fri, 17 Aug 2012 17:15:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tom.rini at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-08/txt/msg01170.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54303 Bug #: 54303 Summary: -fdata-sections -ffunction-sections and -fmerge-constants do not work well together Classification: Unclassified Product: gcc Version: 4.6.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned@gcc.gnu.org ReportedBy: tom.rini@gmail.com Created attachment 28045 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28045 Testcase for the issue The attached test-case demonstrates the problem I see: $ arm-linux-gnueabi-gcc -Wall -fdata-sections -ffunction-sections -o non-collected-strings.o -c non-collected-strings.c $ arm-linux-gnueabi-gcc -Wl,--gc-sections -o non-collected-strings non-collected-strings.o $ strings non-collected-strings | grep here This string should not be here This string should be here $ arm-linux-gnueabi-nm non-collected-strings| grep me 00000000004004d0 t frame_dummy 00000000004004f2 T keep_me $ arm-linux-gnueabi-nm non-collected-strings.o | grep me 0000000000000000 T garbage_collect_me 0000000000000000 T keep_me $ arm-linux-gnueabi-objdump -h non-collected-strings.o | grep str non-collected-strings.o: file format elf32-littlearm 3 .rodata.str1.4 0000003c 00000000 00000000 00000034 2**2 And all strings in the object file are coalesced into a single section. Note that on x86-64 this works as expected as the last step shows instead: $ objdump -h non-collected-strings.o | grep str non-collected-strings.o: file format elf64-x86-64 3 .rodata.str1.8 0000001f 0000000000000000 0000000000000000 00000040 2**3 5 .rodata.str1.1 0000001b 0000000000000000 0000000000000000 0000006f 2**0 I've verified this with a few different arm-linux-gnueabi toolchains (ELDK 4.2, ELDK 5.2.1, Linaro (4:4.6.2-7 in Ubuntu) and this seems like a long-standing thing, not Linaro-patch specific.