diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-05-17 23:46:09 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-05-17 23:46:09 +0200 |
commit | 0002fd0cf786d16c9b3e1ab62f0cb92b2461f185 (patch) | |
tree | b49f7135f649ad7727ba665a744cb1f7b60e9faa /sys/src/libc | |
parent | b599dc0e5486923085f238e146d5a1750bc168a9 (diff) |
libc/arm64: work arround linker bug for cas()
at the _cas0 label, the linker would generate spurious stack
adjustment before the return:
atexitdont+0x84 0x000000000003614c CLREX $0xf
atexitdont+0x88 0x0000000000036150 MOVW R31,R0
atexitdont+0x8c 0x0000000000036154 MOV (SP)16!,R30 <- ????????????
atexitdont+0x90 0x0000000000036158 RETURN
the work arround is to move the code into its own cas0
text symbol.
this fixes impossible cwfs crashes in srvi().
Diffstat (limited to 'sys/src/libc')
-rw-r--r-- | sys/src/libc/arm64/atom.s | 10 | ||||
-rw-r--r-- | sys/src/libc/arm64/tas.s | 1 |
2 files changed, 7 insertions, 4 deletions
diff --git a/sys/src/libc/arm64/atom.s b/sys/src/libc/arm64/atom.s index f1fbc522a..004ebf7d6 100644 --- a/sys/src/libc/arm64/atom.s +++ b/sys/src/libc/arm64/atom.s @@ -3,6 +3,12 @@ * int cas(uint *p, int ov, int nv); * int casl(ulong *p, ulong ov, ulong nv); */ +TEXT cas0(SB), 1, $-4 +_cas0: + CLREX + MOVW $0, R0 + RETURN + TEXT cas32(SB), 1, $-4 TEXT cas(SB), 1, $-4 TEXT casl(SB), 1, $-4 @@ -16,10 +22,6 @@ _cas1: CBNZ R4, _cas1 MOVW $1, R0 B _barrier(SB) -_cas0: - CLREX - MOVW $0, R0 - RETURN TEXT casp(SB), 1, $-4 MOV ov+8(FP), R1 diff --git a/sys/src/libc/arm64/tas.s b/sys/src/libc/arm64/tas.s index 090037c81..c083b1604 100644 --- a/sys/src/libc/arm64/tas.s +++ b/sys/src/libc/arm64/tas.s @@ -5,6 +5,7 @@ _tas1: STXRW R2, (R0), R3 CBNZ R3, _tas1 MOVW R1, R0 + B _barrier(SB) TEXT _barrier(SB), 1, $-4 DMB $0xB // ISH |