about summary refs log tree commit diff stats
path: root/subx/021translate.cc
diff options
context:
space:
mode:
Diffstat (limited to 'subx/021translate.cc')
-rw-r--r--subx/021translate.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/subx/021translate.cc b/subx/021translate.cc
index 94cebc04..636ce607 100644
--- a/subx/021translate.cc
+++ b/subx/021translate.cc
@@ -21,6 +21,7 @@ if (is_equal(argv[1], "translate")) {
   transform(p);
   if (trace_contains_errors()) return 1;
   dump_elf(p, argv[3]);
+  if (trace_contains_errors()) unlink(argv[3]);
 }
 
 :(code)
@@ -106,6 +107,11 @@ void dump_elf_header(ostream& out, const program& p) {
     uint32_t p_align = 0x1000;
     emit(p_align);
 
+    if (p_offset % p_align != p.segments.at(i).start % p_align) {
+      raise << "segment starting at 0x" << HEXWORD << p.segments.at(i).start << " is improperly aligned; alignment for p_offset " << p_offset << " should be " << (p_offset % p_align) << " but is " << (p.segments.at(i).start % p_align) << '\n' << end();
+      return;
+    }
+
     // prepare for next segment
     p_offset += size;
   }