diff options
| author | John "Lameguy" Wilbert Villamor <lameguy64@gmail.com> | 2021-08-31 13:23:20 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-31 13:23:20 +0800 |
| commit | ffa679d4d24b891cb59aba10946368f2ec00c391 (patch) | |
| tree | 0cf6061915ebf48acdedf6d77b0c1b76eec5b8c3 /libpsn00b/libc/malloc.s | |
| parent | 317dc2b91d3afcdbaddb035f38611d12af161970 (diff) | |
| parent | f2fc18f82dd7900465d6ab3ae2080726d5589d39 (diff) | |
| download | psn00bsdk-ffa679d4d24b891cb59aba10946368f2ec00c391.tar.gz | |
Merge pull request #36 from spicyjpeg/dynlink
Dynamic linker, gp-relative addressing, ldscripts and more
Diffstat (limited to 'libpsn00b/libc/malloc.s')
| -rw-r--r-- | libpsn00b/libc/malloc.s | 11 |
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 |
