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.
This commit is contained in:
Faraz Shahbazker 2019-04-28 18:17:14 +00:00 committed by Corinna Vinschen
parent 440559c40a
commit ab2901c843
18 changed files with 118 additions and 18 deletions

View File

@ -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 :

View File

@ -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 :

View File

@ -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 :

View File

@ -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 :

View File

@ -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 :

View File

@ -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 :

View File

@ -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 :

View File

@ -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 :

View File

@ -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 :

View File

@ -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 :

View File

@ -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 :

View File

@ -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 :

View File

@ -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 :

View File

@ -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 :

View File

@ -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 :

View File

@ -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 :

View File

@ -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 :

View File

@ -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 :