shithub: scc

Download patch

ref: 6ce3d85eb82efc253c36de268867cb8e22ea812f
parent: f7685e70ed2dfe601aba35916c3ce8e6281d68b6
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Dec 12 05:34:45 EST 2017

[as] Add section id to symbols

--- a/as/as.h
+++ b/as/as.h
@@ -90,6 +90,7 @@
 	unsigned char flags;
 	unsigned char fill;
 	unsigned char aligment;
+	unsigned id;
 	TUINT base;
 	TUINT max;
 	TUINT curpc;
--- a/as/myro.c
+++ b/as/myro.c
@@ -72,8 +72,12 @@
 	Section *sp;
 	size_t off = 0;
 	struct myrosect sect;
+	unsigned id = 0;;
 
 	for (sp = seclist; sp; sp = sp->next) {
+		if (id == MYROMAXSEC)
+			die("too many sections for a myro file");
+		sp->id = id++;
 		sect.name = sp->name.offset;
 		sect.flags = getsecflags(sp);
 		sect.fill = sp->fill;
@@ -114,7 +118,7 @@
 			continue;
 		symbol.name = sym->name.offset;
 		symbol.type = -1;
-		symbol.section = -1;
+		symbol.section = sym->section->id;
 		symbol.flags = getsymflags(sym);
 		symbol.offset = sym->value;
 		symbol.len = 0;
--- a/inc/myro.h
+++ b/inc/myro.h
@@ -7,6 +7,8 @@
 #define MYROMAGIC_SIZ   4
 #define MYROMAGIC      "uobj"
 
+#define MYROMAXSEC    254
+
 struct myrohdr {
 	char magic[4];
 	unsigned long format;