Fix a whole pile of issues related to the failed attempt to increase
the number of types of relocation possible in the object file. (Now, hopefully, working.) Also change the object serialiser/deserialiser to never try to read or write raw structures; it's way safer this way and we don't need the performance boost any more. --HG-- branch : default-branch
This commit is contained in:
@@ -15,38 +15,16 @@
|
||||
#define CHAR_UNSIGNED 0
|
||||
#endif
|
||||
|
||||
#if CHAR_UNSIGNED
|
||||
#define Xchar(ch) (ch)
|
||||
#else
|
||||
#define Xchar(ch) ((ch) & 0377)
|
||||
#endif
|
||||
#define Xchar(ch) (uint32_t)(uint8_t)(ch)
|
||||
|
||||
#if ! defined(BYTE_ORDER)
|
||||
#define BYTE_ORDER 0x3210
|
||||
#endif
|
||||
|
||||
#if (BYTE_ORDER == 0x3210 || BYTE_ORDER == 0x1032)
|
||||
#define uget2(c) (Xchar((c)[0]) | ((unsigned) Xchar((c)[1]) << 8))
|
||||
#define Xput2(i, c) (((c)[0] = (i)), ((c)[1] = (i) >> 8))
|
||||
#define put2(i, c) { register int j = (i); Xput2(j, c); }
|
||||
#else
|
||||
#define uget2(c) (* ((unsigned short *) (c)))
|
||||
#define Xput2(i, c) (* ((short *) (c)) = (i))
|
||||
#define put2(i, c) Xput2(i, c)
|
||||
#endif
|
||||
#define uget2(c) (Xchar((c)[0]) | (Xchar((c)[1])<<8))
|
||||
#define get2(c) ((int16_t) uget2(c))
|
||||
#define put2(i, c) (((c)[0] = i), ((c)[1] = i>>8))
|
||||
|
||||
#define get2(c) ((short) uget2(c))
|
||||
|
||||
#if BYTE_ORDER != 0x0123
|
||||
#define get4(c) (uget2(c) | ((long) uget2((c)+2) << 16))
|
||||
#define put4(l, c) { register long x=(l); \
|
||||
Xput2((int)x,c); \
|
||||
Xput2((int)(x>>16),(c)+2); \
|
||||
}
|
||||
#else
|
||||
#define get4(c) (* ((long *) (c)))
|
||||
#define put4(l, c) (* ((long *) (c)) = (l))
|
||||
#endif
|
||||
#define uget4(c) (uget2(c) | (uget2((c)+2)<<16))
|
||||
#define get4(c) ((int32_t) uget4(c))
|
||||
#define put4(i, c) (put2(i, c), put2((i)>>16, (c)+2))
|
||||
|
||||
#define SECTCNT 3 /* number of sections with own output buffer */
|
||||
#if BIGMACHINE
|
||||
|
||||
@@ -109,9 +109,6 @@ rd_ohead(head)
|
||||
register long off;
|
||||
|
||||
OUTREAD(PARTEMIT, (char *) head, (long) SZ_HEAD);
|
||||
#if BYTE_ORDER == 0x0123
|
||||
if (sizeof(struct outhead) != SZ_HEAD)
|
||||
#endif
|
||||
{
|
||||
register char *c = (char *) head + (SZ_HEAD-4);
|
||||
|
||||
@@ -157,16 +154,13 @@ rd_sect(sect, cnt)
|
||||
offcnt += cnt;
|
||||
while (cnt--) {
|
||||
sect--;
|
||||
#if BYTE_ORDER == 0x0123
|
||||
if (sizeof(struct outsect) != SZ_SECT)
|
||||
#endif
|
||||
{
|
||||
c -= 4; sect->os_lign = get4(c);
|
||||
c -= 4; sect->os_flen = get4(c);
|
||||
c -= 4; sect->os_foff = get4(c);
|
||||
c -= 4; sect->os_size = get4(c);
|
||||
c -= 4; sect->os_base = get4(c);
|
||||
}
|
||||
|
||||
c -= 4; sect->os_lign = get4(c);
|
||||
c -= 4; sect->os_flen = get4(c);
|
||||
c -= 4; sect->os_foff = get4(c);
|
||||
c -= 4; sect->os_size = get4(c);
|
||||
c -= 4; sect->os_base = get4(c);
|
||||
|
||||
offset[--offcnt] = sect->os_foff + rd_base;
|
||||
}
|
||||
}
|
||||
@@ -197,9 +191,6 @@ rd_relo(relo, cnt)
|
||||
{
|
||||
|
||||
OUTREAD(PARTRELO, (char *) relo, (long) cnt * SZ_RELO);
|
||||
#if BYTE_ORDER == 0x0123
|
||||
if (sizeof(struct outrelo) != SZ_RELO)
|
||||
#endif
|
||||
{
|
||||
register char *c = (char *) relo + (long) cnt * SZ_RELO;
|
||||
|
||||
@@ -208,8 +199,8 @@ rd_relo(relo, cnt)
|
||||
relo--;
|
||||
c -= 4; relo->or_addr = get4(c);
|
||||
c -= 2; relo->or_nami = uget2(c);
|
||||
relo->or_sect = *--c;
|
||||
relo->or_type = *--c;
|
||||
c -= 2; relo->or_sect = uget2(c);
|
||||
c -= 2; relo->or_type = uget2(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,9 +212,6 @@ rd_name(name, cnt)
|
||||
{
|
||||
|
||||
OUTREAD(PARTNAME, (char *) name, (long) cnt * SZ_NAME);
|
||||
#if BYTE_ORDER == 0x0123
|
||||
if (sizeof(struct outname) != SZ_NAME)
|
||||
#endif
|
||||
{
|
||||
register char *c = (char *) name + (long) cnt * SZ_NAME;
|
||||
|
||||
|
||||
@@ -11,9 +11,6 @@ rd_ranlib(fd, ran, cnt)
|
||||
register long cnt;
|
||||
{
|
||||
rd_bytes(fd, (char *) ran, cnt * SZ_RAN);
|
||||
#if BYTE_ORDER == 0x0123
|
||||
if (sizeof (struct ranlib) != SZ_RAN)
|
||||
#endif
|
||||
{
|
||||
register char *c = (char *) ran + cnt * SZ_RAN;
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ wr_ohead(head)
|
||||
BEGINSEEK(PARTDBUG, off);
|
||||
#endif
|
||||
}
|
||||
if (BYTE_ORDER != 0x0123 || sizeof(struct outhead) != SZ_HEAD)
|
||||
|
||||
{
|
||||
char buf[SZ_HEAD];
|
||||
|
||||
@@ -214,7 +214,6 @@ wr_ohead(head)
|
||||
put4(head->oh_nchar, c);
|
||||
OUTWRITE(PARTEMIT, buf, (long)SZ_HEAD);
|
||||
}
|
||||
else OUTWRITE(PARTEMIT, (char *)head, (long)SZ_HEAD);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -233,9 +232,6 @@ wr_sect(sect, cnt)
|
||||
}
|
||||
sect -= cnt;
|
||||
}
|
||||
#if BYTE_ORDER == 0x0123
|
||||
if (sizeof(struct outsect) != SZ_SECT)
|
||||
#endif
|
||||
while (cnt)
|
||||
{
|
||||
register char *c;
|
||||
@@ -259,11 +255,6 @@ wr_sect(sect, cnt)
|
||||
__wr_flush(&__parts[PARTEMIT]);
|
||||
}
|
||||
}
|
||||
#if BYTE_ORDER == 0x0123
|
||||
else {
|
||||
OUTWRITE(PARTEMIT, (char *) sect, (long) cnt * SZ_SECT);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@@ -313,9 +304,6 @@ wr_relo(relo, cnt)
|
||||
unsigned int cnt;
|
||||
{
|
||||
|
||||
#if BYTE_ORDER == 0x0123
|
||||
if (sizeof(struct outrelo) != SZ_RELO)
|
||||
#endif
|
||||
while (cnt)
|
||||
{
|
||||
register char *c;
|
||||
@@ -327,8 +315,8 @@ wr_relo(relo, cnt)
|
||||
cnt -= i;
|
||||
__parts[PARTRELO].cnt -= (i*SZ_RELO);
|
||||
while (i--) {
|
||||
*c++ = relo->or_type;
|
||||
*c++ = relo->or_sect;
|
||||
put2(relo->or_type, c); c += 2;
|
||||
put2(relo->or_sect, c); c += 2;
|
||||
put2(relo->or_nami, c); c += 2;
|
||||
put4(relo->or_addr, c); c += 4;
|
||||
relo++;
|
||||
@@ -338,11 +326,6 @@ wr_relo(relo, cnt)
|
||||
__wr_flush(&__parts[PARTRELO]);
|
||||
}
|
||||
}
|
||||
#if BYTE_ORDER == 0x0123
|
||||
else {
|
||||
OUTWRITE(PARTRELO, (char *) relo, (long) cnt * SZ_RELO);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@@ -350,9 +333,6 @@ wr_name(name, cnt)
|
||||
register struct outname *name;
|
||||
unsigned int cnt;
|
||||
{
|
||||
#if BYTE_ORDER == 0x0123
|
||||
if (sizeof(struct outname) != SZ_NAME)
|
||||
#endif
|
||||
while (cnt)
|
||||
{
|
||||
register char *c;
|
||||
@@ -373,12 +353,6 @@ wr_name(name, cnt)
|
||||
__parts[PARTNAME].pnow = c;
|
||||
if (cnt) __wr_flush(&__parts[PARTNAME]);
|
||||
}
|
||||
#if BYTE_ORDER == 0x0123
|
||||
else {
|
||||
OUTWRITE(PARTNAME, (char *) name, (long)cnt * SZ_NAME);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -10,9 +10,6 @@ wr_ranlib(fd, ran, cnt1)
|
||||
struct ranlib *ran;
|
||||
long cnt1;
|
||||
{
|
||||
#if BYTE_ORDER == 0x0123
|
||||
if (sizeof (struct ranlib) != SZ_RAN)
|
||||
#endif
|
||||
{
|
||||
register long cnt = cnt1;
|
||||
register struct ranlib *r = ran;
|
||||
|
||||
Reference in New Issue
Block a user