aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/libc/malloc.s
diff options
context:
space:
mode:
authorspicyjpeg <88942473+spicyjpeg@users.noreply.github.com>2021-08-17 11:36:50 +0000
committerspicyjpeg <88942473+spicyjpeg@users.noreply.github.com>2021-08-17 11:36:50 +0000
commit5f5461879c73720359e87fa41cbfe8c452f5155e (patch)
tree9de8b0dcfcffa70fac7da91792772679af8341bb /libpsn00b/libc/malloc.s
parentacc1a959fe3c4bc5d5e91f1f31e182ff967008ca (diff)
downloadpsn00bsdk-5f5461879c73720359e87fa41cbfe8c452f5155e.tar.gz
Added missing header declarations, FlushCache, misc library bugfixes
Diffstat (limited to 'libpsn00b/libc/malloc.s')
-rw-r--r--libpsn00b/libc/malloc.s11
1 files changed, 10 insertions, 1 deletions
diff --git a/libpsn00b/libc/malloc.s b/libpsn00b/libc/malloc.s
index 90f9bd4..e441bbe 100644
--- a/libpsn00b/libc/malloc.s
+++ b/libpsn00b/libc/malloc.s
@@ -1,5 +1,10 @@
# Custom first-fit malloc routines by Lameguy64
# Part of the PSn00bSDK Project
+#
+# NOTE: there reportedly is a GCC bug which messes up .weak functions written
+# in assembly if LTO is enabled. I haven't tested but, according to the
+# internet, this bug has never been fixed.
+# https://gcc.gnu.org/legacy-ml/gcc-help/2019-10/msg00092.html
.set noreorder
@@ -10,7 +15,6 @@
.section .text
-
# Stupid small function just to get bss end
# due to GCC insisting externs to be gp relative
.global GetBSSend
@@ -27,6 +31,7 @@ GetBSSend:
#
.global InitHeap
.type InitHeap, @function
+.weak InitHeap
InitHeap:
la $v0, _malloc_addr
sw $a0, 0($v0)
@@ -43,6 +48,7 @@ InitHeap:
# a0 - Size of memory heap in bytes
.global SetHeapSize
.type SetHeapSize, @function
+.weak SetHeapSize
SetHeapSize:
la $v1, _malloc_size
lw $v0, 0($v1)
@@ -55,6 +61,7 @@ SetHeapSize:
#
.global malloc
.type malloc, @function
+.weak malloc
malloc:
addiu $a0, 3 # Round size to a multiple of 4
srl $a0, 2
@@ -170,6 +177,7 @@ malloc:
#
.global calloc
.type calloc, @function
+.weak calloc
calloc:
mult $a0, $a1
addiu $sp, -4
@@ -199,6 +207,7 @@ calloc:
#
.global free
.type free, @function
+.weak free
free:
addiu $a0, -ND_HSIZ