ack/modules/src/object/obj.h
David Given ef8e6e25e0 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
2016-03-18 21:46:55 +01:00

58 lines
1.3 KiB
C

/* $Id$ */
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#include <local.h>
#include <stdlib.h>
#include <stdio.h>
#include <out.h>
#include <ranlib.h>
#include <arch.h>
#include "object.h"
#if ! defined(CHAR_UNSIGNED)
#define CHAR_UNSIGNED 0
#endif
#define Xchar(ch) (uint32_t)(uint8_t)(ch)
#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 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
#define WBUFSIZ (8*BUFSIZ)
#else
#define WBUFSIZ BUFSIZ
#endif
struct fil {
int cnt;
char *pnow;
char *pbegin;
long currpos;
int fd;
char pbuf[WBUFSIZ];
};
extern struct fil __parts[];
#define PARTEMIT 0
#define PARTRELO (PARTEMIT+SECTCNT)
#define PARTNAME (PARTRELO+1)
#define PARTCHAR (PARTNAME+1)
#ifdef SYMDBUG
#define PARTDBUG (PARTCHAR+1)
#else
#define PARTDBUG (PARTCHAR+0)
#endif
#define NPARTS (PARTDBUG + 1)
#define getsect(s) (PARTEMIT+((s)>=(SECTCNT-1)?(SECTCNT-1):(s)))