mips: remove 16-byte alignment from .init and .fini epilogues

The .init and .fini epilogues from crtn should be placed immediately
after any instructions in .init and .fini sections from the linked
objects.  Using 16-byte alignment for the epilogues on MIPS was a bug,
but it did not cause any issue with GNU ld as GNU ld (2.17.50) fills the
padding with NOPs.

Current versions of LLD fill any padding between different object files
with trap instructions.  Inserting trap padding prior to the .init/.fini
epilogue is undesriable as the resulting binary will crash at runtime.

The .init and .fini sections in object files linked between crti and
crtn must already be a multiple of the instruction size and so no
alignment directive is required in crtn.  Indeed, other architectures
(except sparc64) do not specify alignment in their crtn implementations.

Reported by:	arichardson
Reviewed by:	andrew
Event:		Waterloo Hackathon 2019
Differential Revision:	https://reviews.freebsd.org/D18291
This commit is contained in:
emaste 2019-05-20 20:48:04 +00:00
parent 5c1190730c
commit a888be593d

View File

@ -5,7 +5,6 @@ __FBSDID("$FreeBSD$");
.gnu_attribute 4, 0
#endif
.section .init,"ax",%progbits
.align 4
.set noreorder
#if defined(__ABICALLS__) && (defined(__mips_n32) || defined(__mips_n64))
REG_L gp, CALLFRAME_GP(sp)
@ -16,7 +15,6 @@ __FBSDID("$FreeBSD$");
.set reorder
.section .fini,"ax",%progbits
.align 4
.set noreorder
#if defined(__ABICALLS__) && (defined(__mips_n32) || defined(__mips_n64))
REG_L gp, CALLFRAME_GP(sp)