* i386-xdep.c, symm-xdep.c: Remove most 387 support.
[deliverable/binutils-gdb.git] / gdb / tm-convex.h
1 /* Definitions to make GDB run on Convex Unix (4bsd)
2 Copyright (C) 1989 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 #define TARGET_BYTE_ORDER BIG_ENDIAN
21
22 /* I don't know if this will work for cross-debugging, even if you do get
23 the right files. */
24 /* Include certain files for dbxread.c */
25 #include <convex/filehdr.h>
26 #include <convex/opthdr.h>
27 #include <convex/scnhdr.h>
28 #include <nlist.h>
29
30 /* Define this if the C compiler puts an underscore at the front
31 of external names before giving them to the linker. */
32
33 #define NAMES_HAVE_UNDERSCORE
34
35 /* Debugger information will be in DBX format. */
36
37 #define READ_DBX_FORMAT
38
39 /* There is come problem with the debugging symbols generated by the
40 compiler such that the debugging symbol for the first line of a
41 function overlap with the function prologue. */
42 #define PROLOGUE_FIRSTLINE_OVERLAP
43
44 /* When convex pcc says CHAR or SHORT, it provides the correct address. */
45
46 #define BELIEVE_PCC_PROMOTION 1
47
48 /* Symbol types to ignore. */
49 /* 0xc4 is N_MONPT. Use the numeric value for the benefit of people
50 with (rather) old OS's. */
51 #define IGNORE_SYMBOL(TYPE) \
52 (((TYPE) & ~N_EXT) == N_TBSS \
53 || ((TYPE) & ~N_EXT) == N_TDATA \
54 || ((TYPE) & ~N_EXT) == 0xc4)
55
56 /* Offset from address of function to start of its code.
57 Zero on most machines. */
58
59 #define FUNCTION_START_OFFSET 0
60
61 /* Advance PC across any function entry prologue instructions
62 to reach some "real" code.
63 Convex prolog is:
64 [sub.w #-,sp] in one of 3 possible sizes
65 [mov psw,- fc/vc main program prolog
66 and #-,- (skip it because the "mov psw" saves the
67 mov -,psw] T bit, so continue gets a surprise trap)
68 [and #-,sp] fc/vc O2 main program prolog
69 [ld.- -(ap),-] pcc/gcc register arg loads
70 */
71
72 #define SKIP_PROLOGUE(pc) \
73 { int op, ix; \
74 op = read_memory_integer (pc, 2); \
75 if ((op & 0xffc7) == 0x5ac0) pc += 2; \
76 else if (op == 0x1580) pc += 4; \
77 else if (op == 0x15c0) pc += 6; \
78 if ((read_memory_integer (pc, 2) & 0xfff8) == 0x7c40 \
79 && (read_memory_integer (pc + 2, 2) & 0xfff8) == 0x1240 \
80 && (read_memory_integer (pc + 8, 2) & 0xfff8) == 0x7c48) \
81 pc += 10; \
82 if (read_memory_integer (pc, 2) == 0x1240) pc += 6; \
83 for (;;) { \
84 op = read_memory_integer (pc, 2); \
85 ix = (op >> 3) & 7; \
86 if (ix != 6) break; \
87 if ((op & 0xfcc0) == 0x3000) pc += 4; \
88 else if ((op & 0xfcc0) == 0x3040) pc += 6; \
89 else if ((op & 0xfcc0) == 0x2800) pc += 4; \
90 else if ((op & 0xfcc0) == 0x2840) pc += 6; \
91 else break;}}
92
93 /* Immediately after a function call, return the saved pc.
94 (ignore frame and return *$sp so we can handle both calls and callq) */
95
96 #define SAVED_PC_AFTER_CALL(frame) \
97 read_memory_integer (read_register (SP_REGNUM), 4)
98
99 /* Address of end of stack space.
100 This is ((USRSTACK + 0xfff) & -0x1000)) from <convex/vmparam.h> but
101 that expression depends on the kernel version; instead, fetch a
102 page-zero pointer and get it from that. This will be invalid if
103 they ever change the way bkpt signals are delivered. */
104
105 #define STACK_END_ADDR (0xfffff000 & *(unsigned *) 0x80000050)
106
107 /* User-mode traps push an extended rtn block,
108 then fault with one of the following PCs */
109
110 #define is_trace_pc(pc) ((unsigned) ((pc) - (*(int *) 0x80000040)) <= 4)
111 #define is_arith_pc(pc) ((unsigned) ((pc) - (*(int *) 0x80000044)) <= 4)
112 #define is_break_pc(pc) ((unsigned) ((pc) - (*(int *) 0x80000050)) <= 4)
113
114 /* We need to manipulate trap bits in the psw */
115
116 #define PSW_TRAP_FLAGS 0x69670000
117 #define PSW_T_BIT 0x08000000
118 #define PSW_S_BIT 0x01000000
119
120 /* Stack grows downward. */
121
122 #define INNER_THAN <
123
124 /* Sequence of bytes for breakpoint instruction. (bkpt) */
125
126 #define BREAKPOINT {0x7d,0x50}
127
128 /* Amount PC must be decremented by after a breakpoint.
129 This is often the number of bytes in BREAKPOINT but not always.
130 (The break PC needs to be decremented by 2, but we do it when the
131 break frame is recognized and popped. That way gdb can tell breaks
132 from trace traps with certainty.) */
133
134 #define DECR_PC_AFTER_BREAK 0
135
136 /* Nonzero if instruction at PC is a return instruction. (rtn or rtnq) */
137
138 #define ABOUT_TO_RETURN(pc) \
139 ((read_memory_integer (pc, 2) & 0xffe0) == 0x7c80)
140
141 /* Return 1 if P points to an invalid floating point value. */
142
143 #define INVALID_FLOAT(p,len) 0
144
145 /* Say how long (ordinary) registers are. */
146
147 #define REGISTER_TYPE long long
148
149 /* Number of machine registers */
150
151 #define NUM_REGS 26
152
153 /* Initializer for an array of names of registers.
154 There should be NUM_REGS strings in this initializer. */
155
156 #define REGISTER_NAMES {"pc","psw","fp","ap","a5","a4","a3","a2","a1","sp",\
157 "s7","s6","s5","s4","s3","s2","s1","s0",\
158 "S7","S6","S5","S4","S3","S2","S1","S0"}
159
160 /* Register numbers of various important registers.
161 Note that some of these values are "real" register numbers,
162 and correspond to the general registers of the machine,
163 and some are "phony" register numbers which are too large
164 to be actual register numbers as far as the user is concerned
165 but do serve to get the desired values when passed to read_register. */
166
167 #define S0_REGNUM 25 /* the real S regs */
168 #define S7_REGNUM 18
169 #define s0_REGNUM 17 /* low-order halves of S regs */
170 #define s7_REGNUM 10
171 #define SP_REGNUM 9 /* A regs */
172 #define A1_REGNUM 8
173 #define A5_REGNUM 4
174 #define AP_REGNUM 3
175 #define FP_REGNUM 2 /* Contains address of executing stack frame */
176 #define PS_REGNUM 1 /* Contains processor status */
177 #define PC_REGNUM 0 /* Contains program counter */
178
179 /* convert dbx stab register number (from `r' declaration) to a gdb REGNUM */
180
181 #define STAB_REG_TO_REGNUM(value) \
182 ((value) < 8 ? S0_REGNUM - (value) : SP_REGNUM - ((value) - 8))
183
184 /* Vector register numbers, not handled as ordinary regs.
185 They are treated as convenience variables whose values are read
186 from the inferior when needed. */
187
188 #define V0_REGNUM 0
189 #define V7_REGNUM 7
190 #define VM_REGNUM 8
191 #define VS_REGNUM 9
192 #define VL_REGNUM 10
193
194 /* Total amount of space needed to store our copies of the machine's
195 register state, the array `registers'. */
196 #define REGISTER_BYTES (4*10 + 8*8)
197
198 /* Index within `registers' of the first byte of the space for
199 register N.
200 NB: must match structure of struct syscall_context for correct operation */
201
202 #define REGISTER_BYTE(N) ((N) < s7_REGNUM ? 4*(N) : \
203 (N) < S7_REGNUM ? 44 + 8 * ((N)-s7_REGNUM) : \
204 40 + 8 * ((N)-S7_REGNUM))
205
206 /* Number of bytes of storage in the actual machine representation
207 for register N. */
208
209 #define REGISTER_RAW_SIZE(N) ((N) < S7_REGNUM ? 4 : 8)
210
211 /* Number of bytes of storage in the program's representation
212 for register N. */
213
214 #define REGISTER_VIRTUAL_SIZE(N) REGISTER_RAW_SIZE(N)
215
216 /* Largest value REGISTER_RAW_SIZE can have. */
217
218 #define MAX_REGISTER_RAW_SIZE 8
219
220 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
221
222 #define MAX_REGISTER_VIRTUAL_SIZE 8
223
224 /* Nonzero if register N requires conversion
225 from raw format to virtual format. */
226
227 #define REGISTER_CONVERTIBLE(N) 0
228
229 /* Convert data from raw format for register REGNUM
230 to virtual format for register REGNUM. */
231
232 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
233 bcopy ((FROM), (TO), REGISTER_RAW_SIZE (REGNUM));
234
235 /* Convert data from virtual format for register REGNUM
236 to raw format for register REGNUM. */
237
238 #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
239 bcopy ((FROM), (TO), REGISTER_RAW_SIZE (REGNUM));
240
241 /* Return the GDB type object for the "standard" data type
242 of data in register N. */
243
244 #define REGISTER_VIRTUAL_TYPE(N) \
245 ((N) < S7_REGNUM ? builtin_type_int : builtin_type_long_long)
246
247 /* Store the address of the place in which to copy the structure the
248 subroutine will return. This is called from call_function. */
249
250 #define STORE_STRUCT_RETURN(ADDR, SP) \
251 { write_register (A1_REGNUM, (ADDR)); }
252
253 /* Extract from an array REGBUF containing the (raw) register state
254 a function return value of type TYPE, and copy that, in virtual format,
255 into VALBUF. */
256
257 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
258 bcopy (&((char *) REGBUF) [REGISTER_BYTE (S0_REGNUM) + \
259 8 - TYPE_LENGTH (TYPE)],\
260 VALBUF, TYPE_LENGTH (TYPE))
261
262 /* Write into appropriate registers a function return value
263 of type TYPE, given in virtual format. */
264
265 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
266 write_register_bytes (REGISTER_BYTE (S0_REGNUM), VALBUF, 8)
267
268 /* Extract from an array REGBUF containing the (raw) register state
269 the address in which a function should return its structure value,
270 as a CORE_ADDR (or an expression that can be used as one). */
271
272 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \
273 (*(int *) & ((char *) REGBUF) [REGISTER_BYTE (s0_REGNUM)])
274
275 /* Define trapped internal variable hooks to read and write
276 vector and communication registers. */
277
278 #define IS_TRAPPED_INTERNALVAR is_trapped_internalvar
279 #define VALUE_OF_TRAPPED_INTERNALVAR value_of_trapped_internalvar
280 #define SET_TRAPPED_INTERNALVAR set_trapped_internalvar
281
282 extern struct value *value_of_trapped_internalvar ();
283
284 /* Hooks to read data from soff exec and core files,
285 and to describe the files. */
286
287 #define XFER_CORE_FILE
288 #define FILES_INFO_HOOK print_maps
289
290 /* Hook to call to print a typeless integer value, normally printed in decimal.
291 For convex, use hex instead if the number looks like an address. */
292
293 #define PRINT_TYPELESS_INTEGER decout
294
295 /* For the native compiler, variables for a particular lexical context
296 are listed after the beginning LBRAC instead of before in the
297 executables list of symbols. Using "gcc_compiled." to distinguish
298 between GCC and native compiler doesn't work on Convex because the
299 linker sorts the symbols to put "gcc_compiled." in the wrong place.
300 desc is nonzero for native, zero for gcc. */
301 #define VARIABLES_INSIDE_BLOCK(desc, gcc_p) (desc != 0)
302
303 /* Pcc occaisionally puts an SO where there should be an SOL. */
304 #define PCC_SOL_BROKEN
305 \f
306 /* Describe the pointer in each stack frame to the previous stack frame
307 (its caller). */
308
309 /* FRAME_CHAIN takes a frame_info with a frame's nominal address in fi->frame,
310 and produces the frame's chain-pointer.
311
312 FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
313 and produces the nominal address of the caller frame.
314
315 However, if FRAME_CHAIN_VALID returns zero,
316 it means the given frame is the outermost one and has no caller.
317 In that case, FRAME_CHAIN_COMBINE is not used. */
318
319 /* (caller fp is saved at 8(fp)) */
320
321 #define FRAME_CHAIN(fi) (read_memory_integer ((fi)->frame + 8, 4))
322
323 #define FRAME_CHAIN_VALID(chain, thisframe) \
324 (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe))))
325
326 #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
327
328 /* Define other aspects of the stack frame. */
329
330 /* We need the boundaries of the text in the exec file, as a kludge,
331 for FRAMELESS_FUNCTION_INVOCATION and CALL_DUMMY_LOCATION. */
332
333 #define NEED_TEXT_START_END
334
335 /* A macro that tells us whether the function invocation represented
336 by FI does not have a frame on the stack associated with it. If it
337 does not, FRAMELESS is set to 1, else 0.
338 On convex, check at the return address for `callq' -- if so, frameless,
339 otherwise, not. */
340
341 #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
342 { \
343 extern CORE_ADDR text_start, text_end; \
344 CORE_ADDR call_addr = SAVED_PC_AFTER_CALL (FI); \
345 (FRAMELESS) = (call_addr >= text_start && call_addr < text_end \
346 && read_memory_integer (call_addr - 6, 1) == 0x22); \
347 }
348
349 #define FRAME_SAVED_PC(fi) (read_memory_integer ((fi)->frame, 4))
350
351 #define FRAME_ARGS_ADDRESS(fi) (read_memory_integer ((fi)->frame + 12, 4))
352
353 #define FRAME_LOCALS_ADDRESS(fi) (fi)->frame
354
355 /* Return number of args passed to a frame.
356 Can return -1, meaning no way to tell. */
357
358 #define FRAME_NUM_ARGS(numargs, fi) \
359 { numargs = read_memory_integer (FRAME_ARGS_ADDRESS (fi) - 4, 4); \
360 if (numargs < 0 || numargs >= 256) numargs = -1;}
361
362 /* Return number of bytes at start of arglist that are not really args. */
363
364 #define FRAME_ARGS_SKIP 0
365
366 /* Put here the code to store, into a struct frame_saved_regs,
367 the addresses of the saved registers of frame described by FRAME_INFO.
368 This includes special registers such as pc and fp saved in special
369 ways in the stack frame. sp is even more special:
370 the address we return for it IS the sp for the next frame. */
371
372 /* Normal (short) frames save only PC, FP, (callee's) AP. To reasonably
373 handle gcc and pcc register variables, scan the code following the
374 call for the instructions the compiler inserts to reload register
375 variables from stack slots and record the stack slots as the saved
376 locations of those registers. This will occasionally identify some
377 random load as a saved register; this is harmless. vc does not
378 declare its register allocation actions in the stabs. */
379
380 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
381 { register int regnum; \
382 register int frame_length = /* 3 short, 2 long, 1 extended, 0 context */\
383 (read_memory_integer ((frame_info)->frame + 4, 4) >> 25) & 3; \
384 register CORE_ADDR frame_fp = \
385 read_memory_integer ((frame_info)->frame + 8, 4); \
386 register CORE_ADDR next_addr; \
387 bzero (&frame_saved_regs, sizeof frame_saved_regs); \
388 (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 0; \
389 (frame_saved_regs).regs[PS_REGNUM] = (frame_info)->frame + 4; \
390 (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame + 8; \
391 (frame_saved_regs).regs[AP_REGNUM] = frame_fp + 12; \
392 next_addr = (frame_info)->frame + 12; \
393 if (frame_length < 3) \
394 for (regnum = A5_REGNUM; regnum < SP_REGNUM; ++regnum) \
395 (frame_saved_regs).regs[regnum] = (next_addr += 4); \
396 if (frame_length < 2) \
397 (frame_saved_regs).regs[SP_REGNUM] = (next_addr += 4); \
398 next_addr -= 4; \
399 if (frame_length < 3) \
400 for (regnum = S7_REGNUM; regnum < S0_REGNUM; ++regnum) \
401 (frame_saved_regs).regs[regnum] = (next_addr += 8); \
402 if (frame_length < 2) \
403 (frame_saved_regs).regs[S0_REGNUM] = (next_addr += 8); \
404 else \
405 (frame_saved_regs).regs[SP_REGNUM] = next_addr + 8; \
406 if (frame_length == 3) { \
407 CORE_ADDR pc = read_memory_integer ((frame_info)->frame, 4); \
408 int op, ix, disp; \
409 op = read_memory_integer (pc, 2); \
410 if ((op & 0xffc7) == 0x1480) pc += 4; /* add.w #-,sp */ \
411 else if ((op & 0xffc7) == 0x58c0) pc += 2; /* add.w #-,sp */ \
412 op = read_memory_integer (pc, 2); \
413 if ((op & 0xffc7) == 0x2a06) pc += 4; /* ld.w -,ap */ \
414 for (;;) { \
415 op = read_memory_integer (pc, 2); \
416 ix = (op >> 3) & 7; \
417 if ((op & 0xfcc0) == 0x2800) { /* ld.- -,ak */ \
418 regnum = SP_REGNUM - (op & 7); \
419 disp = read_memory_integer (pc + 2, 2); \
420 pc += 4;} \
421 else if ((op & 0xfcc0) == 0x2840) { /* ld.- -,ak */ \
422 regnum = SP_REGNUM - (op & 7); \
423 disp = read_memory_integer (pc + 2, 4); \
424 pc += 6;} \
425 if ((op & 0xfcc0) == 0x3000) { /* ld.- -,sk */ \
426 regnum = S0_REGNUM - (op & 7); \
427 disp = read_memory_integer (pc + 2, 2); \
428 pc += 4;} \
429 else if ((op & 0xfcc0) == 0x3040) { /* ld.- -,sk */ \
430 regnum = S0_REGNUM - (op & 7); \
431 disp = read_memory_integer (pc + 2, 4); \
432 pc += 6;} \
433 else if ((op & 0xff00) == 0x7100) { /* br crossjump */ \
434 pc += 2 * (char) op; \
435 continue;} \
436 else if (op == 0x0140) { /* jmp crossjump */ \
437 pc = read_memory_integer (pc + 2, 4); \
438 continue;} \
439 else break; \
440 if ((frame_saved_regs).regs[regnum]) \
441 break; \
442 if (ix == 7) disp += frame_fp; \
443 else if (ix == 6) disp += read_memory_integer (frame_fp + 12, 4); \
444 else if (ix != 0) break; \
445 (frame_saved_regs).regs[regnum] = \
446 disp - 8 + (1 << ((op >> 8) & 3)); \
447 if (regnum >= S7_REGNUM) \
448 (frame_saved_regs).regs[regnum - S0_REGNUM + s0_REGNUM] = \
449 disp - 4 + (1 << ((op >> 8) & 3)); \
450 } \
451 } \
452 }
453 \f
454 /* Things needed for making the inferior call functions. */
455
456 #define CALL_DUMMY_LOCATION BEFORE_TEXT_END
457
458 /* Push an empty stack frame, to record the current PC, etc. */
459
460 #define PUSH_DUMMY_FRAME \
461 { register CORE_ADDR sp = read_register (SP_REGNUM); \
462 register int regnum; \
463 char buf[8]; \
464 long word; \
465 for (regnum = S0_REGNUM; regnum >= S7_REGNUM; --regnum) { \
466 read_register_bytes (REGISTER_BYTE (regnum), buf, 8); \
467 sp = push_bytes (sp, buf, 8);} \
468 for (regnum = SP_REGNUM; regnum >= FP_REGNUM; --regnum) { \
469 word = read_register (regnum); \
470 sp = push_bytes (sp, &word, 4);} \
471 word = (read_register (PS_REGNUM) &~ (3<<25)) | (1<<25); \
472 sp = push_bytes (sp, &word, 4); \
473 word = read_register (PC_REGNUM); \
474 sp = push_bytes (sp, &word, 4); \
475 write_register (SP_REGNUM, sp); \
476 write_register (FP_REGNUM, sp); \
477 write_register (AP_REGNUM, sp);}
478
479 /* Discard from the stack the innermost frame, restoring all registers. */
480
481 #define POP_FRAME do {\
482 register CORE_ADDR fp = read_register (FP_REGNUM); \
483 register int regnum; \
484 register int frame_length = /* 3 short, 2 long, 1 extended, 0 context */ \
485 (read_memory_integer (fp + 4, 4) >> 25) & 3; \
486 char buf[8]; \
487 write_register (PC_REGNUM, read_memory_integer (fp, 4)); \
488 write_register (PS_REGNUM, read_memory_integer (fp += 4, 4)); \
489 write_register (FP_REGNUM, read_memory_integer (fp += 4, 4)); \
490 write_register (AP_REGNUM, read_memory_integer (fp += 4, 4)); \
491 if (frame_length < 3) \
492 for (regnum = A5_REGNUM; regnum < SP_REGNUM; ++regnum) \
493 write_register (regnum, read_memory_integer (fp += 4, 4)); \
494 if (frame_length < 2) \
495 write_register (SP_REGNUM, read_memory_integer (fp += 4, 4)); \
496 fp -= 4; \
497 if (frame_length < 3) \
498 for (regnum = S7_REGNUM; regnum < S0_REGNUM; ++regnum) { \
499 read_memory (fp += 8, buf, 8); \
500 write_register_bytes (REGISTER_BYTE (regnum), buf, 8);} \
501 if (frame_length < 2) { \
502 read_memory (fp += 8, buf, 8); \
503 write_register_bytes (REGISTER_BYTE (regnum), buf, 8);} \
504 else write_register (SP_REGNUM, fp + 8); \
505 flush_cached_frames (); \
506 set_current_frame (create_new_frame (read_register (FP_REGNUM), \
507 read_pc ())); \
508 } while (0)
509
510 /* This sequence of words is the instructions
511 mov sp,ap
512 pshea 69696969
513 calls 32323232
514 bkpt
515 Note this is 16 bytes. */
516
517 #define CALL_DUMMY {0x50860d4069696969LL,0x2140323232327d50LL}
518
519 #define CALL_DUMMY_LENGTH 16
520
521 #define CALL_DUMMY_START_OFFSET 0
522
523 /* Insert the specified number of args and function address
524 into a call sequence of the above form stored at DUMMYNAME. */
525
526 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
527 { *(int *)((char *) dummyname + 4) = nargs; \
528 *(int *)((char *) dummyname + 10) = fun; }
529 \f
530 /* Defs to read soff symbol tables, see dbxread.c */
531
532 #define NUMBER_OF_SYMBOLS ((long) opthdr.o_nsyms)
533 #define STRING_TABLE_OFFSET ((long) filehdr.h_strptr)
534 #define SYMBOL_TABLE_OFFSET ((long) opthdr.o_symptr)
535 #define STRING_TABLE_SIZE ((long) filehdr.h_strsiz)
536 #define SIZE_OF_TEXT_SEGMENT ((long) txthdr.s_size)
537 #define ENTRY_POINT ((long) opthdr.o_entry)
538
539 #define READ_STRING_TABLE_SIZE(BUFFER) \
540 (BUFFER = STRING_TABLE_SIZE)
541
542 #define DECLARE_FILE_HEADERS \
543 FILEHDR filehdr; \
544 OPTHDR opthdr; \
545 SCNHDR txthdr
546
547 #define READ_FILE_HEADERS(DESC,NAME) \
548 { \
549 int n; \
550 val = myread (DESC, &filehdr, sizeof filehdr); \
551 if (val < 0) \
552 perror_with_name (NAME); \
553 if (! IS_SOFF_MAGIC (filehdr.h_magic)) \
554 error ("%s: not an executable file.", NAME); \
555 lseek (DESC, 0L, 0); \
556 if (myread (DESC, &filehdr, sizeof filehdr) < 0) \
557 perror_with_name (NAME); \
558 if (myread (DESC, &opthdr, filehdr.h_opthdr) <= 0) \
559 perror_with_name (NAME); \
560 for (n = 0; n < filehdr.h_nscns; n++) \
561 { \
562 if (myread (DESC, &txthdr, sizeof txthdr) < 0) \
563 perror_with_name (NAME); \
564 if ((txthdr.s_flags & S_TYPMASK) == S_TEXT) \
565 break; \
566 } \
567 }
This page took 0.040802 seconds and 4 git commands to generate.