#include "rd.h"
+#if (defined(sun) && defined(mc68020)) || defined(vax)
#if defined(sun) && defined(mc68020)
+#define relocation_info reloc_info_68k
+#endif
#include <a.out.h>
#include <stdio.h>
h->oh_stamp = 0;
h->oh_nsect = 4;
h->oh_nname = 3 + bh.a_syms / sizeof(struct nlist);
- h->oh_nrelo = (bh.a_trsize + bh.a_drsize) / sizeof(struct reloc_info_68k);
+ h->oh_nrelo = (bh.a_trsize + bh.a_drsize) / sizeof(struct relocation_info);
h->oh_flags = h->oh_nrelo ? HF_LINK : 0;
+#if defined(sun)
if (bh.a_magic == ZMAGIC) bh.a_text -= sizeof(struct exec);
+#endif
h->oh_nemit = bh.a_text + bh.a_data;
+#if defined(sun)
if (bh.a_magic == ZMAGIC) bh.a_text += sizeof(struct exec);
+#endif
fseek(inf, N_STROFF(bh), 0);
h->oh_nchar = getw(inf) + 6 + 6 + 5 - 4; /* ".text", ".data", ".bss",
minus the size word */
seg_strings = h->oh_nchar - 17;
- if (bh.a_magic == ZMAGIC) bh.a_text -= sizeof(struct exec);
- fseek(inf, sizeof(struct exec) + bh.a_text + bh.a_data, 0);
+ fseek(inf, N_TXTOFF(bh)+bh.a_text+bh.a_data, 0);
hh = *h;
+#if defined(sun)
+ if (bh.a_magic == ZMAGIC) bh.a_text -= sizeof(struct exec);
+#endif
}
/*ARGSUSED1*/
register char *strings;
long count;
{
+#if defined(sun)
if (bh.a_magic == ZMAGIC) bh.a_text += sizeof(struct exec);
+#endif
fseek(inf, N_STROFF(bh)+4, 0);
if (! readf(strings, (int)count-17, 1)) rd_fatal();
strings += count-17;
init_run();
return;
}
- curr_stop = BUFTOI(m.m_buf+1, (int) PS);
+ curr_stop = BUFTOI(m.m_buf+1, PS);
CurrentScope = get_scope_from_addr(curr_stop);
}
perform_items();
if (! level) {
child_interrupted = 0;
interrupted = 0;
- return stopped("interrupted", (t_addr) BUFTOI(answer.m_buf+1, (int)PS), 0);
+ return stopped("interrupted", (t_addr) BUFTOI(answer.m_buf+1, PS), 0);
}
return 1;
}
level--;
return 1;
}
- a = BUFTOI(answer.m_buf+1, (int)PS);
+ a = BUFTOI(answer.m_buf+1, PS);
type = answer.m_type & 0377;
if (type == M_END_SS) type = 0;
else if (type == M_OK || type == M_DB_SS) type = 1;
struct message_hdr m;
m.m_type = kind;
- ITOBUF(m.m_buf+1, size, (int) LS);
- ITOBUF(m.m_buf+LS+1, (long)from, (int) PS);
+ ITOBUF(m.m_buf+1, size, LS);
+ ITOBUF(m.m_buf+LS+1, (long)from, PS);
if (! could_send(&m, 0)) {
return 0;
if (errmess) error("interrupted");
return 0;
case M_DATA:
- return ureceive(to, BUFTOI(answer.m_buf+1, (int)LS));
+ return ureceive(to, BUFTOI(answer.m_buf+1, LS));
default:
assert(0);
}
{
int retval = getbytes(size, from, to, M_GETSTR, 0);
- to[(int)BUFTOI(answer.m_buf+1, (int)LS)] = 0;
+ to[(int)BUFTOI(answer.m_buf+1, LS)] = 0;
return retval;
}
struct message_hdr m;
m.m_type = M_SETBYTES;
- ITOBUF(m.m_buf+1, size, (int) LS);
- ITOBUF(m.m_buf+LS+1, (long) to, (int) PS);
+ ITOBUF(m.m_buf+1, size, LS);
+ ITOBUF(m.m_buf+LS+1, (long) to, PS);
if (! uputm(&m) || ! usend(from, size) || ! ugetm(&m)) {
return;
assert(0);
}
- sz = BUFTOI(answer.m_buf+1, (int)LS);
+ sz = BUFTOI(answer.m_buf+1, LS);
*globbuf = malloc((unsigned) (sz+sizeof(struct message_hdr)));
if (! *globbuf
|| ! ureceive(*globbuf+sizeof(struct message_hdr), sz)
*globm = answer;
assert(m.m_type == M_DSTACK);
- sz = BUFTOI(m.m_buf+1, (int)LS);
+ sz = BUFTOI(m.m_buf+1, LS);
*stackbuf = malloc((unsigned) sz+sizeof(struct message_hdr));
if (! *stackbuf || ! ureceive(*stackbuf+sizeof(struct message_hdr), sz)) {
free(*globbuf);
}
stackm = (struct message_hdr *) *stackbuf;
*stackm = m;
- ITOBUF(globm->m_buf+SP_OFF, BUFTOI(stackm->m_buf+SP_OFF, (int)PS), (int) PS);
- return BUFTOI(globm->m_buf+PC_OFF, (int)PS);
+ ITOBUF(globm->m_buf+SP_OFF, BUFTOI(stackm->m_buf+SP_OFF, PS), PS);
+ return BUFTOI(globm->m_buf+PC_OFF, PS);
}
int
restoring = 0;
}
return uputm(globm)
- && usend(globbuf, BUFTOI(globm->m_buf+1, (int) LS))
+ && usend(globbuf, BUFTOI(globm->m_buf+1, LS))
&& uputm(stackm)
- && usend(stackbuf, BUFTOI(stackm->m_buf+1, (int) LS))
+ && usend(stackbuf, BUFTOI(stackm->m_buf+1, LS))
&& ugetm(&m)
- && stopped("restored", BUFTOI(m.m_buf+1, (int) PS), 0);
+ && stopped("restored", BUFTOI(m.m_buf+1, PS), 0);
}
t_addr *
register t_addr *to = &buf[0];
m.m_type = M_GETEMREGS;
- ITOBUF(m.m_buf+1, (long) level, (int) LS);
+ ITOBUF(m.m_buf+1, (long) level, LS);
if (! could_send(&m, 0)) {
return 0;
default:
assert(0);
}
- *to++ = (t_addr) BUFTOI(answer.m_buf+LB_OFF, (int)PS);
- *to++ = (t_addr) BUFTOI(answer.m_buf+AB_OFF, (int)PS);
- *to++ = (t_addr) BUFTOI(answer.m_buf+PC_OFF, (int)PS);
- *to++ = (t_addr) BUFTOI(answer.m_buf+HP_OFF, (int)PS);
- *to++ = (t_addr) BUFTOI(answer.m_buf+PC_OFF, (int)PS);
+ *to++ = (t_addr) BUFTOI(answer.m_buf+LB_OFF, PS);
+ *to++ = (t_addr) BUFTOI(answer.m_buf+AB_OFF, PS);
+ *to++ = (t_addr) BUFTOI(answer.m_buf+PC_OFF, PS);
+ *to++ = (t_addr) BUFTOI(answer.m_buf+HP_OFF, PS);
+ *to++ = (t_addr) BUFTOI(answer.m_buf+PC_OFF, PS);
return buf;
}
struct message_hdr m;
m.m_type = M_SETEMREGS;
- ITOBUF(m.m_buf+PC_OFF, (long)PC, (int)PS);
+ ITOBUF(m.m_buf+PC_OFF, (long)PC, PS);
if (! could_send(&m, 0)) return 0;
switch(answer.m_type) {
case M_FAIL:
struct message_hdr m;
m.m_type = (type ? M_SETSSF : M_SETSS) | (db_ss ? M_DB_SS : 0);
- ITOBUF(m.m_buf+1, count, (int) LS);
+ ITOBUF(m.m_buf+1, count, LS);
single_stepping = 1;
if (could_send(&m, 1) && child_pid) return 1;
single_stepping = 0;
struct message_hdr m;
m.m_type = type ? M_SETBP : M_CLRBP;
- ITOBUF(m.m_buf+1, (long) a, (int) PS);
+ ITOBUF(m.m_buf+1, (long) a, PS);
if (debug) printf("%s breakpoint at 0x%lx\n", type ? "setting" : "clearing", (long) a);
if (child_pid && ! could_send(&m, 0)) {
}
struct message_hdr m;
m.m_type = type ? M_SETTRACE : M_CLRTRACE;
- ITOBUF(m.m_buf+1, (long)start, (int) PS);
- ITOBUF(m.m_buf+PS+1, (long)end, (int) PS);
+ ITOBUF(m.m_buf+1, (long)start, PS);
+ ITOBUF(m.m_buf+PS+1, (long)end, PS);
if (debug) printf("%s trace at [0x%lx,0x%lx]\n", type ? "setting" : "clearing", (long) start, (long) end);
if (child_pid && ! could_send(&m, 0)) {
return 0;