aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDan Nicolaescu2008-07-16 07:11:19 +0000
committerDan Nicolaescu2008-07-16 07:11:19 +0000
commitc3b5f109164f9e7224c086a16c766257d4e3ddde (patch)
tree026f0482ff1f90c05fbc0af7f3f78b5d608cd77c /src
parent6b0273cd0a5ffcb7dc98b311bbfb4a112fc7db65 (diff)
downloademacs-c3b5f109164f9e7224c086a16c766257d4e3ddde.tar.gz
emacs-c3b5f109164f9e7224c086a16c766257d4e3ddde.zip
* m/mips.h: Remove boilerplate comments and code for systems that
do not use this file. (SIGN_EXTEND_CHAR): * m/arm.h (SIGN_EXTEND_CHAR): Remove, unused. * unexmips.c: Remove file, unused.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/m/arm.h5
-rw-r--r--src/m/mips.h122
-rw-r--r--src/unexmips.c348
4 files changed, 8 insertions, 473 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 491931820ec..434f6de6fdf 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,11 @@
12008-07-16 Dan Nicolaescu <dann@ics.uci.edu> 12008-07-16 Dan Nicolaescu <dann@ics.uci.edu>
2 2
3 * m/mips.h: Remove boilerplate comments and code for systems that
4 do not use this file.
5 (SIGN_EXTEND_CHAR):
6 * m/arm.h (SIGN_EXTEND_CHAR): Remove, unused.
7 * unexmips.c: Remove file, unused.
8
3 * editfns.c (Fuser_full_name): Replace the only use of 9 * editfns.c (Fuser_full_name): Replace the only use of
4 USER_FULL_NAME with its value. 10 USER_FULL_NAME with its value.
5 * config.in: Regenerate. 11 * config.in: Regenerate.
diff --git a/src/m/arm.h b/src/m/arm.h
index 3b798795744..34d98a89b3d 100644
--- a/src/m/arm.h
+++ b/src/m/arm.h
@@ -34,11 +34,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
34#undef NO_ARG_ARRAY 34#undef NO_ARG_ARRAY
35#endif 35#endif
36 36
37/* Define how to take a char and sign-extend into an int.
38 On machines where char is signed, this is a no-op. */
39
40#define SIGN_EXTEND_CHAR(c) (((int)(c) << 24) >> 24)
41
42#define NO_REMAP 37#define NO_REMAP
43 38
44/* arch-tag: 07856f0c-f0c8-4bd8-99af-0b7fa1e5ee42 39/* arch-tag: 07856f0c-f0c8-4bd8-99af-0b7fa1e5ee42
diff --git a/src/m/mips.h b/src/m/mips.h
index ce0f56aa754..ec26a86d988 100644
--- a/src/m/mips.h
+++ b/src/m/mips.h
@@ -23,8 +23,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
23 USUAL-OPSYS="note" 23 USUAL-OPSYS="note"
24 24
25NOTE-START 25NOTE-START
26Use mips4.h for RISCOS version 4; use s-bsd4-3.h with the BSD world. 26This is only used on GNU/Linux.
27Note that the proper m file for the Decstation is pmax.h.
28NOTE-END */ 27NOTE-END */
29 28
30/* Define WORDS_BIG_ENDIAN if lowest-numbered byte in a word 29/* Define WORDS_BIG_ENDIAN if lowest-numbered byte in a word
@@ -39,15 +38,8 @@ NOTE-END */
39 38
40#define NO_ARG_ARRAY 39#define NO_ARG_ARRAY
41 40
42/* Define how to take a char and sign-extend into an int.
43 On machines where char is signed, this is a no-op. */
44
45#define SIGN_EXTEND_CHAR(c) ((signed char)(c))
46
47/* Now define a symbol for the cpu type, if your compiler 41/* Now define a symbol for the cpu type, if your compiler
48 does not define it automatically: 42 does not define it automatically. */
49 Ones defined so far include vax, m68000, ns16000, pyramid,
50 orion, tahoe, APOLLO and many others */
51#ifndef mips 43#ifndef mips
52# define mips 44# define mips
53#endif 45#endif
@@ -68,28 +60,6 @@ NOTE-END */
68 60
69#define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / 256.0) 61#define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / 256.0)
70 62
71/* CDC EP/IX 1.4.3 uses /unix */
72
73#ifndef __linux__
74#undef KERNEL_FILE
75#define KERNEL_FILE "/unix"
76#endif /* not __linux__ */
77
78/* Define CANNOT_DUMP on machines where unexec does not work.
79 Then the function dump-emacs will not be defined
80 and temacs will do (load "loadup") automatically unless told otherwise. */
81
82#undef CANNOT_DUMP
83
84/* Define VIRT_ADDR_VARIES if the virtual addresses of
85 pure and impure space as loaded can vary, and even their
86 relative order cannot be relied on.
87
88 Otherwise Emacs assumes that text space precedes data space,
89 numerically. */
90
91/* #define VIRT_ADDR_VARIES */
92
93/* Define NO_REMAP if memory segmentation makes it not work well 63/* Define NO_REMAP if memory segmentation makes it not work well
94 to change the boundary between the text section and data section 64 to change the boundary between the text section and data section
95 when Emacs is dumped. If you define this, the preloaded Lisp 65 when Emacs is dumped. If you define this, the preloaded Lisp
@@ -97,59 +67,12 @@ NOTE-END */
97 67
98#define NO_REMAP 68#define NO_REMAP
99 69
100/* This machine requires completely different unexec code
101 which lives in a separate file. Specify the file name. */
102
103#if !defined(__linux__) && !defined(__NetBSD__)
104#undef UNEXEC
105#define UNEXEC unexmips.o
106#endif /* not __linux__ && not __NetBSD__ */
107
108/* Describe layout of the address space in an executing process. */ 70/* Describe layout of the address space in an executing process. */
109 71
110#ifdef __linux__
111#define TEXT_START 0x00400000 72#define TEXT_START 0x00400000
112#define DATA_START 0x10000000 73#define DATA_START 0x10000000
113#define DATA_SEG_BITS 0x10000000 74#define DATA_SEG_BITS 0x10000000
114#else /* not __linux__ */
115#define TEXT_START 0x400000
116#define DATA_START 0x800000
117#endif /* __linux__ */
118
119/* Alter some of the options used when linking. */
120
121#if !defined(__linux__)
122#ifdef BSD_SYSTEM
123
124/* DECstations don't have this library.
125 #define LIBS_MACHINE -lmld */
126
127#define LD_SWITCH_MACHINE -D 800000
128#define LIBS_DEBUG
129
130#if defined (__NetBSD__) || defined (__OpenBSD__)
131#else /* bsd with elf */
132#define LINKER /bsd43/bin/ld
133
134#define LD_SWITCH_MACHINE -D 800000 -g3
135#define START_FILES pre-crt0.o /usr/lib/crt1.o
136#define LIB_STANDARD -lbsd -lc /usr/lib/crtn.o
137#define LIBS_TERMCAP -lcurses
138
139#define C_SWITCH_MACHINE -I/usr/include/bsd
140#define C_DEBUG_SWITCH -O -g3
141 75
142#endif /* bsd with elf */
143#else /* not BSD_SYSTEM */
144
145#if defined(__GNUC__) && defined(_ABIN32)
146#define LIBS_MACHINE
147#else
148#define LIBS_MACHINE -lmld
149#endif
150
151#endif /* not BSD_SYSTEM */
152#endif /* not __linux__ */
153 76
154/* The standard definitions of these macros would work ok, 77/* The standard definitions of these macros would work ok,
155 but these are faster because the constants are short. */ 78 but these are faster because the constants are short. */
@@ -160,47 +83,6 @@ NOTE-END */
160 ((var) = \ 83 ((var) = \
161 ((int)(type) << VALBITS) \ 84 ((int)(type) << VALBITS) \
162 + (((unsigned) (ptr) << (BITS_PER_INT-VALBITS)) >> (BITS_PER_INT-VALBITS))) 85 + (((unsigned) (ptr) << (BITS_PER_INT-VALBITS)) >> (BITS_PER_INT-VALBITS)))
163
164#if !defined (__linux__)
165#ifdef USG
166
167/* Cancel certain parts of standard sysV support. */
168#undef NONSYSTEM_DIR_LIBRARY
169#define SYSV_SYSTEM_DIR
170#undef static
171
172/* Don't try to use SIGIO or FIONREAD even though they are defined. */
173#define BROKEN_SIGIO
174#define BROKEN_FIONREAD
175
176/* Describe special kernel features. */
177
178#define HAVE_SYSVIPC
179
180#if defined(emacs)
181#include <bsd/sys/time.h>
182#endif
183
184/* The `select' in the system won't work for pipes, so don't use it. */
185#undef HAVE_SELECT /* override configuration decision */
186
187#define HAVE_PTYS
188#define HAVE_SOCKETS
189
190#undef NOMULTIPLEJOBS
191
192/* ??? */
193#define IRIS
194
195#endif /* USG */
196
197#ifdef BSD_SYSTEM
198#define COFF
199#define TERMINFO
200#undef MAIL_USE_FLOCK /* Someone should check this. */
201#endif /* BSD_SYSTEM */
202
203#endif /* not __linux__ */
204 86
205/* arch-tag: 8fd020ee-78a7-4d87-96ce-6129f52f7bee 87/* arch-tag: 8fd020ee-78a7-4d87-96ce-6129f52f7bee
206 (do not change this comment) */ 88 (do not change this comment) */
diff --git a/src/unexmips.c b/src/unexmips.c
deleted file mode 100644
index fca96d6f32a..00000000000
--- a/src/unexmips.c
+++ /dev/null
@@ -1,348 +0,0 @@
1/* Unexec for MIPS (including IRIS4D).
2 Note that the GNU project considers support for MIPS operation
3 a peripheral activity which should not be allowed to divert effort
4 from development of the GNU system. Changes in this code will be
5 installed when users send them in, but aside from that
6 we don't plan to think about it, or about whether other Emacs
7 maintenance might break it.
8
9 Copyright (C) 1988, 1994, 2001, 2002, 2003, 2004,
10 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
11
12This file is part of GNU Emacs.
13
14GNU Emacs is free software: you can redistribute it and/or modify
15it under the terms of the GNU General Public License as published by
16the Free Software Foundation, either version 3 of the License, or
17(at your option) any later version.
18
19GNU Emacs is distributed in the hope that it will be useful,
20but WITHOUT ANY WARRANTY; without even the implied warranty of
21MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22GNU General Public License for more details.
23
24You should have received a copy of the GNU General Public License
25along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26
27
28#include <config.h>
29#include <sys/types.h>
30#include <sys/file.h>
31#include <sys/stat.h>
32#include <stdio.h>
33#include <varargs.h>
34
35#ifdef MACH
36
37#include <a.out.h>
38
39/* I don't know why this isn't defined. */
40#ifndef STYP_INIT
41#define STYP_INIT 0x80000000
42#endif
43
44/* I don't know why this isn't defined. */
45#ifndef _RDATA
46#define _RDATA ".rdata"
47#define STYP_RDATA 0x00000100
48#endif
49
50/* Small ("near") data section. */
51#ifndef _SDATA
52#define _SDATA ".sdata"
53#define STYP_SDATA 0x00000200
54#endif
55
56/* Small ("near") bss section. */
57#ifndef _SBSS
58#define _SBSS ".sbss"
59#define STYP_SBSS 0x00000400
60#endif
61
62/* We don't seem to have a sym.h or syms.h anywhere, so we'll do it the
63 hard way. This stinks. */
64typedef struct {
65 short magic;
66 short vstamp;
67 long ilineMax;
68 struct { long foo, offset; } offsets[11];
69} HDRR, *pHDRR;
70
71#else /* not MACH */
72
73#include <filehdr.h>
74#include <aouthdr.h>
75#include <scnhdr.h>
76#include <sym.h>
77
78#endif /* not MACH */
79
80#if defined (IRIS_4D)
81#include "getpagesize.h"
82#include <fcntl.h>
83#endif
84
85static void fatal_unexec ();
86static void mark_x ();
87
88#define READ(_fd, _buffer, _size, _error_message, _error_arg) \
89 errno = EEOF; \
90 if (read (_fd, _buffer, _size) != _size) \
91 fatal_unexec (_error_message, _error_arg);
92
93#define WRITE(_fd, _buffer, _size, _error_message, _error_arg) \
94 if (write (_fd, _buffer, _size) != _size) \
95 fatal_unexec (_error_message, _error_arg);
96
97#define SEEK(_fd, _position, _error_message, _error_arg) \
98 errno = EEOF; \
99 if (lseek (_fd, _position, L_SET) != _position) \
100 fatal_unexec (_error_message, _error_arg);
101
102extern int errno;
103extern char *strerror ();
104#define EEOF -1
105
106static struct scnhdr *text_section;
107static struct scnhdr *init_section;
108static struct scnhdr *finit_section;
109static struct scnhdr *rdata_section;
110static struct scnhdr *data_section;
111static struct scnhdr *lit8_section;
112static struct scnhdr *lit4_section;
113static struct scnhdr *sdata_section;
114static struct scnhdr *sbss_section;
115static struct scnhdr *bss_section;
116
117struct headers {
118 struct filehdr fhdr;
119 struct aouthdr aout;
120 struct scnhdr section[10];
121};
122
123/* Define name of label for entry point for the dumped executable. */
124
125#ifndef DEFAULT_ENTRY_ADDRESS
126#define DEFAULT_ENTRY_ADDRESS __start
127#endif
128
129unexec (new_name, a_name, data_start, bss_start, entry_address)
130 char *new_name, *a_name;
131 unsigned data_start, bss_start, entry_address;
132{
133 int new, old;
134 int pagesize, brk;
135 int newsyms, symrel;
136 int nread;
137 struct headers hdr;
138 int i;
139 int vaddr, scnptr;
140#define BUFSIZE 8192
141 char buffer[BUFSIZE];
142
143 old = open (a_name, O_RDONLY, 0);
144 if (old < 0) fatal_unexec ("opening %s", a_name);
145
146 new = creat (new_name, 0666);
147 if (new < 0) fatal_unexec ("creating %s", new_name);
148
149 hdr = *((struct headers *)TEXT_START);
150 if (hdr.fhdr.f_magic != MIPSELMAGIC
151 && hdr.fhdr.f_magic != MIPSEBMAGIC)
152 {
153 fprintf (stderr, "unexec: input file magic number is %x, not %x or %x.\n",
154 hdr.fhdr.f_magic, MIPSELMAGIC, MIPSEBMAGIC);
155 exit (1);
156 }
157 if (hdr.fhdr.f_opthdr != sizeof (hdr.aout))
158 {
159 fprintf (stderr, "unexec: input a.out header is %d bytes, not %d.\n",
160 hdr.fhdr.f_opthdr, sizeof (hdr.aout));
161 exit (1);
162 }
163 if (hdr.aout.magic != ZMAGIC)
164 {
165 fprintf (stderr, "unexec: input file a.out magic number is %o, not %o.\n",
166 hdr.aout.magic, ZMAGIC);
167 exit (1);
168 }
169
170#define CHECK_SCNHDR(ptr, name, flags) \
171 ptr = NULL; \
172 for (i = 0; i < hdr.fhdr.f_nscns && !ptr; i++) \
173 if (strcmp (hdr.section[i].s_name, name) == 0) \
174 { \
175 if (hdr.section[i].s_flags != flags) \
176 fprintf (stderr, "unexec: %x flags (%x expected) in %s section.\n", \
177 hdr.section[i].s_flags, flags, name); \
178 ptr = hdr.section + i; \
179 } \
180
181 CHECK_SCNHDR (text_section, _TEXT, STYP_TEXT);
182 CHECK_SCNHDR (init_section, _INIT, STYP_INIT);
183 CHECK_SCNHDR (rdata_section, _RDATA, STYP_RDATA);
184 CHECK_SCNHDR (data_section, _DATA, STYP_DATA);
185#ifdef _LIT8
186 CHECK_SCNHDR (lit8_section, _LIT8, STYP_LIT8);
187 CHECK_SCNHDR (lit4_section, _LIT4, STYP_LIT4);
188#endif /* _LIT8 */
189 CHECK_SCNHDR (sdata_section, _SDATA, STYP_SDATA);
190 CHECK_SCNHDR (sbss_section, _SBSS, STYP_SBSS);
191 CHECK_SCNHDR (bss_section, _BSS, STYP_BSS);
192#if 0 /* Apparently this error check goes off on irix 3.3,
193 but it doesn't indicate a real problem. */
194 if (i != hdr.fhdr.f_nscns)
195 fprintf (stderr, "unexec: %d sections found instead of %d.\n",
196 i, hdr.fhdr.f_nscns);
197#endif
198
199 text_section->s_scnptr = 0;
200
201 pagesize = getpagesize ();
202 /* Casting to int avoids compiler error on NEWS-OS 5.0.2. */
203 brk = (((int) (sbrk (0))) + pagesize - 1) & (-pagesize);
204 hdr.aout.dsize = brk - DATA_START;
205 hdr.aout.bsize = 0;
206 if (entry_address == 0)
207 {
208 extern DEFAULT_ENTRY_ADDRESS ();
209 hdr.aout.entry = (unsigned)DEFAULT_ENTRY_ADDRESS;
210 }
211 else
212 hdr.aout.entry = entry_address;
213
214 hdr.aout.bss_start = hdr.aout.data_start + hdr.aout.dsize;
215 rdata_section->s_size = data_start - DATA_START;
216
217 /* Adjust start and virtual addresses of rdata_section, too. */
218 rdata_section->s_vaddr = DATA_START;
219 rdata_section->s_paddr = DATA_START;
220 rdata_section->s_scnptr = text_section->s_scnptr + hdr.aout.tsize;
221
222 data_section->s_vaddr = data_start;
223 data_section->s_paddr = data_start;
224 data_section->s_size = brk - data_start;
225 data_section->s_scnptr = rdata_section->s_scnptr + rdata_section->s_size;
226 vaddr = data_section->s_vaddr + data_section->s_size;
227 scnptr = data_section->s_scnptr + data_section->s_size;
228 if (lit8_section != NULL)
229 {
230 lit8_section->s_vaddr = vaddr;
231 lit8_section->s_paddr = vaddr;
232 lit8_section->s_size = 0;
233 lit8_section->s_scnptr = scnptr;
234 }
235 if (lit4_section != NULL)
236 {
237 lit4_section->s_vaddr = vaddr;
238 lit4_section->s_paddr = vaddr;
239 lit4_section->s_size = 0;
240 lit4_section->s_scnptr = scnptr;
241 }
242 if (sdata_section != NULL)
243 {
244 sdata_section->s_vaddr = vaddr;
245 sdata_section->s_paddr = vaddr;
246 sdata_section->s_size = 0;
247 sdata_section->s_scnptr = scnptr;
248 }
249 if (sbss_section != NULL)
250 {
251 sbss_section->s_vaddr = vaddr;
252 sbss_section->s_paddr = vaddr;
253 sbss_section->s_size = 0;
254 sbss_section->s_scnptr = scnptr;
255 }
256 if (bss_section != NULL)
257 {
258 bss_section->s_vaddr = vaddr;
259 bss_section->s_paddr = vaddr;
260 bss_section->s_size = 0;
261 bss_section->s_scnptr = scnptr;
262 }
263
264 WRITE (new, (char *)TEXT_START, hdr.aout.tsize,
265 "writing text section to %s", new_name);
266 WRITE (new, (char *)DATA_START, hdr.aout.dsize,
267 "writing data section to %s", new_name);
268
269 SEEK (old, hdr.fhdr.f_symptr, "seeking to start of symbols in %s", a_name);
270 errno = EEOF;
271 nread = read (old, buffer, BUFSIZE);
272 if (nread < sizeof (HDRR)) fatal_unexec ("reading symbols from %s", a_name);
273 newsyms = hdr.aout.tsize + hdr.aout.dsize;
274 symrel = newsyms - hdr.fhdr.f_symptr;
275 hdr.fhdr.f_symptr = newsyms;
276#define symhdr ((pHDRR)buffer)
277#ifdef MACH
278 for (i = 0; i < 11; i++)
279 symhdr->offsets[i].offset += symrel;
280#else
281 symhdr->cbLineOffset += symrel;
282 symhdr->cbDnOffset += symrel;
283 symhdr->cbPdOffset += symrel;
284 symhdr->cbSymOffset += symrel;
285 symhdr->cbOptOffset += symrel;
286 symhdr->cbAuxOffset += symrel;
287 symhdr->cbSsOffset += symrel;
288 symhdr->cbSsExtOffset += symrel;
289 symhdr->cbFdOffset += symrel;
290 symhdr->cbRfdOffset += symrel;
291 symhdr->cbExtOffset += symrel;
292#endif
293#undef symhdr
294 do
295 {
296 if (write (new, buffer, nread) != nread)
297 fatal_unexec ("writing symbols to %s", new_name);
298 nread = read (old, buffer, BUFSIZE);
299 if (nread < 0) fatal_unexec ("reading symbols from %s", a_name);
300#undef BUFSIZE
301 } while (nread != 0);
302
303 SEEK (new, 0, "seeking to start of header in %s", new_name);
304 WRITE (new, &hdr, sizeof (hdr),
305 "writing header of %s", new_name);
306
307 close (old);
308 close (new);
309 mark_x (new_name);
310}
311
312/*
313 * mark_x
314 *
315 * After successfully building the new a.out, mark it executable
316 */
317
318static void
319mark_x (name)
320 char *name;
321{
322 struct stat sbuf;
323 int um = umask (777);
324 umask (um);
325 if (stat (name, &sbuf) < 0)
326 fatal_unexec ("getting protection on %s", name);
327 sbuf.st_mode |= 0111 & ~um;
328 if (chmod (name, sbuf.st_mode) < 0)
329 fatal_unexec ("setting protection on %s", name);
330}
331
332static void
333fatal_unexec (s, va_alist)
334 va_dcl
335{
336 va_list ap;
337 if (errno == EEOF)
338 fputs ("unexec: unexpected end of file, ", stderr);
339 else
340 fprintf (stderr, "unexec: %s, ", strerror (errno));
341 va_start (ap);
342 _doprnt (s, ap, stderr);
343 fputs (".\n", stderr);
344 exit (1);
345}
346
347/* arch-tag: ebdd2058-3bbc-4de4-b5c7-5760379ab153
348 (do not change this comment) */