This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, i386]: Additional fix for PR62599 with -mcmodel=medium -fpic
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Uros Bizjak <ubizjak at gmail dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Jakub Jelinek <jakub at redhat dot com>
- Date: Thu, 12 May 2016 16:19:54 -0700
- Subject: Re: [PATCH, i386]: Additional fix for PR62599 with -mcmodel=medium -fpic
- Authentication-results: sourceware.org; auth=none
- References: <CAFULd4aNJVQ4geKP+9FwZfpNe5GnBj79+2424bFVFQRuN9585A at mail dot gmail dot com>
On Thu, May 12, 2016 at 3:02 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
> 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?
I prefer this patch.
--
H.J.
diff --git a/ld/plugin.c b/ld/plugin.c
index bf66f52..01d76dd 100644
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -674,7 +674,21 @@ get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms,
syms[n].name, FALSE, FALSE, TRUE);
if (!blhe)
{
- res = LDPR_UNKNOWN;
+ /* This symbol is defined and referenced only in IR. */
+ switch (syms[n].def)
+ {
+ default:
+ abort ();
+ case LDPK_UNDEF:
+ case LDPK_WEAKUNDEF:
+ res = LDPR_UNDEF;
+ break;
+ case LDPK_DEF:
+ case LDPK_WEAKDEF:
+ case LDPK_COMMON:
+ res = LDPR_PREVAILING_DEF_IRONLY;
+ break;
+ }
goto report_symbol;
}