Actually handle the gp correctly (needed to find errno, sigh; if pc
was accessible we wouldn't have to do this in the fast path and replicate
among each function. Oh well. It's a dead architecture anyway.)
diff --git a/klibc/arch/alpha/syscall.S b/klibc/arch/alpha/syscall.S
index 99ecbe3..95dcbed 100644
--- a/klibc/arch/alpha/syscall.S
+++ b/klibc/arch/alpha/syscall.S
@@ -10,12 +10,12 @@
.ent __syscall_common, 0
.globl __syscall_common
__syscall_common:
+ .frame sp,0,ra,0
callsys
- ldgp gp, 0(pv)
beq a3, 1f
lda a1, errno
lda v0, -1(zero)
- std a3, 0(a1)
+ stl a3, 0(a1)
1:
ret zero,(ra),1
diff --git a/klibc/arch/alpha/sysdual.S b/klibc/arch/alpha/sysdual.S
index a5933c1..4ffbf76 100644
--- a/klibc/arch/alpha/sysdual.S
+++ b/klibc/arch/alpha/sysdual.S
@@ -16,13 +16,13 @@
.ent __syscall_dual1, 0
.globl __syscall_dual1
__syscall_dual1:
+ .frame sp,0,ra,0
callsys
mov v0, a4
- ldgp gp, 0(pv)
beq a3, 1f
lda a1, errno
lda v0, -1(zero)
- std a3, 0(a1)
+ stl a3, 0(a1)
1:
ret zero,(ra),1
diff --git a/klibc/arch/alpha/sysstub.ph b/klibc/arch/alpha/sysstub.ph
index a24b6c0..d1dc827 100644
--- a/klibc/arch/alpha/sysstub.ph
+++ b/klibc/arch/alpha/sysstub.ph
@@ -12,6 +12,10 @@
# A few system calls are dual-return with the second return value in
# r20 (a4).
+# In order to find errno, we need the gp, which is computed from the
+# pv register. This is two instructions, so the total length of the
+# stub is 4x4 = 16 bytes.
+
sub make_sysstub($$$$@) {
my($fname, $type, $sname, $stype, @args) = @_;
@@ -27,6 +31,7 @@
print OUT "\t.ent\t${fname}, 0\n"; # What is this?
print OUT "\t.globl ${fname}\n";
print OUT "${fname}:\n";
+ print OUT "\tldgp\tgp,0(pv)\n";
print OUT "\tlda\tv0, __NR_${sname}(zero)\n";
print OUT "\tbr __syscall_${stype}\n";
print OUT "\t.size\t${fname},.-${fname}\n";