shithub: scc

Download patch

ref: 6a2031a326adf120eaa2c0baa5201f074251ed9c
parent: 8df711f4d80aa9402bf9d7aa5e5603e0032c248d
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Jan 4 10:27:03 EST 2019

Remove myro files

We also remove the pack/unpack functions because they had a dependency
with the myro files. It also meant to disable the output in ld.

--- a/doc/myro.txt
+++ /dev/null
@@ -1,177 +1,0 @@
-Object File Format
-------------------
-
-The object file format is designed to be the simplest format that covers
-all the needs of many modern programming languages, with sufficient support
-for hand written assembly. All the types are little endian.
-
-File Format
------------
-
-	+== Header ======+
-	| signature      | 32 bits
-	+----------------+
-	| format str     | MyroN bit
-	|                |
-	+----------------+
-	| entrypoint     | MyroN bit
-	|                |
-	+----------------+
-	| stringtab size | MyroN bit
-	|                |
-	+----------------+
-	| section size   | MyroN bit
-	| 		 |
-	+----------------+
-	| symtab size    | MyroN bit
-	|                |
-	+----------------+
-	| reloctab size  | MyroN bit
-	|                |
-	+== Metadata ====+
-	| strings...     |
-	| ....           |
-	+----------------+
-	| sections...    |
-	| ...            |
-	|----------------+
-	| symbols....    |
-	| ...            |
-	+----------------+
-	| relocations... |
-	| ...            |
-	+== Data ========+
-	| data...        |
-	| ...            |
-	+================+
-
-The file is composed of three components: The header, the metadata, and
-the data. The header begins with a signature, containing the four bytes
-"uobj", identifying this file as a unified object. It is followed by
-a string offste with a format description (it may be used to indicate
-file format version, architecture, abi, ...) .This is followed by the
-size of the string table, the size of the section table, the size of
-the symbol table, and the size of the relocation table.
-
-Metadata: Strings
------------------
-
-The string table directly follows the header. It contains an array
-of strings.  Each string is a sequence of bytes terminated by a zero
-byte. A string may contain any characters other than the zero byte. Any
-reference to a string is done using an offset into the string table. If
-it is needed to indicate a "no string" then the value -1 may be used.
-
-Metadata: Sections
-------------------
-
-The section table follows the string table. The section table defines where
-data in a program goes.
-
-	+== Sect ========+
-	| str 		 | 32 bit
-	+----------------+
-	| flags          | 16 bit
-	+----------------+
-	| fill value     |  8 bit
-	+----------------+
-	| aligment       |  8 bit
-	+----------------+
-	| offset         | MyroN bit
-	+----------------+
-	| len            | MyroN bit
-	+----------------+
-
-All the files must defined at least 5 sections, numbered 1 through 5,
-which are implcitly included in every binary:
-
-	.text		SprotRread | SprotWrite | Sload | Sfile | SprotExec
-	.data		SprotRread | SprotWrite | Sload | Sfile
-	.bss		SprotRread | SprotWrite | Sload
-	.rodata		SprotRread | Sload | Sfile
-	.blob		Sblod      | Sfile
-
-A program may have at most 65,535 sections. Sections have the followign flags;
-
-	SprotRead	= 1 << 0
-	SprotWrite	= 1 << 1
-	SprotExec	= 1 << 2
-	Sload		= 1 << 3
-	Sfile		= 1 << 4
-	Sabsolute	= 1 << 5
-	Sblob		= 1 << 6
-
-Blob section. This is not loaded into the program memory. It may be used
-for debug info, tagging the binary, and other similar uses.
-
-Metadata: Symbols
------------------
-
-The symbol table follows the string table. The symbol table contains an array
-of symbol defs. Each symbol has the following structure:
-
-
-	+== Sym =========+
-	| str name	 | 32 bits
-	+----------------+
-	| str type       | 32 bits
-	+----------------+
-	| section id     | 8 bits
-	+----------------+
-	| flags          | 8 bits
-	+----------------+
-	| offset         | MyroN bits
-	|                |
-	+----------------+
-	| len            | MyroN bits
-	|                |
-	+----------------+
-
-The string is an offset into the string table, pointing to the start
-of the string. The kind describes where in the output the data goes
-and what its role is. The offset describes where, relative to the start
-of the data, the symbol begins. The length describes how many bytes it is.
-
-Currently, there's one flag supported:
-
-	1 << 1:	Deduplicate the symbol.
-	1 << 2: Common storage for the symbol.
-	1 << 3: external symbol
-	1 << 4: undefined symbol
-
-Metadata: Relocations
-----------------------
-
-The relocations follow the symbol table. Each relocation has the
-following structure:
-
-
-	+== Reloc =======+
-	| 0 | symbol id  | 32 bits
-	| 1 | section id |
-	+----------------+
-	| flags          | 8 bits
-	+----------------+
-	| rel size       | 8 bits
-	+----------------+
-	| mask size      | 8 bits
-	+----------------+
-	| mask shift     | 8 bits
-	+----------------+
-	| offset         | MyroN bits
-	|                |
-	+----------------+
-
-Relocations write the appropriate value into the offset requested.
-The offset is relative to the base of the section where the symbol
-is defined.
-
-The flags may be:
-
-	Rabsolute   = 1 << 0
-	Roverflow   = 1 << 1
-
-Data
-----
-
-It's just data. What do you want?
--- a/include/scc/scc/myro.h
+++ /dev/null
@@ -1,79 +1,0 @@
-#define MYROHDR_SIZ    48
-#define MYROSECT_SIZ   24
-#define MYROSYM_SIZ    26
-#define MYROREL_SIZ    16
-
-#define MYROMAGIC_SIZ   4
-#define MYROMAGIC      "uobj"
-
-#define MYROMAXSEC    254
-
-struct myrohdr {
-	char magic[4];
-	unsigned long format;
-	unsigned long long entry;
-	unsigned long long strsize;
-	unsigned long long secsize;
-	unsigned long long symsize;
-	unsigned long long relsize;
-};
-
-struct myrosect {
-	unsigned long name;
-	unsigned short flags;
-	unsigned char fill;
-	unsigned char aligment;
-	unsigned long long offset;
-	unsigned long long len;
-};
-
-struct myrosym {
-	unsigned long name;
-	unsigned long type;
-	unsigned char section;
-	unsigned char flags;
-	unsigned long long offset;
-	unsigned long long len;
-};
-
-struct myrorel {
-	unsigned long id;
-	unsigned char flags;
-	unsigned char size;
-	unsigned char nbits;
-	unsigned char shift;
-	unsigned long long offset;
-};
-
-enum myrosecflg {
-	MYROSEC_READ  = 1 << 0,
-	MYROSEC_WRITE = 1 << 1,
-	MYROSEC_EXEC  = 1 << 2,
-	MYROSEC_LOAD  = 1 << 3,
-	MYROSEC_FILE  = 1 << 4,
-	MYROSEC_ABS   = 1 << 5,
-};
-
-enum myrosymflg {
-	MYROSYM_COMMON = 1 << 0,
-	MYROSYM_EXTERN = 1 << 1,
-	MYROSYM_GLOBAL = 1 << 2,
-	MYROSYM_UNDEF  = 1 << 3,
-	MYROSYM_ABS    = 1 << 4,
-};
-
-enum myrosectnames {
-	MYRO_TEXT = 0,
-	MYRO_DATA = 1,
-	MYRO_BSS  = 2,
-	MYRO_ABS  = 3,
-};
-
-extern int wrmyrohdr(FILE *fp, struct myrohdr *hdr);
-extern int wrmyrosec(FILE *fp, struct myrosect *sect);
-extern int wrmyrosym(FILE *fp, struct myrosym *sym);
-extern int wrmyrorel(FILE *fp, struct myrorel *rel);
-extern int rdmyrohdr(FILE *fp, struct myrohdr *hdr);
-extern int rdmyrosec(FILE *fp, struct myrosect *sect);
-extern int rdmyrosym(FILE *fp, struct myrosym *sym);
-extern int rdmyrorel(FILE *fp, struct myrorel *rel);
--- a/src/ld/Makefile
+++ b/src/ld/Makefile
@@ -4,7 +4,6 @@
 include $(PROJECTDIR)/scripts/rules.mk
 
 OBJS = main.o \
-       coff32.o \
        obj.o \
 
 TARGET = $(BINDIR)/ld
@@ -11,10 +10,10 @@
 
 all: $(TARGET)
 
-$(TARGET): $(LIBDIR)/libcoff32.a $(LIBDIR)/libscc.a
+$(TARGET): $(LIBDIR)/libscc.a
 
 $(TARGET): $(OBJS)
-	$(CC) $(SCC_LDFLAGS) $(OBJS) -lcoff32 -lscc -o $@
+	$(CC) $(SCC_LDFLAGS) $(OBJS) -lscc -o $@
 
 dep: inc-dep
 
--- a/src/ld/main.c
+++ b/src/ld/main.c
@@ -23,6 +23,21 @@
 
 static int done;
 
+Obj *
+probe(char *fname, char *member, FILE *fp)
+{
+}
+
+Obj *
+load(Obj *obj)
+{
+}
+
+void
+writeout(FILE *fp)
+{
+}
+
 void
 redefined(Obj *obj, Symbol *sym)
 {
--- a/src/libscc/Makefile
+++ b/src/libscc/Makefile
@@ -12,12 +12,6 @@
        xstrdup.o \
        alloc.o \
        casecmp.o \
-       lunpack.o \
-       lpack.o \
-       bunpack.o \
-       bpack.o \
-       wmyro.o \
-       rmyro.o \
 
 TARGET = $(LIBDIR)/libscc.a
 
--- a/src/libscc/bunpack.c
+++ /dev/null
@@ -1,71 +1,0 @@
-static char sccsid[] = "@(#) ./lib/scc/bunpack.c";
-
-#include <ctype.h>
-#include <stdarg.h>
-
-#include <scc/scc.h>
-
-int
-bunpack(unsigned char *src, char *fmt, ...)
-{
-	unsigned char *bp, *cp;
-	unsigned short *sp;
-	unsigned s;
-	unsigned long *lp, l;
-	unsigned long long *qp, q;
-	va_list va;
-	size_t n;
-	int d;
-
-	bp = src;
-	va_start(va, fmt);
-	while (*fmt) {
-		switch (*fmt++) {
-		case '\'':
-			for (n = 0; isdigit(*fmt); n += d) {
-				n *= 10;
-				d = *fmt++ - '0';
-			}
-			cp = va_arg(va, unsigned char *);
-			while (n--)
-				*cp++ = *bp++;
-			break;
-		case 'c':
-			cp = va_arg(va, unsigned char *);
-			*cp = *bp++;
-			break;
-		case 's':
-			sp = va_arg(va, unsigned short *);
-			s =  (unsigned) *bp++ << 8;
-			s |= (unsigned) *bp++;
-			*sp = s;
-			break;
-		case 'l':
-			lp = va_arg(va, unsigned long *);
-			l =  (unsigned long) *bp++ << 24;
-			l |= (unsigned long) *bp++ << 16;
-			l |= (unsigned long) *bp++ << 8;
-			l |= (unsigned long) *bp++;
-			*lp = l;
-			break;
-		case 'q':
-			qp = va_arg(va, unsigned long long *);
-			q =  (unsigned long long) *bp++ << 56;
-			q |= (unsigned long long) *bp++ << 48;
-			q |= (unsigned long long) *bp++ << 40;
-			q |= (unsigned long long) *bp++ << 32;
-			q |= (unsigned long long) *bp++ << 24;
-			q |= (unsigned long long) *bp++ << 16;
-			q |= (unsigned long long) *bp++ << 8;
-			q |= (unsigned long long) *bp++;
-			*qp = q;
-			break;
-		default:
-			va_end(va);
-			return -1;
-		}
-	}
-	va_end(va);
-
-	return bp - src;
-}
--- a/src/libscc/deps.mk
+++ b/src/libscc/deps.mk
@@ -1,17 +1,11 @@
 #deps
 alloc.o: $(INCDIR)/scc/scc/scc.h
 bpack.o: $(INCDIR)/scc/scc/scc.h
-bunpack.o: $(INCDIR)/scc/scc/scc.h
 casecmp.o: $(INCDIR)/scc/scc/scc.h
 debug.o: $(INCDIR)/scc/scc/scc.h
 die.o: $(INCDIR)/scc/scc/scc.h
 lpack.o: $(INCDIR)/scc/scc/scc.h
-lunpack.o: $(INCDIR)/scc/scc/scc.h
 newitem.o: $(INCDIR)/scc/scc/scc.h
-rmyro.o: $(INCDIR)/scc/scc/myro.h
-rmyro.o: $(INCDIR)/scc/scc/scc.h
-wmyro.o: $(INCDIR)/scc/scc/myro.h
-wmyro.o: $(INCDIR)/scc/scc/scc.h
 xcalloc.o: $(INCDIR)/scc/scc/scc.h
 xmalloc.o: $(INCDIR)/scc/scc/scc.h
 xrealloc.o: $(INCDIR)/scc/scc/scc.h
--- a/src/libscc/lunpack.c
+++ /dev/null
@@ -1,71 +1,0 @@
-static char sccsid[] = "@(#) ./lib/scc/lunpack.c";
-
-#include <ctype.h>
-#include <stdarg.h>
-
-#include <scc/scc.h>
-
-int
-lunpack(unsigned char *src, char *fmt, ...)
-{
-	unsigned char *bp, *cp;
-	unsigned short *sp;
-	unsigned s;
-	unsigned long *lp, l;
-	unsigned long long *qp, q;
-	va_list va;
-	size_t n;
-	int d;
-
-	bp = src;
-	va_start(va, fmt);
-	while (*fmt) {
-		switch (*fmt++) {
-		case '\'':
-			for (n = 0; isdigit(*fmt); n += d) {
-				n *= 10;
-				d = *fmt++ - '0';
-			}
-			cp = va_arg(va, unsigned char *);
-			while (n--)
-				*cp++ = *bp++;
-			break;
-		case 'c':
-			cp = va_arg(va, unsigned char *);
-			*cp = *bp++;
-			break;
-		case 's':
-			sp = va_arg(va, unsigned short *);
-			s =  (unsigned) *bp++;
-			s |= (unsigned) *bp++ << 8;
-			*sp = s;
-			break;
-		case 'l':
-			lp = va_arg(va, unsigned long *);
-			l = (unsigned long) *bp++;
-			l |= (unsigned long) *bp++ << 8;
-			l |= (unsigned long) *bp++ << 16;
-			l |= (unsigned long) *bp++ << 24;
-			*lp = l;
-			break;
-		case 'q':
-			qp = va_arg(va, unsigned long long *);
-			q = (unsigned long long) *bp++;
-			q |= (unsigned long long) *bp++ << 8;
-			q |= (unsigned long long) *bp++ << 16;
-			q |= (unsigned long long) *bp++ << 24;
-			q |= (unsigned long long) *bp++ << 32;
-			q |= (unsigned long long) *bp++ << 40;
-			q |= (unsigned long long) *bp++ << 48;
-			q |= (unsigned long long) *bp++ << 56;
-			*qp = q;
-			break;
-		default:
-			va_end(va);
-			return -1;
-		}
-	}
-	va_end(va);
-
-	return bp - src;
-}
--- a/src/libscc/rmyro.c
+++ /dev/null
@@ -1,94 +1,0 @@
-static char sccsid[] = "@(#) ./lib/scc/rmyro.c";
-
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <scc/scc.h>
-#include <scc/myro.h>
-
-int
-rdmyrohdr(FILE *fp, struct myrohdr *hdr)
-{
-	unsigned char buf[MYROHDR_SIZ];
-	int len;
-
-	fread(buf, sizeof(buf), 1, fp);
-	if (ferror(fp))
-		return EOF;
-	len = lunpack(buf, "cccclqqqqq",
-	              hdr->magic+0, hdr->magic+1,
-	              hdr->magic+2, hdr->magic+3,
-	              &hdr->format,
-	              &hdr->entry,
-	              &hdr->strsize,
-	              &hdr->secsize,
-	              &hdr->symsize,
-	              &hdr->relsize);
-	assert(len == MYROHDR_SIZ);
-
-	return len;
-}
-
-int
-rdmyrosec(FILE *fp, struct myrosect *sect)
-{
-	unsigned char buf[MYROSECT_SIZ];
-	int len;
-
-	fread(buf, sizeof(buf), 1, fp);
-	if (ferror(fp))
-		return EOF;
-	len = lunpack(buf, "lsccqq",
-	              &sect->name,
-	              &sect->flags,
-	              &sect->fill,
-	              &sect->aligment,
-	              &sect->offset,
-	              &sect->len);
-	assert(len == MYROSECT_SIZ);
-
-	return len;
-}
-
-int
-rdmyrosym(FILE *fp, struct myrosym *sym)
-{
-	unsigned char buf[MYROSYM_SIZ];
-	int len;
-
-	fread(buf, sizeof(buf), 1, fp);
-	if (ferror(fp))
-		return EOF;
-	len = lunpack(buf, "llccqq",
-	              &sym->name,
-	              &sym->type,
-	              &sym->section,
-	              &sym->flags,
-	              &sym->offset,
-	              &sym->len);
-	assert(len == MYROSYM_SIZ);
-
-	return len;
-}
-
-int
-rdmyrorel(FILE *fp, struct myrorel *rel)
-{
-	unsigned char buf[MYROREL_SIZ];
-	int len;
-
-	fread(buf, sizeof(buf), 1, fp);
-	if (ferror(fp))
-		return EOF;
-	len = lunpack(buf, "lccccq",
-	              &rel->id,
-	              &rel->flags,
-	              &rel->size,
-	              &rel->nbits,
-	              &rel->shift,
-	              &rel->offset);
-	assert(len == MYROREL_SIZ);
-
-	return len;
-}
--- a/src/libscc/wmyro.c
+++ /dev/null
@@ -1,86 +1,0 @@
-static char sccsid[] = "@(#) ./lib/scc/wmyro.c";
-
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <scc/scc.h>
-#include <scc/myro.h>
-
-int
-wrmyrohdr(FILE *fp, struct myrohdr *hdr)
-{
-	unsigned char buf[MYROHDR_SIZ];
-	int len;
-
-	len = lpack(buf, "cccclqqqqq",
-	            hdr->magic[0], hdr->magic[1],
-	            hdr->magic[2], hdr->magic[3],
-	            hdr->format,
-	            hdr->entry,
-	            hdr->strsize,
-	            hdr->secsize,
-	            hdr->symsize,
-	            hdr->relsize);
-	assert(MYROHDR_SIZ == len);
-	fwrite(buf, len, 1, fp);
-
-	return (ferror(fp)) ? EOF : len;
-}
-
-int
-wrmyrosec(FILE *fp, struct myrosect *sect)
-{
-	unsigned char buf[MYROSECT_SIZ];
-	int len;
-
-	len = lpack(buf, "lsccqq",
-	            sect->name,
-	            sect->flags,
-	            sect->fill,
-	            sect->aligment,
-	            sect->offset,
-	            sect->len);
-	assert(MYROSECT_SIZ == len);
-	fwrite(buf, len, 1, fp);
-
-	return (ferror(fp)) ? EOF : len;
-}
-
-int
-wrmyrosym(FILE *fp, struct myrosym *sym)
-{
-	unsigned char buf[MYROSYM_SIZ];
-	int len;
-
-	len = lpack(buf, "llccqq",
-	            sym->name,
-	            sym->type,
-	            sym->section,
-	            sym->flags,
-	            sym->offset,
-	            sym->len);
-	assert(MYROSYM_SIZ == len);
-	fwrite(buf, len, 1, fp);
-
-	return (ferror(fp)) ? EOF : len;
-}
-
-int
-wrmyrorel(FILE *fp, struct myrorel *rel)
-{
-	unsigned char buf[MYROREL_SIZ];
-	int len;
-
-	len = lpack(buf, "lccccq",
-	            rel->id,
-	            rel->flags,
-	            rel->size,
-	            rel->nbits,
-	            rel->shift,
-	            rel->offset);
-	assert(MYROREL_SIZ == len);
-	fwrite(buf, len, 1, fp);
-
-	return (ferror(fp)) ? EOF : len;
-}