This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] [MIPS] Fix order of eh_frame sections in linker scripts


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 are placed after crtend.o and the
end-of-frame marker provided by crtend.o ends up in between .eh_frames
instead of being at the end.

This has always been a problem, but a 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_frames in all
MIPS linker scripts so that the one from crtend.o is always placed last.

libgloss/
	* mips/array.ld: Re-order to place .eh_frame from crtend.o
	after all other .eh_frame sections.
	* mips/cfe.ld: Likewise.
	* mips/ddb-kseg0.ld: Likewise.
	* mips/ddb.ld: Likewise.
	* mips/dve.ld: Likewise.
	* mips/idt.ld: Likewise.
	* mips/idt32.ld: Likewise.
	* mips/idt64.ld: Likewise.
	* mips/jmr3904app.ld: Likewise.
	* mips/lsi.ld: Likewise.
	* mips/mti32.ld: Likewise.
	* mips/mti64.ld: Likewise.
	* mips/mti64_64.ld: Likewise.
	* mips/mti64_n32.ld: Likewise.
	* mips/nullmon.ld: Likewise.
	* mips/pmon.ld: Likewise.
	* mips/sde32.ld: Likewise.
	* mips/sde64.ld: Likewise.
---
 libgloss/mips/array.ld      | 7 ++++++-
 libgloss/mips/cfe.ld        | 8 +++++++-
 libgloss/mips/ddb-kseg0.ld  | 7 ++++++-
 libgloss/mips/ddb.ld        | 7 ++++++-
 libgloss/mips/dve.ld        | 8 +++++++-
 libgloss/mips/idt.ld        | 8 +++++++-
 libgloss/mips/idt32.ld      | 7 ++++++-
 libgloss/mips/idt64.ld      | 7 ++++++-
 libgloss/mips/jmr3904app.ld | 7 ++++++-
 libgloss/mips/lsi.ld        | 7 ++++++-
 libgloss/mips/mti32.ld      | 7 ++++++-
 libgloss/mips/mti64.ld      | 8 +++++++-
 libgloss/mips/mti64_64.ld   | 8 +++++++-
 libgloss/mips/mti64_n32.ld  | 8 +++++++-
 libgloss/mips/nullmon.ld    | 8 +++++++-
 libgloss/mips/pmon.ld       | 8 +++++++-
 libgloss/mips/sde32.ld      | 8 +++++++-
 libgloss/mips/sde64.ld      | 8 +++++++-
 18 files changed, 118 insertions(+), 18 deletions(-)

diff --git a/libgloss/mips/array.ld b/libgloss/mips/array.ld
index fc4cc8f..2bc49c7 100644
--- a/libgloss/mips/array.ld
+++ b/libgloss/mips/array.ld
@@ -100,7 +100,12 @@ SECTIONS
   }
   
   .eh_frame_hdr : { *(.eh_frame_hdr) }
-  .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) }
   .jcr : { KEEP (*(.jcr)) }
   .ctors    :
diff --git a/libgloss/mips/cfe.ld b/libgloss/mips/cfe.ld
index 58e8014..78fb853 100644
--- a/libgloss/mips/cfe.ld
+++ b/libgloss/mips/cfe.ld
@@ -55,7 +55,13 @@ SECTIONS
   _etext  =  .;
   
   .eh_frame_hdr : { *(.eh_frame_hdr) }
-  .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) }
   .jcr : { KEEP (*(.jcr)) }
   .ctors    :
diff --git a/libgloss/mips/ddb-kseg0.ld b/libgloss/mips/ddb-kseg0.ld
index db3759e..74bc1b0 100644
--- a/libgloss/mips/ddb-kseg0.ld
+++ b/libgloss/mips/ddb-kseg0.ld
@@ -49,7 +49,12 @@ SECTIONS
   }
   
   .eh_frame_hdr : { *(.eh_frame_hdr) }
-  .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) }
   .jcr : { KEEP (*(.jcr)) }
   .ctors    :
diff --git a/libgloss/mips/ddb.ld b/libgloss/mips/ddb.ld
index 0280783..8fcafd3 100644
--- a/libgloss/mips/ddb.ld
+++ b/libgloss/mips/ddb.ld
@@ -49,7 +49,12 @@ SECTIONS
   }
   
   .eh_frame_hdr : { *(.eh_frame_hdr) }
-  .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) }
   .jcr : { KEEP (*(.jcr)) }
   .ctors    :
diff --git a/libgloss/mips/dve.ld b/libgloss/mips/dve.ld
index 073d1e9..adce60f 100644
--- a/libgloss/mips/dve.ld
+++ b/libgloss/mips/dve.ld
@@ -49,7 +49,13 @@ SECTIONS
   }
   
   .eh_frame_hdr : { *(.eh_frame_hdr) }
-  .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) }
   .jcr : { KEEP (*(.jcr)) }
   .ctors    :
diff --git a/libgloss/mips/idt.ld b/libgloss/mips/idt.ld
index 05b39b7..0d69af4 100644
--- a/libgloss/mips/idt.ld
+++ b/libgloss/mips/idt.ld
@@ -56,7 +56,13 @@ SECTIONS
   _etext  =  .;
   
   .eh_frame_hdr : { *(.eh_frame_hdr) }
-  .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) }
   .jcr : { KEEP (*(.jcr)) }
   .ctors    :
diff --git a/libgloss/mips/idt32.ld b/libgloss/mips/idt32.ld
index 9555529..175a98b 100644
--- a/libgloss/mips/idt32.ld
+++ b/libgloss/mips/idt32.ld
@@ -58,7 +58,12 @@ SECTIONS
 
 
   .eh_frame_hdr : { *(.eh_frame_hdr) }
-  .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) }
   .jcr : { KEEP (*(.jcr)) }
   .ctors    :
diff --git a/libgloss/mips/idt64.ld b/libgloss/mips/idt64.ld
index 4a95820..bd217e5 100644
--- a/libgloss/mips/idt64.ld
+++ b/libgloss/mips/idt64.ld
@@ -59,7 +59,12 @@ SECTIONS
   _etext  =  .;
 
   .eh_frame_hdr : { *(.eh_frame_hdr) }
-  .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) }
   .jcr : { KEEP (*(.jcr)) }
   .ctors    :
diff --git a/libgloss/mips/jmr3904app.ld b/libgloss/mips/jmr3904app.ld
index 3056a36..d5b3109 100644
--- a/libgloss/mips/jmr3904app.ld
+++ b/libgloss/mips/jmr3904app.ld
@@ -48,7 +48,12 @@ SECTIONS
   }
   
   .eh_frame_hdr : { *(.eh_frame_hdr) }
-  .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) }
   .jcr : { KEEP (*(.jcr)) }
   .ctors    :
diff --git a/libgloss/mips/lsi.ld b/libgloss/mips/lsi.ld
index 8393825..ca64ab9 100644
--- a/libgloss/mips/lsi.ld
+++ b/libgloss/mips/lsi.ld
@@ -48,7 +48,12 @@ SECTIONS
   }
   
   .eh_frame_hdr : { *(.eh_frame_hdr) }
-  .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) }
   .jcr : { KEEP (*(.jcr)) }
   .ctors    :
diff --git a/libgloss/mips/mti32.ld b/libgloss/mips/mti32.ld
index 2739c62..41592d1 100644
--- a/libgloss/mips/mti32.ld
+++ b/libgloss/mips/mti32.ld
@@ -57,7 +57,12 @@ SECTIONS
   _etext  =  .;
 
   .eh_frame_hdr : { *(.eh_frame_hdr) }
-  .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) }
   .jcr : { KEEP (*(.jcr)) }
   .ctors    :
diff --git a/libgloss/mips/mti64.ld b/libgloss/mips/mti64.ld
index 15975ad..8a47c47 100644
--- a/libgloss/mips/mti64.ld
+++ b/libgloss/mips/mti64.ld
@@ -59,7 +59,13 @@ SECTIONS
   _etext  =  .;
 
   .eh_frame_hdr : { *(.eh_frame_hdr) }
-  .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) }
   .jcr : { KEEP (*(.jcr)) }
   .ctors    :
diff --git a/libgloss/mips/mti64_64.ld b/libgloss/mips/mti64_64.ld
index 7a2074f..81704f0 100644
--- a/libgloss/mips/mti64_64.ld
+++ b/libgloss/mips/mti64_64.ld
@@ -62,7 +62,13 @@ SECTIONS
   _etext  =  .;
 
   .eh_frame_hdr : { *(.eh_frame_hdr) }
-  .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) }
   .jcr : { KEEP (*(.jcr)) }
   .ctors    :
diff --git a/libgloss/mips/mti64_n32.ld b/libgloss/mips/mti64_n32.ld
index 4003845..6c53809 100644
--- a/libgloss/mips/mti64_n32.ld
+++ b/libgloss/mips/mti64_n32.ld
@@ -62,7 +62,13 @@ SECTIONS
   _etext  =  .;
 
   .eh_frame_hdr : { *(.eh_frame_hdr) }
-  .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) }
   .jcr : { KEEP (*(.jcr)) }
   .ctors    :
diff --git a/libgloss/mips/nullmon.ld b/libgloss/mips/nullmon.ld
index c90aed3..14b0d0e 100644
--- a/libgloss/mips/nullmon.ld
+++ b/libgloss/mips/nullmon.ld
@@ -50,7 +50,13 @@ SECTIONS
   }
   
   .eh_frame_hdr : { *(.eh_frame_hdr) }
-  .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) }
   .jcr : { KEEP (*(.jcr)) }
   .ctors    :
diff --git a/libgloss/mips/pmon.ld b/libgloss/mips/pmon.ld
index 81fd8ee..244c1f6 100644
--- a/libgloss/mips/pmon.ld
+++ b/libgloss/mips/pmon.ld
@@ -50,7 +50,13 @@ SECTIONS
   }
   
   .eh_frame_hdr : { *(.eh_frame_hdr) }
-  .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) }
   .jcr : { KEEP (*(.jcr)) }
   .ctors    :
diff --git a/libgloss/mips/sde32.ld b/libgloss/mips/sde32.ld
index 715639e..657f5f3 100644
--- a/libgloss/mips/sde32.ld
+++ b/libgloss/mips/sde32.ld
@@ -57,7 +57,13 @@ SECTIONS
   _etext  =  .;
 
   .eh_frame_hdr : { *(.eh_frame_hdr) }
-  .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) }
   .jcr : { KEEP (*(.jcr)) }
   .ctors    :
diff --git a/libgloss/mips/sde64.ld b/libgloss/mips/sde64.ld
index 1bd11f6..e3a0f29 100644
--- a/libgloss/mips/sde64.ld
+++ b/libgloss/mips/sde64.ld
@@ -59,7 +59,13 @@ SECTIONS
   _etext  =  .;
 
   .eh_frame_hdr : { *(.eh_frame_hdr) }
-  .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) }
   .jcr : { KEEP (*(.jcr)) }
   .ctors    :
-- 
2.9.5


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]