[committed] MAINTAINERS: add myself for write after approval

2020-11-09 Thread Pat Bernardi
2020-11-09  Pat Bernardi  

* MAINTAINERS (Write After Approval): Add myself.
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 24b77f5e663..a0216185de9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -323,6 +323,7 @@ Jon Beniston

 Andrew Bennett 
 Andrew Benson  
 Daniel Berlin  
+Pat Bernardi   
 Jan Beulich
 David Billinghurst 

 Tomas Bily 
-- 
2.27.0



Re: [PATCH] i386: Cleanup i386/i386elf.h and align it's return convention with the SVR4 ABI

2020-11-04 Thread Pat Bernardi
> So, since the unpatched compiler crashes with an example that would
> make a difference, I think the patch is OK as it is.

Thanks for taking the time to look at that Uros, and apologies for not getting 
back to you sooner.

With regards to your other question:

> So, is it necessary to define DEFAULT_PCC_STRUCT_RETURN ?

It’s not necessary, but a number of other i386 targets like GNU and NetBSD have 
it explicitly defined. I wasn’t sure if it was for legacy reasons or to 
document clearly the choice. I can prepare a patch to remove 
DEFAULT_PCC_STRUCT_RETURN from i386elf.h if you think it would be clearer not 
to explicitly define it.

Thanks,

Pat Bernardi

[PATCH] i386: Set the stack usage to 0 for naked functions

2020-10-30 Thread Pat Bernardi
-fstack-usage raises a "stack usage computation not supported for this target"
warning when it encounters a naked function because the prologue returns early
for naked function on i386. This patch sets the stack usage to zero for naked 
function, following the fix done for Arm by Eric Botcazou:

https://gcc.gnu.org/pipermail/gcc-patches/2016-May/448258.html

Bootstrapped and tested on x86_64-linux. If approved, I'll need a maintainer to
commit on my behalf.

Thanks,

Pat Bernardi
Senior Software Engineer, AdaCore


2020-10-29  Pat Bernardi  

gcc/ChangeLog

* config/i386/i386.c (ix86_expand_prologue): Set the stack usage to 0
for naked functions.

---
 gcc/config/i386/i386.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 0268d87f198..129fe6fa1eb 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -13197,7 +13197,11 @@ ix86_expand_prologue (void)
   rtx static_chain = NULL_RTX;

   if (ix86_function_naked (current_function_decl))
-return;
+{
+  if (flag_stack_usage_info)
+   current_function_static_stack_size = 0;
+  return;
+}

   ix86_finalize_stack_frame_flags ();



[PATCH] SPARC: add leon3v7 libgcc to leon3-elf

2020-10-29 Thread Pat Bernardi
This patch adds the leon3v7 version of libgcc to the leon3-elf target.

If approved, I'll need a maintainer to kindly commit on my behalf.

Thanks,

Pat Bernardi
Senior Software Engineer, AdaCore


2020-10-29  Pat Bernardi  mailto:berna...@adacore.com>>

gcc/ChangeLog

* config/sparc/t-leon3: Add leon3v7 version of libgcc.

libgcc/Changelog

* config.host (sparc-*-elf*): Use sparc/t-softmul on leon3

---
gcc/config/sparc/t-leon3 | 4 ++--
libgcc/config.host   | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/config/sparc/t-leon3 b/gcc/config/sparc/t-leon3
index 283ca6c45c3..e5bad3d99cf 100644
--- a/gcc/config/sparc/t-leon3
+++ b/gcc/config/sparc/t-leon3
@@ -17,6 +17,6 @@
# <http://www.gnu.org/licenses/ <http://www.gnu.org/licenses/>>.

# Multilibs for LEON3
-MULTILIB_OPTIONS = msoft-float
-MULTILIB_DIRNAMES = soft
+MULTILIB_OPTIONS = mcpu=leon3v7 msoft-float
+MULTILIB_DIRNAMES = leon3v7 soft
MULTILIB_MATCHES = msoft-float=mno-fpu
diff --git a/libgcc/config.host b/libgcc/config.host
index 5576c8c3723..e58ba75c873 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -1283,7 +1283,7 @@ sparc64-*-openbsd*)
;;
sparc-*-elf*)
case ${host} in
-   *-leon[3-9]*)
+   *-leon[4-9]*)
;;
*)
tmake_file="sparc/t-softmul"


Ping: [PATCH] i386: Cleanup i386/i386elf.h and align it's return convention with the SVR4 ABI

2020-10-29 Thread Pat Bernardi
Ping: https://gcc.gnu.org/pipermail/gcc-patches/2020-August/552186.html 
<https://gcc.gnu.org/pipermail/gcc-patches/2020-August/552186.html>

Thanks.

> On 18 Aug 2020, at 6:02 pm, Pat Bernardi  wrote:
> 
> As observed a number of years ago in the following thread, i386/i386elf.h has 
> not been kept up to date:
> 
> https://gcc.gnu.org/pipermail/gcc/2013-August/209981.html
> 
> This patch does the following cleanup:
> 
> 1. The return convention now follows the i386 and x86_64 SVR4 ABIs again. As 
> discussed in the above thread, the current return convention does not match 
> any other target or existing ABI, which is problematic since the current 
> approach is inefficient (particularly on x86_64-elf) and confuses other tools 
> like GDB (unfortunately that thread did not lead to any fix at the time). 
> 
> 2. The default version of ASM_OUTPUT_ASCII from elfos.h is used. As mentioned 
> in the cleanup of i386/sysv4.h [1] the ASM_OUTPUT_ASCII implementation then 
> used by sysv4.h, and currently used by i386elf.h, has a significantly higher 
> computation complexity than the default version provided by elfos.h.
> 
> [1] https://gcc.gnu.org/pipermail/gcc-patches/2011-February/305559.html



[PATCH] i386: Add c99 runtime requirement to math optimisation tests

2020-08-18 Thread Pat Bernardi
A number of i386 math optimisation tests are looking assembly instructions
that are only emitted when the compiler knows the target has a C99 libm
available. Since targets like *-elf may not have such a libm, a C99 runtime
requirement is added to these tests.

Tested on x86-elf and x86_64-elf hosted on x86_64-linux in addition to 
x86_64-pc-linux-gnu

If approved, I'll need a maintainer to kindly commit on my behalf.

Thanks,

Pat Bernardi
Senior Software Engineer, AdaCore

2020-08-18  Pat Bernardi  

gcc/testsuite/ChangeLog

* gcc.target/i386/387-7.c: Add dg-require-effective-target c99_runtime.
* gcc.target/i386/387-9.c: Likewise.
* gcc.target/i386/avx512bw-pr96246-1.c: Likewise.
* gcc.target/i386/avx512f-rint-sfix-vec-2.c: Likewise.
* gcc.target/i386/avx512f-rintf-sfix-vec-2.c: Likewise.
* gcc.target/i386/avx512vl-pr96246-1.c: Likewise.
* gcc.target/i386/pr61403.c: Likewise.
* gcc.target/i386/sse4_1-ceil-sfix-vec.c: Likewise.
* gcc.target/i386/sse4_1-ceilf-sfix-vec.c: Likewise.
* gcc.target/i386/sse4_1-floor-sfix-vec.c: Likewise.
* gcc.target/i386/sse4_1-floorf-sfix-vec.c: Likewise.
* gcc.target/i386/sse4_1-rint-sfix-vec.c: Likewise.
* gcc.target/i386/sse4_1-rintf-sfix-vec.c: Likewise.
* gcc.target/i386/sse4_1-round-sfix-vec.c: Likewise.
* gcc.target/i386/sse4_1-roundf-sfix-vec.c: Likewise.
---
 gcc/testsuite/gcc.target/i386/387-7.c| 1 +
 gcc/testsuite/gcc.target/i386/387-9.c| 1 +
 gcc/testsuite/gcc.target/i386/avx512bw-pr96246-1.c   | 1 +
 gcc/testsuite/gcc.target/i386/avx512f-rint-sfix-vec-2.c  | 1 +
 gcc/testsuite/gcc.target/i386/avx512f-rintf-sfix-vec-2.c | 1 +
 gcc/testsuite/gcc.target/i386/avx512vl-pr96246-1.c   | 1 +
 gcc/testsuite/gcc.target/i386/pr61403.c  | 1 +
 gcc/testsuite/gcc.target/i386/sse4_1-ceil-sfix-vec.c | 1 +
 gcc/testsuite/gcc.target/i386/sse4_1-ceilf-sfix-vec.c| 1 +
 gcc/testsuite/gcc.target/i386/sse4_1-floor-sfix-vec.c| 1 +
 gcc/testsuite/gcc.target/i386/sse4_1-floorf-sfix-vec.c   | 1 +
 gcc/testsuite/gcc.target/i386/sse4_1-rint-sfix-vec.c | 1 +
 gcc/testsuite/gcc.target/i386/sse4_1-rintf-sfix-vec.c| 1 +
 gcc/testsuite/gcc.target/i386/sse4_1-round-sfix-vec.c| 1 +
 gcc/testsuite/gcc.target/i386/sse4_1-roundf-sfix-vec.c   | 1 +
 15 files changed, 15 insertions(+)

diff --git a/gcc/testsuite/gcc.target/i386/387-7.c 
b/gcc/testsuite/gcc.target/i386/387-7.c
index e01ed2e0576..3c1ad606462 100644
--- a/gcc/testsuite/gcc.target/i386/387-7.c
+++ b/gcc/testsuite/gcc.target/i386/387-7.c
@@ -1,6 +1,7 @@
 /* Verify that 387 fsincos instruction is generated.  */
 /* { dg-do compile } */
 /* { dg-options "-O -ffast-math -mfpmath=387 -mfancy-math-387" } */
+/* { dg-require-effective-target c99_runtime } */
 /* { dg-final { scan-assembler "fsincos" } } */
 
 extern double sin (double);
diff --git a/gcc/testsuite/gcc.target/i386/387-9.c 
b/gcc/testsuite/gcc.target/i386/387-9.c
index 2667aa46872..469c635e479 100644
--- a/gcc/testsuite/gcc.target/i386/387-9.c
+++ b/gcc/testsuite/gcc.target/i386/387-9.c
@@ -1,6 +1,7 @@
 /* Verify that 387 fsincos instruction is generated.  */
 /* { dg-do compile } */
 /* { dg-options "-O -funsafe-math-optimizations -mfpmath=387 -mfancy-math-387" 
} */
+/* { dg-require-effective-target c99_runtime } */
 
 extern double sin (double);
 extern double cos (double);
diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-pr96246-1.c 
b/gcc/testsuite/gcc.target/i386/avx512bw-pr96246-1.c
index 2bfcc840a91..4aaa28866ca 100644
--- a/gcc/testsuite/gcc.target/i386/avx512bw-pr96246-1.c
+++ b/gcc/testsuite/gcc.target/i386/avx512bw-pr96246-1.c
@@ -1,6 +1,7 @@
 /* PR target/96246 */
 /* { dg-do compile } */
 /* { dg-options "-O2 -ftree-vectorize -mavx512bw" } */
+/* { dg-require-effective-target c99_runtime } */
 /* { dg-final { scan-assembler-times "vpblendm\[bwdq\]\[\t ]" 4 } } */
 /* { dg-final { scan-assembler-times "vblendmp\[sd\]\[\t ]" 2 } } */
 
diff --git a/gcc/testsuite/gcc.target/i386/avx512f-rint-sfix-vec-2.c 
b/gcc/testsuite/gcc.target/i386/avx512f-rint-sfix-vec-2.c
index c3f78ac3f25..2d2099f77cb 100644
--- a/gcc/testsuite/gcc.target/i386/avx512f-rint-sfix-vec-2.c
+++ b/gcc/testsuite/gcc.target/i386/avx512f-rint-sfix-vec-2.c
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -ffast-math -ftree-vectorize -mavx512f" } */
+/* { dg-require-effective-target c99_runtime } */
 
 #include "avx512f-rint-sfix-vec-1.c"
 
diff --git a/gcc/testsuite/gcc.target/i386/avx512f-rintf-sfix-vec-2.c 
b/gcc/testsuite/gcc.target/i386/avx512f-rintf-sfix-vec-2.c
index c172e61f84a..fe473766c86 100644
--- a/gcc/testsuite/gcc.target/i386/avx512f-rintf-sfix-vec-2.c
+++ b/gcc/testsuite/gcc.target/i386/avx512f-rintf-sfix-vec-2.c
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -ffas

[PATCH] testsuite: require c99 runtime for trigonometric optimisation tests

2020-08-18 Thread Pat Bernardi
A number of optimisation that simplify trigonometric expressions are only
performed when the compiler knows the target has a C99 libm available.
Since targets like *-elf may not have such a libm, a C99 runtime requirement
is added to these tests.

Tested on x86-elf and x86_64-elf hosted on x86_64-linux in addition to 
x86_64-pc-linux-gnu

If approved, I'll need a maintainer to kindly commit on my behalf.

Thanks,

Pat Bernardi
Senior Software Engineer, AdaCore

2020-08-18  Pat Bernardi  

gcc/testsuite/ChangeLog

* gcc.dg/sinatan-2.c: Add dg-require-effective-target c99_runtime.
* gcc.dg/sinhovercosh-1.c: Likewise.
* gcc.dg/tanhbysinh.c: Likewise.
---
 gcc/testsuite/gcc.dg/sinatan-2.c  | 1 +
 gcc/testsuite/gcc.dg/sinhovercosh-1.c | 1 +
 gcc/testsuite/gcc.dg/tanhbysinh.c | 3 ++-
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/sinatan-2.c b/gcc/testsuite/gcc.dg/sinatan-2.c
index 8e7ea3c90fc..64d6d301535 100644
--- a/gcc/testsuite/gcc.dg/sinatan-2.c
+++ b/gcc/testsuite/gcc.dg/sinatan-2.c
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-Ofast -fdump-tree-optimized" } */
+/* { dg-require-effective-target c99_runtime } */
 
 extern float sinf (float);
 extern float cosf (float);
diff --git a/gcc/testsuite/gcc.dg/sinhovercosh-1.c 
b/gcc/testsuite/gcc.dg/sinhovercosh-1.c
index d41093fa6de..564d3c51b3e 100644
--- a/gcc/testsuite/gcc.dg/sinhovercosh-1.c
+++ b/gcc/testsuite/gcc.dg/sinhovercosh-1.c
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-Ofast -fdump-tree-optimized" } */
+/* { dg-require-effective-target c99_runtime } */
 
 extern float sinhf (float);
 extern float coshf (float);
diff --git a/gcc/testsuite/gcc.dg/tanhbysinh.c 
b/gcc/testsuite/gcc.dg/tanhbysinh.c
index fde72c2f93b..9dbe133ec74 100644
--- a/gcc/testsuite/gcc.dg/tanhbysinh.c
+++ b/gcc/testsuite/gcc.dg/tanhbysinh.c
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-Ofast -fdump-tree-optimized" } */
+/* { dg-require-effective-target c99_runtime } */
 
 extern float sinhf (float);
 extern float tanhf (float);
@@ -37,4 +38,4 @@ tanhbysinhl_ (long double x)
 /* {dg-final { scan-tree-dump-not "tanhl " "optimized" }} */
 /* { dg-final { scan-tree-dump "cosh " "optimized" } } */
 /* { dg-final { scan-tree-dump "coshf " "optimized" } } */
-/* { dg-final { scan-tree-dump "coshl " "optimized" } } */
\ No newline at end of file
+/* { dg-final { scan-tree-dump "coshl " "optimized" } } */
-- 
2.27.0



[PATCH] i386: Cleanup i386/i386elf.h and align it's return convention with the SVR4 ABI

2020-08-18 Thread Pat Bernardi
As observed a number of years ago in the following thread, i386/i386elf.h has 
not been kept up to date:

https://gcc.gnu.org/pipermail/gcc/2013-August/209981.html

This patch does the following cleanup:

1. The return convention now follows the i386 and x86_64 SVR4 ABIs again. As 
discussed in the above thread, the current return convention does not match any 
other target or existing ABI, which is problematic since the current approach 
is inefficient (particularly on x86_64-elf) and confuses other tools like GDB 
(unfortunately that thread did not lead to any fix at the time). 

2. The default version of ASM_OUTPUT_ASCII from elfos.h is used. As mentioned 
in the cleanup of i386/sysv4.h [1] the ASM_OUTPUT_ASCII implementation then 
used by sysv4.h, and currently used by i386elf.h, has a significantly higher 
computation complexity than the default version provided by elfos.h.

The patch has been tested on i386-elf and x86_64-elf hosted on x86_64-linux, 
fixing a number failing tests that were expecting the SVR4 ABI return 
convention. It has also been bootstrapped and tested on x86_64-pc-linux-gnu 
without regression.

If approved, I'll need a maintainer to kindly commit on my behalf.

Thanks,

Pat Bernardi
Senior Software Engineer, AdaCore

[1] https://gcc.gnu.org/pipermail/gcc-patches/2011-February/305559.html

2020-08-18  Pat Bernardi  

gcc/ChangeLog

* config/i386/i386elf.h (SUBTARGET_RETURN_IN_MEMORY): Remove.
(ASM_OUTPUT_ASCII): Likewise.
(DEFAULT_PCC_STRUCT_RETURN): Define.
* config/i386/i386.c (ix86_return_in_memory): Remove
SUBTARGET_RETURN_IN_MEMORY.

From fe617455561a4c8d898b4e231c447b16e5661e10 Mon Sep 17 00:00:00 2001
From: Pat Bernardi 
Date: Fri, 14 Aug 2020 17:34:38 -0400
Subject: [PATCH] i386: Cleanup i386/i386elf.h and align it's return convention
 with the SVR4 ABI

While i386elf.h was originally derived from sysv4.h it has not been kept
up to date with the development of the compiler. Two changes are made:

* The return convention now follows the i386 and x86_64 SVR4 ABIs again.

* The more efficient default version of ASM_OUTPUT_ASCII in elfos.h is used.

2020-08-18  Pat Bernardi  

gcc/ChangeLog

* config/i386/i386elf.h (SUBTARGET_RETURN_IN_MEMORY): Remove.
(ASM_OUTPUT_ASCII): Likewise.
(DEFAULT_PCC_STRUCT_RETURN): Define.
* config/i386/i386.c (ix86_return_in_memory): Remove
SUBTARGET_RETURN_IN_MEMORY.
---
 gcc/config/i386/i386.c|  4 ---
 gcc/config/i386/i386elf.h | 62 ---
 2 files changed, 6 insertions(+), 60 deletions(-)

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index e9ecb94d174..65e87b41e80 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -3796,9 +3796,6 @@ ix86_libcall_value (machine_mode mode)
 static bool
 ix86_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED)
 {
-#ifdef SUBTARGET_RETURN_IN_MEMORY
-  return SUBTARGET_RETURN_IN_MEMORY (type, fntype);
-#else
   const machine_mode mode = type_natural_mode (type, NULL, true);
   HOST_WIDE_INT size;
 
@@ -3879,7 +3876,6 @@ ix86_return_in_memory (const_tree type, const_tree fntype 
ATTRIBUTE_UNUSED)
 
   return false;
 }
-#endif
 }
 
 
diff --git a/gcc/config/i386/i386elf.h b/gcc/config/i386/i386elf.h
index eb2203cf323..05cee89f795 100644
--- a/gcc/config/i386/i386elf.h
+++ b/gcc/config/i386/i386elf.h
@@ -19,12 +19,12 @@ You should have received a copy of the GNU General Public 
License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-/* The ELF ABI for the i386 says that records and unions are returned
-   in memory.  */
-
-#define SUBTARGET_RETURN_IN_MEMORY(TYPE, FNTYPE) \
-   (TYPE_MODE (TYPE) == BLKmode \
-|| (VECTOR_MODE_P (TYPE_MODE (TYPE)) && int_size_in_bytes (TYPE) == 8))
+/* Define DEFAULT_PCC_STRUCT_RETURN to 1 because the i386 SVR4 ABI returns
+   records and unions in memory. ix86_option_override_internal will overide
+   this flag when compiling 64-bit code as we never do pcc_struct_return
+   scheme on x86-64.  */
+#undef DEFAULT_PCC_STRUCT_RETURN
+#define DEFAULT_PCC_STRUCT_RETURN 1
 
 #undef CPP_SPEC
 #define CPP_SPEC ""
@@ -40,56 +40,6 @@ along with GCC; see the file COPYING3.  If not see
 #define DBX_REGISTER_NUMBER(n) \
   (TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n])
 
-/* The routine used to output sequences of byte values.  We use a special
-   version of this for most svr4 targets because doing so makes the
-   generated assembly code more compact (and thus faster to assemble)
-   as well as more readable.  Note that if we find subparts of the
-   character sequence which end with NUL (and which are shorter than
-   ELF_STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING.  */
-
-#undef ASM_OUTPUT_ASCII
-#define ASM_OUTPUT_ASCII(FILE, STR, LENGTH)   

[PATCH] m68k: tag floating-point ABI used

2020-06-25 Thread Pat Bernardi
Tag the floating-point calling convention used on m68k-elf (either hard-float
or soft-float) through the GNU assembler attribute. The use of the tag enables
the linker to ensure linked objects use a consistent floating-point ABI and
allows tools like GDB to infer the ABI used from the ELF file. It is based on
similar work done for PowerPC.

The patch has been tested for m68k-elf and x86-64/Linux. Since tagging is only
enabled when the m68k assembler supports GNU attributes, this patch can be
applied independently from the corresponding binutils patch.

If approved, I'll need a maintainer to commit on my behalf.

Thanks,

Pat Bernardi
AdaCore

---
2020-06-25  Pat Bernardi  

gcc/ChangeLog
* configure.ac: Check m68k assembler supports .gnu_attribute.
* configure: Regenerate.
* config/m68k/linux.h (TARGET_ELF, M68K_LINUX): Define.
* config/m68k/m68kelf.h (TARGET_ELF): Define.
* config/m68k/m68k.c (m68k_elf_file_end): New function.
(TARGET_ASM_FILE_END): Define.
(m68k_passes_float): New static variable.
(m68k_libcall_value, m68k_function_value): set m68k_passes_float if
value is floating point.
(m68k_elf_file_end): New function.

gcc/testsuite/ChangeLog
* gcc.target/m68k/gnuattr1.c: New file.
* gcc.target/m68k/gnuattr2.c: Likewise.

diff --git a/gcc/config/m68k/linux.h b/gcc/config/m68k/linux.h
index 0d18e5ae5ac..2e064ef486d 100644
--- a/gcc/config/m68k/linux.h
+++ b/gcc/config/m68k/linux.h
@@ -18,6 +18,11 @@ You should have received a copy of the GNU General Public 
License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.  */

+/* Target is ELF and M68K_LINUX */
+
+#define TARGET_ELF
+#define M68K_LINUX
+
/* Add %(asm_cpu_spec) to a generic definition of ASM_SPEC.  */
#undef ASM_SPEC
#define ASM_SPEC "%(asm_cpu_spec) %(asm_pcrel_spec)"
@@ -226,8 +231,6 @@ along with GCC; see the file COPYING3.  If not see
 : "%d0", "%d2", "%d3");\
}

-#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
-
#undef DBX_REGISTER_NUMBER
#define DBX_REGISTER_NUMBER(REGNO) (REGNO)

diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c
index 67b109447b3..f6809386bf2 100644
--- a/gcc/config/m68k/m68k.c
+++ b/gcc/config/m68k/m68k.c
@@ -196,7 +196,8 @@ static bool m68k_modes_tieable_p (machine_mode, 
machine_mode);
static machine_mode m68k_promote_function_mode (const_tree, machine_mode,
int *, const_tree, int);
static void m68k_asm_final_postscan_insn (FILE *, rtx_insn *insn, rtx [], int);
-
+static void m68k_elf_file_end (void) ATTRIBUTE_UNUSED;
+
/* Initialize the GCC target structure.  */

#if INT_OP_GROUP == INT_OP_DOT_WORD
@@ -360,6 +361,11 @@ static void m68k_asm_final_postscan_insn (FILE *, rtx_insn 
*insn, rtx [], int);
#undef TARGET_ASM_FINAL_POSTSCAN_INSN
#define TARGET_ASM_FINAL_POSTSCAN_INSN m68k_asm_final_postscan_insn

+#ifdef TARGET_ELF
+#undef TARGET_ASM_FILE_END
+#define TARGET_ASM_FILE_END m68k_elf_file_end
+#endif
+
static const struct attribute_spec m68k_attribute_table[] =
{
  /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
@@ -482,6 +488,11 @@ unsigned int m68k_cpu_flags;
/* The set of FL_* flags that apply to the processor to be tuned for.  */
unsigned int m68k_tune_flags;

+#ifdef HAVE_AS_GNU_ATTRIBUTE
+/* Flag whether floating point values have been passed/returned. */
+static bool m68k_passes_float;
+#endif
+
/* Asm templates for calling or jumping to an arbitrary symbolic address,
   or NULL if such calls or jumps are not supported.  The address is held
   in operand 0.  */
@@ -5823,6 +5834,9 @@ m68k_libcall_value (machine_mode mode)
  case E_SFmode:
  case E_DFmode:
  case E_XFmode:
+#ifdef HAVE_AS_GNU_ATTRIBUTE
+m68k_passes_float = true;
+#endif
if (TARGET_68881)
  return gen_rtx_REG (mode, FP0_REG);
break;
@@ -5846,6 +5860,9 @@ m68k_function_value (const_tree valtype, const_tree func 
ATTRIBUTE_UNUSED)
  case E_SFmode:
  case E_DFmode:
  case E_XFmode:
+#ifdef HAVE_AS_GNU_ATTRIBUTE
+m68k_passes_float = true;
+#endif
if (TARGET_68881)
  return gen_rtx_REG (mode, FP0_REG);
break;
@@ -7150,4 +7167,21 @@ m68k_promote_function_mode (const_tree type, 
machine_mode mode,
  return mode;
}

+/* Write out end of ELF file attributes */
+
+static void
+m68k_elf_file_end (void)
+{
+#ifdef HAVE_AS_GNU_ATTRIBUTE
+  /* TARGET_68881 indicates use of hard-float ABI */
+  if (m68k_passes_float)
+  fprintf (asm_out_file, "\t.gnu_attribute 4, %d\n",
+   TARGET_68881 ? 1 : 2);
+#endif
+
+#if defined (M68K_LINUX)
+  file_end_indicate_exec_stack ();
+#endif
+}
+
#include "gt-m68k.h"
diff --git a/gcc/config/m68k/m68kelf.h b/gcc/config/m68k/m68kelf.h
index f10dd326732..849481e9307 100644
--- a/gcc/config/m68k/m68kelf.h
+++ b/gcc/config/m68k/m68kelf.h
@@ -21,6 +21,9 @@