ref: 663e1ef436aee781206c85d42fd304afb6272ba5
parent: 1b169832c674cb39af811555866106673b6eb602
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Nov 27 18:11:22 EST 2017
[as] Add section flags to myro object file This is a first version and not all the flags can be written to the output.
--- a/as/myro.c
+++ b/as/myro.c
@@ -46,6 +46,20 @@
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 @@
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;
--- a/inc/myro.h
+++ b/inc/myro.h
@@ -44,6 +44,16 @@
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);