public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/63538] New: [X86_64] With -mcmodel=medium .lrodata accesses do not use 64-bit addresses
@ 2014-10-14 20:14 tmsriram at google dot com
  2014-11-03 20:46 ` [Bug target/63538] " ubizjak at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: tmsriram at google dot com @ 2014-10-14 20:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63538

            Bug ID: 63538
           Summary: [X86_64] With -mcmodel=medium .lrodata accesses do not
                    use 64-bit addresses
           Product: gcc
           Version: 5.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

foo.cc
======

#include <stdio.h>

const char *str = "Hello World";

int main() {
 printf("str = %p %s\n",str, str);
 return 0;
}


$ g++ --save-temps foo.cc -mcmodel=medium -mlarge-data-threshold=0 -O2

Linked with gold linker.

Look at foo.s:
===========

       .section        .lrodata,"a",@progbits
.LC0:
       .string "str = %p %s\n"

.....

main:
    ...
    movl       $.LC0, %edi

This is the problem, it treats .LC0 as a 32-bit address when it should a 64-bit
address since it is placed in .lrodata

Now this bug will not manifest until .lrodata exceeds the 2GB limit.  That can
be done by linking with -Wl,-Ttext=0x7ffff000  which moves the start address of
.text to be very close to 2GB and enough to throw .lrodata out of the limit.

Program segfaults.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-11-05 22:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-14 20:14 [Bug target/63538] New: [X86_64] With -mcmodel=medium .lrodata accesses do not use 64-bit addresses tmsriram at google dot com
2014-11-03 20:46 ` [Bug target/63538] " ubizjak at gmail dot com
2014-11-05 21:00 ` uros at gcc dot gnu.org
2014-11-05 22:23 ` uros at gcc dot gnu.org
2014-11-05 22:25 ` ubizjak at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).