freebsd-dev/lib/csu/mips/crtn.S
Ed Maste b0ec537031 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
2019-05-20 20:48:04 +00:00

26 lines
570 B
ArmAsm

#include <machine/asm.h>
__FBSDID("$FreeBSD$");
#ifndef __clang__
.gnu_attribute 4, 0
#endif
.section .init,"ax",%progbits
.set noreorder
#if defined(__ABICALLS__) && (defined(__mips_n32) || defined(__mips_n64))
REG_L gp, CALLFRAME_GP(sp)
#endif
REG_L ra, CALLFRAME_RA(sp)
jr ra
PTR_ADDU sp, sp, CALLFRAME_SIZ
.set reorder
.section .fini,"ax",%progbits
.set noreorder
#if defined(__ABICALLS__) && (defined(__mips_n32) || defined(__mips_n64))
REG_L gp, CALLFRAME_GP(sp)
#endif
REG_L ra, CALLFRAME_RA(sp)
jr ra
PTR_ADDU sp, sp, CALLFRAME_SIZ
.set reorder