diff options
author | Mitya Selivanov <automainint@guattari.tech> | 2024-07-30 15:35:20 +0200 |
---|---|---|
committer | Mitya Selivanov <automainint@guattari.tech> | 2024-07-30 15:35:20 +0200 |
commit | 41b51baf9b14bae073aff088e624c139e47a1d62 (patch) | |
tree | a67e45431e76adc0c24f4a7739a29829355a797f | |
parent | cd19e4b8d2fe164661a7cbcf6e28ec87f05d91c5 (diff) | |
download | bxgen-41b51baf9b14bae073aff088e624c139e47a1d62.zip |
Do not rewrite symbols in place
-rwxr-xr-x | bxgen.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -2502,8 +2502,6 @@ i64 unit_write_in_memory( if (end > buf.end) end = buf.end; - - write_i64(LE, sym_address, begin + 8, end); } } @@ -2576,7 +2574,6 @@ i64 unit_write_in_memory( i64 dst_index = elf_find_related_section_index(buf, sec_index); i64 dst_index_global = sec_index_global + dst_index - 1; - BX_CHECK(dst_index_global >= 0 && dst_index_global < linker->max_num_sections, "Buffer overflow",); for (i64 entry_index = 0; entry_index < src_sec.num_entries; ++entry_index) { @@ -2610,12 +2607,15 @@ i64 unit_write_in_memory( bx_mem_cpy(linker->not_found_buffer + not_found_size, sym_name, relx.symbol.name.size); not_found_size += relx.symbol.name.size + 1; } - } else + } else { + i64 src_index_global = sec_index_global + relx.symbol.section - 1; + symbol = (Symbol_Entry) { - .section = sec_index_global, - .address = relx.symbol.value.offset, + .section = src_index_global, + .address = relx.symbol.value.offset + linker->section_addresses[src_index_global], .size = relx.symbol.value.size, }; + } u8 *dst = buf.begin + elf_section(buf, dst_index).data.offset + relx.offset; @@ -3424,7 +3424,7 @@ int main(int argc, char **argv) { // Add the `main` procedure. i64 mainproc = p_new_entry(u, "main"); - // Call printf + // Call puts n_call_by_name( mainproc, CONV_CDECL, // calling convention |