diff options
-rw-r--r-- | subx/020elf.cc | 1 | ||||
-rw-r--r-- | subx/021translate.cc | 6 |
2 files changed, 6 insertions, 1 deletions
diff --git a/subx/020elf.cc b/subx/020elf.cc index e61212b1..7121f933 100644 --- a/subx/020elf.cc +++ b/subx/020elf.cc @@ -137,7 +137,6 @@ ostream& operator<<(unused ostream& os, unused die) { #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> -#include <unistd.h> #include <stdarg.h> #include <errno.h> 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; } |