THIS IS NOT FOR THE NEXTSTEP AWARE EMACS (4.2 beta6) THIS IS ONLY FOR emacs-19.34b.tar.gz AS DISTRIBUTED BY THE FSF !!! x-gateway: relay2.UU.NET from bug-gnu-emacs to gnu.emacs.bug; Wed, 16 Oct 1996 10:46:34 EDT Date: Wed, 16 Oct 1996 08:44:52 -0600 From: nygard@agt.net (Steven Nygard) Subject: Compiling Emacs on Openstep Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Approved: bug-gnu-emacs-request@prep.ai.mit.edu Newsgroups: gnu.emacs.bug Path: nowhere.ethz.ch!elna.ethz.ch!scsing.switch.ch!swidir.switch.ch!in2p3.fr!univ-lyon1.fr!pasteur.fr!jussieu.fr!math.ohio-state.edu!howland.erols.net!news.mathworks.com!uunet!in1.uu.net!wendy-fate.uu.net!bug-gnu-emacs Sender: bug-gnu-emacs-request@prep.ai.mit.edu Lines: 211 These changes to emacs-19.34b allow you to compile and dump Emacs with Openstep for Mach 4.0. It adds support for the new dynamic libraries, and works around a bug in the compiler that gives an "array type used where scalar required" error when compiling !"string". -- Steve Nygard *** src/s/nextstep.h Mon Jan 15 01:16:45 1996 --- src/s/nextstep.h Sat Oct 12 15:58:13 1996 *************** *** 73,82 **** /* Link this program just by running cc. */ #define ORDINARY_LINK ! #define LD_SWITCH_SYSTEM -X -noseglinkedit /* Don't use -lc on the NeXT. */ ! #define LIB_STANDARD -lsys_s #define LIB_MATH -lm #define START_FILES pre-crt0.o --- 73,87 ---- /* Link this program just by running cc. */ #define ORDINARY_LINK ! #define LD_SWITCH_SYSTEM -X /* Don't use -lc on the NeXT. */ ! #ifdef NS_TARGET /* We use the dynamic libraries under Openstep for Mach 4.0 */ ! # define LIB_STANDARD ! #else ! # define LIB_STANDARD -lsys_s ! #endif ! #define LIB_MATH -lm #define START_FILES pre-crt0.o *** lib-src/etags.c Tue Jul 23 10:32:10 1996 --- lib-src/etags.c Sat Oct 12 15:23:40 1996 *************** *** 104,111 **** #define C_STAR 0x00003 /* C* */ #define YACC 0x10000 /* yacc file */ ! #define streq(s,t) ((DEBUG &&!(s)&&!(t)&&(abort(),1)) || !strcmp(s,t)) ! #define strneq(s,t,n) ((DEBUG &&!(s)&&!(t)&&(abort(),1)) || !strncmp(s,t,n)) #define lowcase(c) tolower ((unsigned char)c) --- 104,116 ---- #define C_STAR 0x00003 /* C* */ #define YACC 0x10000 /* yacc file */ ! #ifdef NS_TARGET ! # define streq(s,t) ((DEBUG &&(s)==NULL&&(t)==NULL&&(abort(),1)) || !strcmp(s,t)) ! # define strneq(s,t,n) ((DEBUG &&(s)==NULL&&(t)==NULL&&(abort(),1)) || !strncmp(s,t,n)) ! #else ! # define streq(s,t) ((DEBUG &&!(s)&&!(t)&&(abort(),1)) || !strcmp(s,t)) ! # define strneq(s,t,n) ((DEBUG &&!(s)&&!(t)&&(abort(),1)) || !strncmp(s,t,n)) ! #endif #define lowcase(c) tolower ((unsigned char)c) *** src/unexnext..c Mon Jan 15 02:06:29 1996 --- src/unexnext.c Sat Oct 12 15:52:29 1996 *************** *** 27,32 **** --- 27,33 ---- #include #include #include + #include #include #include #include *************** *** 243,249 **** struct load_command **the_commands = NULL; unsigned the_commands_len; struct mach_header the_header; ! int fgrowth; int fdatastart; int fdatasize; int size; --- 244,250 ---- struct load_command **the_commands = NULL; unsigned the_commands_len; struct mach_header the_header; ! int fgrowth = 0; int fdatastart; int fdatasize; int size; *************** *** 251,259 **** --- 252,269 ---- char *buf; vm_address_t data_address; vm_size_t data_size; + vm_size_t vmaddr_growth = 0; + vm_size_t dataseg_vmaddr, dataseg_vmend; struct segment_command *segment; + #ifdef NS_TARGET + unsigned long extreloff = 0; + unsigned long nextrel = 0; + struct dysymtab_command *dysymtab; + struct relocation_info reloc_info; + #endif + if (!read_macho(infd, &the_header, &the_commands, &the_commands_len)) { return (0); } *************** *** 284,290 **** --- 294,310 ---- segment->filesize); segment->vmsize = data_size; segment->filesize = data_size; + dataseg_vmaddr = segment->vmaddr; + dataseg_vmend = segment->vmaddr + segment->vmsize; + vmaddr_growth = segment->vmaddr + segment->vmsize; + } else { + ((struct segment_command *)the_commands[i])->fileoff += fgrowth; } + + if( strcmp( segment->segname, SEG_LINKEDIT ) == 0 ) { + segment->vmaddr = vmaddr_growth; + } + break; case LC_SYMTAB: ((struct symtab_command *) *************** *** 296,301 **** --- 316,330 ---- ((struct symseg_command *) the_commands[i])->offset += fgrowth; break; + #ifdef NS_TARGET + case LC_DYSYMTAB: + dysymtab = ((struct dysymtab_command *)the_commands[i]); + extreloff = dysymtab->extreloff; + nextrel = dysymtab->nextrel; + dysymtab->indirectsymoff += fgrowth; + dysymtab->extreloff += fgrowth; + break; + #endif default: break; } *************** *** 382,387 **** --- 411,465 ---- return (0); } free(buf); + + #ifdef NS_TARGET + /* + * Fix up relocation entries in the data segment. + */ + + if (lseek(infd, extreloff, L_SET) < 0) { + fatal_unexec("cannot seek input file"); + return (0); + } + + for (i = 0; i < nextrel; i++) + { + long zeroval = 0; + + if (read(infd, &reloc_info, sizeof (reloc_info)) != sizeof (reloc_info)) { + fatal_unexec("cannot read input file"); + return (0); + } + if (reloc_info.r_address >= dataseg_vmaddr && reloc_info.r_address < dataseg_vmend) + { + if (lseek (outfd, fdatastart + reloc_info.r_address - dataseg_vmaddr, L_SET) < 0 ) { + fatal_unexec("cannot seek input file"); + return (0); + } + switch (reloc_info.r_length) { + case 0: + if (write(outfd, &zeroval, 1) != 1) { + fatal_unexec("cannot write output file"); + return (0); + } + break; + case 1: + if (write(outfd, &zeroval, 2) != 2) { + fatal_unexec("cannot write output file"); + return (0); + } + break; + case 2: + if (write(outfd, &zeroval, 4) != 4) { + fatal_unexec("cannot write output file"); + return (0); + } + break; + } + } + } + #endif + return (1); }