Allow abort PLT references in libc.so for SH

Message ID alpine.DEB.2.20.1708152131150.19980@digraph.polyomino.org.uk
State New, archived
Headers

Commit Message

Joseph Myers Aug. 15, 2017, 9:31 p.m. UTC
  Given my patch
<https://gcc.gnu.org/ml/gcc-patches/2017-08/msg00965.html> for the
ICEs building a glibc string function test for SH, the testsuite can
build completely for SH with GCC 7 and mainline.  However, there is a
test failure that does not appear for GCC 6: check-localplt fails
because of an abort PLT reference in libc.so.

Given the lack of a trap insn pattern for SH, it seems unavoidable
that the compiler might sometimes generate abort calls, and such abort
calls (generated from __builtin_trap when there is no trap insn
pattern) will be unaffected by the normal mapping to __GI_abort for
calls within glibc.  Thus, this patch allows (but does not require) an
abort PLT reference in libc.so for SH.

Tested for sh4-linux-gnu with build-many-glibcs.py (GCC 7, with my
patch applied).

2017-08-15  Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/unix/sysv/linux/sh/localplt.data: Allow abort in
	libc.so.
  

Comments

Carlos O'Donell Aug. 16, 2017, 3:56 p.m. UTC | #1
On 08/15/2017 05:31 PM, Joseph Myers wrote:
> Given my patch
> <https://gcc.gnu.org/ml/gcc-patches/2017-08/msg00965.html> for the
> ICEs building a glibc string function test for SH, the testsuite can
> build completely for SH with GCC 7 and mainline.  However, there is a
> test failure that does not appear for GCC 6: check-localplt fails
> because of an abort PLT reference in libc.so.
> 
> Given the lack of a trap insn pattern for SH, it seems unavoidable
> that the compiler might sometimes generate abort calls, and such abort
> calls (generated from __builtin_trap when there is no trap insn
> pattern) will be unaffected by the normal mapping to __GI_abort for
> calls within glibc.  Thus, this patch allows (but does not require) an
> abort PLT reference in libc.so for SH.
> 
> Tested for sh4-linux-gnu with build-many-glibcs.py (GCC 7, with my
> patch applied).
> 
> 2017-08-15  Joseph Myers  <joseph@codesourcery.com>
> 
> 	* sysdeps/unix/sysv/linux/sh/localplt.data: Allow abort in
> 	libc.so.
> 
> diff --git a/sysdeps/unix/sysv/linux/sh/localplt.data b/sysdeps/unix/sysv/linux/sh/localplt.data
> index 2753547..babb19d 100644
> --- a/sysdeps/unix/sysv/linux/sh/localplt.data
> +++ b/sysdeps/unix/sysv/linux/sh/localplt.data
> @@ -10,6 +10,8 @@ libc.so: _Unwind_Find_FDE
>  libc.so: _exit
>  libc.so: __errno_location
>  libm.so: matherr
> +# Generated by the compiler because there is no trap insn pattern.
> +libc.so: abort ?
>  # The main malloc is interposed into the dynamic linker, for
>  # allocations after the initial link (when dlopen is used).
>  ld.so: malloc
> 

I agree that this is a good temporary measure, but why can't gcc be
fixed to use what we use in glibc for ABORT_INSTRUCTION?
  
Joseph Myers Aug. 16, 2017, 5 p.m. UTC | #2
On Wed, 16 Aug 2017, Carlos O'Donell wrote:

> I agree that this is a good temporary measure, but why can't gcc be
> fixed to use what we use in glibc for ABORT_INSTRUCTION?

See the problem in <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70216> 
agreeing *what* trapping instruction to use.
  

Patch

diff --git a/sysdeps/unix/sysv/linux/sh/localplt.data b/sysdeps/unix/sysv/linux/sh/localplt.data
index 2753547..babb19d 100644
--- a/sysdeps/unix/sysv/linux/sh/localplt.data
+++ b/sysdeps/unix/sysv/linux/sh/localplt.data
@@ -10,6 +10,8 @@  libc.so: _Unwind_Find_FDE
 libc.so: _exit
 libc.so: __errno_location
 libm.so: matherr
+# Generated by the compiler because there is no trap insn pattern.
+libc.so: abort ?
 # The main malloc is interposed into the dynamic linker, for
 # allocations after the initial link (when dlopen is used).
 ld.so: malloc