about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--subx/011run.cc4
-rw-r--r--subx/028translate.cc6
2 files changed, 7 insertions, 3 deletions
diff --git a/subx/011run.cc b/subx/011run.cc
index cc3b82f6..1730c790 100644
--- a/subx/011run.cc
+++ b/subx/011run.cc
@@ -91,10 +91,12 @@ void run(const string& text_bytes) {
   if (trace_contains_errors()) return;
   load(p);
   if (trace_contains_errors()) return;
+  // convenience to keep tests concise: 'Entry' label need not be provided
+  // not allowed in real programs
   if (p.entry)
     EIP = p.entry;
   else
-    EIP = find(p, "code")->start;  // just in unit tests
+    EIP = find(p, "code")->start;
   while (EIP < End_of_program)
     run_one_instruction();
 }
diff --git a/subx/028translate.cc b/subx/028translate.cc
index 937647f2..46f4f219 100644
--- a/subx/028translate.cc
+++ b/subx/028translate.cc
@@ -80,6 +80,10 @@ void save_elf(const program& p, const string& filename) {
 }
 
 void save_elf(const program& p, ostream& out) {
+  if (p.entry == 0) {
+    raise << "no 'Entry' label found\n" << end();
+    return;
+  }
   write_elf_header(out, p);
   for (size_t i = 0;  i < p.segments.size();  ++i)
     write_segment(p.segments.at(i), out);
@@ -104,8 +108,6 @@ void write_elf_header(ostream& out, const program& p) {
   // e_version
   O(0x01); O(0x00); O(0x00); O(0x00);
   // e_entry
-  if (p.entry == 0)
-    raise << "no 'Entry' label found\n" << end();
   uint32_t e_entry = p.entry;
   // Override e_entry
   emit(e_entry);