ORG support.

This commit is contained in:
Kelvin Sherlock 2020-11-12 19:24:28 -05:00
parent 4a05a8687c
commit f7d70702f9
3 changed files with 8 additions and 3 deletions

View File

@ -31,7 +31,7 @@
#include "script.h"
void save_omf(const std::string &path, std::vector<omf::segment> &segments, bool compress, bool expressload);
void save_bin(const std::string &path, omf::segment &segment, uint32_t org);
void save_bin(const std::string &path, omf::segment &segment);
int set_file_type(const std::string &path, uint16_t file_type, uint32_t aux_type, std::error_code &ec);
void set_file_type(const std::string &path, uint16_t file_type, uint32_t aux_type);
@ -796,7 +796,7 @@ void finish(void) {
if (verbose) printf("Saving %s\n", path.c_str());
try {
if (lkv == 0)
save_bin(path, segments.back(), org);
save_bin(path, segments.back());
else
save_omf(path, segments, compress, express);
@ -1205,6 +1205,7 @@ void evaluate(label_t label, opcode_t opcode, const char *cursor) {
case OP_ORG:
org = number_operand(cursor, local_symbol_table);
segments.back().org = org;
atype = org;
break;

View File

@ -446,7 +446,7 @@ uint32_t add_relocs(std::vector<uint8_t> &data, size_t data_offset, omf::segment
return reloc_size;
}
void save_bin(const std::string &path, omf::segment &segment, uint32_t org) {
void save_bin(const std::string &path, omf::segment &segment) {
int fd;
fd = open(path.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
@ -454,6 +454,7 @@ void save_bin(const std::string &path, omf::segment &segment, uint32_t org) {
err(EX_CANTCREAT, "Unable to open %s", path.c_str());
}
uint32_t org = segment.org;
auto &data = segment.data;
for (auto &r : segment.relocs) {
@ -494,6 +495,7 @@ void save_object(const std::string &path, omf::segment &s, uint32_t length) {
h.segnum = 0;
h.alignment = s.alignment;
h.reserved_space = s.reserved_space;
h.org = s.org;
std::vector<uint8_t> data;
@ -560,6 +562,7 @@ void save_omf(const std::string &path, std::vector<omf::segment> &segments, bool
h.segnum = s.segnum;
h.alignment = s.alignment;
h.reserved_space = s.reserved_space;
h.org = s.org;
uint32_t reserved_space = 0;
if (expressload) {

1
omf.h
View File

@ -66,6 +66,7 @@ namespace omf {
uint16_t kind = 0;
uint32_t alignment = 0;
uint32_t reserved_space = 0;
uint32_t org = 0;
std::string loadname;
std::string segname;