Subject: Problems building emacs on pmax (unexec/dump difficulties)
To: None <port-pmax@netbsd.org>
From: Joel Reicher <joel@panacea.null.org>
List: port-pmax
Date: 12/21/2001 10:18:05
This time around I'm building GNU emacs 21, but I had the same problem
with 20. I've never tried xemacs though.

Everything appears to work except the unexec facility, and even that
works partially. I fixed the build so that it uses the settings in
src/s/netbsd.h (unexelf, linking with pre-crt0, crt0, crtbegin and crtend)
and it happily does the loadup and dump.

Problem is the resulting executable only runs in a terminal. Whenever I try
X11 output it segfaults, and even worse the executable seems so dodgy that
gdb segfaults too when trying to load it, so I can't even debug the problem.

To try to simplify matters I wiped out the src/m/pmax.h file and put
together another from scratch, without including mips.h. I've found that
it needs the following:

#define NO_UNION_TYPE
#define HAVE_ALLOCA
#define NO_ARG_ARRAY
#define DATA_SEG_BITS 0x10000000

Everything else seems unimportant.

objdump gives the following, though it's probably not very informative:

emacs:     file format elf32-littlemips

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .interp       00000017  00400134  00400134  00000134  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  1 .note.netbsd.ident 00000034  0040014c  0040014c  0000014c  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .reginfo      00000018  00400180  00400180  00000180  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  3 .dynamic      00000148  004001a0  004001a0  000001a0  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .hash         00005274  004002f0  004002f0  000002f0  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  5 .dynsym       0000c960  00405570  00405570  00005570  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  6 .dynstr       0000ce0b  00411ed0  00411ed0  00011ed0  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  7 .init         00000074  0041ecdc  0041ecdc  0001ecdc  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  8 .text         00269bc0  0041ed50  0041ed50  0001ed50  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  9 .fini         0000004c  00688910  00688910  00288910  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 10 .rodata       0002fd10  00688960  00688960  00288960  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 11 .rel.dyn      00000138  006b8670  006b8670  002b8670  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 12 .data         000b49e0  10000000  10000000  002b9000  2**4
                  CONTENTS, ALLOC, LOAD, DATA
 13 .rld_map      00000004  100b49e0  100b49e0  0036d9e0  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 14 .ctors        00000008  100b49e4  100b49e4  0036d9e4  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 15 .dtors        00000008  100b49ec  100b49ec  0036d9ec  2**2
                  CONTENTS, ALLOC, LOAD, DATA
 16 .got          000032f4  100b4a00  100b4a00  0036da00  2**4
                  CONTENTS, ALLOC, LOAD, DATA
 17 .data         00269308  100b7cf8  100b7cf8  00370cf8  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 18 .sbss         00000000  10321000  10321000  005da000  2**4
                  CONTENTS, ALLOC, LOAD, DATA
 19 .bss          00000000  10321000  10321000  005da000  2**2
                  ALLOC
 20 .mdebug       004756d0  100edb00  100edb00  005da004  2**2
                  CONTENTS, READONLY, DEBUGGING
 21 .ident        00000035  1078da84  1078da84  00a4f6d4  2**0
                  CONTENTS, READONLY
 22 .compact_rel  00009168  1078dabc  1078dabc  00a4f70c  2**2
                  CONTENTS, READONLY

Can anyone help with this?

Many thanks,

	- Joel