This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 2/X, i386, PR54232] Enable EBX for x86 in 32bits PIC code
- From: Evgeny Stupachenko <evstupac at gmail dot com>
- To: Andrew Pinski <pinskia at gmail dot com>
- Cc: Uros Bizjak <ubizjak at gmail dot com>, Jeff Law <law at redhat dot com>, Vladimir Makarov <vmakarov at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 25 Oct 2014 03:37:55 +0400
- Subject: Re: [PATCH 2/X, i386, PR54232] Enable EBX for x86 in 32bits PIC code
- Authentication-results: sourceware.org; auth=none
- References: <CAOvf_xxXRSvjzRY-MnmBEgwmUhfqbqPjbVw8ZBjwvRheL8AZFA at mail dot gmail dot com> <CA+=Sn1nrUOENX4MKi13OgB40dWGZbf7zH1QJzbBjpte1YTU0xg at mail dot gmail dot com>
What if we remove the check?
glibc build pass?
On Sat, Oct 25, 2014 at 3:09 AM, Andrew Pinski <pinskia@gmail.com> wrote:
> On Fri, Oct 10, 2014 at 12:43 AM, Evgeny Stupachenko <evstupac@gmail.com> wrote:
>> i386 specific part of the patch:
>>
>> 2014-10-08 Ilya Enkovich <ilya.enkovich@intel.com>
>> Vladimir Makarov <vmakarov@redhat.com>
>> * gcc/config/i386/i386.c (ix86_use_pseudo_pic_reg): New.
>> (ix86_init_pic_reg): New.
>> (ix86_select_alt_pic_regnum): Add check on pseudo register.
>> (ix86_save_reg): Likewise.
>> (ix86_expand_prologue): Remove irrelevant code.
>> (ix86_output_function_epilogue): Add check on pseudo register.
>> (set_pic_reg_ever_alive): New.
>> (legitimize_pic_address): Replace df_set_regs_ever_live with new
>> set_pic_reg_ever_alive.
>> (legitimize_tls_address): Likewise.
>> (ix86_pic_register_p): New check.
>> (ix86_delegitimize_address): Add check on pseudo register.
>> (ix86_expand_call): Insert move from pseudo PIC register to ABI
>> defined REAL_PIC_OFFSET_TABLE_REGNUM.
>> (TARGET_INIT_PIC_REG): New.
>> (TARGET_USE_PSEUDO_PIC_REG): New.
>> (PIC_OFFSET_TABLE_REGNUM): New check.
>
>
> This patch breaks glibc's ld.so on i686.
> glibc has a check to make sure the PIC register is setup correctly:
> /* Consistency check for position-independent code. */
> #ifdef __PIC__
> # define check_consistency() \
> ({ int __res; \
> __asm__ __volatile__ \
> (LOAD_PIC_REG_STR (cx) ";" \
> "subl %%ebx, %%ecx;" \
> "je 1f;" \
> "ud2;" \
> "1:\n" \
> : "=c" (__res)); \
> __res; })
> #endif
>
> This depends on ebx being the PIC register. Now we don't have this so
> we get ud2 in some cases.
>
>
>
> Thanks,
> Andrew Pinski