From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24584 invoked by alias); 24 Jun 2014 17:32:15 -0000 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 Received: (qmail 24560 invoked by uid 48); 24 Jun 2014 17:32:10 -0000 From: "tmsriram at google dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/61599] New: [x86_64] With -mcmodel=medium, extern global arrays without size are not treated conservatively. Date: Tue, 24 Jun 2014 17:32:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 4.10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tmsriram at google 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-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-06/txt/msg01891.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61599 Bug ID: 61599 Summary: [x86_64] With -mcmodel=medium, extern global arrays without size are not treated conservatively. Product: gcc Version: 4.10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: tmsriram at google dot com CC: davidxl at google dot com, ppluzhnikov at google dot com foo.cc ====== char c[1*1024*1024*1024]; extern int bar(); int main() { return bar() + c[225]; } bar.cc ====== extern char c[]; int bar() { return c[225]; } $ g++ -mcmodel=medium foo.cc bar.cc -fdata-sections BFD linker warns: bar.cc:(.text+0x7): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .lbss.c section in foo.o Reason is the compiler does not treat 'c' conservatively as being in .lbss when it does not know its size. Worse, adding -mlarge-data-threshold=0 still does not solve the problem. Changing the declaration "extern char c[]" to "extern char c[1*1024*1024*1024]" solves the problem.