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