summaryrefslogtreecommitdiff
path: root/rdoff
diff options
context:
space:
mode:
Diffstat (limited to 'rdoff')
-rw-r--r--rdoff/Makefile.in57
-rw-r--r--rdoff/hash.h1
-rw-r--r--rdoff/ldsegs.h1
-rw-r--r--rdoff/rdflib.c2
-rw-r--r--rdoff/rdlar.h1
-rw-r--r--rdoff/rdoff.c1
-rw-r--r--rdoff/rdoff.h293
-rw-r--r--rdoff/segtab.h1
-rw-r--r--rdoff/symtab.h1
9 files changed, 36 insertions, 322 deletions
diff --git a/rdoff/Makefile.in b/rdoff/Makefile.in
index 1f2d19df..404818ce 100644
--- a/rdoff/Makefile.in
+++ b/rdoff/Makefile.in
@@ -19,45 +19,59 @@ datarootdir = @datarootdir@
CC = @CC@
CFLAGS = @CFLAGS@
BUILD_CFLAGS = $(CFLAGS) @DEFS@
-INTERNAL_CFLAGS = -I$(srcdir) -I$(top_srcdir) -I..
+INTERNAL_CFLAGS = -I$(srcdir) -I$(top_srcdir) -I$(top_srcdir)/include -I..
ALL_CFLAGS = $(BUILD_CFLAGS) $(INTERNAL_CFLAGS)
LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+
+AR = @AR@
+RANLIB = @RANLIB@
+STRIP = @STRIP@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
-LN_S = @LN_S@
+LN_S = @LN_S@
+
MKDIR = mkdir
+RM = rm
-LDRDFLIBS = rdoff.$(O) symtab.$(O) collectn.$(O) \
+LIBOBJS = rdoff.$(O) rdfload.$(O) symtab.$(O) collectn.$(O) \
rdlib.$(O) segtab.$(O) hash.$(O)
-RDXLIBS = rdoff.$(O) rdfload.$(O) symtab.$(O) collectn.$(O) hash.$(O)
-NASMLIB = ../nasmlib.$(O)
+RDFLIB = librdoff.$(A)
+NASMLIB = ../libnasm.$(A)
+LIBS = $(RDFLIB) $(NASMLIB)
# Binary suffixes
O = @OBJEXT@
X = @EXEEXT@
+A = @LIBEXT@
PROGRAMS = rdfdump$(X) ldrdf$(X) rdx$(X) rdflib$(X) \
rdf2bin$(X) rdf2com$(X) rdf2ith$(X) rdf2ihx$(X) rdf2srec$(X)
-.SUFFIXES: .c .i .s .$(O) .1 .man
+.SUFFIXES: .c .i .s .$(O) .$(A) .1 .man
.c.$(O):
$(CC) -c $(ALL_CFLAGS) $<
all: $(PROGRAMS)
-rdfdump$(X): rdfdump.$(O) rdoff.$(O)
- $(CC) $(LDFLAGS) -o rdfdump$(X) rdfdump.$(O) rdoff.$(O)
-ldrdf$(X): ldrdf.$(O) $(LDRDFLIBS) $(NASMLIB)
- $(CC) $(LDFLAGS) -o ldrdf$(X) ldrdf.$(O) $(LDRDFLIBS) $(NASMLIB)
-rdx$(X): rdx.$(O) $(RDXLIBS) $(NASMLIB)
- $(CC) $(LDFLAGS) -o rdx$(X) rdx.$(O) $(RDXLIBS) $(NASMLIB)
-rdflib$(X): rdflib.$(O)
- $(CC) $(LDFLAGS) -o rdflib$(X) rdflib.$(O)
-rdf2bin$(X): rdf2bin.$(O) $(RDXLIBS) $(NASMLIB)
- $(CC) $(LDFLAGS) -o rdf2bin$(X) rdf2bin.$(O) $(RDXLIBS) $(NASMLIB)
+$(RDFLIB): $(LIBOBJS)
+ $(RM) -f $(RDFLIB)
+ $(AR) cq $(RDFLIB) $(LIBOBJS)
+ $(RANLIB) $(RDFLIB)
+
+rdfdump$(X): rdfdump.$(O) $(LIBS)
+ $(CC) $(LDFLAGS) -o rdfdump$(X) rdfdump.$(O) $(LIBS)
+ldrdf$(X): ldrdf.$(O) $(LIBS)
+ $(CC) $(LDFLAGS) -o ldrdf$(X) ldrdf.$(O) $(LIBS)
+rdx$(X): rdx.$(O) $(LIBS)
+ $(CC) $(LDFLAGS) -o rdx$(X) rdx.$(O) $(LIBS)
+rdflib$(X): rdflib.$(O) $(LIBS)
+ $(CC) $(LDFLAGS) -o rdflib$(X) rdflib.$(O) $(LIBS)
+rdf2bin$(X): rdf2bin.$(O) $(LIBS)
+ $(CC) $(LDFLAGS) -o rdf2bin$(X) rdf2bin.$(O) $(LIBS)
rdf2com$(X): rdf2bin$(X)
rm -f rdf2com$(X) && $(LN_S) rdf2bin$(X) rdf2com$(X)
rdf2ith$(X): rdf2bin$(X)
@@ -70,18 +84,19 @@ rdf2srec$(X): rdf2bin$(X)
rdf2ihx.$(O): rdf2ihx.c
rdf2bin.$(O): rdf2bin.c
rdfdump.$(O): rdfdump.c
-rdoff.$(O): rdoff.c rdoff.h
-ldrdf.$(O): ldrdf.c rdoff.h ../nasmlib.h symtab.h collectn.h rdlib.h
+rdoff.$(O): rdoff.c ../include/rdoff.h
+ldrdf.$(O): ldrdf.c ../include/rdoff.h ../include/nasmlib.h symtab.h \
+ collectn.h rdlib.h
symtab.$(O): symtab.c symtab.h
collectn.$(O): collectn.c collectn.h
-rdx.$(O): rdx.c rdoff.h rdfload.h symtab.h
-rdfload.$(O): rdfload.c rdfload.h rdoff.h collectn.h symtab.h
+rdx.$(O): rdx.c ../include/rdoff.h rdfload.h symtab.h
+rdfload.$(O): rdfload.c rdfload.h ../include/rdoff.h collectn.h symtab.h
rdlib.$(O): rdlib.c rdlib.h
rdflib.$(O): rdflib.c
segtab.$(O): segtab.c
clean:
- rm -f *.$(O) $(PROGRAMS)
+ rm -f *.$(O) *.$(A) $(PROGRAMS)
spotless: clean
rm -f Makefile
diff --git a/rdoff/hash.h b/rdoff/hash.h
index a6920e70..0379305f 100644
--- a/rdoff/hash.h
+++ b/rdoff/hash.h
@@ -11,7 +11,6 @@
#ifndef RDOFF_HASH_H
#define RDOFF_HASH_H 1
-#include <inttypes.h>
uint32_t hash(const char *name);
diff --git a/rdoff/ldsegs.h b/rdoff/ldsegs.h
index fcecdf67..7dccaace 100644
--- a/rdoff/ldsegs.h
+++ b/rdoff/ldsegs.h
@@ -6,7 +6,6 @@
#ifndef RDOFF_LDSEGS_H
#define RDOFF_LDSEGS_H 1
-#include <inttypes.h>
struct segconfig {
uint16_t typelow, typehi; /* range of seg nos for which this is valid */
diff --git a/rdoff/rdflib.c b/rdoff/rdflib.c
index 06cce3c7..0844e6ce 100644
--- a/rdoff/rdflib.c
+++ b/rdoff/rdflib.c
@@ -62,9 +62,7 @@
#include <stdlib.h>
#include <errno.h>
#include <string.h>
-#include <inttypes.h>
#include <time.h>
-#include <inttypes.h>
/* functions supported:
* create a library (no extra operands required)
diff --git a/rdoff/rdlar.h b/rdoff/rdlar.h
index ee00f2e8..16633a11 100644
--- a/rdoff/rdlar.h
+++ b/rdoff/rdlar.h
@@ -5,7 +5,6 @@
#ifndef RDOFF_RDLAR_H
#define RDOFF_RDLAR_H 1
-#include <inttypes.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
diff --git a/rdoff/rdoff.c b/rdoff/rdoff.c
index 9f2ac2af..ef9a5651 100644
--- a/rdoff/rdoff.c
+++ b/rdoff/rdoff.c
@@ -46,7 +46,6 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <inttypes.h>
#define RDOFF_UTILS
diff --git a/rdoff/rdoff.h b/rdoff/rdoff.h
deleted file mode 100644
index 1451c6ea..00000000
--- a/rdoff/rdoff.h
+++ /dev/null
@@ -1,293 +0,0 @@
-/* ----------------------------------------------------------------------- *
- *
- * Copyright 1996-2009 The NASM Authors - All Rights Reserved
- * See the file AUTHORS included with the NASM distribution for
- * the specific copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following
- * conditions are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * rdoff.h RDOFF Object File manipulation routines header file
- */
-
-#ifndef RDOFF_RDOFF_H
-#define RDOFF_RDOFF_H 1
-
-#include <inttypes.h>
-
-/*
- * RDOFF definitions. They are used by RDOFF utilities and by NASM's
- * 'outrdf2.c' output module.
- */
-
-/* RDOFF format revision (currently used only when printing the version) */
-#define RDOFF2_REVISION "0.6.1"
-
-/* RDOFF2 file signature */
-#define RDOFF2_SIGNATURE "RDOFF2"
-
-/* Maximum size of an import/export label (including trailing zero) */
-#define EXIM_LABEL_MAX 256
-
-/* Maximum size of library or module name (including trailing zero) */
-#define MODLIB_NAME_MAX 128
-
-/* Maximum number of segments that we can handle in one file */
-#define RDF_MAXSEGS 64
-
-/* Record types that may present the RDOFF header */
-#define RDFREC_GENERIC 0
-#define RDFREC_RELOC 1
-#define RDFREC_IMPORT 2
-#define RDFREC_GLOBAL 3
-#define RDFREC_DLL 4
-#define RDFREC_BSS 5
-#define RDFREC_SEGRELOC 6
-#define RDFREC_FARIMPORT 7
-#define RDFREC_MODNAME 8
-#define RDFREC_COMMON 10
-
-/*
- * Generic record - contains the type and length field, plus a 128 byte
- * array 'data'
- */
-struct GenericRec {
- uint8_t type;
- uint8_t reclen;
- char data[128];
-};
-
-/*
- * Relocation record
- */
-struct RelocRec {
- uint8_t type; /* must be 1 */
- uint8_t reclen; /* content length */
- uint8_t segment; /* only 0 for code, or 1 for data supported,
- but add 64 for relative refs (ie do not require
- reloc @ loadtime, only linkage) */
- int32_t offset; /* from start of segment in which reference is loc'd */
- uint8_t length; /* 1 2 or 4 bytes */
- uint16_t refseg; /* segment to which reference refers to */
-};
-
-/*
- * Extern/import record
- */
-struct ImportRec {
- uint8_t type; /* must be 2 */
- uint8_t reclen; /* content length */
- uint8_t flags; /* SYM_* flags (see below) */
- uint16_t segment; /* segment number allocated to the label for reloc
- records - label is assumed to be at offset zero
- in this segment, so linker must fix up with offset
- of segment and of offset within segment */
- char label[EXIM_LABEL_MAX]; /* zero terminated, should be written to file
- until the zero, but not after it */
-};
-
-/*
- * Public/export record
- */
-struct ExportRec {
- uint8_t type; /* must be 3 */
- uint8_t reclen; /* content length */
- uint8_t flags; /* SYM_* flags (see below) */
- uint8_t segment; /* segment referred to (0/1/2) */
- int32_t offset; /* offset within segment */
- char label[EXIM_LABEL_MAX]; /* zero terminated as in import */
-};
-
-/*
- * DLL record
- */
-struct DLLRec {
- uint8_t type; /* must be 4 */
- uint8_t reclen; /* content length */
- char libname[MODLIB_NAME_MAX]; /* name of library to link with at load time */
-};
-
-/*
- * BSS record
- */
-struct BSSRec {
- uint8_t type; /* must be 5 */
- uint8_t reclen; /* content length */
- int32_t amount; /* number of bytes BSS to reserve */
-};
-
-/*
- * Module name record
- */
-struct ModRec {
- uint8_t type; /* must be 8 */
- uint8_t reclen; /* content length */
- char modname[MODLIB_NAME_MAX]; /* module name */
-};
-
-/*
- * Common variable record
- */
-struct CommonRec {
- uint8_t type; /* must be 10 */
- uint8_t reclen; /* equals 7+label length */
- uint16_t segment; /* segment number */
- int32_t size; /* size of common variable */
- uint16_t align; /* alignment (power of two) */
- char label[EXIM_LABEL_MAX]; /* zero terminated as in import */
-};
-
-/* Flags for ExportRec */
-#define SYM_DATA 1
-#define SYM_FUNCTION 2
-#define SYM_GLOBAL 4
-#define SYM_IMPORT 8
-
-/*** The following part is used only by the utilities *************************/
-
-#ifdef RDOFF_UTILS
-
-/* Some systems don't define this automatically */
-#if !defined(strdup)
-extern char *strdup(const char *);
-#endif
-
-typedef union RDFHeaderRec {
- char type; /* invariant throughout all below */
- struct GenericRec g; /* type 0 */
- struct RelocRec r; /* type == 1 / 6 */
- struct ImportRec i; /* type == 2 / 7 */
- struct ExportRec e; /* type == 3 */
- struct DLLRec d; /* type == 4 */
- struct BSSRec b; /* type == 5 */
- struct ModRec m; /* type == 8 */
- struct CommonRec c; /* type == 10 */
-} rdfheaderrec;
-
-struct SegmentHeaderRec {
- /* information from file */
- uint16_t type;
- uint16_t number;
- uint16_t reserved;
- int32_t length;
-
- /* information built up here */
- int32_t offset;
- uint8_t *data; /* pointer to segment data if it exists in memory */
-};
-
-typedef struct RDFFileInfo {
- FILE *fp; /* file descriptor; must be open to use this struct */
- int rdoff_ver; /* should be 1; any higher => not guaranteed to work */
- int32_t header_len;
- int32_t header_ofs;
-
- uint8_t *header_loc; /* keep location of header */
- int32_t header_fp; /* current location within header for reading */
-
- struct SegmentHeaderRec seg[RDF_MAXSEGS];
- int nsegs;
-
- int32_t eof_offset; /* offset of the first uint8_t beyond the end of this
- module */
-
- char *name; /* name of module in libraries */
- int *refcount; /* pointer to reference count on file, or NULL */
-} rdffile;
-
-#define BUF_BLOCK_LEN 4088 /* selected to match page size (4096)
- * on 80x86 machines for efficiency */
-typedef struct memorybuffer {
- int length;
- uint8_t buffer[BUF_BLOCK_LEN];
- struct memorybuffer *next;
-} memorybuffer;
-
-typedef struct {
- memorybuffer *buf; /* buffer containing header records */
- int nsegments; /* number of segments to be written */
- int32_t seglength; /* total length of all the segments */
-} rdf_headerbuf;
-
-/* segments used by RDOFF, understood by rdoffloadseg */
-#define RDOFF_CODE 0
-#define RDOFF_DATA 1
-#define RDOFF_HEADER -1
-/* mask for 'segment' in relocation records to find if relative relocation */
-#define RDOFF_RELATIVEMASK 64
-/* mask to find actual segment value in relocation records */
-#define RDOFF_SEGMENTMASK 63
-
-extern int rdf_errno;
-
-/* rdf_errno can hold these error codes */
-enum {
- /* 0 */ RDF_OK,
- /* 1 */ RDF_ERR_OPEN,
- /* 2 */ RDF_ERR_FORMAT,
- /* 3 */ RDF_ERR_READ,
- /* 4 */ RDF_ERR_UNKNOWN,
- /* 5 */ RDF_ERR_HEADER,
- /* 6 */ RDF_ERR_NOMEM,
- /* 7 */ RDF_ERR_VER,
- /* 8 */ RDF_ERR_RECTYPE,
- /* 9 */ RDF_ERR_RECLEN,
- /* 10 */ RDF_ERR_SEGMENT
-};
-
-/* utility functions */
-int32_t translateint32_t(int32_t in);
-uint16_t translateint16_t(uint16_t in);
-char *translatesegmenttype(uint16_t type);
-
-/* RDOFF file manipulation functions */
-int rdfopen(rdffile * f, const char *name);
-int rdfopenhere(rdffile * f, FILE * fp, int *refcount, const char *name);
-int rdfclose(rdffile * f);
-int rdffindsegment(rdffile * f, int segno);
-int rdfloadseg(rdffile * f, int segment, void *buffer);
-rdfheaderrec *rdfgetheaderrec(rdffile * f); /* returns static storage */
-void rdfheaderrewind(rdffile * f); /* back to start of header */
-void rdfperror(const char *app, const char *name);
-
-/* functions to write a new RDOFF header to a file -
- use rdfnewheader to allocate a header, rdfaddheader to add records to it,
- rdfaddsegment to notify the header routines that a segment exists, and
- to tell it how int32_t the segment will be.
- rdfwriteheader to write the file id, object length, and header
- to a file, and then rdfdoneheader to dispose of the header */
-
-rdf_headerbuf *rdfnewheader(void);
-int rdfaddheader(rdf_headerbuf * h, rdfheaderrec * r);
-int rdfaddsegment(rdf_headerbuf * h, int32_t seglength);
-int rdfwriteheader(FILE * fp, rdf_headerbuf * h);
-void rdfdoneheader(rdf_headerbuf * h);
-
-#endif /* RDOFF_UTILS */
-
-#endif /* RDOFF_RDOFF_H */
diff --git a/rdoff/segtab.h b/rdoff/segtab.h
index 87ef0171..e5e87931 100644
--- a/rdoff/segtab.h
+++ b/rdoff/segtab.h
@@ -34,7 +34,6 @@
#ifndef RDOFF_SEGTAB_H
#define RDOFF_SEGTAB_H 1
-#include <inttypes.h>
typedef void *segtab;
diff --git a/rdoff/symtab.h b/rdoff/symtab.h
index 0dc8c7b1..efd1b68e 100644
--- a/rdoff/symtab.h
+++ b/rdoff/symtab.h
@@ -38,7 +38,6 @@
#ifndef RDOFF_SYMTAB_H
#define RDOFF_SYMTAB_H 1
-#include <inttypes.h>
typedef struct {
char *name;