This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/61599] New: [x86_64] With -mcmodel=medium, extern global arrays without size are not treated conservatively.
- From: "tmsriram at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 24 Jun 2014 17:32:09 +0000
- Subject: [Bug target/61599] New: [x86_64] With -mcmodel=medium, extern global arrays without size are not treated conservatively.
- Auto-submitted: auto-generated
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.