From mboxrd@z Thu Jan 1 00:00:00 1970 From: Harry Kalogirou Subject: [Resend] Processes with growing heap support Date: 17 Jul 2003 01:45:41 +0300 Sender: linux-8086-owner@vger.kernel.org Message-ID: <1058395541.9661.15.camel@cool> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-xK5IpNwrdpN1oc1Wq4n0" Return-path: List-Id: To: Linux-8086 --=-xK5IpNwrdpN1oc1Wq4n0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Ok it is done. I commited to the CVS code to support growing heap. There are two new configuration variables you need : CONFIG_EXEC_ELKS which enables support for the new executable format CONFIG_ADVANCED_MM which enables some new features in the memory manager, that you better have when using the new executable format. The kernel can still run the standar minix executables like it used to. To create executables in the new format you will need the patched linker ld86. The patch is attached to this e-mail. There are two patches for the linker, one for the package dev-0.16.0 and one for dev-0.16.9. You better go with dev-0.16.0 since the kernel Oops-es when compiler with dev-0.16.9. The dev-0.16.9 patch is attached more for Robert to add it easier to that version. The patch makes the linker to create an executable with the "big" a.aout header when given the -D option. So giving -D0x1000 to the linker creates an executable with the new header, that when loaded from ELKS will have an 0x1000 bytes stack and a nice growing heap. I started changing the elkscmd package to create this type of binaries for the most used utilities. On my testbox having init, getty, login, and ash in the new format gives me 302KB free memory when logged in! ---------------------------- # ps 1 0 root S 26676 init 8 5 root R 27264 ps 7 7 root S 27166 /bin/getty 6 6 root S 27166 /bin/getty 5 5 root S 27068 -/bin/ash # meminfo memory usage : 460KB total, 158KB used, 302KB free swap usage : 0KB total, 0KB used, 0KB free # ---------------------------- I also include a patch to make the dev-0.16.x complilable with the ansified ELKS kernel headers. Harry --=-xK5IpNwrdpN1oc1Wq4n0 Content-Disposition: attachment; filename=dev86-0.16.0.diff Content-Type: text/x-patch; name=dev86-0.16.0.diff; charset=ISO-8859-7 Content-Transfer-Encoding: 7bit diff -urN linux-86-vanila/ld/globvar.h linux-86/ld/globvar.h --- linux-86-vanila/ld/globvar.h Tue Oct 29 23:05:22 2002 +++ linux-86/ld/globvar.h Wed Oct 30 15:57:56 2002 @@ -13,6 +13,7 @@ /* K&R _explicitly_ says extern followed by public is OK */ extern char hexdigit[]; /* constant */ extern int headerless; /* Don't output header on exe */ +extern int bigheader; extern bin_off_t text_base_value; /* Base address of text seg */ extern bin_off_t data_base_value; /* Base or alignment of data seg */ diff -urN linux-86-vanila/ld/ld.c linux-86/ld/ld.c --- linux-86-vanila/ld/ld.c Tue Oct 29 23:05:22 2002 +++ linux-86/ld/ld.c Wed Oct 30 15:56:45 2002 @@ -19,6 +19,7 @@ PUBLIC bin_off_t data_base_value = 0; /* XXX */ PUBLIC bin_off_t heap_top_value = 0; /* XXX */ PUBLIC int headerless = 0; +PUBLIC int bigheader = 0; PUBLIC char hexdigit[] = "0123456789abcdef"; PRIVATE bool_t flag[128]; @@ -172,6 +173,7 @@ data_base_value = strtoul(arg+2, (char **)0, 16); if (errno != 0) use_error("invalid data address"); + bigheader = 1; break; case 'H': /* heap top address */ if (arg[2] == 0 && ++argn >= argc) diff -urN linux-86-vanila/ld/writex86.c linux-86/ld/writex86.c --- linux-86-vanila/ld/writex86.c Tue Oct 29 23:05:22 2002 +++ linux-86/ld/writex86.c Wed Oct 30 15:57:25 2002 @@ -17,7 +17,7 @@ #define ELF_SYMS 0 #endif -# define FILEHEADERLENGTH (headerless?0:A_MINHDR) +# define FILEHEADERLENGTH (headerless?0:(bigheader?sizeof(struct exec):A_MINHDR)) /* part of header not counted in offsets */ #define DPSEG 2 @@ -620,8 +620,10 @@ offtocn((char *) &header.a_total, (bin_off_t) heap_top_value, sizeof header.a_total); - if( FILEHEADERLENGTH ) - writeout((char *) &header, FILEHEADERLENGTH); + if(bigheader) + offtocn((char *) &header.a_dbase, data_base_value, sizeof header.a_dbase); + if( header.a_hdrlen ) + writeout((char *) &header, header.a_hdrlen); } PRIVATE void writenulls(count) --- linux-86-vanila/libc/bcc/heap.c Fri Nov 1 02:43:13 2002 +++ linux-86/libc/bcc/heap.c Fri Nov 1 02:41:12 2002 @@ -44,9 +44,6 @@ js go_down add ax,[brk_addr] ! Goin up! jc Enomem - sub bx,#511 ! Safety space 512 bytes - cmp bx,ax ! Too close ? - jb Enomem sbrk_ok: #if !defined(__MSDOS__) && !defined(__STANDALONE__) @@ -121,6 +118,7 @@ #ifdef L___brk_addr char * __brk_addr = 0; /* This holds the current return for sbrk(0) */ + char * __brk(val) { --=-xK5IpNwrdpN1oc1Wq4n0 Content-Disposition: attachment; filename=dev86-0.16.9.diff Content-Type: text/x-patch; name=dev86-0.16.9.diff; charset=ISO-8859-7 Content-Transfer-Encoding: 7bit diff -urN dev86-0.16.9-vanila/ld/globvar.h dev86-0.16.9/ld/globvar.h --- dev86-0.16.9-vanila/ld/globvar.h Fri Nov 1 02:20:12 2002 +++ dev86-0.16.9/ld/globvar.h Fri Nov 1 02:23:53 2002 @@ -13,6 +13,7 @@ /* K&R _explicitly_ says extern followed by public is OK */ extern char hexdigit[]; /* constant */ extern int headerless; /* Don't output header on exe */ +extern int bigheader; extern int cpm86; /* Generate CP/M-86 CMD header */ extern bin_off_t text_base_value; /* Base address of text seg */ diff -urN dev86-0.16.9-vanila/ld/ld.c dev86-0.16.9/ld/ld.c --- dev86-0.16.9-vanila/ld/ld.c Fri Nov 1 02:20:11 2002 +++ dev86-0.16.9/ld/ld.c Fri Nov 1 02:24:46 2002 @@ -19,6 +19,7 @@ PUBLIC bin_off_t data_base_value = 0; /* XXX */ PUBLIC bin_off_t heap_top_value = 0; /* XXX */ PUBLIC int headerless = 0; +PUBLIC int bigheader = 0; PUBLIC int cpm86 = 0; PUBLIC char hexdigit[] = "0123456789abcdef"; @@ -176,6 +177,7 @@ data_base_value = strtoul(arg+2, (char **)0, 16); if (errno != 0) use_error("invalid data address"); + bigheader = 1; break; case 'H': /* heap top address */ if (arg[2] == 0 && ++argn >= argc) diff -urN dev86-0.16.9-vanila/ld/writex86.c dev86-0.16.9/ld/writex86.c --- dev86-0.16.9-vanila/ld/writex86.c Fri Nov 1 02:20:12 2002 +++ dev86-0.16.9/ld/writex86.c Fri Nov 1 02:27:50 2002 @@ -18,7 +18,7 @@ #define ELF_SYMS 0 #endif -# define FILEHEADERLENGTH (headerless?0:(cpm86?CPM86_HEADERLEN:A_MINHDR)) +# define FILEHEADERLENGTH (headerless?0:(bigheader?sizeof(struct exec):(cpm86?CPM86_HEADERLEN:A_MINHDR))) /* part of header not counted in offsets */ #define DPSEG 2 @@ -651,8 +651,10 @@ offtocn((char *) &header.a_total, (bin_off_t) heap_top_value, sizeof header.a_total); - if( FILEHEADERLENGTH ) - writeout((char *) &header, FILEHEADERLENGTH); + if(bigheader) + offtocn((char *) &header.a_dbase, data_base_value, sizeof header.a_dbase); + if( header.a_hdrlen ) + writeout((char *) &header, header.a_hdrlen); } PRIVATE void writenulls(count) diff -urN dev86-0.16.9-vanila/libc/bcc/heap.c dev86-0.16.9/libc/bcc/heap.c --- dev86-0.16.9-vanila/libc/bcc/heap.c Fri Nov 1 02:20:12 2002 +++ dev86-0.16.9/libc/bcc/heap.c Fri Nov 1 02:34:02 2002 @@ -44,9 +44,6 @@ js go_down add ax,[brk_addr] ! Goin up! jc Enomem - sub bx,#511 ! Safety space 512 bytes - cmp bx,ax ! Too close ? - jb Enomem sbrk_ok: #if !defined(__MSDOS__) && !defined(__STANDALONE__) --=-xK5IpNwrdpN1oc1Wq4n0 Content-Disposition: attachment; filename=dev86-0.16.x-ansi.diff Content-Type: text/x-patch; name=dev86-0.16.x-ansi.diff; charset=ISO-8859-7 Content-Transfer-Encoding: 7bit diff -urN linux-86/libbsd/Make.defs linux-86-vanila/libbsd/Make.defs --- linux-86/libbsd/Make.defs Sun Feb 3 03:07:06 2002 +++ linux-86-vanila/libbsd/Make.defs Wed Oct 30 16:45:32 2002 @@ -27,8 +27,7 @@ # Normal standard 8086 code ifeq ($(PLATFORM),i86-ELKS) -ARCH=-0 - +ARCH=-ansi -0 # 8086 elks code With "Caller saves" and "First arg in AX" # ARCH=-0 -C-c -C-f endif @@ -60,5 +59,5 @@ endif # ifeq ($(PLATFORM),i386-Linux) -CFLAGS=$(CCFLAGS) $(LIBDEFS) +CFLAGS=$(ARCH) $(CCFLAGS) $(LIBDEFS) LDFLAGS=$(LKFLAGS) --- linux-86/libc/Make.defs Wed Oct 30 16:33:05 2002 +++ linux-86-vanila/libc/Make.defs Wed Oct 30 16:48:28 2002 @@ -4,7 +4,7 @@ ifeq ($(PLATFORM),i86-ELKS) OBJ=crt0.o LIBC=$(TOP)/libc.a -ARCH=-Mn +ARCH=-ansi -Mn LIB_CPU=i86 LIB_OS=ELKS endif @@ -15,7 +15,7 @@ ifeq ($(PLATFORM),i86-FAST) OBJ=crt0.o LIBC=$(TOP)/libc_f.a -ARCH=-Mf +ARCH=-ansi -Mf LIB_CPU=i86 LIB_OS=ELKS endif --=-xK5IpNwrdpN1oc1Wq4n0--