commit 1f77007724382f0824b79f3990a61337ae499242
parent c937f394cf20a8d3d5d29539c077e74e4ecd17ab
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 27 Nov 2017 23:11:22 +0100
[as] Add section flags to myro object file
This is a first version and not all the flags can be written
to the output.
Diffstat:
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/as/myro.c b/as/myro.c
@@ -46,6 +46,20 @@ writestrings(FILE *fp)
 	return off;
 }
 
+static unsigned
+getsecflags(Section *sp)
+{
+	unsigned flags = MYROSEC_LOAD;
+
+	if (sp->flags & SREAD)
+		flags |= MYROSEC_READ;
+	if (sp->flags & SWRITE)
+		flags |= MYROSEC_WRITE;
+	if (sp->flags & SFILE)
+		flags |= MYROSEC_FILE;
+	return flags;
+}
+
 static size_t
 writesections(FILE *fp)
 {
@@ -55,7 +69,7 @@ writesections(FILE *fp)
 
 	for (sp = seclist; sp; sp = sp->next) {
 		sect.name = sp->name.offset;
-		sect.flags = 0;
+		sect.flags = getsecflags(sp);
 		sect.fill = sp->fill;
 		sect.aligment = sp->aligment;
 		sect.offset = off;
diff --git a/inc/myro.h b/inc/myro.h
@@ -44,6 +44,16 @@ struct myrorel {
 	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,
+	MYROSEC_BLOB  = 1 << 6,
+};
+
 extern int wrmyrohdr(FILE *fp, struct myrohdr *hdr);
 extern int wrmyrosec(FILE *fp, struct myrosect *sect);
 extern int wrmyrosym(FILE *fp, struct myrosym *sym);