Well, 'next week' happened to be quite a long one, but nevertheless,
here's the patch MkII. I've patched up configure.in to use brand new
'machine' file for irix6.X, plus the previous patches for
lib-src/Makefile.in.in and unexelfsgi.c.
max
--- ./src/ChangeLog Wed Nov 3 13:34:24 1999
+++ ../xemacs-21.1.8/./src/ChangeLog Tue Dec 28 16:14:42 1999
@@ -1,3 +1,18 @@
+1999-12-28 Max Matveev <max(a)melbourne.sgi.com>
+
+ * unexelfsgi.c (unexec): Change the way we decide which segment
+ should be extended.
+
+ Assumption that .bss section should be outside the PT_LOADable
+ segment. On IRIX with version 6.2 and above, .bss (or .sbss, if
+ it's present) is inside the 'data' segment. This would fail the
+ test which was used to find a segment to grow and cover new
+ heap. Instead of this assumption, I created another one - on IRIX
+ the segment to grow should start below .bss and it's address
+ should extent above the end of .bss. Once thise segment is
+ identified, it's grown to accomodate the new heap and new
+ zero-length .bss section is added at the end of .data2.
+
1999-11-02 XEmacs Build Bot <builds(a)cvs.xemacs.org>
* XEmacs 21.1.8 is released
--- ./src/unexelfsgi.c Tue Jun 2 13:50:59 1998
+++ ../xemacs-21.1.8/./src/unexelfsgi.c Tue Dec 28 16:14:55 1999
@@ -615,6 +615,7 @@
l_Elf_Ehdr *old_file_h, *new_file_h;
l_Elf_Phdr *old_program_h, *new_program_h;
l_Elf_Shdr *old_section_h, *new_section_h;
+ l_Elf_Shdr *oldbss;
/* Point to the section name table in the old file. */
char *old_section_names;
@@ -697,8 +698,8 @@
(new_data2_addr - OLD_SECTION_H (old_data_index).sh_addr);
new_base_offset = OLD_SECTION_H (old_data_index).sh_offset +
(old_base_addr - OLD_SECTION_H (old_data_index).sh_addr);
- new_offsets_shift = new_bss_addr -
- ((old_base_addr & ~0xfff) + ((old_base_addr & 0xfff) ? 0x1000 : 0));
+ new_offsets_shift = new_bss_addr - (old_base_addr & ~0xfff) +
+ ((old_base_addr & 0xfff) ? 0x1000 : 0);
#ifdef DEBUG
fprintf (stderr, "old_bss_index %d\n", old_bss_index);
@@ -768,37 +769,41 @@
/* Fix up a new program header. Extend the writable data segment so
that the bss area is covered too. Find that segment by looking
- for a segment that ends just before the .bss area. Make sure
- that no segments are above the new .data2. Put a loop at the end
- to adjust the offset and address of any segment that is above
- data2, just in case we decide to allow this later. */
+ for one that starts before and ends after the .bss and it PT_LOADable.
+ Put a loop at the end to adjust the offset and address of any segment
+ that is above data2, just in case we decide to allow this later. */
+ oldbss = &OLD_SECTION_H(old_bss_index);
for (n = new_file_h->e_phnum - 1; n >= 0; n--)
{
/* Compute maximum of all requirements for alignment of section. */
- int alignment = (NEW_PROGRAM_H (n)).p_align;
- if ((OLD_SECTION_H (old_bss_index)).sh_addralign > alignment)
- alignment = OLD_SECTION_H (old_bss_index).sh_addralign;
-
- /* Supposedly this condition is okay for the SGI. */
-#if 0
- if (NEW_PROGRAM_H (n).p_vaddr + NEW_PROGRAM_H (n).p_filesz > old_base_addr)
- fatal ("Program segment above .bss in %s\n", old_name);
+ l_Elf_Phdr * ph = (l_Elf_Phdr *)((byte *) new_program_h +
+ new_file_h->e_phentsize*(n));
+#ifdef DEBUG
+ printf ("%d @ %0x + %0x against %0x + %0x",
+ n, ph->p_vaddr, ph->p_memsz,
+ oldbss->sh_addr, oldbss->sh_size);
#endif
-
- if (NEW_PROGRAM_H (n).p_type == PT_LOAD
- && (round_up ((NEW_PROGRAM_H (n)).p_vaddr
- + (NEW_PROGRAM_H (n)).p_filesz,
- alignment)
- == round_up (old_base_addr, alignment)))
- break;
+ if ((ph->p_type == PT_LOAD) &&
+ (ph->p_vaddr <= oldbss->sh_addr) &&
+ ((ph->p_vaddr + ph->p_memsz)>=(oldbss->sh_addr +
oldbss->sh_size))) {
+ ph->p_filesz += new_offsets_shift;
+ ph->p_memsz = ph->p_filesz;
+#ifdef DEBUG
+ puts (" That's the one!");
+ fflush (stdout);
+#endif
+ break;
+ }
+#ifdef DEBUG
+ putchar ('\n');
+ fflush (stdout);
+#endif
}
if (n < 0)
fatal ("Couldn't find segment next to %s in %s\n",
old_sbss_index == -1 ? ".sbss" : ".bss", old_name);
- NEW_PROGRAM_H (n).p_filesz += new_offsets_shift;
- NEW_PROGRAM_H (n).p_memsz = NEW_PROGRAM_H (n).p_filesz;
#if 1 /* Maybe allow section after data2 - does this ever happen? */
for (n = new_file_h->e_phnum - 1; n >= 0; n--)
--- ./lib-src/ChangeLog Wed Nov 3 13:34:21 1999
+++ ../xemacs-21.1.8/./lib-src/ChangeLog Tue Dec 28 15:45:23 1999
@@ -1,3 +1,8 @@
+1999-12-28 Max Matveev <max(a)melbourne.sgi.com>
+
+ * Makefile.in.in: Change the order of -I to make sure that local
+ stuff is always ahead of any user-defined options.
+
1999-11-02 XEmacs Build Bot <builds(a)cvs.xemacs.org>
* XEmacs 21.1.8 is released
--- ./lib-src/Makefile.in.in Mon Jun 14 16:32:00 1999
+++ ../xemacs-21.1.8/./lib-src/Makefile.in.in Tue Dec 28 15:52:15 1999
@@ -262,7 +262,7 @@
$(CC) -c `echo $(cflags) | sed 's/-Demacs/ /'` \
-DINHIBIT_STRING_HEADER ${srcdir}/../src/regex.c
-etags_args = -I. $(cflags) -I${srcdir} -I${srcdir}/../src \
+etags_args = -I. -I${srcdir} -I${srcdir}/../src $(cflags) \
-DVERSION='"${version}"' ${srcdir}/etags.c \
$(GETOPTOBJS) regex.o $(ldflags)
etags_deps = ${srcdir}/etags.c $(GETOPTDEPS) regex.o ../src/config.h
@@ -270,7 +270,7 @@
etags: ${etags_deps}
$(CC) ${etags_args} -o $@
-runemacs_args = -I. $(cflags) -I${srcdir} -I${srcdir}/../src \
+runemacs_args = -I. -I${srcdir} -I${srcdir}/../src $(cflags)\
-DVERSION='"${version}"' ${srcdir}/../nt/runemacs.c \
$(ldflags) -Wl,--subsystem,windows
runemacs_deps = ${srcdir}/../nt/runemacs.c ${srcdir}/../nt/xemacs.ico ../src/config.h
@@ -280,7 +280,7 @@
| windres -o runemacs_res.o
$(CC) runemacs_res.o ${runemacs_args} -o $@
-ootags_args = -I. $(cflags) -I${srcdir} -I${srcdir}/../src \
+ootags_args = -I. -I${srcdir} -I${srcdir}/../src $(cflags) \
-DVERSION='"${version}"' ${srcdir}/ootags.c \
$(GETOPTOBJS) regex.o $(ldflags)
ootags_deps = ${srcdir}/ootags.c $(GETOPTDEPS) regex.o ../src/config.h
--- ./ChangeLog Wed Nov 3 13:34:20 1999
+++ ../xemacs-21.1.8/./ChangeLog Tue Dec 28 15:38:44 1999
@@ -1,3 +1,12 @@
+1999-12-28 Max Matveev <max(a)melbourne.sgi.com>
+
+ * configure.in (machine): add new machine type for IRIX 6.[2-5] to
+ switch from using unexelf.o to unexelfsgi.o for just those
+ versions of IRIX.
+ In the ideal world it would be handled by the s/irix6-0.h but
+ since machine config is included AFTER OS config, I had to add a
+ new machine type.
+
1999-11-02 XEmacs Build Bot <builds(a)cvs.xemacs.org>
* XEmacs 21.1.8 is released
--- ./configure.in Tue Nov 2 15:17:06 1999
+++ ../xemacs-21.1.8/./configure.in Tue Dec 28 15:27:41 1999
@@ -1032,6 +1032,7 @@
alpha*-*-* ) machine=alpha ;;
vax-*-* ) machine=vax ;;
mips-dec-* ) machine=pmax ;;
+ mips-sgi-irix6* ) machine=iris6d ;;
mips-sgi-* ) machine=iris4d ;;
mips*-linux ) machine=mips ;;
romp-ibm-* ) machine=ibmrt ;;
/* machine description file for Iris-4D machines. Use with s/irix*.h.
Copyright (C) 1987 Free Software Foundation, Inc.
This file is part of GNU Emacs.
GNU Emacs is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with XEmacs; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* Synched up with: FSF 19.31. */
/* Define WORD_MACHINE if addresses and such have
* to be corrected before they can be used as byte counts. */
#undef WORD_MACHINE
/* Now define a symbol for the cpu type, if your compiler
does not define it automatically:
Ones defined so far include vax, m68000, ns16000, pyramid,
orion, tahoe, APOLLO and many others */
#ifndef mips
#define mips
#endif
#ifndef IRIS_4D
#define IRIS_4D
#endif
/* Define EXPLICIT_SIGN_EXTEND if XINT must explicitly sign-extend
the bit field into an int. In other words, if bit fields
are always unsigned.
If you use NO_UNION_TYPE, this flag does not matter. */
#define EXPLICIT_SIGN_EXTEND
/* jg(a)genmagic.genmagic.com (John Giannandrea) says this is unnecessary. */
#if 0
/* Data type of load average, as read out of kmem. */
#define LOAD_AVE_TYPE long /* This doesn't quite work on the 4D */
/* Convert that into an integer that is 100 for a load average of 1.0 */
#define LOAD_AVE_CVT(x) (int)(((double)(x)*100)/1024.0)
/* s-iris3-6.h uses /vmunix */
#undef KERNEL_FILE
#define KERNEL_FILE "/unix"
#endif
/* Define CANNOT_DUMP on machines where unexec does not work.
Then the function dump-emacs will not be defined
and temacs will do (load "loadup") automatically unless told otherwise. */
#undef CANNOT_DUMP
/* Define VIRT_ADDR_VARIES if the virtual addresses of
pure and impure space as loaded can vary, and even their
relative order cannot be relied on.
Otherwise Emacs assumes that text space precedes data space,
numerically. */
/* #define VIRT_ADDR_VARIES */
/* Define C_ALLOCA if this machine does not support a true alloca
and the one written in C should be used instead.
Define HAVE_ALLOCA to say that the system provides a properly
working alloca function and it should be used.
Define neither one if an assembler-language alloca
in the file alloca.s should be used. */
/* #define C_ALLOCA */ /* Sjoerd.Mullender(a)cwi.nl says no need. */
/* #define HAVE_ALLOCA */
/* Define NO_REMAP if memory segmentation makes it not work well
to change the boundary between the text section and data section
when Emacs is dumped. If you define this, the preloaded Lisp
code will not be sharable; but that's better than failing completely. */
#define NO_REMAP
/* This machine requires completely different unexec code
which lives in a separate file. Specify the file name. */
#ifdef USG5_4
#undef UNEXEC
#define UNEXEC "unexelfsgi.o"
#else
#define UNEXEC "unexmips.o"
#endif
#define TEXT_START 0x400000
/*
* DATA_SEG_BITS forces extra bits to be or'd in with any pointers which
* were stored in a Lisp_Object (as Emacs uses fewer than 32 bits for
* the value field of a LISP_OBJECT).
*/
#define DATA_START 0x10000000
#define DATA_SEG_BITS 0x10000000
#undef LIBS_MACHINE
/* -lsun in case using Yellow Pages for passwords. */
#define LIBS_DEBUG
/* Define this if you have a fairly recent system,
in which crt1.o and crt1.n should be used. */
#define HAVE_CRTN
#ifndef USG5_4
#ifdef HAVE_CRTN
/* Must define START-FILES so that the linker can find /usr/lib/crt0.o. */
#define START_FILES "pre-crt0.o /usr/lib/crt1.o"
#define LIB_STANDARD "-lc /usr/lib/crtn.o"
#else
#define START_FILES "pre-crt0.o /usr/lib/crt0.o"
/* The entry-point label (start of text segment) is `start', not `__start'. */
#define DEFAULT_ENTRY_ADDRESS start
#define LIB_STANDARD "-lc"
#endif
#endif
/* Use terminfo instead of termcap. */
#define TERMINFO
/* Letter to use in finding device name of first pty,
if system supports pty's. 'a' means it is /dev/ptya0 */
#undef FIRST_PTY_LETTER
#define FIRST_PTY_LETTER 'q'
/* Define STACK_DIRECTION for alloca.c */
#undef STACK_DIRECTION
#define STACK_DIRECTION -1