Subject: Re: Volunteer list?
To: Manuel Bouyer <bouyer@lix.polytechnique.fr>
From: Per Fogelstrom <pefo@enea.se>
List: port-pmax
Date: 03/14/1996 23:59:42
> 
> Some time ago, Gord Matzigkeit said:
> > 
> > SB> I'd add R4{4,0}00 support.  I haven't heard what Per's been up to
> > SB> for a while.  I imagine we can lift a lot from the work he's done.
> > SB> I've got a 5000/260 just waiting for NetBSD, and I'd like to think
> > SB> I can help with this one.  Wasn't Per also working on shared libs?
> > 
> > Per's modifications are now in the GNU binutils snapshots at:
> > 
> > <ftp://ftp.cygnus.com/private/gas>
> > 
> 
> I can't work alone on shared libraries, because i don't have enoutgh
> knowledge/documentation about mips assembler and processes headers.
> But if someone else has started working on it, i could help to 
> test/debug.
> 
> For now i've installed the GNU binutils, and i am able to produce shared
> libraries using it. But if i try to compile (statically) a simple
> 'hello world', it coredumps.
> No what next ? I thing i need a ld.so and a crt0, is there one available yet ? 
It coredumps because the data segment is loaded at the wrong address.
Pmax elf loader can't handle unaligned segment starts. The following
patch handles the problem. The ifdeffed code is a test to try using
paging of the data segment as well as the text segment. It doesn't
work yet so don't try it...



---------------------[snip]----8><-------------------------------------
*** /var/tmp/sys/arch/pica/pica/elf.c   Wed Oct 18 11:39:19 1995
--- elf.c       Tue Mar 12 19:35:05 1996
***************
*** 132,148 ****
                                        epp->ep_daddr = vaddr;
                                epp->ep_dsize += ph.memsz;
                                /* Read the data from the file... */
                                NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn,
                                          length, vaddr,
                                          epp->ep_vp, offset, prot);
                                if (residue) {
-                                       vaddr &= ~(NBPG - 1);
-                                       offset &= ~(NBPG - 1);
-                                       length = roundup (length + ph.vaddr
-                                                         - vaddr, NBPG);
                                        residue = (ph.vaddr + ph.memsz)
                                                  - (vaddr + length);
                                }
                        } else {
                                vaddr &= ~(NBPG - 1);
                                offset &= ~(NBPG - 1);
--- 132,161 ----
                                        epp->ep_daddr = vaddr;
                                epp->ep_dsize += ph.memsz;
                                /* Read the data from the file... */
+ #if 1
+                               offset -= (vaddr & (NBPG - 1));
+                               length += (vaddr & (NBPG - 1));
+                               vaddr &= ~(NBPG - 1);
                                NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn,
                                          length, vaddr,
                                          epp->ep_vp, offset, prot);
+                               length = roundup (length, NBPG);
                                if (residue) {
                                        residue = (ph.vaddr + ph.memsz)
                                                  - (vaddr + length);
                                }
+ #else
+                               offset -= (vaddr & (NBPG - 1));
+                               vaddr &= ~(NBPG - 1);
+                               length = roundup (length + ph.vaddr - vaddr, NBPG);
+                               NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn,
+                                         length, vaddr, epp->ep_vp,
+                                         offset, prot);
+                               if (residue) {
+                                       residue = (ph.vaddr + ph.memsz)
+                                                 - (vaddr + length);
+                               }
+ #endif
                        } else {
                                vaddr &= ~(NBPG - 1);
                                offset &= ~(NBPG - 1);
---------------------[snip]----8><-------------------------------------