diff options
-rwxr-xr-x | bxgen.c | 35 |
1 files changed, 24 insertions, 11 deletions
@@ -2423,16 +2423,29 @@ void unit_write(Pool *pool, i64 unit, u16 target, i64 io_out, void *io_user_data .address = relx.symbol.value.offset, }; - i64 A = relx.addent; // Represents the addend used to compute the value of the relocatable field. - i64 B = pool->section_addresses[dst_index]; // Represents the base address at which a shared object has been loaded into memory during execution. Generally, a shared object is built with a 0 base virtual address, but the execution address will be different. - i64 G = symbol.address - base_address - data_offset; // Represents the offset into the global offset table at which the relocation entry's symbol will reside during execution. - i64 GOT = base_address + data_offset; // Represents the address of the global offset table. - i64 L = base_address + data_offset; // Represents the place (section offset or address) of the Procedure Linkage Table entry for a symbol. - i64 P = pool->section_addresses[dst_index] + relx.offset; // Represents the place (section offset or address) of the storage unit being relocated (computed using r_offset). - i64 S = symbol.address; // Represents the value of the symbol whose index resides in the relocation entry. - u8 *dst = buf.begin + elf_section(buf, dst_index).data.offset + relx.offset; + // Represents the addend used to compute the value of the relocatable field. + i64 A = relx.addent; + + // Represents the base address at which a shared object has been loaded into memory during execution. Generally, a shared object is built with a 0 base virtual address, but the execution address will be different. + i64 B = pool->section_addresses[dst_index]; + + // Represents the offset into the global offset table at which the relocation entry's symbol will reside during execution. + i64 G = symbol.address - base_address - data_offset; + + // Represents the address of the global offset table. + i64 GOT = base_address + data_offset; + + // Represents the place (section offset or address) of the Procedure Linkage Table entry for a symbol. + i64 L = base_address + data_offset; + + // Represents the place (section offset or address) of the storage unit being relocated (computed using r_offset). + i64 P = pool->section_addresses[dst_index] + relx.offset; + + // Represents the value of the symbol whose index resides in the relocation entry. + i64 S = symbol.address; + switch (relx.type) { #define ADD_(BITS, OP) \ do { \ @@ -2442,16 +2455,16 @@ void unit_write(Pool *pool, i64 unit, u16 target, i64 io_out, void *io_user_data #define TODO_ BX_FAIL("Not implemented",) - case R_X86_64_NONE: /* do nothing */ break; + case R_X86_64_NONE: /* Do nothing */ break; case R_X86_64_64: ADD_(64, S + A); break; case R_X86_64_PC32: ADD_(32, S + A - P); break; case R_X86_64_GOT32: ADD_(32, G + A); break; case R_X86_64_PLT32: ADD_(32, L + A - P); break; - case R_X86_64_COPY: /* do nothing */ break; + case R_X86_64_COPY: /* Do nothing */ break; case R_X86_64_GLOB_DAT: ADD_(64, S); break; case R_X86_64_JUMP_SLOT: ADD_(64, S); break; case R_X86_64_RELATIVE: ADD_(64, B + A); break; - case R_X86_64_GOTPCREL: ADD_(64, G + GOT + A - P); break; + case R_X86_64_GOTPCREL: ADD_(32, G + GOT + A - P); break; case R_X86_64_32: ADD_(32, S + A); break; case R_X86_64_32S: ADD_(32, S + A); break; case R_X86_64_16: ADD_(16, S + A); break; |