public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, i386]: Additional fix for PR62599 with -mcmodel=medium -fpic
@ 2016-05-12 22:03 Uros Bizjak
  2016-05-12 23:19 ` H.J. Lu
  0 siblings, 1 reply; 8+ messages in thread
From: Uros Bizjak @ 2016-05-12 22:03 UTC (permalink / raw)
  To: gcc-patches; +Cc: H.J. Lu, Jakub Jelinek

[-- Attachment #1: Type: text/plain, Size: 937 bytes --]

Hello!

testsuite/gcc.target/i386/pr61599-{1,2}.c testcases expose a failure
with -mcmodel -fpic, where:

/tmp/ccfpoxHY.o: In function `bar':
pr61599-2.c:(.text+0xe): relocation truncated to fit: R_X86_64_PC32
against symbol `a' defined in LARGE_COMMON section in /tmp/ccKTKST2.o
collect2: error: ld returned 1 exit status
compiler exited with status 1

CM_MEDIUM_PIC code model assumes that code+got/plt fits in a 31 bit
region, data is unlimited. Based on these assumptions, code should be
accessed via R_X86_64_GOT64.

Attached patch uses UNSPEC_GOT instead of UNSPEC_GOTPCREL also for
CM_MEDIUM_PIC.

2016-05-12  Uros Bizjak  <ubizjak@gmail.com>

    PR target/61599
    * config/i386/i386.c (legitimize_pic_address): Do not use
    UNSPEC_GOTPCREL for CM_MEDIUM_PIC code model.

Patch was bootstrapped on x86_64-linux-gnu and regression tested with
-mcmodel=medium -fpic.

Jakub, H.J., do you have any comments on the patch?

Uros.

[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 574 bytes --]

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 236182)
+++ config/i386/i386.c	(working copy)
@@ -15475,7 +15475,7 @@ legitimize_pic_address (rtx orig, rtx reg)
 	  new_rtx = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr), UNSPEC_PCREL);
 	  new_rtx = gen_rtx_CONST (Pmode, new_rtx);
 	}
-      else if (TARGET_64BIT && ix86_cmodel != CM_LARGE_PIC)
+      else if (TARGET_64BIT && ix86_cmodel == CM_SMALL_PIC)
 	{
 	  new_rtx = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr),
 				    UNSPEC_GOTPCREL);

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

end of thread, other threads:[~2016-05-13 17:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-12 22:03 [PATCH, i386]: Additional fix for PR62599 with -mcmodel=medium -fpic Uros Bizjak
2016-05-12 23:19 ` H.J. Lu
2016-05-12 23:20   ` H.J. Lu
2016-05-13  7:07     ` Uros Bizjak
2016-05-13 16:51       ` Uros Bizjak
2016-05-13 17:03         ` Uros Bizjak
2016-05-13 17:21         ` H.J. Lu
2016-05-13 17:22           ` Uros Bizjak

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).