Skip to content

Commit

Permalink
GTM18-293: Fix order of exception handling frames
Browse files Browse the repository at this point in the history
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.

libgloss/
	* mips/cfe.ld: Re-order to place .eh_frame from crtend.o
	after all other .eh_frame sections.
	* mips/dve.ld: Likewise.
	* mips/idt.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.
	* mips/uhi32.ld: Likewise.
	* mips/uhi64_64.ld: Likewise.
	* mips/uhi64_n32.ld: Likewise.
  • Loading branch information
Faraz Shahbazker committed Oct 28, 2019
1 parent c5421e3 commit 14ce586
Show file tree
Hide file tree
Showing 15 changed files with 106 additions and 15 deletions.
8 changes: 7 additions & 1 deletion libgloss/mips/cfe.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand Down
8 changes: 7 additions & 1 deletion libgloss/mips/dve.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand Down
8 changes: 7 additions & 1 deletion libgloss/mips/idt.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand Down
8 changes: 7 additions & 1 deletion libgloss/mips/lsi.ld
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,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 :
Expand Down
8 changes: 7 additions & 1 deletion libgloss/mips/mti32.ld
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,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)) }
Expand Down
8 changes: 7 additions & 1 deletion libgloss/mips/mti64.ld
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,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 :
Expand Down
8 changes: 7 additions & 1 deletion libgloss/mips/mti64_64.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand Down
8 changes: 7 additions & 1 deletion libgloss/mips/mti64_n32.ld
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,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 :
Expand Down
8 changes: 7 additions & 1 deletion libgloss/mips/nullmon.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand Down
8 changes: 7 additions & 1 deletion libgloss/mips/pmon.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand Down
8 changes: 7 additions & 1 deletion libgloss/mips/sde32.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand Down
8 changes: 7 additions & 1 deletion libgloss/mips/sde64.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand Down
9 changes: 8 additions & 1 deletion libgloss/mips/uhi32.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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)) }
Expand Down
8 changes: 7 additions & 1 deletion libgloss/mips/uhi64_64.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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)) }
Expand Down
8 changes: 7 additions & 1 deletion libgloss/mips/uhi64_n32.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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)) }
Expand Down

0 comments on commit 14ce586

Please sign in to comment.