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