[newlib-cygwin/main] libgloss: mips: g++ exception handling failure on o32 elf targets

Jeff Johnston jjohnstn@sourceware.org
Sat Jul 5 01:26:46 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=9d9c0c70e88b88cad1691f8572f66100e690a6af

commit 9d9c0c70e88b88cad1691f8572f66100e690a6af
Author: Faraz Shahbazker <fshahbazker@wavecomp.com>
Date:   Wed Nov 21 10:33:47 2018 -0800

    libgloss: mips: g++ exception handling failure on o32 elf targets
    
    The compiler driver positions the linker script at the end of the linker
    command-line, after crtend.o. As a result, any INPUT objects and archive
    GROUPs introduced by the linker script end up after crtend.o.  This messes up
    the end-of-frame marker provided by crtend.o
    
    This has always been a problem, but a recent binutils update to clean-up
    redundant NULL markers in .eh_frame exposes it as a execution failure in
    exception-handling tests. This patch re-orders .eh_frame in all linker
    scripts so that the one from crtend.o is placed last.
    
    An alternative approach would be to fix the compiler driver to put
    the linker script before the ENDFILE spec.
    
    Signed-off-by: Jovan Dmitrović <jovan.dmitrovic@htecgroup.com>

Diff:
---
 libgloss/mips/uhi32.ld     | 9 ++++++++-
 libgloss/mips/uhi64_64.ld  | 8 +++++++-
 libgloss/mips/uhi64_n32.ld | 8 +++++++-
 3 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/libgloss/mips/uhi32.ld b/libgloss/mips/uhi32.ld
index 96f697add..ae3536ead 100644
--- a/libgloss/mips/uhi32.ld
+++ b/libgloss/mips/uhi32.ld
@@ -181,7 +181,14 @@ SECTIONS
   _etext  =  .;
 
   .eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) }
-  .eh_frame : { KEEP (*(.eh_frame)) }
+  .eh_frame :
+  {
+    /* The .eh_frame section from the crtend file contains the
+       end of eh_frame marker and it must be last.  */
+    KEEP (*(EXCLUDE_FILE (*crtend.o) .eh_frame))
+    KEEP (*(.eh_frame))
+  }
+
   .gcc_except_table : { *(.gcc_except_table .gcc_except_table.*) }
   .gnu_extab : { *(.gnu_extab .gnu_extab.*) }
   .jcr : { KEEP (*(.jcr)) }
diff --git a/libgloss/mips/uhi64_64.ld b/libgloss/mips/uhi64_64.ld
index 1aece1bf2..e6c3bee89 100644
--- a/libgloss/mips/uhi64_64.ld
+++ b/libgloss/mips/uhi64_64.ld
@@ -181,7 +181,13 @@ SECTIONS
   _etext  =  .;
 
   .eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) }
-  .eh_frame : { KEEP (*(.eh_frame)) }
+  .eh_frame :
+  {
+    /* The .eh_frame section from the crtend file contains the
+       end of eh_frame marker and it must be last.  */
+    KEEP (*(EXCLUDE_FILE (*crtend.o) .eh_frame))
+    KEEP (*(.eh_frame))
+  }
   .gcc_except_table : { *(.gcc_except_table .gcc_except_table.*) }
   .gnu_extab : { *(.gnu_extab .gnu_extab.*) }
   .jcr : { KEEP (*(.jcr)) }
diff --git a/libgloss/mips/uhi64_n32.ld b/libgloss/mips/uhi64_n32.ld
index 2ca0b4c11..25cdd06ca 100644
--- a/libgloss/mips/uhi64_n32.ld
+++ b/libgloss/mips/uhi64_n32.ld
@@ -181,7 +181,13 @@ SECTIONS
   _etext  =  .;
 
   .eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) }
-  .eh_frame : { KEEP (*(.eh_frame)) }
+  .eh_frame :
+  {
+    /* The .eh_frame section from the crtend file contains the
+       end of eh_frame marker and it must be last.  */
+    KEEP (*(EXCLUDE_FILE (*crtend.o) .eh_frame))
+    KEEP (*(.eh_frame))
+  }
   .gcc_except_table : { *(.gcc_except_table .gcc_except_table.*) }
   .gnu_extab : { *(.gnu_extab .gnu_extab.*) }
   .jcr : { KEEP (*(.jcr)) }


More information about the Newlib-cvs mailing list