Make initSystem and __ctru_exit weak. Use asm macros
This commit is contained in:
parent
92ddd9e9b3
commit
6f34257b57
@ -54,7 +54,7 @@ CFLAGS += $(INCLUDE) -DARM11 -D_3DS
|
|||||||
|
|
||||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||||
|
|
||||||
ASFLAGS := -g $(ARCH)
|
ASFLAGS := -g $(ARCH) $(INCLUDE)
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# list of directories containing libraries, this must be the top level containing
|
# list of directories containing libraries, this must be the top level containing
|
||||||
|
21
libctru/include/3ds/asminc.h
Normal file
21
libctru/include/3ds/asminc.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if !__ASSEMBLER__
|
||||||
|
#error This header file is only for use in assembly files!
|
||||||
|
#endif // !__ASSEMBLER__
|
||||||
|
|
||||||
|
.macro BEGIN_ASM_FUNC name, linkage=global, section=text
|
||||||
|
.section .\section\().\name, "ax", %progbits
|
||||||
|
.align 2
|
||||||
|
.\linkage \name
|
||||||
|
.type \name, %function
|
||||||
|
.func \name
|
||||||
|
.cfi_sections .debug_frame
|
||||||
|
.cfi_startproc
|
||||||
|
\name:
|
||||||
|
.endm
|
||||||
|
|
||||||
|
.macro END_ASM_FUNC
|
||||||
|
.cfi_endproc
|
||||||
|
.endfunc
|
||||||
|
.endm
|
@ -1,17 +1,14 @@
|
|||||||
|
#include <3ds/asminc.h>
|
||||||
|
|
||||||
.arm
|
.arm
|
||||||
.align 4
|
.align 4
|
||||||
|
|
||||||
.macro SVC_BEGIN name
|
.macro SVC_BEGIN name
|
||||||
.section .text.\name, "ax", %progbits
|
BEGIN_ASM_FUNC \name
|
||||||
.global \name
|
|
||||||
.type \name, %function
|
|
||||||
.align 2
|
|
||||||
.cfi_startproc
|
|
||||||
\name:
|
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro SVC_END
|
.macro SVC_END
|
||||||
.cfi_endproc
|
END_ASM_FUNC
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
SVC_BEGIN svcControlMemory
|
SVC_BEGIN svcControlMemory
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
|
#include <3ds/asminc.h>
|
||||||
|
|
||||||
.arm
|
.arm
|
||||||
.section .text.__aeabi_read_tp, "ax", %progbits
|
|
||||||
.global __aeabi_read_tp
|
BEGIN_ASM_FUNC __aeabi_read_tp
|
||||||
.type __aeabi_read_tp, %function
|
|
||||||
.align 2
|
|
||||||
__aeabi_read_tp:
|
|
||||||
mrc p15, 0, r0, c13, c0, 3
|
mrc p15, 0, r0, c13, c0, 3
|
||||||
ldr r0, [r0, #0xC] @ Read ThreadVars.tls_tp
|
ldr r0, [r0, #0xC] @ Read ThreadVars.tls_tp
|
||||||
bx lr
|
bx lr
|
||||||
|
END_ASM_FUNC
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
|
#include <3ds/asminc.h>
|
||||||
|
|
||||||
.arm
|
.arm
|
||||||
.align 2
|
|
||||||
|
|
||||||
.global initSystem
|
BEGIN_ASM_FUNC initSystem, weak
|
||||||
.type initSystem, %function
|
|
||||||
|
|
||||||
initSystem:
|
|
||||||
ldr r2, =saved_stack
|
ldr r2, =saved_stack
|
||||||
str sp, [r2]
|
str sp, [r2]
|
||||||
str lr, [r2,#4]
|
str lr, [r2,#4]
|
||||||
@ -29,18 +26,16 @@ initSystem:
|
|||||||
ldr r2, =saved_stack
|
ldr r2, =saved_stack
|
||||||
ldr lr, [r2,#4]
|
ldr lr, [r2,#4]
|
||||||
bx lr
|
bx lr
|
||||||
|
END_ASM_FUNC
|
||||||
|
|
||||||
|
BEGIN_ASM_FUNC __ctru_exit, weak
|
||||||
.global __ctru_exit
|
|
||||||
.type __ctru_exit, %function
|
|
||||||
|
|
||||||
__ctru_exit:
|
|
||||||
bl __libc_fini_array
|
bl __libc_fini_array
|
||||||
bl __appExit
|
bl __appExit
|
||||||
|
|
||||||
ldr r2, =saved_stack
|
ldr r2, =saved_stack
|
||||||
ldr sp, [r2]
|
ldr sp, [r2]
|
||||||
b __libctru_exit
|
b __libctru_exit
|
||||||
|
END_ASM_FUNC
|
||||||
|
|
||||||
.data
|
.data
|
||||||
.align 2
|
.align 2
|
||||||
|
Loading…
Reference in New Issue
Block a user