musl/arch/mips/crt_arch.h
Rich Felker 869a9df5b5 remove workaround for broken mips assemblers
the workaround was for a bug that botched .gpword references to local
labels, applying a nonsensical random offset of -0x4000 to them.

this reverses commit 5e396fb996 and a
removes a similar hack that was added to syscall_cp.s in the later
commit 756c8af858. it turns out one
additional instance of the same idiom, the GETFUNCSYM macro in
arch/mips/reloc.h, was still affected by the assembler bug and does
not admit an easy workaround without making assumptions about how the
macro is used. the previous workarounds made static linking work but
left the early-stage dynamic linker broken and thus had limited
usefulness.

instead, affected users (using binutils versions older than 2.20) will
need to fix the bug on the binutils side; the trivial patch is commit
453f5985b13e35161984bf1bf657bbab11515aa4 in the binutils-gdb
repository.
2016-02-08 21:07:09 +00:00

30 lines
572 B
C

__asm__(
".set push\n"
".set noreorder\n"
".text \n"
".global _" START "\n"
".global " START "\n"
".type _" START ", @function\n"
".type " START ", @function\n"
"_" START ":\n"
"" START ":\n"
" bal 1f \n"
" move $fp, $0 \n"
" .gpword . \n"
" .gpword " START "_c \n"
".weak _DYNAMIC \n"
".hidden _DYNAMIC \n"
" .gpword _DYNAMIC \n"
"1: lw $gp, 0($ra) \n"
" subu $gp, $ra, $gp \n"
" move $4, $sp \n"
" lw $5, 8($ra) \n"
" addu $5, $5, $gp \n"
" lw $25, 4($ra) \n"
" addu $25, $25, $gp \n"
" and $sp, $sp, -8 \n"
" jalr $25 \n"
" subu $sp, $sp, 16 \n"
".set pop \n"
);