static void translate_relocation (struct reloc_entry *reloc, struct aout_relocation_info *input_reloc, struct section_part *part, struct aout_exec *exec_p) {
- unsigned long r_symbolnum = array_to_integer (input_reloc->r_symbolnum, 4);
+ unsigned long r_symbolnum = array_to_integer (input_reloc->r_symbolnum, 4, 0);
- unsigned long r_address = array_to_integer (input_reloc->r_address, 4);
+ unsigned long r_address = array_to_integer (input_reloc->r_address, 4, 0);
long symbolnum = (r_symbolnum & 0xffffff);
if ((r_symbolnum >> 27) & 1) { /* ext */
} else if (symbolnum == N_DATA) {
reloc->symbol = part->of->symbol_arr + part->of->symbol_cnt - 2;
- reloc->addend -= array_to_integer (exec_p->a_text, 4);
+ reloc->addend -= array_to_integer (exec_p->a_text, 4, 0);
} else if (symbolnum == N_BSS) {
reloc->symbol = part->of->symbol_arr + part->of->symbol_cnt - 1;
- reloc->addend -= (array_to_integer (exec_p->a_text, 4) + array_to_integer (exec_p->a_data, 4));
+ reloc->addend -= (array_to_integer (exec_p->a_text, 4, 0) + array_to_integer (exec_p->a_data, 4, 0));
} else {
aout_exec = (struct aout_exec *) pos;
pos += sizeof (*aout_exec);
- num_symbols = array_to_integer (aout_exec->a_syms, 4) / sizeof (*aout_nlist);
+ num_symbols = array_to_integer (aout_exec->a_syms, 4, 0) / sizeof (*aout_nlist);
of = object_file_make (filename, num_symbols + 4);
section = section_find_or_make (".text");
part = section_part_new (section, of);
- part->content_size = array_to_integer (aout_exec->a_text, 4);
+ part->content_size = array_to_integer (aout_exec->a_text, 4, 0);
part->content = xmalloc (part->content_size);
if ((pos - data + part->content_size > data_size) || pos < data) {
part = section_part_new (section, of);
- part->content_size = array_to_integer (aout_exec->a_data, 4);
+ part->content_size = array_to_integer (aout_exec->a_data, 4, 0);
part->content = xmalloc (part->content_size);
if ((pos - data + part->content_size > data_size) || pos < data) {
section->is_bss = 1;
part = section_part_new (section, of);
- part->content_size = array_to_integer (aout_exec->a_bss, 4);
+ part->content_size = array_to_integer (aout_exec->a_bss, 4, 0);
section_append_section_part (section, part);
part_p_array[3] = part;
- pos += array_to_integer (aout_exec->a_syms, 4) + array_to_integer (aout_exec->a_trsize, 4) + array_to_integer (aout_exec->a_drsize, 4);
+ pos += array_to_integer (aout_exec->a_syms, 4, 0) + array_to_integer (aout_exec->a_trsize, 4, 0) + array_to_integer (aout_exec->a_drsize, 4, 0);
if ((unsigned long) (pos - data + 4) > data_size || pos < data) {
}
- strtab_size = array_to_integer (pos, 4);
+ strtab_size = array_to_integer (pos, 4, 0);
if (strtab_size < 4) {
}
- pos -= array_to_integer (aout_exec->a_syms, 4);
+ pos -= array_to_integer (aout_exec->a_syms, 4, 0);
for (i = 0; i < num_symbols; i++) {
aout_nlist = (struct aout_nlist *) (pos + (i * sizeof (*aout_nlist)));
symbol = of->symbol_arr + i;
- if (array_to_integer (aout_nlist->n_strx, 4) < strtab_size) {
- symbol->name = xstrdup (strtab + array_to_integer (aout_nlist->n_strx, 4));
+ if (array_to_integer (aout_nlist->n_strx, 4, 0) < strtab_size) {
+ symbol->name = xstrdup (strtab + array_to_integer (aout_nlist->n_strx, 4, 0));
} else {
report_at (program_name, 0, REPORT_FATAL_ERROR, "%s: invalid offset into string table", filename);
}
- symbol->value = array_to_integer (aout_nlist->n_value, 4);
+ symbol->value = array_to_integer (aout_nlist->n_value, 4, 0);
symbol->size = 0;
symbol->n_type = aout_nlist->n_type;
symbol->section_number = 2;
symbol->part = part_p_array[2];
- symbol->value -= array_to_integer (aout_exec->a_text, 4);
+ symbol->value -= array_to_integer (aout_exec->a_text, 4, 0);
} else if ((aout_nlist->n_type & N_TYPE) == N_BSS) {
symbol->section_number = 3;
symbol->part = part_p_array[3];
- symbol->value -= (array_to_integer (aout_exec->a_text, 4) + array_to_integer (aout_exec->a_data, 4));
+ symbol->value -= (array_to_integer (aout_exec->a_text, 4, 0) + array_to_integer (aout_exec->a_data, 4, 0));
} else {
}
- pos -= (array_to_integer (aout_exec->a_trsize, 4) + array_to_integer (aout_exec->a_drsize, 4));
+ pos -= (array_to_integer (aout_exec->a_trsize, 4, 0) + array_to_integer (aout_exec->a_drsize, 4, 0));
part = part_p_array[1];
- part->reloc_cnt = array_to_integer (aout_exec->a_trsize, 4) / sizeof (*reloc_info);
+ part->reloc_cnt = array_to_integer (aout_exec->a_trsize, 4, 0) / sizeof (*reloc_info);
part->reloc_arr = xmalloc (sizeof (*part->reloc_arr) * part->reloc_cnt);
for (i = 0; i < part->reloc_cnt; i++) {
}
- pos += array_to_integer (aout_exec->a_trsize, 4);
+ pos += array_to_integer (aout_exec->a_trsize, 4, 0);
part = part_p_array[2];
- part->reloc_cnt = array_to_integer (aout_exec->a_drsize, 4) / sizeof (*reloc_info);
+ part->reloc_cnt = array_to_integer (aout_exec->a_drsize, 4, 0) / sizeof (*reloc_info);
part->reloc_arr = xmalloc (sizeof (*part->reloc_arr) * part->reloc_cnt);
for (i = 0; i < part->reloc_cnt; i++) {
symbol = symbol_find (symbol->name);
}
- integer_to_array (part->rva - part->section->rva + part->reloc_arr[i].offset, rel.r_address, 4);
+ integer_to_array (part->rva - part->section->rva + part->reloc_arr[i].offset, rel.r_address, 4, 0);
if (!symbol->part || strcmp (symbol->part->section->name, ".text") == 0) {
r_symbolnum = N_TEXT;
}
- integer_to_array (r_symbolnum | (size_log2 << 25), rel.r_symbolnum, 4);
+ integer_to_array (r_symbolnum | (size_log2 << 25), rel.r_symbolnum, 4, 0);
memcpy (pos, &rel, sizeof (rel));
pos += sizeof (rel);
data_section = section_find (".data");
bss_section = section_find (".bss");
- integer_to_array (OMAGIC, exec.a_info, 4);
+ integer_to_array (OMAGIC, exec.a_info, 4, 0);
if (text_section) {
}
- integer_to_array (text_size, exec.a_text, 4);
- integer_to_array (data_size, exec.a_data, 4);
+ integer_to_array (text_size, exec.a_text, 4, 0);
+ integer_to_array (data_size, exec.a_data, 4, 0);
- integer_to_array (bss_size, exec.a_bss, 4);
- integer_to_array (state->entry_point, exec.a_entry, 4);
+ integer_to_array (bss_size, exec.a_bss, 4, 0);
+ integer_to_array (state->entry_point, exec.a_entry, 4, 0);
if (text_section) {
- integer_to_array (section_get_num_relocs (text_section) * sizeof (struct aout_relocation_info), exec.a_trsize, 4);
+ integer_to_array (section_get_num_relocs (text_section) * sizeof (struct aout_relocation_info), exec.a_trsize, 4, 0);
}
if (data_section) {
- integer_to_array (section_get_num_relocs (data_section) * sizeof (struct aout_relocation_info), exec.a_drsize, 4);
+ integer_to_array (section_get_num_relocs (data_section) * sizeof (struct aout_relocation_info), exec.a_drsize, 4, 0);
}
image_size = sizeof (exec);
- image_size += (array_to_integer (exec.a_text, 4) + array_to_integer (exec.a_data, 4));
- image_size += (array_to_integer (exec.a_trsize, 4) + array_to_integer (exec.a_drsize, 4));
+ image_size += (array_to_integer (exec.a_text, 4, 0) + array_to_integer (exec.a_data, 4, 0));
+ image_size += (array_to_integer (exec.a_trsize, 4, 0) + array_to_integer (exec.a_drsize, 4, 0));
image_size += 4;
section_write (text_section, pos);
}
- pos += array_to_integer (exec.a_text, 4);
+ pos += array_to_integer (exec.a_text, 4, 0);
if (data_section) {
section_write (data_section, pos);
}
- pos += array_to_integer (exec.a_data, 4);
+ pos += array_to_integer (exec.a_data, 4, 0);
if (text_section) {
pos = write_relocs_for_section (pos, text_section);
pos = write_relocs_for_section (pos, data_section);
}
- integer_to_array (4, pos, 4);
+ integer_to_array (4, pos, 4, 0);
if (fwrite (data, image_size, 1, fp) != 1) {
report_at (program_name, 0, REPORT_ERROR, "failed to write data to '%s'", filename);
static void translate_relocation (struct reloc_entry *reloc, struct coff_relocation_entry *input, struct section_part *part) {
- reloc->symbol = part->of->symbol_arr + array_to_integer (input->SymbolTableIndex, 4);
- reloc->offset = array_to_integer (input->VirtualAddress, 4);
+ reloc->symbol = part->of->symbol_arr + array_to_integer (input->SymbolTableIndex, 4, 0);
+ reloc->offset = array_to_integer (input->VirtualAddress, 4, 0);
- switch (array_to_integer (input->Type, 2)) {
+ switch (array_to_integer (input->Type, 2, 0)) {
case IMAGE_REL_I386_ABSOLUTE:
default:
/* There is no point in continuing, the object is broken. */
- report_at (program_name, 0, REPORT_FATAL_ERROR, "invalid relocation type 0x%04hx (origin object '%s')", array_to_integer (input->Type, 2), part->of->filename);
+ report_at (program_name, 0, REPORT_FATAL_ERROR, "invalid relocation type 0x%04hx (origin object '%s')", array_to_integer (input->Type, 2, 0), part->of->filename);
exit (EXIT_FAILURE);
}
coff_hdr = (struct coff_header *) data;
- pos = (unsigned char *) data + array_to_integer (coff_hdr->PointerToSymbolTable, 4) + sizeof (struct symbol_table_entry) * array_to_integer (coff_hdr->NumberOfSymbols, 4);
+ pos = (unsigned char *) data + array_to_integer (coff_hdr->PointerToSymbolTable, 4, 0) + sizeof (struct symbol_table_entry) * array_to_integer (coff_hdr->NumberOfSymbols, 4, 0);
string_table_hdr = (struct string_table_header *) pos;
- if ((string_table_size = array_to_integer (string_table_hdr->StringTableSize, 4)) < 4) {
+ if ((string_table_size = array_to_integer (string_table_hdr->StringTableSize, 4, 0)) < 4) {
report_at (program_name, 0, REPORT_ERROR, "%s: invalid string table size: %lu", filename, string_table_size);
return;
string_table = (char *) pos;
- part_p_array = xmalloc (sizeof (*part_p_array) * (array_to_integer (coff_hdr->NumberOfSections, 2) + 1));
- of = object_file_make (filename, array_to_integer (coff_hdr->NumberOfSymbols, 4));
+ part_p_array = xmalloc (sizeof (*part_p_array) * (array_to_integer (coff_hdr->NumberOfSections, 2, 0) + 1));
+ of = object_file_make (filename, array_to_integer (coff_hdr->NumberOfSymbols, 4, 0));
- no_sections = array_to_integer (coff_hdr->NumberOfSections, 2);
+ no_sections = array_to_integer (coff_hdr->NumberOfSections, 2, 0);
for (i = 0; i < no_sections; i++) {
unsigned long offset = strtoul (section_name + 1, NULL, 10);
- if (offset < array_to_integer (string_table_hdr->StringTableSize, 4)) {
+ if (offset < array_to_integer (string_table_hdr->StringTableSize, 4, 0)) {
free (section_name);
section_name = xstrdup (string_table + offset);
if (state->format == LD_FORMAT_I386_PE && strcmp (section_name, ".drectve") == 0) {
- pe_interpret_dot_drectve_section (/*filename, data, data_size, */data + array_to_integer (section_hdr->PointerToRawData, 4), array_to_integer (section_hdr->SizeOfRawData, 4));
+ pe_interpret_dot_drectve_section (/*filename, data, data_size, */data + array_to_integer (section_hdr->PointerToRawData, 4, 0), array_to_integer (section_hdr->SizeOfRawData, 4, 0));
part_p_array[i + 1] = 0;
free (section_name);
}
- if (array_to_integer (section_hdr->Characteristics, 4) & IMAGE_SCN_LNK_REMOVE) {
+ if (array_to_integer (section_hdr->Characteristics, 4, 0) & IMAGE_SCN_LNK_REMOVE) {
part_p_array[i + 1] = 0;
}
section = section_find_or_make (section_name);
- section->flags = translate_Characteristics_to_section_flags (array_to_integer (section_hdr->Characteristics, 4));
+ section->flags = translate_Characteristics_to_section_flags (array_to_integer (section_hdr->Characteristics, 4, 0));
- if (array_to_integer (section_hdr->PointerToRawData, 4) == 0 && array_to_integer (section_hdr->SizeOfRawData, 4)) {
+ if (array_to_integer (section_hdr->PointerToRawData, 4, 0) == 0 && array_to_integer (section_hdr->SizeOfRawData, 4, 0)) {
section->is_bss = 1;
}
free (section_name);
part = section_part_new (section, of);
- part->alignment = translate_Characteristics_to_alignment (array_to_integer (section_hdr->Characteristics, 4));
- part->content_size = array_to_integer (section_hdr->SizeOfRawData, 4);
+ part->alignment = translate_Characteristics_to_alignment (array_to_integer (section_hdr->Characteristics, 4, 0));
+ part->content_size = array_to_integer (section_hdr->SizeOfRawData, 4, 0);
- if (array_to_integer (section_hdr->PointerToRawData, 4)) {
+ if (array_to_integer (section_hdr->PointerToRawData, 4, 0)) {
- pos = (unsigned char *) data + array_to_integer (section_hdr->PointerToRawData, 4);
+ pos = (unsigned char *) data + array_to_integer (section_hdr->PointerToRawData, 4, 0);
part->content = xmalloc (part->content_size);
memcpy (part->content, pos, part->content_size);
}
- if (array_to_integer (section_hdr->PointerToRelocations, 4) && array_to_integer (section_hdr->NumberOfRelocations, 2)) {
+ if (array_to_integer (section_hdr->PointerToRelocations, 4, 0) && array_to_integer (section_hdr->NumberOfRelocations, 2, 0)) {
unsigned long j, no_relocs;
- if (!array_to_integer (section_hdr->PointerToRawData, 4)) {
+ if (!array_to_integer (section_hdr->PointerToRawData, 4, 0)) {
report_at (program_name, 0, REPORT_FATAL_ERROR, "%s: section '%s' is BSS but has relocations", filename, section->name);
exit (EXIT_FAILURE);
}
- pos = (unsigned char *) data + array_to_integer (section_hdr->PointerToRelocations, 4);
+ pos = (unsigned char *) data + array_to_integer (section_hdr->PointerToRelocations, 4, 0);
- part->reloc_arr = xmalloc (sizeof (struct reloc_entry) * array_to_integer (section_hdr->NumberOfRelocations, 2));
- part->reloc_cnt = array_to_integer (section_hdr->NumberOfRelocations, 2);
+ part->reloc_arr = xmalloc (sizeof (struct reloc_entry) * array_to_integer (section_hdr->NumberOfRelocations, 2, 0));
+ part->reloc_cnt = array_to_integer (section_hdr->NumberOfRelocations, 2, 0);
- no_relocs = array_to_integer (section_hdr->NumberOfRelocations, 2);
+ no_relocs = array_to_integer (section_hdr->NumberOfRelocations, 2, 0);
for (j = 0; j < no_relocs; j++) {
}
- no_syms = array_to_integer (coff_hdr->NumberOfSymbols, 4);
+ no_syms = array_to_integer (coff_hdr->NumberOfSymbols, 4, 0);
for (i = 0; i < no_syms; i++) {
struct symbol_table_entry *coff_symbol;
short section_no, no_sections;
- coff_symbol = (struct symbol_table_entry *) ((unsigned char *) data + array_to_integer (coff_hdr->PointerToSymbolTable, 4) + sizeof (struct symbol_table_entry) * i);
+ coff_symbol = (struct symbol_table_entry *) ((unsigned char *) data + array_to_integer (coff_hdr->PointerToSymbolTable, 4, 0) + sizeof (struct symbol_table_entry) * i);
if (memcmp (coff_symbol->Name, "\0\0\0\0", 4) == 0) {
- unsigned long offset = array_to_integer (coff_symbol->Name + 4, 4);
+ unsigned long offset = array_to_integer (coff_symbol->Name + 4, 4, 0);
- if (offset < array_to_integer (string_table_hdr->StringTableSize, 4)) {
+ if (offset < array_to_integer (string_table_hdr->StringTableSize, 4, 0)) {
symbol->name = xstrdup (string_table + offset);
} else {
symbol->name = xstrndup ((char *) coff_symbol->Name, 8);
}
- section_no = array_to_integer (coff_symbol->SectionNumber, 2);
+ section_no = array_to_integer (coff_symbol->SectionNumber, 2, 0);
- symbol->value = array_to_integer (coff_symbol->value, 4);
+ symbol->value = array_to_integer (coff_symbol->value, 4, 0);
symbol->size = 0;
symbol->section_number = section_no;
- no_sections = array_to_integer (coff_hdr->NumberOfSections, 2);
+ no_sections = array_to_integer (coff_hdr->NumberOfSections, 2, 0);
if (section_no == IMAGE_SYM_UNDEFINED) {
bss_section->flags = translate_Characteristics_to_section_flags (IMAGE_SCN_CNT_UNINITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE);
bss_section->is_bss = 1;
- bss_section_number = array_to_integer (coff_hdr->NumberOfSections, 2) ? array_to_integer (coff_hdr->NumberOfSections, 2) : 1;
+ bss_section_number = array_to_integer (coff_hdr->NumberOfSections, 2, 0) ? array_to_integer (coff_hdr->NumberOfSections, 2, 0) : 1;
}
for (i = ((part == saved_part) ? saved_i : 0); i < part->reloc_cnt; i++) {
- integer_to_array (part->rva + relocs[i].offset, ibr_hdr_p->VirtualAddress, 4);
+ integer_to_array (part->rva + relocs[i].offset, ibr_hdr_p->VirtualAddress, 4, 0);
if (relocs[i].howto == &reloc_howtos[RELOC_TYPE_16]) {
- integer_to_array (IMAGE_REL_I386_DIR16, ibr_hdr_p->Type, 2);
+ integer_to_array (IMAGE_REL_I386_DIR16, ibr_hdr_p->Type, 2, 0);
} else if (relocs[i].howto == &reloc_howtos[RELOC_TYPE_32]) {
- integer_to_array (IMAGE_REL_I386_DIR32, ibr_hdr_p->Type, 2);
+ integer_to_array (IMAGE_REL_I386_DIR32, ibr_hdr_p->Type, 2, 0);
} else {
continue;
}
write741_to_byte_array (hdr->SizeOfRawData, section->total_size);
write741_to_byte_array (hdr->PointerToRawData, pos - data);
- if (array_to_integer (hdr->NumberOfRelocations, 2) > 0) {
+ if (array_to_integer (hdr->NumberOfRelocations, 2, 0) > 0) {
write741_to_byte_array (hdr->PointerToRelocations, (pos - data) + section->total_size);
}
section_write (section, pos);
- pos += (section->total_size + (array_to_integer (hdr->NumberOfRelocations, 2) * sizeof (struct coff_relocation_entry)));
+ pos += (section->total_size + (array_to_integer (hdr->NumberOfRelocations, 2, 0) * sizeof (struct coff_relocation_entry)));
}
if (characteristics & IMAGE_SCN_CNT_CODE) {
if (!base_of_code) {
- base_of_code = array_to_integer (hdr->VirtualAddress, 4);
+ base_of_code = array_to_integer (hdr->VirtualAddress, 4, 0);
}
- size_of_code += array_to_integer (hdr->VirtualSize, 4);
+ size_of_code += array_to_integer (hdr->VirtualSize, 4, 0);
} else if (characteristics & IMAGE_SCN_CNT_INITIALIZED_DATA) {
if (!base_of_data) {
- base_of_data = array_to_integer (hdr->VirtualAddress, 4);
+ base_of_data = array_to_integer (hdr->VirtualAddress, 4, 0);
}
- size_of_initialized_data += array_to_integer (hdr->VirtualSize, 4);
+ size_of_initialized_data += array_to_integer (hdr->VirtualSize, 4, 0);
} else if (characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA) {
- size_of_uninitialized_data += array_to_integer (hdr->VirtualSize, 4);
+ size_of_uninitialized_data += array_to_integer (hdr->VirtualSize, 4, 0);
}
last_section = section;
continue;
}
- if (num_relocs && part->rva + relocs[i].offset < array_to_integer (ibr_hdr.VirtualAddress, 4)) {
+ if (num_relocs && part->rva + relocs[i].offset < array_to_integer (ibr_hdr.VirtualAddress, 4, 0)) {
generate_base_relocation_block (section, &ibr_hdr, num_relocs, saved_section, saved_part, saved_i);
num_relocs = 0;
if (num_relocs == 0) {
- integer_to_array (part->rva + relocs[i].offset, ibr_hdr.VirtualAddress, 4);
+ integer_to_array (part->rva + relocs[i].offset, ibr_hdr.VirtualAddress, 4, 0);
saved_section = section;
saved_part = part;
generate_base_relocation_block (section, &ibr_hdr, num_relocs, saved_section, saved_part, saved_i);
}
- integer_to_array (num_relocs, hdr->NumberOfRelocations, 2);
+ integer_to_array (num_relocs, hdr->NumberOfRelocations, 2, 0);
}
data_size += section->total_size;
if ((sec_ent = section->object_dependent_data)) {
- data_size += (array_to_integer (sec_ent->NumberOfRelocations, 2) * sizeof (struct coff_relocation_entry));
+ data_size += (array_to_integer (sec_ent->NumberOfRelocations, 2, 0) * sizeof (struct coff_relocation_entry));
}
}
static void translate_relocation (struct reloc_entry *reloc, struct elks_relocation_info *input_reloc, struct section_part *part, struct elks_exec *exec_p) {
- unsigned long r_symbolnum = array_to_integer (input_reloc->r_symbolnum, 4);
+ unsigned long r_symbolnum = array_to_integer (input_reloc->r_symbolnum, 4, 0);
- unsigned long r_address = array_to_integer (input_reloc->r_address, 4);
+ unsigned long r_address = array_to_integer (input_reloc->r_address, 4, 0);
long symbolnum = (r_symbolnum & 0x7ffffff);
if ((r_symbolnum >> 31) & 1) { /* ext */
} else if (symbolnum == N_DATA) {
reloc->symbol = part->of->symbol_arr + part->of->symbol_cnt - 2;
- reloc->addend -= array_to_integer (exec_p->a_text, 4);
+ reloc->addend -= array_to_integer (exec_p->a_text, 4, 0);
} else if (symbolnum == N_BSS) {
reloc->symbol = part->of->symbol_arr + part->of->symbol_cnt - 1;
- reloc->addend -= (array_to_integer (exec_p->a_text, 4) + array_to_integer (exec_p->a_data, 4));
+ reloc->addend -= (array_to_integer (exec_p->a_text, 4, 0) + array_to_integer (exec_p->a_data, 4, 0));
} else {
elks_exec = (struct elks_exec *) pos;
pos += sizeof (*elks_exec);
- num_symbols = array_to_integer (elks_exec->a_syms, 4) / sizeof (*elks_nlist);
+ num_symbols = array_to_integer (elks_exec->a_syms, 4, 0) / sizeof (*elks_nlist);
of = object_file_make (filename, num_symbols + 4);
section = section_find_or_make (".text");
part = section_part_new (section, of);
- part->content_size = array_to_integer (elks_exec->a_text, 4);
+ part->content_size = array_to_integer (elks_exec->a_text, 4, 0);
part->content = xmalloc (part->content_size);
if ((pos - data + part->content_size > data_size) || pos < data) {
part = section_part_new (section, of);
- part->content_size = array_to_integer (elks_exec->a_data, 4);
+ part->content_size = array_to_integer (elks_exec->a_data, 4, 0);
part->content = xmalloc (part->content_size);
if ((pos - data + part->content_size > data_size) || pos < data) {
section->is_bss = 1;
part = section_part_new (section, of);
- part->content_size = array_to_integer (elks_exec->a_bss, 4);
+ part->content_size = array_to_integer (elks_exec->a_bss, 4, 0);
section_append_section_part (section, part);
part_p_array[3] = part;
- pos += array_to_integer (elks_exec->a_syms, 4) + array_to_integer (elks_exec->a_trsize, 4) + array_to_integer (elks_exec->a_drsize, 4);
+ pos += array_to_integer (elks_exec->a_syms, 4, 0) + array_to_integer (elks_exec->a_trsize, 4, 0) + array_to_integer (elks_exec->a_drsize, 4, 0);
if ((unsigned long) (pos - data + 4) > data_size || pos < data) {
}
- strtab_size = array_to_integer (pos, 4);
+ strtab_size = array_to_integer (pos, 4, 0);
if (strtab_size < 4) {
}
- pos -= array_to_integer (elks_exec->a_syms, 4);
+ pos -= array_to_integer (elks_exec->a_syms, 4, 0);
for (i = 0; i < num_symbols; i++) {
elks_nlist = (struct elks_nlist *) (pos + (i * sizeof (*elks_nlist)));
symbol = of->symbol_arr + i;
- if (array_to_integer (elks_nlist->n_strx, 4) < strtab_size) {
- symbol->name = xstrdup (strtab + array_to_integer (elks_nlist->n_strx, 4));
+ if (array_to_integer (elks_nlist->n_strx, 4, 0) < strtab_size) {
+ symbol->name = xstrdup (strtab + array_to_integer (elks_nlist->n_strx, 4, 0));
} else {
report_at (program_name, 0, REPORT_FATAL_ERROR, "%s: invalid offset into string table", filename);
}
- symbol->value = array_to_integer (elks_nlist->n_value, 4);
+ symbol->value = array_to_integer (elks_nlist->n_value, 4, 0);
symbol->size = 0;
symbol->n_type = elks_nlist->n_type;
symbol->section_number = 2;
symbol->part = part_p_array[2];
- symbol->value -= array_to_integer (elks_exec->a_text, 4);
+ symbol->value -= array_to_integer (elks_exec->a_text, 4, 0);
} else if ((elks_nlist->n_type & N_TYPE) == N_BSS) {
symbol->section_number = 3;
symbol->part = part_p_array[3];
- symbol->value -= (array_to_integer (elks_exec->a_text, 4) + array_to_integer (elks_exec->a_data, 4));
+ symbol->value -= (array_to_integer (elks_exec->a_text, 4, 0) + array_to_integer (elks_exec->a_data, 4, 0));
} else {
}
- pos -= (array_to_integer (elks_exec->a_trsize, 4) + array_to_integer (elks_exec->a_drsize, 4));
+ pos -= (array_to_integer (elks_exec->a_trsize, 4, 0) + array_to_integer (elks_exec->a_drsize, 4, 0));
part = part_p_array[1];
- part->reloc_cnt = array_to_integer (elks_exec->a_trsize, 4) / sizeof (*reloc_info);
+ part->reloc_cnt = array_to_integer (elks_exec->a_trsize, 4, 0) / sizeof (*reloc_info);
part->reloc_arr = xmalloc (sizeof (*part->reloc_arr) * part->reloc_cnt);
for (i = 0; i < part->reloc_cnt; i++) {
}
- pos += array_to_integer (elks_exec->a_trsize, 4);
+ pos += array_to_integer (elks_exec->a_trsize, 4, 0);
part = part_p_array[2];
- part->reloc_cnt = array_to_integer (elks_exec->a_drsize, 4) / sizeof (*reloc_info);
+ part->reloc_cnt = array_to_integer (elks_exec->a_drsize, 4, 0) / sizeof (*reloc_info);
part->reloc_arr = xmalloc (sizeof (*part->reloc_arr) * part->reloc_cnt);
for (i = 0; i < part->reloc_cnt; i++) {
symbol = symbol_find (symbol->name);
}
- integer_to_array (part->rva - part->section->rva + part->reloc_arr[i].offset, rel.r_address, 4);
+ integer_to_array (part->rva - part->section->rva + part->reloc_arr[i].offset, rel.r_address, 4, 0);
if (!symbol->part || strcmp (symbol->part->section->name, ".text") == 0) {
r_symbolnum = N_TEXT;
r_symbolnum |= (1LU << 27);
}
- integer_to_array (r_symbolnum | (size_log2 << 25), rel.r_symbolnum, 4);
+ integer_to_array (r_symbolnum | (size_log2 << 25), rel.r_symbolnum, 4, 0);
memcpy (pos, &rel, sizeof (rel));
pos += sizeof (rel);
data_section = section_find (".data");
bss_section = section_find (".bss");
- integer_to_array (ELKS_MAGIC, exec.a_magic, 4);
+ integer_to_array (ELKS_MAGIC, exec.a_magic, 4, 0);
exec.a_flags = 0x10;
exec.a_cpu = (state->format == LD_FORMAT_I386_ELKS) ? 0x10 : 0x04;
}
- integer_to_array (text_size, exec.a_text, 4);
- integer_to_array (data_size, exec.a_data, 4);
+ integer_to_array (text_size, exec.a_text, 4, 0);
+ integer_to_array (data_size, exec.a_data, 4, 0);
- integer_to_array (bss_size, exec.a_bss, 4);
- integer_to_array (state->entry_point, exec.a_entry, 4);
+ integer_to_array (bss_size, exec.a_bss, 4, 0);
+ integer_to_array (state->entry_point, exec.a_entry, 4, 0);
- integer_to_array (array_to_integer (exec.a_text, 4) + array_to_integer (exec.a_data, 4), exec.a_total, 4);
+ integer_to_array (array_to_integer (exec.a_text, 4, 0) + array_to_integer (exec.a_data, 4, 0), exec.a_total, 4, 0);
if (text_section) {
- integer_to_array (section_get_num_relocs (text_section) * sizeof (struct elks_relocation_info), exec.a_trsize, 4);
+ integer_to_array (section_get_num_relocs (text_section) * sizeof (struct elks_relocation_info), exec.a_trsize, 4, 0);
}
if (data_section) {
- integer_to_array (section_get_num_relocs (data_section) * sizeof (struct elks_relocation_info), exec.a_drsize, 4);
+ integer_to_array (section_get_num_relocs (data_section) * sizeof (struct elks_relocation_info), exec.a_drsize, 4, 0);
}
image_size = sizeof (exec);
- image_size += (array_to_integer (exec.a_text, 4) + array_to_integer (exec.a_data, 4));
- image_size += (array_to_integer (exec.a_trsize, 4) + array_to_integer (exec.a_drsize, 4));
+ image_size += (array_to_integer (exec.a_text, 4, 0) + array_to_integer (exec.a_data, 4, 0));
+ image_size += (array_to_integer (exec.a_trsize, 4, 0) + array_to_integer (exec.a_drsize, 4, 0));
image_size += 4;
section_write (text_section, pos);
}
- pos += array_to_integer (exec.a_text, 4);
+ pos += array_to_integer (exec.a_text, 4, 0);
if (data_section) {
section_write (data_section, pos);
}
- pos += array_to_integer (exec.a_data, 4);
+ pos += array_to_integer (exec.a_data, 4, 0);
if (text_section) {
pos = write_relocs_for_section (pos, text_section);
pos = write_relocs_for_section (pos, data_section);
}
- integer_to_array (4, pos, 4);
+ integer_to_array (4, pos, 4, 0);
if (fwrite (data, image_size, 1, fp) != 1) {
report_at (program_name, 0, REPORT_ERROR, "failed to write data to '%s'", filename);
free (name);
pos += sizeof (*hdr);
- no_symbols = byte_array_to_integer (pos, 4, 1);
+ no_symbols = array_to_integer (pos, 4, 1);
pos += 4;
offset_name_table = xmalloc (sizeof (*offset_name_table) * no_symbols);
for (i = 0; i < no_symbols; i++) {
- offset_name_table[i].offset = byte_array_to_integer (pos, 4, 1);
+ offset_name_table[i].offset = array_to_integer (pos, 4, 1);
offset_name_table[i].name = (char *) string_table_pos;
string_table_pos += strlen (offset_name_table[i].name) + 1;
}
-unsigned long array_to_integer (unsigned char *arr, int size) {
+unsigned long array_to_integer (unsigned char *arr, int size, int big_endian) {
unsigned long value = 0;
int i;
- for (i = 0; i < size; i++) {
- value |= (unsigned long) arr[i] << (CHAR_BIT * i);
- }
-
- return value;
-
-}
-
-unsigned long byte_array_to_integer (unsigned char *arr, int size, int big_endian) {
-
if (big_endian) {
- unsigned long value = 0;
- int i, j;
+ int j;
for (i = size, j = 0; i > 0; i--, j++) {
value |= (unsigned long) arr[j] << (CHAR_BIT * (i - 1));
}
-
- return value;
- }
+ } else {
- return array_to_integer (arr, size);
-
-}
-
-void integer_to_array (unsigned long value, unsigned char *dest, int size) {
-
- int i;
+ for (i = 0; i < size; i++) {
+ value |= (unsigned long) arr[i] << (CHAR_BIT * i);
+ }
- for (i = 0; i < size; i++) {
- dest[i] = (value >> (CHAR_BIT * i)) & UCHAR_MAX;
}
+
+ return value;
}
-void integer_to_byte_array (unsigned long value, unsigned char *dest, int size, int big_endian) {
+void integer_to_array (unsigned long value, unsigned char *dest, int size, int big_endian) {
if (big_endian) {
#define LD_OPTION_NO_ARG 0
#define LD_OPTION_HAS_ARG 1
-unsigned long array_to_integer (unsigned char *arr, int size);
-unsigned long byte_array_to_integer (unsigned char *arr, int size, int big_endian);
-
-void integer_to_array (unsigned long value, unsigned char *dest, int size);
-void integer_to_byte_array (unsigned long value, unsigned char *dest, int size, int big_endian);
+unsigned long array_to_integer (unsigned char *arr, int size, int big_endian);
+void integer_to_array (unsigned long value, unsigned char *dest, int size, int big_endian);
int xstrcasecmp (const char *__s1, const char *__s2);
continue;
}
- integer_to_array (symbol_get_value_no_base (symbol), part->content + pos, 4);
+ integer_to_array (symbol_get_value_no_base (symbol), part->content + pos, 4, 0);
pos += 4;
- integer_to_array (offset, part->content + pos, 4);
+ integer_to_array (offset, part->content + pos, 4, 0);
pos += 4;
offset += strlen (symbol->name) + 1;
case 8: {
- result = array_to_integer (part->content + offset, 8);
+ result = array_to_integer (part->content + offset, 8, 0);
break;
}
case 4: {
- result = array_to_integer (part->content + offset, 4);
+ result = array_to_integer (part->content + offset, 4, 0);
break;
}
case 3: {
- result = array_to_integer (part->content + offset, 3);
+ result = array_to_integer (part->content + offset, 3, 0);
break;
}
case 2: {
- result = array_to_integer (part->content + offset, 2);
+ result = array_to_integer (part->content + offset, 2, 0);
break;
}
case 1: {
- result = array_to_integer (part->content + offset, 1);
+ result = array_to_integer (part->content + offset, 1, 0);
break;
}
case 8: {
- integer_to_array (result, part->content + offset, 8);
+ integer_to_array (result, part->content + offset, 8, 0);
break;
}
case 4: {
- integer_to_array (result, part->content + offset, 4);
+ integer_to_array (result, part->content + offset, 4, 0);
break;
}
case 3: {
- integer_to_array (result, part->content + offset, 3);
+ integer_to_array (result, part->content + offset, 3, 0);
break;
}
case 2: {
- integer_to_array (result, part->content + offset, 2);
+ integer_to_array (result, part->content + offset, 2, 0);
break;
}
case 1: {
- integer_to_array (result, part->content + offset, 1);
+ integer_to_array (result, part->content + offset, 1, 0);
break;
}
addr = part->rva + part->reloc_arr[i].offset;
- integer_to_array (addr % 65536, pos, 2);
+ integer_to_array (addr % 65536, pos, 2, 0);
pos += 2;
- integer_to_array (addr / 65536, pos, 2);
+ integer_to_array (addr / 65536, pos, 2, 0);
pos += 2;
}
big_fields = record_type & 1;
record_type &= ~1;
- record_len = array_to_integer (pos + 1, 2);
+ record_len = array_to_integer (pos + 1, 2, 0);
{
big_fields = record_type & 1;
record_type &= ~1;
- record_len = array_to_integer (pos + 1, 2);
+ record_len = array_to_integer (pos + 1, 2, 0);
pos += 3;
if (record_type == RECORD_TYPE_THEADR) {
pubdef_name_len = pubdef_name[prefix - 1];
if (big_fields) {
- public_offset = array_to_integer (pubdef_name + prefix + pubdef_name_len, 4);
+ public_offset = array_to_integer (pubdef_name + prefix + pubdef_name_len, 4, 0);
} else {
- public_offset = array_to_integer (pubdef_name + prefix + pubdef_name_len, 2);
+ public_offset = array_to_integer (pubdef_name + prefix + pubdef_name_len, 2, 0);
}
symbol = of->symbol_arr + i_pubdefs++;
if (big_fields) {
- segment_len = array_to_integer (pos + 1, 4);
+ segment_len = array_to_integer (pos + 1, 4, 0);
segment_name_index = pos[5];
class_name_index = pos[6];
} else {
- segment_len = array_to_integer (pos + 1, 2);
+ segment_len = array_to_integer (pos + 1, 2, 0);
segment_name_index = pos[3];
class_name_index = pos[4];
if (big_fields) {
- offset = array_to_integer (pos + 1, 4);
+ offset = array_to_integer (pos + 1, 4, 0);
size = record_len - 6;
data_bytes = pos + 5;
} else {
- offset = array_to_integer (pos + 1, 2);
+ offset = array_to_integer (pos + 1, 2, 0);
size = record_len - 4;
data_bytes = pos + 3;
struct section *section;
struct section_part *part;
- integer_to_array (ALIGN (sizeof (*ibr_hdr_p) + num_relocs * 2, 4), ibr_hdr_p->SizeOfBlock, 4);
+ integer_to_array (ALIGN (sizeof (*ibr_hdr_p) + num_relocs * 2, 4), ibr_hdr_p->SizeOfBlock, 4, 0);
reloc_part = section_part_new (reloc_section, object_file_make (FAKE_LD_FILENAME, 0));
- reloc_part->content_size = array_to_integer (ibr_hdr_p->SizeOfBlock, 4);
+ reloc_part->content_size = array_to_integer (ibr_hdr_p->SizeOfBlock, 4, 0);
reloc_part->content = xmalloc (reloc_part->content_size);
reloc_part->content[reloc_part->content_size - 2] = reloc_part->content[reloc_part->content_size - 1] = 0;
continue;
}
- if (part->rva + relocs[i].offset < array_to_integer (ibr_hdr_p->RVAOfBlock, 4)) {
+ if (part->rva + relocs[i].offset < array_to_integer (ibr_hdr_p->RVAOfBlock, 4, 0)) {
continue;
}
- rel_word = (part->rva + relocs[i].offset - array_to_integer (ibr_hdr_p->RVAOfBlock, 4)) & 0xfff;
+ rel_word = (part->rva + relocs[i].offset - array_to_integer (ibr_hdr_p->RVAOfBlock, 4, 0)) & 0xfff;
rel_word |= base_relocation_type << 12;
- integer_to_array (rel_word, write_pos, 2);
+ integer_to_array (rel_word, write_pos, 2, 0);
write_pos += 2;
if (!--num_relocs) {
if (characteristics & IMAGE_SCN_CNT_CODE) {
if (!base_of_code) {
- base_of_code = array_to_integer (hdr->VirtualAddress, 4);
+ base_of_code = array_to_integer (hdr->VirtualAddress, 4, 0);
}
- size_of_code += array_to_integer (hdr->VirtualSize, 4);
+ size_of_code += array_to_integer (hdr->VirtualSize, 4, 0);
} else if (characteristics & IMAGE_SCN_CNT_INITIALIZED_DATA) {
if (!base_of_data) {
- base_of_data = array_to_integer (hdr->VirtualAddress, 4);
+ base_of_data = array_to_integer (hdr->VirtualAddress, 4, 0);
}
- size_of_initialized_data += array_to_integer (hdr->VirtualSize, 4);
+ size_of_initialized_data += array_to_integer (hdr->VirtualSize, 4, 0);
} else if (characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA) {
- size_of_uninitialized_data += array_to_integer (hdr->VirtualSize, 4);
+ size_of_uninitialized_data += array_to_integer (hdr->VirtualSize, 4, 0);
}
last_section = section;
length += sizeof (g_Data2) + (sizeof (struct data_entry) * 3);
length += module_name_length + 1;
- integer_to_array (IMAGE_FILE_MACHINE_I386, data_descriptor.Architecture, 2);
- integer_to_array (3, data_descriptor.a, 2);
- integer_to_array (0, data_descriptor.Id, 4);
- integer_to_array (length, data_descriptor.Length, 4);
- integer_to_array (8, data_descriptor.b, 4);
- integer_to_array (0x1000000, data_descriptor.Flags, 4);
+ integer_to_array (IMAGE_FILE_MACHINE_I386, data_descriptor.Architecture, 2, 0);
+ integer_to_array (3, data_descriptor.a, 2, 0);
+ integer_to_array (0, data_descriptor.Id, 4, 0);
+ integer_to_array (length, data_descriptor.Length, 4, 0);
+ integer_to_array (8, data_descriptor.b, 4, 0);
+ integer_to_array (0x1000000, data_descriptor.Flags, 4, 0);
offset2 += write_data (outfile, &data_descriptor, sizeof (data_descriptor));
memset (§ion_descriptor_long, 0, sizeof (section_descriptor_long));
strcpy ((char *) section_descriptor_long.SectionName, ".debug$S");
- integer_to_array (length, section_descriptor_long.Length, 4);
- integer_to_array (offset3, section_descriptor_long.Offset, 4);
- integer_to_array (0x42100040, section_descriptor_long.b, 4);
+ integer_to_array (length, section_descriptor_long.Length, 4, 0);
+ integer_to_array (offset3, section_descriptor_long.Offset, 4, 0);
+ integer_to_array (0x42100040, section_descriptor_long.b, 4, 0);
offset2 += write_data (outfile, §ion_descriptor_long, sizeof (section_descriptor_long));
memset (§ion_descriptor_long, 0, sizeof (section_descriptor_long));
strcpy ((char *) section_descriptor_long.SectionName, ".idata$2");
- integer_to_array (length, section_descriptor_long.Length, 4);
- integer_to_array (offset3, section_descriptor_long.Offset, 4);
- integer_to_array (offset3 + length, section_descriptor_long.AOffset, 4);
- integer_to_array (3, section_descriptor_long.ACount, 4);
- integer_to_array (0xC0300040, section_descriptor_long.b, 4);
+ integer_to_array (length, section_descriptor_long.Length, 4, 0);
+ integer_to_array (offset3, section_descriptor_long.Offset, 4, 0);
+ integer_to_array (offset3 + length, section_descriptor_long.AOffset, 4, 0);
+ integer_to_array (3, section_descriptor_long.ACount, 4, 0);
+ integer_to_array (0xC0300040, section_descriptor_long.b, 4, 0);
offset2 += write_data (outfile, §ion_descriptor_long, sizeof (section_descriptor_long));
memset (§ion_descriptor_long, 0, sizeof (section_descriptor_long));
strcpy ((char *) section_descriptor_long.SectionName, ".idata$6");
- integer_to_array (length, section_descriptor_long.Length, 4);
- integer_to_array (offset3, section_descriptor_long.Offset, 4);
- integer_to_array (0xC0200040, section_descriptor_long.b, 4);
+ integer_to_array (length, section_descriptor_long.Length, 4, 0);
+ integer_to_array (offset3, section_descriptor_long.Offset, 4, 0);
+ integer_to_array (0xC0200040, section_descriptor_long.b, 4, 0);
offset2 += write_data (outfile, §ion_descriptor_long, sizeof (section_descriptor_long));
offset2 += write_data (outfile, g_Data0, sizeof (g_Data0));
offset2 += write_data (outfile, g_Data1, sizeof (g_Data1));
offset2 += write_data (outfile, g_Data2, sizeof (g_Data2));
- integer_to_array (12, data_entry.a, 4);
- integer_to_array (3, data_entry.b, 4);
- integer_to_array (7, data_entry.c, 2);
+ integer_to_array (12, data_entry.a, 4, 0);
+ integer_to_array (3, data_entry.b, 4, 0);
+ integer_to_array (7, data_entry.c, 2, 0);
offset2 += write_data (outfile, &data_entry, sizeof (data_entry));
- integer_to_array (0, data_entry.a, 4);
- integer_to_array (4, data_entry.b, 4);
- integer_to_array (7, data_entry.c, 2);
+ integer_to_array (0, data_entry.a, 4, 0);
+ integer_to_array (4, data_entry.b, 4, 0);
+ integer_to_array (7, data_entry.c, 2, 0);
offset2 += write_data (outfile, &data_entry, sizeof (data_entry));
- integer_to_array (16, data_entry.a, 4);
- integer_to_array (5, data_entry.b, 4);
- integer_to_array (7, data_entry.c, 2);
+ integer_to_array (16, data_entry.a, 4, 0);
+ integer_to_array (5, data_entry.b, 4, 0);
+ integer_to_array (7, data_entry.c, 2, 0);
offset2 += write_data (outfile, &data_entry, sizeof (data_entry));
offset2 += write_data (outfile, module_name, module_name_length + 1);
memset (§ion_descriptor_short, 0, sizeof (section_descriptor_short));
memcpy ((char *) section_descriptor_short.z.SectionName, "@comp.id", 8);
- integer_to_array (0xDD520D, section_descriptor_short.b, 4);
- integer_to_array (0xFFFF, section_descriptor_short.c, 4);
- integer_to_array (3, section_descriptor_short.type, 2);
+ integer_to_array (0xDD520D, section_descriptor_short.b, 4, 0);
+ integer_to_array (0xFFFF, section_descriptor_short.c, 4, 0);
+ integer_to_array (3, section_descriptor_short.type, 2, 0);
offset2 += write_data (outfile, §ion_descriptor_short, sizeof (section_descriptor_short));
offset3 = 4;
memset (§ion_descriptor_short, 0, sizeof (section_descriptor_short));
- integer_to_array (offset3, section_descriptor_short.z.x.Offset, 4);
- integer_to_array (2, section_descriptor_short.c, 4);
- integer_to_array (2, section_descriptor_short.type, 2);
+ integer_to_array (offset3, section_descriptor_short.z.x.Offset, 4, 0);
+ integer_to_array (2, section_descriptor_short.c, 4, 0);
+ integer_to_array (2, section_descriptor_short.type, 2, 0);
offset2 += write_data (outfile, §ion_descriptor_short, sizeof (section_descriptor_short));
memset (§ion_descriptor_short, 0, sizeof (section_descriptor_short));
memcpy ((char *) section_descriptor_short.z.SectionName, ".idata$2", 8);
- integer_to_array (0xC0000040, section_descriptor_short.b, 4);
- integer_to_array (2, section_descriptor_short.c, 4);
- integer_to_array (0x68, section_descriptor_short.type, 2);
+ integer_to_array (0xC0000040, section_descriptor_short.b, 4, 0);
+ integer_to_array (2, section_descriptor_short.c, 4, 0);
+ integer_to_array (0x68, section_descriptor_short.type, 2, 0);
offset2 += write_data (outfile, §ion_descriptor_short, sizeof (section_descriptor_short));
memset (§ion_descriptor_short, 0, sizeof (section_descriptor_short));
memcpy ((char *) section_descriptor_short.z.SectionName, ".idata$6", 8);
- integer_to_array (0, section_descriptor_short.b, 4);
- integer_to_array (3, section_descriptor_short.c, 4);
- integer_to_array (3, section_descriptor_short.type, 2);
+ integer_to_array (0, section_descriptor_short.b, 4, 0);
+ integer_to_array (3, section_descriptor_short.c, 4, 0);
+ integer_to_array (3, section_descriptor_short.type, 2, 0);
offset2 += write_data (outfile, §ion_descriptor_short, sizeof (section_descriptor_short));
memset (§ion_descriptor_short, 0, sizeof (section_descriptor_short));
memcpy ((char *) section_descriptor_short.z.SectionName, ".idata$4", 8);
- integer_to_array (0xC0000040, section_descriptor_short.b, 4);
- integer_to_array (0, section_descriptor_short.c, 4);
- integer_to_array (0x68, section_descriptor_short.type, 2);
+ integer_to_array (0xC0000040, section_descriptor_short.b, 4, 0);
+ integer_to_array (0, section_descriptor_short.c, 4, 0);
+ integer_to_array (0x68, section_descriptor_short.type, 2, 0);
offset2 += write_data (outfile, §ion_descriptor_short, sizeof (section_descriptor_short));
memset (§ion_descriptor_short, 0, sizeof (section_descriptor_short));
memcpy ((char *) section_descriptor_short.z.SectionName, ".idata$5", 8);
- integer_to_array (0xC0000040, section_descriptor_short.b, 4);
- integer_to_array (0, section_descriptor_short.c, 4);
- integer_to_array (0x68, section_descriptor_short.type, 2);
+ integer_to_array (0xC0000040, section_descriptor_short.b, 4, 0);
+ integer_to_array (0, section_descriptor_short.c, 4, 0);
+ integer_to_array (0x68, section_descriptor_short.type, 2, 0);
offset2 += write_data (outfile, §ion_descriptor_short, sizeof (section_descriptor_short));
memset (§ion_descriptor_short, 0, sizeof (section_descriptor_short));
offset3 += info->name_length + 1;
- integer_to_array (offset3, section_descriptor_short.z.x.Offset, 4);
- integer_to_array (0, section_descriptor_short.c, 4);
- integer_to_array (2, section_descriptor_short.type, 2);
+ integer_to_array (offset3, section_descriptor_short.z.x.Offset, 4, 0);
+ integer_to_array (0, section_descriptor_short.c, 4, 0);
+ integer_to_array (2, section_descriptor_short.type, 2, 0);
offset2 += write_data (outfile, §ion_descriptor_short, sizeof (section_descriptor_short));
length += sizeof (g_Data0) + 1 + module_name_length + sizeof (g_Data1);
length += sizeof (g_Data2);
- integer_to_array (IMAGE_FILE_MACHINE_I386, data_descriptor.Architecture, 2);
- integer_to_array (2, data_descriptor.a, 2);
- integer_to_array (0, data_descriptor.Id, 4);
- integer_to_array (length, data_descriptor.Length, 4);
- integer_to_array (2, data_descriptor.b, 4);
- integer_to_array (0x1000000, data_descriptor.Flags, 4);
+ integer_to_array (IMAGE_FILE_MACHINE_I386, data_descriptor.Architecture, 2, 0);
+ integer_to_array (2, data_descriptor.a, 2, 0);
+ integer_to_array (0, data_descriptor.Id, 4, 0);
+ integer_to_array (length, data_descriptor.Length, 4, 0);
+ integer_to_array (2, data_descriptor.b, 4, 0);
+ integer_to_array (0x1000000, data_descriptor.Flags, 4, 0);
offset2 += write_data (outfile, &data_descriptor, sizeof (data_descriptor));
memset (§ion_descriptor_long, 0, sizeof (section_descriptor_long));
strcpy ((char *) section_descriptor_long.SectionName, ".debug$S");
- integer_to_array (length, section_descriptor_long.Length, 4);
- integer_to_array (offset3, section_descriptor_long.Offset, 4);
- integer_to_array (0x42100040, section_descriptor_long.b, 4);
+ integer_to_array (length, section_descriptor_long.Length, 4, 0);
+ integer_to_array (offset3, section_descriptor_long.Offset, 4, 0);
+ integer_to_array (0x42100040, section_descriptor_long.b, 4, 0);
offset2 += write_data (outfile, §ion_descriptor_long, sizeof (section_descriptor_long));
memset (§ion_descriptor_long, 0, sizeof (section_descriptor_long));
strcpy ((char *) section_descriptor_long.SectionName, ".idata$3");
- integer_to_array (length, section_descriptor_long.Length, 4);
- integer_to_array (offset3, section_descriptor_long.Offset, 4);
- integer_to_array (0xC0300040, section_descriptor_long.b, 4);
+ integer_to_array (length, section_descriptor_long.Length, 4, 0);
+ integer_to_array (offset3, section_descriptor_long.Offset, 4, 0);
+ integer_to_array (0xC0300040, section_descriptor_long.b, 4, 0);
offset2 += write_data (outfile, §ion_descriptor_long, sizeof (section_descriptor_long));
offset2 += write_data (outfile, g_Data0, sizeof (g_Data0));
memset (§ion_descriptor_short, 0, sizeof (section_descriptor_short));
memcpy ((char *) section_descriptor_short.z.SectionName, "@comp.id", 8);
- integer_to_array (0xDD520D, section_descriptor_short.b, 4);
- integer_to_array (0xFFFF, section_descriptor_short.c, 4);
- integer_to_array (3, section_descriptor_short.type, 2);
+ integer_to_array (0xDD520D, section_descriptor_short.b, 4, 0);
+ integer_to_array (0xFFFF, section_descriptor_short.c, 4, 0);
+ integer_to_array (3, section_descriptor_short.type, 2, 0);
offset2 += write_data (outfile, §ion_descriptor_short, sizeof (section_descriptor_short));
memset (§ion_descriptor_short, 0, sizeof (section_descriptor_short));
offset3 = 4;
- integer_to_array (offset3, section_descriptor_short.z.x.Offset, 4);
- integer_to_array (2, section_descriptor_short.c, 4);
- integer_to_array (2, section_descriptor_short.type, 2);
+ integer_to_array (offset3, section_descriptor_short.z.x.Offset, 4, 0);
+ integer_to_array (2, section_descriptor_short.c, 4, 0);
+ integer_to_array (2, section_descriptor_short.type, 2, 0);
offset2 += write_data (outfile, §ion_descriptor_short, sizeof (section_descriptor_short));
length = offset3 + (info_list->next->name_length + 1);
length += sizeof (g_Data0) + 1 + module_name_length + sizeof (g_Data1);
length += pad_length + pad_length;
- integer_to_array (IMAGE_FILE_MACHINE_I386, data_descriptor.Architecture, 2);
- integer_to_array (3, data_descriptor.a, 2);
- integer_to_array (0, data_descriptor.Id, 4);
- integer_to_array (length, data_descriptor.Length, 4);
- integer_to_array (2, data_descriptor.b, 4);
- integer_to_array (0x1000000, data_descriptor.Flags, 4);
+ integer_to_array (IMAGE_FILE_MACHINE_I386, data_descriptor.Architecture, 2, 0);
+ integer_to_array (3, data_descriptor.a, 2, 0);
+ integer_to_array (0, data_descriptor.Id, 4, 0);
+ integer_to_array (length, data_descriptor.Length, 4, 0);
+ integer_to_array (2, data_descriptor.b, 4, 0);
+ integer_to_array (0x1000000, data_descriptor.Flags, 4, 0);
offset2 += write_data (outfile, &data_descriptor, sizeof (data_descriptor));
memset (§ion_descriptor_long, 0, sizeof (section_descriptor_long));
strcpy ((char *) section_descriptor_long.SectionName, ".debug$S");
- integer_to_array (length, section_descriptor_long.Length, 4);
- integer_to_array (offset3, section_descriptor_long.Offset, 4);
- integer_to_array (0x42100040, section_descriptor_long.b, 4);
+ integer_to_array (length, section_descriptor_long.Length, 4, 0);
+ integer_to_array (offset3, section_descriptor_long.Offset, 4, 0);
+ integer_to_array (0x42100040, section_descriptor_long.b, 4, 0);
offset2 += write_data (outfile, §ion_descriptor_long, sizeof (section_descriptor_long));
memset (§ion_descriptor_long, 0, sizeof (section_descriptor_long));
strcpy ((char *) section_descriptor_long.SectionName, ".idata$5");
- integer_to_array (length, section_descriptor_long.Length, 4);
- integer_to_array (offset3, section_descriptor_long.Offset, 4);
- integer_to_array (0xC0300040, section_descriptor_long.b, 4);
+ integer_to_array (length, section_descriptor_long.Length, 4, 0);
+ integer_to_array (offset3, section_descriptor_long.Offset, 4, 0);
+ integer_to_array (0xC0300040, section_descriptor_long.b, 4, 0);
offset2 += write_data (outfile, §ion_descriptor_long, sizeof (section_descriptor_long));
memset (§ion_descriptor_long, 0, sizeof (section_descriptor_long));
strcpy ((char *) section_descriptor_long.SectionName, ".idata$4");
- integer_to_array (length, section_descriptor_long.Length, 4);
- integer_to_array (offset3, section_descriptor_long.Offset, 4);
- integer_to_array (0xC0300040, section_descriptor_long.b, 4);
+ integer_to_array (length, section_descriptor_long.Length, 4, 0);
+ integer_to_array (offset3, section_descriptor_long.Offset, 4, 0);
+ integer_to_array (0xC0300040, section_descriptor_long.b, 4, 0);
offset2 += write_data (outfile, §ion_descriptor_long, sizeof (section_descriptor_long));
offset2 += write_data (outfile, g_Data0, sizeof (g_Data0));
memset (§ion_descriptor_short, 0, sizeof (section_descriptor_short));
memcpy ((char *) section_descriptor_short.z.SectionName, "@comp.id", 8);
- integer_to_array (0xDD520D, section_descriptor_short.b, 4);
- integer_to_array (0xFFFF, section_descriptor_short.c, 4);
- integer_to_array (3, section_descriptor_short.type, 2);
+ integer_to_array (0xDD520D, section_descriptor_short.b, 4, 0);
+ integer_to_array (0xFFFF, section_descriptor_short.c, 4, 0);
+ integer_to_array (3, section_descriptor_short.type, 2, 0);
offset2 += write_data (outfile, §ion_descriptor_short, sizeof (section_descriptor_short));
memset (§ion_descriptor_short, 0, sizeof (section_descriptor_short));
offset3 = 4;
- integer_to_array (offset3, section_descriptor_short.z.x.Offset, 4);
- integer_to_array (2, section_descriptor_short.c, 4);
- integer_to_array (2, section_descriptor_short.type, 2);
+ integer_to_array (offset3, section_descriptor_short.z.x.Offset, 4, 0);
+ integer_to_array (2, section_descriptor_short.c, 4, 0);
+ integer_to_array (2, section_descriptor_short.type, 2, 0);
offset2 += write_data (outfile, §ion_descriptor_short, sizeof (section_descriptor_short));
length = offset3 + (info_list->next->next->name_length + 1);
offset2 += write_file_header (outfile, header_name, bHeaderName, sizeof (import_hdr) + 1 + strlen (export_names[i].name) + 1 + module_name_length + 1, 0);
memset (&import_hdr, 0, sizeof (import_hdr));
- integer_to_array (0xFFFF, import_hdr.Magic2, 2);
- integer_to_array (IMAGE_FILE_MACHINE_I386, import_hdr.Machine, 2);
- integer_to_array (1 + strlen (export_names[i].name) + 1 + module_name_length + 1, import_hdr.SizeOfData, 4);
- integer_to_array (ordinal_base + i, import_hdr.OrdinalHint, 2);
+ integer_to_array (0xFFFF, import_hdr.Magic2, 2, 0);
+ integer_to_array (IMAGE_FILE_MACHINE_I386, import_hdr.Machine, 2, 0);
+ integer_to_array (1 + strlen (export_names[i].name) + 1 + module_name_length + 1, import_hdr.SizeOfData, 4, 0);
+ integer_to_array (ordinal_base + i, import_hdr.OrdinalHint, 2, 0);
switch (export_names[i].export_type) {
type |= (kill_at ? IMPORT_NAME_UNDECORATE : IMPORT_NAME_NOPREFIX) << 2;
- integer_to_array (type, import_hdr.Type, 2);
+ integer_to_array (type, import_hdr.Type, 2, 0);
offset2 += write_data (outfile, &import_hdr, sizeof (import_hdr));
name = xmalloc (1 + strlen (export_names[i].name) + 1);
ied = (struct pe_export_directory *) part->content;
memset (ied, 0, sizeof (*ied));
- integer_to_array (name_table_offset, ied->NameRVA, 4);
- integer_to_array (ordinal_base, ied->OrdinalBase, 4);
- integer_to_array (num_names, ied->AddressTableEntries, 4);
- integer_to_array (num_names, ied->NumberOfNamePointers, 4);
- integer_to_array (sizeof (*ied), ied->ExportAddressTableRVA, 4);
+ integer_to_array (name_table_offset, ied->NameRVA, 4, 0);
+ integer_to_array (ordinal_base, ied->OrdinalBase, 4, 0);
+ integer_to_array (num_names, ied->AddressTableEntries, 4, 0);
+ integer_to_array (num_names, ied->NumberOfNamePointers, 4, 0);
+ integer_to_array (sizeof (*ied), ied->ExportAddressTableRVA, 4, 0);
- integer_to_array (array_to_integer (ied->ExportAddressTableRVA, 4) + num_names * 4, ied->NamePointerRVA, 4);
- integer_to_array (array_to_integer (ied->NamePointerRVA, 4) + num_names * 4, ied->OrdinalTableRVA, 4);
+ integer_to_array (array_to_integer (ied->ExportAddressTableRVA, 4, 0) + num_names * 4, ied->NamePointerRVA, 4, 0);
+ integer_to_array (array_to_integer (ied->NamePointerRVA, 4, 0) + num_names * 4, ied->OrdinalTableRVA, 4, 0);
for (i = 0; i < 4; i++) {
symbol_record_external_symbol (symbol);
- relocs[0].offset = array_to_integer (ied->ExportAddressTableRVA, 4) + 4 * i;
+ relocs[0].offset = array_to_integer (ied->ExportAddressTableRVA, 4, 0) + 4 * i;
relocs[0].symbol = symbol;
relocs[0].howto = &reloc_howtos[RELOC_TYPE_32_NO_BASE];
symbol++;
relocs++;
- relocs[0].offset = array_to_integer (ied->NamePointerRVA, 4) + 4 * i;
+ relocs[0].offset = array_to_integer (ied->NamePointerRVA, 4, 0) + 4 * i;
relocs[0].symbol = &of->symbol_arr[0];
relocs[0].howto = &reloc_howtos[RELOC_TYPE_32_NO_BASE];
- integer_to_array (name_table_offset, part->content + relocs[0].offset, 4);
+ integer_to_array (name_table_offset, part->content + relocs[0].offset, 4, 0);
relocs++;
- integer_to_array (i, part->content + array_to_integer (ied->OrdinalTableRVA, 4) + 2 * i, 4);
+ integer_to_array (i, part->content + array_to_integer (ied->OrdinalTableRVA, 4, 0) + 2 * i, 4, 0);
name = kill_at ? export_names[i].name_no_at : export_names[i].name;
strcpy ((char *) part->content + name_table_offset, name);
report_at (program_name, 0, REPORT_INTERNAL_ERROR, ".reloc section could not be found");
}
- integer_to_array (0, ibr_hdr.RVAOfBlock, 4);
+ integer_to_array (0, ibr_hdr.RVAOfBlock, 4, 0);
for (section = all_sections; section; section = section->next) {
continue;
}
- if (num_relocs && (part->rva + relocs[i].offset >= array_to_integer (ibr_hdr.RVAOfBlock, 4) + BASE_RELOCATION_PAGE_SIZE || part->rva + relocs[i].offset < array_to_integer (ibr_hdr.RVAOfBlock, 4))) {
+ if (num_relocs && (part->rva + relocs[i].offset >= array_to_integer (ibr_hdr.RVAOfBlock, 4, 0) + BASE_RELOCATION_PAGE_SIZE || part->rva + relocs[i].offset < array_to_integer (ibr_hdr.RVAOfBlock, 4, 0))) {
generate_base_relocation_block (reloc_section, &ibr_hdr, num_relocs, saved_section, saved_part, saved_i);
num_relocs = 0;
if (num_relocs == 0) {
- integer_to_array (FLOOR_TO (part->rva + relocs[i].offset, BASE_RELOCATION_PAGE_SIZE), ibr_hdr.RVAOfBlock, 4);
+ integer_to_array (FLOOR_TO (part->rva + relocs[i].offset, BASE_RELOCATION_PAGE_SIZE), ibr_hdr.RVAOfBlock, 4, 0);
saved_section = section;
saved_part = part;
write721_to_byte_array (doshdr->e_lfarlc, sizeof (*doshdr));
write741_to_byte_array (doshdr->e_lfanew, sizeof (*doshdr) + sizeof (dos_stub));
- memcpy ((char *) data + array_to_integer (doshdr->e_lfarlc, 2), dos_stub, sizeof (dos_stub));
+ memcpy ((char *) data + array_to_integer (doshdr->e_lfarlc, 2, 0), dos_stub, sizeof (dos_stub));
pehdr->Signature[0] = 'P';
part->content = xmalloc (part->content_size = ALIGN (2 + strlen (real_import_name) + 1, 2));
- integer_to_array (ordinal_hint, part->content, 2);
+ integer_to_array (ordinal_hint, part->content, 2, 0);
strcpy ((char *) part->content + 2, real_import_name);
free (real_import_name);
import_dt = (struct pe_import_directory_table *) (part->content = xmalloc (part->content_size = sizeof (*import_dt)));
- integer_to_array (0, import_dt->ImportNameTableRVA, 4);
- integer_to_array (0, import_dt->TimeDateStamp, 4);
- integer_to_array (0, import_dt->ForwarderChain, 4);
- integer_to_array (0, import_dt->NameRVA, 4);
- integer_to_array (0, import_dt->ImportAddressTableRVA, 4);
+ integer_to_array (0, import_dt->ImportNameTableRVA, 4, 0);
+ integer_to_array (0, import_dt->TimeDateStamp, 4, 0);
+ integer_to_array (0, import_dt->ForwarderChain, 4, 0);
+ integer_to_array (0, import_dt->NameRVA, 4, 0);
+ integer_to_array (0, import_dt->ImportAddressTableRVA, 4, 0);
part->reloc_cnt = 3;
part->reloc_arr = xmalloc (part->reloc_cnt * sizeof (*part->reloc_arr));
return;
}
- if ((array_to_integer (import_header->Type, 2) & 0x03) == IMPORT_CONST) {
+ if ((array_to_integer (import_header->Type, 2, 0) & 0x03) == IMPORT_CONST) {
- report_at (__FILE__, __LINE__, REPORT_INTERNAL_ERROR, "+++ not yet supported import header import Type: 0x%x", array_to_integer (import_header->Type, 2) & 0x3);
+ report_at (__FILE__, __LINE__, REPORT_INTERNAL_ERROR, "+++ not yet supported import header import Type: 0x%x", array_to_integer (import_header->Type, 2, 0) & 0x3);
return;
}
}
- import_generate_import (import_name, array_to_integer (import_header->OrdinalHint, 2), array_to_integer (import_header->Type, 2) & 0x03, array_to_integer (import_header->Type, 2) >> 2, filename);
+ import_generate_import (import_name, array_to_integer (import_header->OrdinalHint, 2, 0), array_to_integer (import_header->Type, 2, 0) & 0x03, array_to_integer (import_header->Type, 2, 0) >> 2, filename);
}