Mercurial > emacs
annotate src/unexmips.c @ 1720:4f5e3ac5d822
* frame.h (struct frame): New fields `can_have_scrollbars' and
`has_vertical_scrollbars'.
(FRAME_CAN_HAVE_SCROLLBARS, FRAME_HAS_VERTICAL_SCROLLBARS): New
accessors, for both the MULTI_FRAME and non-MULTI_FRAME.
(VERTICAL_SCROLLBAR_WIDTH, WINDOW_VERTICAL_SCROLLBAR,
WINDOW_VERTICAL_SCROLLBAR_COLUMN,
WINDOW_VERTICAL_SCROLLBAR_HEIGHT): New macros.
* window.h (struct window): New field `vertical_scrollbar'.
* xterm.h (struct x_display): vertical_scrollbars,
judge_timestamp, vertical_scrollbar_extra: New fields.
(struct scrollbar): New struct.
(VERTICAL_SCROLLBAR_PIXEL_WIDTH, VERTICAL_SCROLLBAR_PIXEL_HEIGHT,
VERTICAL_SCROLLBAR_LEFT_BORDER, VERTICAL_SCROLLBAR_RIGHT_BORDER,
VERTICAL_SCROLLBAR_TOP_BORDER, VERTICAL_SCROLLBAR_BOTTOM_BORDER,
CHAR_TO_PIXEL_WIDTH, CHAR_TO_PIXEL_HEIGHT, PIXEL_TO_CHAR_WIDTH,
PIXEL_TO_CHAR_HEIGHT): New accessors and macros.
* frame.c (make_frame): Initialize the `can_have_scrollbars' and
`has_vertical_scrollbars' fields of the frame.
* term.c (term_init): Note that TERMCAP terminals don't support
scrollbars.
(mouse_position_hook): Document new args.
(set_vertical_scrollbar_hook, condemn_scrollbars_hook,
redeem_scrollbar_hook, judge_scrollbars_hook): New hooks.
* termhooks.h: Declare and document them.
(enum scrollbar_part): New type.
(struct input_event): Describe the new form of the scrollbar_click
event type. Change `part' from a Lisp_Object to an enum
scrollbar_part. Add a new field `scrollbar'.
* keyboard.c (kbd_buffer_get_event): Pass appropriate new
parameters to *mouse_position_hook, and make_lispy_movement.
* xfns.c (x_set_vertical_scrollbar): New function.
(x_figure_window_size): Use new macros to calculate frame size.
(Fx_create_frame): Note that X Windows frames do support scroll
bars. Default to "yes".
* xterm.c: #include <X11/cursorfont.h> and "window.h".
(x_vertical_scrollbar_cursor): New variable.
(x_term_init): Initialize it.
(last_mouse_bar, last_mouse_bar_frame, last_mouse_part,
last_mouse_scroll_range_start, last_mouse_scroll_range_end): New
variables.
(XTmouse_position): Use them to return scrollbar movement events.
Take new arguments, for that purpose.
(x_window_to_scrollbar, x_scrollbar_create,
x_scrollbar_set_handle, x_scrollbar_remove, x_scrollbar_move,
XTset_scrollbar, XTcondemn_scrollbars, XTredeem_scrollbar,
XTjudge_scrollbars, x_scrollbar_expose,
x_scrollbar_background_expose, x_scrollbar_handle_click,
x_scrollbar_handle_motion): New functions to implement scrollbars.
(x_term_init): Set the termhooks.h hooks to point to them.
(x_set_window_size): Use new macros to calculate frame size. Set
vertical_scrollbar_extra field.
(x_make_frame_visible): Use the frame accessor
FRAME_HAS_VERTICAL_SCROLLBARS to decide if we need to map the
frame's subwindows as well.
(XTread_socket): Use new size-calculation macros from xterm.h when
processing ConfigureNotify events.
(x_wm_set_size_hint): Use PIXEL_TO_CHAR_WIDTH and
PIXEL_TO_CHAR_HEIGHT macros.
* ymakefile (xdisp.o): This now depends on termhooks.h.
(xterm.o): This now depends on window.h.
* xterm.h (struct x_display): Delete v_scrollbar, v_thumbup,
v_thumbdown, v_slider, h_scrollbar, h_thumbup,
h_thumbdown, h_slider, v_scrollbar_width, h_scrollbar_height
fields.
* keyboard.c (Qvscrollbar_part, Qvslider_part, Qvthumbup_part,
Qvthumbdown_part, Qhscrollbar_part, Qhslider_part, Qhthumbup_part,
Qhthumbdown_part, Qscrollbar_click): Deleted; part of an obsolete
interface.
(head_table): Removed from here as well.
(syms_of_keyboard): And here.
* keyboard.h: And here.
(POSN_SCROLLBAR_BUTTON): Removed.
* xscrollbar.h: File removed - no longer necessary.
* xfns.c: Don't #include it any more.
(Qhorizontal_scroll_bar, Qvertical_scroll_bar): Deleted.
(syms_of_xfns): Don't initialize or staticpro them.
(gray_bits): Salvaged from xscrollbar.h.
(x_window_to_scrollbar): Deleted.
(x_set_horizontal_scrollbar): Deleted.
(enum x_frame_parm, x_frame_parms): Remove references to
x_set_horizontal_scrollbar.
(x_set_foreground_color, x_set_background_color,
x_set_border_pixel): Remove special code to support scrollbars.
(Fx_create_frame): Remove old scrollbar setup code.
(install_vertical_scrollbar, install_horizontal_scrollbar,
adjust_scrollbars, x_resize_scrollbars): Deleted.
* xterm.c (construct_mouse_click): This doesn't need to take care of
scrollbar clicks anymore.
(XTread_socket): Remove old code to support scrollbars. Call new
functions instead for events which occur in scrollbar windows.
(XTupdate_end): Remove call to adjust_scrollbars; the main
redisplay code takes care of that now.
(enum window_type): Deleted.
* ymakefile: Note that xfns.o no longer depends on xscrollbar.h.
* xterm.c (x_set_mouse_position): Clip mouse position to be within
frame.
* xterm.c: Adjust the first line of each page to have a reasonable
description. This makes pages-directory more useful.
* xterm.c (x_do_pending_expose): Declare this routine only if
HAVE_X11 is not #defined; X11 doesn't need it.
(XTread_socket): Protect call to x_do_pending_expose with `#ifdef
HAVE_X11'.
* xterm.c (notice_mouse_movement): Deleted; obsolete and unused.
Properly handle focus shift events, so the cursor is filled and
hollow at the appropriate times, even in titleless windows.
* xterm.c (x_focus_event_frame): New variable.
(XTread_socket): When we receive a FocusIn event that's not
NotifyPointer, record the frame in x_focus_event_frame. When we
receive a FocusOut event that's not NotifyPointer, clear it. When
we get a LeaveNotify event, don't take it seriously if we still
have focus.
* xterm.c (XTread_socket): Remove special code in EnterNotify case
to handle scrollbars and fake mouse motion events.
Change the meaning of focus redirection to make switching windows
work properly. Fredirect_frame_focus has the details.
* frame.h (focus_frame): Doc fix.
[not MULTI_FRAME] (FRAME_FOCUS_FRAME): Make this Qnil, which
indicates no focus redirection, instead of zero, which is
selected_frame.
* frame.c (make_frame): Initialize f->focus_frame to Qnil, rather
than making it point to frame itself.
(Fselect_frame): If changing the selected frame from FOO to BAR,
make all redirections to FOO shift to BAR as well. Doc fix.
(Fredirect_frame_focus): Doc fix. Accept nil as a valid
redirection, not just as a default for FRAME.
(Fframe_focus): Doc fix.
* keyboard.c (kbd_buffer_store_event, kbd_buffer_get_event): Deal
with focus redirections being nil.
* xterm.c (XTframe_rehighlight): Doc fix. Deal with focus
redirections being nil.
* xterm.c (x_error_quitter): Just abort, so we can look at the
core to see what happened.
It's a pain to remember that you can't assign to FRAME->visible.
Let's change all references to the `visible' member of struct
frame to use the accessor macros, and then write a setter for the
`visible' field that does the right thing.
* frame.h (FRAME_VISIBLE_P): Make this not an l-value.
(FRAME_SET_VISIBLE): New macro.
* frame.c (make_terminal_frame, Fdelete_frame): Use FRAME_SET_VISIBLE.
(Fframe_visible_p, Fvisible_frame_list): Use FRAME_VISIBLE_P and
FRAME_ICONIFIED_P.
* dispnew.c (Fredraw_display): Use the FRAME_VISIBLE_P and
FRAME_GARBAGED_P accessors.
* xdisp.c (redisplay): Use the FRAME_VISIBLE_P accessor.
* xfns.c (x_set_foreground_color, x_set_background_color,
x_set_cursor_color, x_set_border_pixel, x_set_icon_type): Use the
FRAME_VISIBLE_P accessor.
(Fx_create_frame): Use FRAME_SET_VISIBILITY.
* xterm.c (clear_cursor, x_display_bar_cursor,
x_display_box_cursor): Use FRAME_SET_VISIBILITY.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Thu, 24 Dec 1992 06:21:14 +0000 |
parents | 1a12c5f1c04d |
children | 507f64624555 |
rev | line source |
---|---|
486 | 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 Free Software Foundation, Inc. | |
10 | |
11 This file is part of GNU Emacs. | |
12 | |
13 GNU Emacs is free software; you can redistribute it and/or modify | |
14 it under the terms of the GNU General Public License as published by | |
15 the Free Software Foundation; either version 1, or (at your option) | |
16 any later version. | |
17 | |
18 GNU Emacs is distributed in the hope that it will be useful, | |
19 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 GNU General Public License for more details. | |
22 | |
23 You should have received a copy of the GNU General Public License | |
24 along with GNU Emacs; see the file COPYING. If not, write to | |
25 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
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 #include <filehdr.h> | |
35 #include <aouthdr.h> | |
36 #include <scnhdr.h> | |
37 #include <sym.h> | |
38 | |
1486
1a12c5f1c04d
[sony, IRIS_4D]: Include getpagesize.h and fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
1122
diff
changeset
|
39 #if defined (IRIS_4D) || defined (sony) |
486 | 40 #include "getpagesize.h" |
1486
1a12c5f1c04d
[sony, IRIS_4D]: Include getpagesize.h and fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
1122
diff
changeset
|
41 #include <fcntl.h> |
486 | 42 #endif |
43 | |
44 static void fatal_unexec (); | |
1122
42922d56e5a6
* unexmips.c (mark_x): Declare this as static void at the top of
Jim Blandy <jimb@redhat.com>
parents:
1094
diff
changeset
|
45 static void mark_x (); |
486 | 46 |
47 #define READ(_fd, _buffer, _size, _error_message, _error_arg) \ | |
48 errno = EEOF; \ | |
49 if (read (_fd, _buffer, _size) != _size) \ | |
50 fatal_unexec (_error_message, _error_arg); | |
51 | |
52 #define WRITE(_fd, _buffer, _size, _error_message, _error_arg) \ | |
53 if (write (_fd, _buffer, _size) != _size) \ | |
54 fatal_unexec (_error_message, _error_arg); | |
55 | |
56 #define SEEK(_fd, _position, _error_message, _error_arg) \ | |
57 errno = EEOF; \ | |
58 if (lseek (_fd, _position, L_SET) != _position) \ | |
59 fatal_unexec (_error_message, _error_arg); | |
60 | |
61 extern int errno; | |
62 extern int sys_nerr; | |
63 extern char *sys_errlist[]; | |
64 #define EEOF -1 | |
65 | |
66 static struct scnhdr *text_section; | |
67 static struct scnhdr *init_section; | |
68 static struct scnhdr *finit_section; | |
69 static struct scnhdr *rdata_section; | |
70 static struct scnhdr *data_section; | |
71 static struct scnhdr *lit8_section; | |
72 static struct scnhdr *lit4_section; | |
73 static struct scnhdr *sdata_section; | |
74 static struct scnhdr *sbss_section; | |
75 static struct scnhdr *bss_section; | |
76 | |
77 struct headers { | |
78 struct filehdr fhdr; | |
79 struct aouthdr aout; | |
80 struct scnhdr section[10]; | |
81 }; | |
82 | |
83 /* Define name of label for entry point for the dumped executable. */ | |
84 | |
85 #ifndef DEFAULT_ENTRY_ADDRESS | |
86 #define DEFAULT_ENTRY_ADDRESS __start | |
87 #endif | |
88 | |
89 unexec (new_name, a_name, data_start, bss_start, entry_address) | |
90 char *new_name, *a_name; | |
91 unsigned data_start, bss_start, entry_address; | |
92 { | |
93 int new, old; | |
94 int pagesize, brk; | |
95 int newsyms, symrel; | |
96 int nread; | |
97 struct headers hdr; | |
98 int i; | |
99 int vaddr, scnptr; | |
100 #define BUFSIZE 8192 | |
101 char buffer[BUFSIZE]; | |
102 | |
103 old = open (a_name, O_RDONLY, 0); | |
104 if (old < 0) fatal_unexec ("opening %s", a_name); | |
105 | |
106 new = creat (new_name, 0666); | |
107 if (new < 0) fatal_unexec ("creating %s", new_name); | |
108 | |
109 hdr = *((struct headers *)TEXT_START); | |
110 #ifdef MIPS2 | |
111 if (hdr.fhdr.f_magic != MIPSELMAGIC | |
112 && hdr.fhdr.f_magic != MIPSEBMAGIC | |
113 && hdr.fhdr.f_magic != (MIPSELMAGIC | 1) | |
114 && hdr.fhdr.f_magic != (MIPSEBMAGIC | 1)) | |
115 { | |
1486
1a12c5f1c04d
[sony, IRIS_4D]: Include getpagesize.h and fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
1122
diff
changeset
|
116 fprintf (stderr, |
1a12c5f1c04d
[sony, IRIS_4D]: Include getpagesize.h and fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
1122
diff
changeset
|
117 "unexec: input file magic number is %x, not %x, %x, %x or %x.\n", |
1a12c5f1c04d
[sony, IRIS_4D]: Include getpagesize.h and fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
1122
diff
changeset
|
118 hdr.fhdr.f_magic, |
1a12c5f1c04d
[sony, IRIS_4D]: Include getpagesize.h and fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
1122
diff
changeset
|
119 MIPSELMAGIC, MIPSEBMAGIC, |
1a12c5f1c04d
[sony, IRIS_4D]: Include getpagesize.h and fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
1122
diff
changeset
|
120 MIPSELMAGIC | 1, MIPSEBMAGIC | 1); |
486 | 121 exit(1); |
122 } | |
123 #else /* not MIPS2 */ | |
124 if (hdr.fhdr.f_magic != MIPSELMAGIC | |
125 && hdr.fhdr.f_magic != MIPSEBMAGIC) | |
126 { | |
127 fprintf (stderr, "unexec: input file magic number is %x, not %x or %x.\n", | |
128 hdr.fhdr.f_magic, MIPSELMAGIC, MIPSEBMAGIC); | |
129 exit (1); | |
130 } | |
131 #endif /* not MIPS2 */ | |
132 if (hdr.fhdr.f_opthdr != sizeof (hdr.aout)) | |
133 { | |
134 fprintf (stderr, "unexec: input a.out header is %d bytes, not %d.\n", | |
135 hdr.fhdr.f_opthdr, sizeof (hdr.aout)); | |
136 exit (1); | |
137 } | |
138 if (hdr.aout.magic != ZMAGIC) | |
139 { | |
140 fprintf (stderr, "unexec: input file a.out magic number is %o, not %o.\n", | |
141 hdr.aout.magic, ZMAGIC); | |
142 exit (1); | |
143 } | |
144 | |
145 #define CHECK_SCNHDR(ptr, name, flags) \ | |
1094
861c2997afee
(unexec): Allow sections in any order.
Richard M. Stallman <rms@gnu.org>
parents:
568
diff
changeset
|
146 ptr = NULL; \ |
861c2997afee
(unexec): Allow sections in any order.
Richard M. Stallman <rms@gnu.org>
parents:
568
diff
changeset
|
147 for (i = 0; i < hdr.fhdr.f_nscns && !ptr; i++) \ |
861c2997afee
(unexec): Allow sections in any order.
Richard M. Stallman <rms@gnu.org>
parents:
568
diff
changeset
|
148 if (strcmp (hdr.section[i].s_name, name) == 0) \ |
861c2997afee
(unexec): Allow sections in any order.
Richard M. Stallman <rms@gnu.org>
parents:
568
diff
changeset
|
149 { \ |
861c2997afee
(unexec): Allow sections in any order.
Richard M. Stallman <rms@gnu.org>
parents:
568
diff
changeset
|
150 if (hdr.section[i].s_flags != flags) \ |
861c2997afee
(unexec): Allow sections in any order.
Richard M. Stallman <rms@gnu.org>
parents:
568
diff
changeset
|
151 fprintf (stderr, "unexec: %x flags (%x expected) in %s section.\n", \ |
861c2997afee
(unexec): Allow sections in any order.
Richard M. Stallman <rms@gnu.org>
parents:
568
diff
changeset
|
152 hdr.section[i].s_flags, flags, name); \ |
861c2997afee
(unexec): Allow sections in any order.
Richard M. Stallman <rms@gnu.org>
parents:
568
diff
changeset
|
153 ptr = hdr.section + i; \ |
861c2997afee
(unexec): Allow sections in any order.
Richard M. Stallman <rms@gnu.org>
parents:
568
diff
changeset
|
154 } \ |
486 | 155 |
156 CHECK_SCNHDR (text_section, _TEXT, STYP_TEXT); | |
157 CHECK_SCNHDR (init_section, _INIT, STYP_INIT); | |
158 CHECK_SCNHDR (rdata_section, _RDATA, STYP_RDATA); | |
159 CHECK_SCNHDR (data_section, _DATA, STYP_DATA); | |
160 #ifdef _LIT8 | |
161 CHECK_SCNHDR (lit8_section, _LIT8, STYP_LIT8); | |
162 CHECK_SCNHDR (lit4_section, _LIT4, STYP_LIT4); | |
163 #endif /* _LIT8 */ | |
164 CHECK_SCNHDR (sdata_section, _SDATA, STYP_SDATA); | |
165 CHECK_SCNHDR (sbss_section, _SBSS, STYP_SBSS); | |
166 CHECK_SCNHDR (bss_section, _BSS, STYP_BSS); | |
1486
1a12c5f1c04d
[sony, IRIS_4D]: Include getpagesize.h and fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
1122
diff
changeset
|
167 #if 0 /* Apparently this error check goes off on irix 3.3, |
1a12c5f1c04d
[sony, IRIS_4D]: Include getpagesize.h and fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
1122
diff
changeset
|
168 but it doesn't indicate a real problem. */ |
486 | 169 if (i != hdr.fhdr.f_nscns) |
170 fprintf (stderr, "unexec: %d sections found instead of %d.\n", | |
171 i, hdr.fhdr.f_nscns); | |
1486
1a12c5f1c04d
[sony, IRIS_4D]: Include getpagesize.h and fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
1122
diff
changeset
|
172 #endif |
1a12c5f1c04d
[sony, IRIS_4D]: Include getpagesize.h and fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
1122
diff
changeset
|
173 |
1a12c5f1c04d
[sony, IRIS_4D]: Include getpagesize.h and fcntl.h.
Richard M. Stallman <rms@gnu.org>
parents:
1122
diff
changeset
|
174 text_section->s_scnptr = 0; |
486 | 175 |
176 pagesize = getpagesize (); | |
177 brk = (sbrk (0) + pagesize - 1) & (-pagesize); | |
178 hdr.aout.dsize = brk - DATA_START; | |
179 hdr.aout.bsize = 0; | |
180 if (entry_address == 0) | |
181 { | |
182 extern DEFAULT_ENTRY_ADDRESS (); | |
183 hdr.aout.entry = (unsigned)DEFAULT_ENTRY_ADDRESS; | |
184 } | |
185 else | |
186 hdr.aout.entry = entry_address; | |
187 | |
188 hdr.aout.bss_start = hdr.aout.data_start + hdr.aout.dsize; | |
189 rdata_section->s_size = data_start - DATA_START; | |
1094
861c2997afee
(unexec): Allow sections in any order.
Richard M. Stallman <rms@gnu.org>
parents:
568
diff
changeset
|
190 |
861c2997afee
(unexec): Allow sections in any order.
Richard M. Stallman <rms@gnu.org>
parents:
568
diff
changeset
|
191 /* Adjust start and virtual addresses of rdata_section, too. */ |
861c2997afee
(unexec): Allow sections in any order.
Richard M. Stallman <rms@gnu.org>
parents:
568
diff
changeset
|
192 rdata_section->s_vaddr = DATA_START; |
861c2997afee
(unexec): Allow sections in any order.
Richard M. Stallman <rms@gnu.org>
parents:
568
diff
changeset
|
193 rdata_section->s_paddr = DATA_START; |
861c2997afee
(unexec): Allow sections in any order.
Richard M. Stallman <rms@gnu.org>
parents:
568
diff
changeset
|
194 rdata_section->s_scnptr = text_section->s_scnptr + hdr.aout.tsize; |
861c2997afee
(unexec): Allow sections in any order.
Richard M. Stallman <rms@gnu.org>
parents:
568
diff
changeset
|
195 |
486 | 196 data_section->s_vaddr = data_start; |
197 data_section->s_paddr = data_start; | |
568 | 198 data_section->s_size = brk - data_start; |
486 | 199 data_section->s_scnptr = rdata_section->s_scnptr + rdata_section->s_size; |
200 vaddr = data_section->s_vaddr + data_section->s_size; | |
201 scnptr = data_section->s_scnptr + data_section->s_size; | |
202 if (lit8_section != NULL) | |
203 { | |
204 lit8_section->s_vaddr = vaddr; | |
205 lit8_section->s_paddr = vaddr; | |
206 lit8_section->s_size = 0; | |
207 lit8_section->s_scnptr = scnptr; | |
208 } | |
209 if (lit4_section != NULL) | |
210 { | |
211 lit4_section->s_vaddr = vaddr; | |
212 lit4_section->s_paddr = vaddr; | |
213 lit4_section->s_size = 0; | |
214 lit4_section->s_scnptr = scnptr; | |
215 } | |
216 if (sdata_section != NULL) | |
217 { | |
218 sdata_section->s_vaddr = vaddr; | |
219 sdata_section->s_paddr = vaddr; | |
220 sdata_section->s_size = 0; | |
221 sdata_section->s_scnptr = scnptr; | |
222 } | |
223 if (sbss_section != NULL) | |
224 { | |
225 sbss_section->s_vaddr = vaddr; | |
226 sbss_section->s_paddr = vaddr; | |
227 sbss_section->s_size = 0; | |
228 sbss_section->s_scnptr = scnptr; | |
229 } | |
230 if (bss_section != NULL) | |
231 { | |
232 bss_section->s_vaddr = vaddr; | |
233 bss_section->s_paddr = vaddr; | |
234 bss_section->s_size = 0; | |
235 bss_section->s_scnptr = scnptr; | |
236 } | |
237 | |
238 WRITE (new, TEXT_START, hdr.aout.tsize, | |
239 "writing text section to %s", new_name); | |
240 WRITE (new, DATA_START, hdr.aout.dsize, | |
241 "writing text section to %s", new_name); | |
242 | |
243 SEEK (old, hdr.fhdr.f_symptr, "seeking to start of symbols in %s", a_name); | |
244 errno = EEOF; | |
245 nread = read (old, buffer, BUFSIZE); | |
246 if (nread < sizeof (HDRR)) fatal_unexec ("reading symbols from %s", a_name); | |
247 #define symhdr ((pHDRR)buffer) | |
248 newsyms = hdr.aout.tsize + hdr.aout.dsize; | |
249 symrel = newsyms - hdr.fhdr.f_symptr; | |
250 hdr.fhdr.f_symptr = newsyms; | |
251 symhdr->cbLineOffset += symrel; | |
252 symhdr->cbDnOffset += symrel; | |
253 symhdr->cbPdOffset += symrel; | |
254 symhdr->cbSymOffset += symrel; | |
255 symhdr->cbOptOffset += symrel; | |
256 symhdr->cbAuxOffset += symrel; | |
257 symhdr->cbSsOffset += symrel; | |
258 symhdr->cbSsExtOffset += symrel; | |
259 symhdr->cbFdOffset += symrel; | |
260 symhdr->cbRfdOffset += symrel; | |
261 symhdr->cbExtOffset += symrel; | |
262 #undef symhdr | |
263 do | |
264 { | |
265 if (write (new, buffer, nread) != nread) | |
266 fatal_unexec ("writing symbols to %s", new_name); | |
267 nread = read (old, buffer, BUFSIZE); | |
268 if (nread < 0) fatal_unexec ("reading symbols from %s", a_name); | |
269 #undef BUFSIZE | |
270 } while (nread != 0); | |
271 | |
272 SEEK (new, 0, "seeking to start of header in %s", new_name); | |
273 WRITE (new, &hdr, sizeof (hdr), | |
274 "writing header of %s", new_name); | |
275 | |
276 close (old); | |
277 close (new); | |
278 mark_x (new_name); | |
279 } | |
280 | |
281 /* | |
282 * mark_x | |
283 * | |
284 * After succesfully building the new a.out, mark it executable | |
285 */ | |
286 | |
1122
42922d56e5a6
* unexmips.c (mark_x): Declare this as static void at the top of
Jim Blandy <jimb@redhat.com>
parents:
1094
diff
changeset
|
287 static void |
486 | 288 mark_x (name) |
289 char *name; | |
290 { | |
291 struct stat sbuf; | |
292 int um = umask (777); | |
293 umask (um); | |
294 if (stat (name, &sbuf) < 0) | |
295 fatal_unexec ("getting protection on %s", name); | |
296 sbuf.st_mode |= 0111 & ~um; | |
297 if (chmod (name, sbuf.st_mode) < 0) | |
298 fatal_unexec ("setting protection on %s", name); | |
299 } | |
300 | |
301 static void | |
302 fatal_unexec (s, va_alist) | |
303 va_dcl | |
304 { | |
305 va_list ap; | |
306 if (errno == EEOF) | |
307 fputs ("unexec: unexpected end of file, ", stderr); | |
308 else if (errno < sys_nerr) | |
309 fprintf (stderr, "unexec: %s, ", sys_errlist[errno]); | |
310 else | |
311 fprintf (stderr, "unexec: error code %d, ", errno); | |
312 va_start (ap); | |
313 _doprnt (s, ap, stderr); | |
314 fputs (".\n", stderr); | |
315 exit (1); | |
316 } |