42 #ifdef WITH_LOADER_ARCH
44 #include "loader/mef.h"
46 struct Area areas[MEF_AREA_MAX];
49 mef_load(
unsigned char* offset)
51 unsigned char* start = offset;
52 unsigned char areasize = load_byte();
57 struct Relocation reloc;
59 for (i = 0; i < areasize; i++) {
60 buf = (
unsigned char *) &areas[i];
61 for (j = 0; j <
sizeof(
struct Area); j++) {
66 for (i = 0; i < areasize; i++) {
67 for (j = 0; j < areas[i].size; j++) {
68 *offset = load_byte();
72 if (areas[i].checksum != checksum) {
78 relocsize = load_byte();
79 relocsize = (load_byte() << 8) + relocsize;
80 for (i = 0; i < relocsize; i++) {
81 buf = (
unsigned char *) &reloc;
82 for (j = 0; j <
sizeof(
struct Relocation); j++) {
85 mef_reloc(start, &reloc);
90 mef_reloc(
unsigned char* offset,
struct Relocation *reloc)
92 if (reloc->mode & MEF_RELOC_ABSOLUTE) {
95 offset += reloc->address;
96 if (reloc->mode & MEF_RELOC_MSB_BYTE) {
97 *offset = (
unsigned char) ((reloc->data + (u16_t) offset) >> 8);
98 }
else if (reloc->mode & MEF_RELOC_LSB_BYTE) {
99 *offset = (
unsigned char) ((reloc->data + (u16_t) offset) & 0xff);
101 *offset++ = (
unsigned char) ((reloc->data + (u16_t) offset) & 0xff);
102 *offset = (
unsigned char) ((reloc->data + (u16_t) offset) >> 8);