From 6aa74185614d86554a94a1aa0cc31b1f8aa9190a Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Mon, 16 Jan 2017 20:55:24 -0500 Subject: [PATCH] remove dead code, fix expression location adjustment. --- link.cpp | 14 +++++--------- omf.cpp | 42 ------------------------------------------ 2 files changed, 5 insertions(+), 51 deletions(-) diff --git a/link.cpp b/link.cpp index 63a9dfd..2656967 100644 --- a/link.cpp +++ b/link.cpp @@ -830,15 +830,6 @@ void to_omf(const expression &e, omf::segment &seg) { r.offset = e.offset; r.value = value; - - #if 0 - // handle later. - // if generating a super, store inline. - if (!flags._C && r.can_compress()) { - for (int i = 0; i < e.size; ++i, value >>= 8) - seg.data[e.offset + i] = value & 0xff; - } - #endif seg.relocs.emplace_back(r); } else { omf::interseg r; @@ -1050,8 +1041,13 @@ void build_omf_segments() { // now adjust all the expressions, simplify, and convert to reloc records. for (auto &s :sections) { + + auto &x = remap[s.number]; + for (auto &e : s.expressions) { + e.offset += x.second; + for (auto &t : e.stack) { if (t.tag == OP_LOC) { const auto &x = remap[t.section]; diff --git a/omf.cpp b/omf.cpp index 00cc928..48b3aef 100644 --- a/omf.cpp +++ b/omf.cpp @@ -412,48 +412,6 @@ void save_omf(const std::string &path, std::vector &segments, bool uint32_t reloc_size = 0; reloc_size = add_relocs(data, data_offset, s, compress); -#if 0 - // should interseg/reloc records be sorted? - // todo -- compress into super records. - for (const auto &r : s.relocs) { - if (r.can_compress()) { - push(data, (uint8_t)0xf5); - push(data, (uint8_t)r.size); - push(data, (uint8_t)r.shift); - push(data, (uint16_t)r.offset); - push(data, (uint16_t)r.value); - reloc_size += 7; - } else { - push(data, (uint8_t)0xe5); - push(data, (uint8_t)r.size); - push(data, (uint8_t)r.shift); - push(data, (uint32_t)r.offset); - push(data, (uint32_t)r.value); - reloc_size += 11; - } - } - - for (const auto &r : s.intersegs) { - if (r.can_compress()) { - push(data, (uint8_t)0xf6); - push(data, (uint8_t)r.size); - push(data, (uint8_t)r.shift); - push(data, (uint16_t)r.offset); - push(data, (uint8_t)r.segment); - push(data, (uint16_t)r.segment_offset); - reloc_size += 8; - } else { - push(data, (uint8_t)0xe3); - push(data, (uint8_t)r.size); - push(data, (uint8_t)r.shift); - push(data, (uint32_t)r.offset); - push(data, (uint16_t)r.file); - push(data, (uint16_t)r.segment); - push(data, (uint32_t)r.segment_offset); - reloc_size += 15; - } - } -#endif // end-of-record push(data, (uint8_t)omf::END);