Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support LoongArch architecture (lp64 ABIs) #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ elif arch == 'aarch64'
bitness = 64
elif arch == 'riscv64'
bitness = 64
elif arch == 'loongarch64'
bitness = 64
else
error('Architecture "@0@" is not supported.'.format(arch))
endif
Expand Down
49 changes: 49 additions & 0 deletions src/asm/trampoline-loongarch64.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Dear user,
*
* this file has been released under the Romantic WTF public license.
* I hereby grant you an irrevocable license to do
* WHAT THE GENTLE CARESS YOU WANT TO
* with this lovely code.
*
* -- Alexey Sheplyakov <[email protected]>
*
* P.S.: Even though I poured my heart into this work I cannot provide any
* warranty regarding its fitness for any purpose. You acknowledge
* that I will not be held liable for any damage its use could incur.
*/

#include "config.h"
#include "mangling.h"

#ifdef ASSEMBLER_SUPPORTS_HIDDEN
.hidden MANGLE(bxfi_trampoline)
#endif
.globl MANGLE(bxfi_trampoline)
MANGLE(bxfi_trampoline):
/* All LoongArch instructions are 4 bytes long.
* The destination address is next to the trampoline code.
* Thus the destination address is at current PC + 12 bytes
* for the trampoline code is the following 3 instructions:
*/
pcaddu12i $t0, 0
ld.d $t0, $t0, 0xc
jirl $ra, $t0, 0

.align 1

#ifdef ASSEMBLER_SUPPORTS_HIDDEN
.hidden MANGLE(bxfi_trampoline_addr)
#endif
.globl MANGLE(bxfi_trampoline_addr)
MANGLE(bxfi_trampoline_addr):
addr_data:
.fill 8, 1, 0

#ifdef ASSEMBLER_SUPPORTS_HIDDEN
.hidden MANGLE(bxfi_trampoline_end)
#endif
.globl MANGLE(bxfi_trampoline_end)
MANGLE(bxfi_trampoline_end):

#include "stackfix.h"