Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Re: architecture independent wordcode files (.zwc)



Paul Lew wrote:

> ...
> 
> I have lots of startup files for zsh, fortunately, the .zshenv is good
> enough to trigger the problem.  Attached below.

That helped.

Obviously I had only tried it with functions that were too small.

The zwc files contain the compiled versions for both endianesses, first
in the one for the machine the file was compiled on and after that the
one for the other endianess. When the shell has to use that other
version (with mapping), it has to calculate the offset into the zwc file
for the header (containing the directory of files/functions in the zwc
file including their positions relative to the header etc.). That worked
fine. But it also has to map the part of the part of the zwc it needs
and for that it has to adjust the offset to a page boundary. That worked
fine, too. But then it forgot to increment the length of the mapped
reagion by the difference between the real offset and the aligned one.
For large functions that happened to cross a page boundary that could
result in the string table of the function being not or only partially
mapped.

> ...
> 	dirs=(.)
> 	dirs=($dirs $artool/$bindir $artool/sh $artool/perl)
> 	dirs=($dirs /auto/insbu-cnstools/$bindir)		#cisco CNS
> 	dirs=($dirs /auto/insbu-cnstools/s$bindir)		#cisco CNS
>       ...

Ugh, that's pretty inefficient -- zsh has no problems with arrays
definitions spanning multiple lines.

Bye
  Sven

Index: Src/parse.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/parse.c,v
retrieving revision 1.19
diff -u -r1.19 parse.c
--- Src/parse.c	2001/03/07 12:58:41	1.19
+++ Src/parse.c	2001/05/15 08:25:50
@@ -2782,7 +2782,7 @@
 {
     FuncDump d;
     Wordcode addr;
-    int fd, off;
+    int fd, off, mlen;
 
     if (other) {
 	static size_t pgsz = 0;
@@ -2802,15 +2802,17 @@
 	    pgsz--;
 	}
 	off = len & ~pgsz;
-    } else
+        mlen = len + (len - off);
+    } else {
 	off = 0;
-
+        mlen = len;
+    }
     if ((fd = open(dump, O_RDONLY)) < 0)
 	return;
 
     fd = movefd(fd);
 
-    if ((addr = (Wordcode) mmap(NULL, len, PROT_READ, MAP_SHARED, fd, off)) ==
+    if ((addr = (Wordcode) mmap(NULL, mlen, PROT_READ, MAP_SHARED, fd, off)) ==
 	((Wordcode) -1)) {
 	close(fd);
 	return;

-- 
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author