that the load addresses in the section array are increasing, and that no
section in the array overlap with each other. IRIX proably makes the same
assumptions, but this has not been tested.
The key point with relocation is to always use the same offset for each
section. Because userland gets only the load address off the first section, it
has to assume that all the remaining sections kept the same offset with
respect to the first section. By using fixed offset instead of finding
some free space for each section, we can eliminate the libX11 load hack.
even for program with a DSO using overlapping load virtual addresses.
The fix is a mean hack, see the comments in irix_syssgi.c. It would be nice to
get uvm_map_findspace() to return the page we suggest instead of the page which
is 16384 bytes away.
by SWI numbers above 0x9f0000, but we re-map them down to somewhere just
after the end of the usual syscall range, since NetBSD doesn't handle
sparse syscall arrays well.
The only syscall I've actually implemented in this range is cacheflush(),
which was previously being mapped to fork(), causing ... interesting results.
we used load_psection, then ran each vmcmd and tried to relocate the failing
ones. This fails if there is two vmcmd for one section, and the second is
not a mapping (for instance a map_pagedvn and a map_zero), because the first
one gets relocated, but not the second one.
Additionnaly, it was not necessary to update the userlevel psection array:
libc stubs seems to do the job themselves.
for the text section of libx11.so was overlapping with other ELF sections
aloready loaded, and this resulted into an ENOMEM error.
syssgi(MAPELF) uses elf32_load_psection() from syssrc/sys/kern/exec_subr.c
The problem was never experienced with load_psection() because it only has
to load one section, hence the requested address are not already allocated.
The fix is done when the initial mapping at the default address fails by
finding a free location in the VM space using uvm_map_findspace(), and then
retrying to load the section.
Other details:
- once the ELF section has been relocated, the ELF program header must be
updated with the new address and copied back to userland. For now we always
do it, maybe we could copy it only when it was modified.
- We are able to emulate the exact address where IRIX loads libX11.so instead
of the default location