Subject: cerror bug
To: None <port-pmax@NetBSD.ORG>
From: Arne H Juul <arnej@math.ntnu.no>
List: port-pmax
Date: 07/25/1998 02:04:07
Well, I finally found the cause of a bug that's been troubling me
for some time without really creating big trouble.
Consider the following program:
#include <stdio.h>
int main(void)
{
if (stat("/foo/bar/baz")) perror("stat");
if (rename("/foo/bar/baz", "/qux/quux/quuux")) perror("rename");
exit(0);
}
compile with "cc t.c -o t -lposix", run, and observe:
# ./t
stat: No such file or directory
Segmentation fault
This happens because the program will call the libposix.so "rename",
the system call fails, the "rename" stub calls the common "cerror",
which is in libc.so, but the "cerror" routing doesn't set the pointer
to the libc.so GOT (?) as it should. Here is the (quite simple) fix:
--- /usr/src/lib/libc/arch/mips/sys/cerror.S Mon Oct 14 17:37:39 1996
+++ cerror.S.fix Sat Jul 25 03:57:22 1998
@@ -50,6 +50,9 @@
.globl _C_LABEL(errno)
LEAF(cerror)
.set noreorder
+#ifdef ABICALLS
+ .cpload t9
+#endif
sw v0, _C_LABEL(errno)
li v0, -1
j ra
It was a bit hard to find out what's wrong, but looking at the the other
assembly files in the same directory this fix looks safe.
- Arne H. J.