mirror of
https://github.com/ksherlock/merlin-utils.git
synced 2025-02-16 13:30:33 +00:00
ORG support.
This commit is contained in:
parent
4a05a8687c
commit
f7d70702f9
5
link.cpp
5
link.cpp
@ -31,7 +31,7 @@
|
|||||||
#include "script.h"
|
#include "script.h"
|
||||||
|
|
||||||
void save_omf(const std::string &path, std::vector<omf::segment> &segments, bool compress, bool expressload);
|
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);
|
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);
|
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());
|
if (verbose) printf("Saving %s\n", path.c_str());
|
||||||
try {
|
try {
|
||||||
if (lkv == 0)
|
if (lkv == 0)
|
||||||
save_bin(path, segments.back(), org);
|
save_bin(path, segments.back());
|
||||||
else
|
else
|
||||||
save_omf(path, segments, compress, express);
|
save_omf(path, segments, compress, express);
|
||||||
|
|
||||||
@ -1205,6 +1205,7 @@ void evaluate(label_t label, opcode_t opcode, const char *cursor) {
|
|||||||
|
|
||||||
case OP_ORG:
|
case OP_ORG:
|
||||||
org = number_operand(cursor, local_symbol_table);
|
org = number_operand(cursor, local_symbol_table);
|
||||||
|
segments.back().org = org;
|
||||||
atype = org;
|
atype = org;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
5
omf.cpp
5
omf.cpp
@ -446,7 +446,7 @@ uint32_t add_relocs(std::vector<uint8_t> &data, size_t data_offset, omf::segment
|
|||||||
return reloc_size;
|
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;
|
int fd;
|
||||||
fd = open(path.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
|
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());
|
err(EX_CANTCREAT, "Unable to open %s", path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t org = segment.org;
|
||||||
auto &data = segment.data;
|
auto &data = segment.data;
|
||||||
|
|
||||||
for (auto &r : segment.relocs) {
|
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.segnum = 0;
|
||||||
h.alignment = s.alignment;
|
h.alignment = s.alignment;
|
||||||
h.reserved_space = s.reserved_space;
|
h.reserved_space = s.reserved_space;
|
||||||
|
h.org = s.org;
|
||||||
|
|
||||||
std::vector<uint8_t> data;
|
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.segnum = s.segnum;
|
||||||
h.alignment = s.alignment;
|
h.alignment = s.alignment;
|
||||||
h.reserved_space = s.reserved_space;
|
h.reserved_space = s.reserved_space;
|
||||||
|
h.org = s.org;
|
||||||
|
|
||||||
uint32_t reserved_space = 0;
|
uint32_t reserved_space = 0;
|
||||||
if (expressload) {
|
if (expressload) {
|
||||||
|
1
omf.h
1
omf.h
@ -66,6 +66,7 @@ namespace omf {
|
|||||||
uint16_t kind = 0;
|
uint16_t kind = 0;
|
||||||
uint32_t alignment = 0;
|
uint32_t alignment = 0;
|
||||||
uint32_t reserved_space = 0;
|
uint32_t reserved_space = 0;
|
||||||
|
uint32_t org = 0;
|
||||||
|
|
||||||
std::string loadname;
|
std::string loadname;
|
||||||
std::string segname;
|
std::string segname;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user