Publish VCC Plus OSS source distribution for 3.6.2 build 60
This commit is contained in:
commit
c652a5276d
1192 files changed
+272368
No files matched your search
@@ -0,0 +1,362 @@
|
||||
--- a/lwasm/input.c
|
||||
+++ b/lwasm/input.c
|
||||
@@ -26,6 +26,9 @@
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
+#include <limits.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -65,8 +68,40 @@
|
||||
void *data;
|
||||
int data2;
|
||||
char *filespec;
|
||||
+ const char *source_path;
|
||||
+ int source_line;
|
||||
struct input_stack_node *stack;
|
||||
};
|
||||
+
|
||||
+/* VCC Plus native assembly builds run in a private, immutable snapshot.
|
||||
+ * Resolve the target before opening it, including the second binary-include
|
||||
+ * read during emission. Ordinary LWASM invocations retain upstream behavior. */
|
||||
+static char *project_root;
|
||||
+
|
||||
+void input_restrict_to_project(void)
|
||||
+{
|
||||
+ project_root = realpath(".", NULL);
|
||||
+ if (!project_root)
|
||||
+ lw_error("Cannot resolve assembly project folder.\n");
|
||||
+}
|
||||
+
|
||||
+FILE *input_fopen(const char *path)
|
||||
+{
|
||||
+ if (project_root)
|
||||
+ {
|
||||
+ char resolved[PATH_MAX];
|
||||
+ struct stat info;
|
||||
+ size_t length = strlen(project_root);
|
||||
+ if (!realpath(path, resolved))
|
||||
+ return NULL;
|
||||
+ if (strncmp(project_root, resolved, length) || resolved[length] != '/')
|
||||
+ lw_error("Assembly input leaves the project snapshot: %s\n", path);
|
||||
+ if (stat(resolved, &info) != 0 || !S_ISREG(info.st_mode))
|
||||
+ lw_error("Assembly input is not a regular file: %s\n", path);
|
||||
+ return fopen(resolved, "rb");
|
||||
+ }
|
||||
+ return fopen(path, "rb");
|
||||
+}
|
||||
|
||||
static char *make_filename(char *p, char *f)
|
||||
{
|
||||
@@ -110,7 +145,7 @@
|
||||
}
|
||||
|
||||
/* this adds real filenames that were opened to a list */
|
||||
-void input_add_to_resource_list(asmstate_t *as, const char *s)
|
||||
+static const char *input_add_to_resource_list(asmstate_t *as, const char *s)
|
||||
{
|
||||
struct ifl *ifl;
|
||||
|
||||
@@ -127,6 +162,7 @@
|
||||
ifl_head = ifl;
|
||||
ifl -> fn = lw_strdup(s);
|
||||
}
|
||||
+ return ifl -> fn;
|
||||
}
|
||||
|
||||
void input_init(asmstate_t *as)
|
||||
@@ -155,6 +191,12 @@
|
||||
char *dn, *dp;
|
||||
// int o;
|
||||
|
||||
+ if (as->project_map_file && project_root)
|
||||
+ {
|
||||
+ char resolved[PATH_MAX];
|
||||
+ if (realpath(fn, resolved))
|
||||
+ IS->source_path = input_add_to_resource_list(as, resolved + strlen(project_root) + 1);
|
||||
+ }
|
||||
dn = lw_strdup(fn);
|
||||
lw_stack_push(as -> includelist, dn);
|
||||
|
||||
@@ -186,6 +228,8 @@
|
||||
struct input_stack *t;
|
||||
|
||||
t = lw_alloc(sizeof(struct input_stack));
|
||||
+ t -> source_path = NULL;
|
||||
+ t -> source_line = 0;
|
||||
t -> filespec = lw_strdup(s);
|
||||
|
||||
t -> type = input_type_string;
|
||||
@@ -204,6 +248,8 @@
|
||||
char *p, *p2;
|
||||
|
||||
t = lw_alloc(sizeof(struct input_stack));
|
||||
+ t -> source_path = NULL;
|
||||
+ t -> source_line = 0;
|
||||
t -> filespec = lw_strdup(s);
|
||||
|
||||
for (s2 = s; *s2 && (*s2 != ':'); s2++)
|
||||
@@ -238,7 +284,7 @@
|
||||
if (input_isabsolute(s))
|
||||
{
|
||||
/* absolute path */
|
||||
- IS -> data = fopen(s, "rb");
|
||||
+ IS -> data = input_fopen(s);
|
||||
debug_message(as, 1, "Opening (abs) %s", s);
|
||||
if (!IS -> data && !IGNOREERROR)
|
||||
{
|
||||
@@ -257,7 +303,7 @@
|
||||
p = lw_stack_top(as -> file_dir);
|
||||
p2 = make_filename(p, s);
|
||||
debug_message(as, 1, "Open: (cd) %s\n", p2);
|
||||
- IS -> data = fopen(p2, "rb");
|
||||
+ IS -> data = input_fopen(p2);
|
||||
if (IS -> data)
|
||||
{
|
||||
input_pushpath(as, p2);
|
||||
@@ -274,7 +320,7 @@
|
||||
{
|
||||
p2 = make_filename(p, s);
|
||||
debug_message(as, 1, "Open (sp): %s\n", p2);
|
||||
- IS -> data = fopen(p2, "rb");
|
||||
+ IS -> data = input_fopen(p2);
|
||||
if (IS -> data)
|
||||
{
|
||||
input_pushpath(as, p2);
|
||||
@@ -300,7 +346,7 @@
|
||||
if (s[0] == '-' && s[1] == '\0')
|
||||
IS -> data = stdin;
|
||||
else
|
||||
- IS -> data = fopen(s, "rb");
|
||||
+ IS -> data = input_fopen(s);
|
||||
|
||||
if (!IS -> data)
|
||||
{
|
||||
@@ -328,7 +374,7 @@
|
||||
debug_message(as, 2, "Open file (st abs) %s", s);
|
||||
if (as -> flags & FLAG_DEPEND)
|
||||
printf("%s\n", s);
|
||||
- fp = fopen(s, "rb");
|
||||
+ fp = input_fopen(s);
|
||||
if (!fp)
|
||||
{
|
||||
return NULL;
|
||||
@@ -343,7 +389,7 @@
|
||||
p = lw_stack_top(as -> file_dir);
|
||||
p2 = make_filename(p ? p : "", s);
|
||||
debug_message(as, 2, "Open file (st cd) %s", p2);
|
||||
- fp = fopen(p2, "rb");
|
||||
+ fp = input_fopen(p2);
|
||||
if (fp)
|
||||
{
|
||||
if (as -> flags & FLAG_DEPEND)
|
||||
@@ -362,7 +408,7 @@
|
||||
{
|
||||
p2 = make_filename(p, s);
|
||||
debug_message(as, 2, "Open file (st ip) %s", p2);
|
||||
- fp = fopen(p2, "rb");
|
||||
+ fp = input_fopen(p2);
|
||||
if (fp)
|
||||
{
|
||||
if (as -> flags & FLAG_DEPEND)
|
||||
@@ -471,6 +517,7 @@
|
||||
if (eol)
|
||||
{
|
||||
s = lw_strdup(linebuff);
|
||||
+ IS->source_line++;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
@@ -537,6 +584,15 @@
|
||||
default:
|
||||
lw_error("Problem reading from unknown input type\n");
|
||||
return NULL;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void input_project_location(asmstate_t *as, line_t *line)
|
||||
+{
|
||||
+ if (IS && IS->type != input_type_string)
|
||||
+ {
|
||||
+ line->project_source = IS->source_path;
|
||||
+ line->project_line = IS->source_line;
|
||||
}
|
||||
}
|
||||
|
||||
--- a/lwasm/input.h
|
||||
+++ b/lwasm/input.h
|
||||
@@ -32,6 +32,9 @@
|
||||
void input_stack_push(asmstate_t *as, input_stack_entry *se);
|
||||
input_stack_entry *input_stack_pop(asmstate_t *as, int magic, int (*fn)(input_stack_entry *e, void *data), void *data);
|
||||
|
||||
+void input_restrict_to_project(void);
|
||||
+FILE *input_fopen(const char *path);
|
||||
+void input_project_location(asmstate_t *as, line_t *line);
|
||||
void input_init(asmstate_t *as);
|
||||
void input_openstring(asmstate_t *as, char *s, char *str);
|
||||
void input_open(asmstate_t *as, char *s);
|
||||
--- a/lwasm/list.c
|
||||
+++ b/lwasm/list.c
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <lw_alloc.h>
|
||||
+#include <lw_error.h>
|
||||
#include <lw_string.h>
|
||||
|
||||
#include "lwasm.h"
|
||||
@@ -489,3 +490,43 @@
|
||||
if (of && of != stdout)
|
||||
fclose(of);
|
||||
}
|
||||
+
|
||||
+/* VCC Plus project source map. Keep the normal human-readable listing intact.
|
||||
+ * Physical file lines are captured at input; macro strings have no file identity.
|
||||
+ * The client still validates original object bytes, link relocations and the BIN. */
|
||||
+void do_project_map(asmstate_t *as)
|
||||
+{
|
||||
+ FILE *out = fopen(as->project_map_file, "w");
|
||||
+ line_t *line;
|
||||
+ const int synthetic = lwasm_insn_is6800 | lwasm_insn_is6809conv |
|
||||
+ lwasm_insn_is6309conv | lwasm_insn_isemuext;
|
||||
+ if (!out) lw_error("Cannot write project instruction map.\n");
|
||||
+ for (line = as->line_head; line; line = line->next)
|
||||
+ {
|
||||
+ const char *section = line->csect ? line->csect->name : "";
|
||||
+ lw_expr_t address;
|
||||
+ int i;
|
||||
+ if (!line->project_source || !line->emitted_opcode || line->insn < 0 ||
|
||||
+ (instab[line->insn].flags & synthetic) || !strcmp(instab[line->insn].opcode, "os9") ||
|
||||
+ line->outputl < 1 || line->outputl > 8 || line->outputl != line->len ||
|
||||
+ strpbrk(line->project_source, "\t\r\n") || strpbrk(section, "\t\r\n"))
|
||||
+ continue;
|
||||
+ address = lw_expr_copy(line->addr);
|
||||
+ as->exportcheck = 1;
|
||||
+ as->csect = line->csect;
|
||||
+ lwasm_reduce_expr(as, address);
|
||||
+ as->exportcheck = 0;
|
||||
+ if (lw_expr_istype(address, lw_expr_type_int))
|
||||
+ {
|
||||
+ int value = lw_expr_intval(address);
|
||||
+ if (value >= 0 && value <= 65535)
|
||||
+ {
|
||||
+ fprintf(out, "%s\t%d\t%s\t%04X\t", line->project_source, line->project_line, section, value);
|
||||
+ for (i = 0; i < line->outputl; ++i) fprintf(out, "%02X", line->output[i]);
|
||||
+ fputc('\n', out);
|
||||
+ }
|
||||
+ }
|
||||
+ lw_expr_destroy(address);
|
||||
+ }
|
||||
+ if (fclose(out)) lw_error("Cannot finish writing project instruction map.\n");
|
||||
+}
|
||||
--- a/lwasm/lwasm.c
|
||||
+++ b/lwasm/lwasm.c
|
||||
@@ -504,6 +504,7 @@
|
||||
|
||||
void lwasm_emitop(line_t *cl, int opc)
|
||||
{
|
||||
+ cl->emitted_opcode = 1;
|
||||
if (cl->cycle_base == 0)
|
||||
lwasm_cycle_update_count(cl, opc); /* only call first time, never on postbyte */
|
||||
|
||||
--- a/lwasm/lwasm.h
|
||||
+++ b/lwasm/lwasm.h
|
||||
@@ -278,6 +278,9 @@
|
||||
|
||||
struct line_s
|
||||
{
|
||||
+ const char *project_source;
|
||||
+ int project_line;
|
||||
+ int emitted_opcode;
|
||||
lw_expr_t addr; // assembly address of the line
|
||||
lw_expr_t daddr; // data address of the line (os9 only)
|
||||
lw_expr_t phase; // the "phase" setting (assumed address for assembly)
|
||||
@@ -440,6 +443,8 @@
|
||||
sectiontab_t *sections; // section table
|
||||
exportlist_t *exportlist; // list of exported symbols
|
||||
importlist_t *importlist; // list of imported symbols
|
||||
+ char *project_map_file;
|
||||
+ int project_6809_only;
|
||||
char *list_file; // name of file to list to
|
||||
char *symbol_dump_file; // name of file to dump symbol table to
|
||||
int tabwidth; // tab width in list file
|
||||
--- a/lwasm/main.c
|
||||
+++ b/lwasm/main.c
|
||||
@@ -71,6 +71,8 @@
|
||||
{ "6800compat", 0x200, 0, 0, "Enable 6800 compatibility instructions, equivalent to --pragma=6800compat" },
|
||||
{ "no-output", 0x105, 0, 0, "Inhibit creation of output file" },
|
||||
{ "no-warn", 0x109, "FLAG", 0, "Suppress warnings of the specified type" },
|
||||
+ { "project-map", 0x10d, "FILE", 0, "Write physical source instruction locations for a project snapshot" },
|
||||
+ { "project-inputs", 0x10c, 0, 0, "Restrict all assembly inputs to the current project folder" },
|
||||
{ "error-format", 0x10b, "STYLE", 0, "Error output style: lwasm (default), gcc, vs" },
|
||||
{ 0 }
|
||||
};
|
||||
@@ -82,6 +84,12 @@
|
||||
|
||||
switch (key)
|
||||
{
|
||||
+ case 0x10d:
|
||||
+ as->project_map_file = lw_strdup(arg);
|
||||
+ break;
|
||||
+ case 0x10c:
|
||||
+ input_restrict_to_project();
|
||||
+ break;
|
||||
case 'I':
|
||||
lw_stringlist_addstring(as -> include_list, arg);
|
||||
break;
|
||||
@@ -333,6 +341,7 @@
|
||||
void do_output(asmstate_t *as);
|
||||
void do_symdump(asmstate_t *as);
|
||||
void do_list(asmstate_t *as);
|
||||
+void do_project_map(asmstate_t *as);
|
||||
void do_map(asmstate_t *as);
|
||||
lw_expr_t lwasm_evaluate_special(int t, void *ptr, void *priv);
|
||||
lw_expr_t lwasm_evaluate_var(char *var, void *priv);
|
||||
@@ -391,6 +400,7 @@
|
||||
asmstate.output_file = lw_strdup("a.out");
|
||||
}
|
||||
|
||||
+ asmstate.project_6809_only = asmstate.project_map_file && (asmstate.pragmas & PRAGMA_6809);
|
||||
input_init(&asmstate);
|
||||
|
||||
for (passnum = 0; passlist[passnum].fn; passnum++)
|
||||
@@ -450,6 +460,7 @@
|
||||
}
|
||||
do_symdump(&asmstate);
|
||||
do_list(&asmstate);
|
||||
+ if (asmstate.project_map_file) do_project_map(&asmstate);
|
||||
do_map(&asmstate);
|
||||
|
||||
if (asmstate.testmode_errorcount > 0) exit(1);
|
||||
--- a/lwasm/pass1.c
|
||||
+++ b/lwasm/pass1.c
|
||||
@@ -115,12 +115,15 @@
|
||||
memset(cl, 0, sizeof(line_t));
|
||||
cl -> outputl = -1;
|
||||
cl -> linespec = lw_strdup(input_curspec(as));
|
||||
+ if (as->project_map_file) input_project_location(as, cl);
|
||||
cl -> prev = as -> line_tail;
|
||||
cl -> insn = -1;
|
||||
cl -> as = as;
|
||||
cl -> inmod = as -> inmod;
|
||||
cl -> csect = as -> csect;
|
||||
cl -> pragmas = as -> pragmas;
|
||||
+ if (as->project_6809_only && !(cl->pragmas & PRAGMA_6809))
|
||||
+ lwasm_register_error2(as, cl, E_6309_INVALID, "Source changes the selected 6809 project target.");
|
||||
cl -> context = as -> context;
|
||||
cl -> hasoperand = 1; // default: assume operand present; cleared by inherent insns
|
||||
cl -> ltext = lw_strdup(line);
|
||||
--- a/lwasm/pseudo.c
|
||||
+++ b/lwasm/pseudo.c
|
||||
@@ -1662,7 +1662,7 @@
|
||||
FILE *fp;
|
||||
int c, i;
|
||||
|
||||
- fp = fopen(l -> lstr, "rb");
|
||||
+ fp = input_fopen(l -> lstr);
|
||||
if (!fp)
|
||||
{
|
||||
lwasm_register_error2(as, l, E_FILE_OPEN, "%s", "(emit)!");
|
||||
Reference in new issue
Block a user