summaryrefslogtreecommitdiff
path: root/bxgen.c
diff options
context:
space:
mode:
Diffstat (limited to 'bxgen.c')
-rwxr-xr-xbxgen.c54
1 files changed, 46 insertions, 8 deletions
diff --git a/bxgen.c b/bxgen.c
index d69cc01..33a6908 100755
--- a/bxgen.c
+++ b/bxgen.c
@@ -1315,9 +1315,10 @@ void unit_write(Pool *pool, i64 unit, u16 target, i64 io_out, void *io_user_data
switch (type) {
// ================================================================
//
- // Symbols
+ // Symbols and dynamic linking symbols
- case 2: {
+ case 2:
+ case 6: {
// Find symbol addresses
//
@@ -1417,6 +1418,43 @@ void unit_write(Pool *pool, i64 unit, u16 target, i64 io_out, void *io_user_data
// ================================================================
//
+ // Relocarions without addends
+
+ case 9: {
+ BX_ASSERT(entsize == 16);
+
+ i64 prev_offset = current_offset;
+ i64 prev_byte_count = byte_count;
+ io_seek(f, begin_offset + offset, IO_SEEK_BEGIN, io_user_data);
+ current_offset = begin_offset + offset;
+
+ printf("\n");
+
+ for (byte_count = size; byte_count > 0;) {
+ u64 rela_offset;
+ u64 rela_info;
+
+ READ(rela_offset); BX_ASSERT(n != 0);
+ READ(rela_info); BX_ASSERT(n != 0);
+
+ u32 rela_sym = (u32) (rela_info >> 32);
+ u32 rela_type = (u32) (rela_info & 0xffffffff);
+
+ printf(" ");
+
+ printf("%08llx sym %-2d type %-2d", rela_offset, rela_sym, rela_type);
+ printf("\n");
+ }
+
+ printf("\n");
+
+ io_seek(f, prev_offset, IO_SEEK_BEGIN, io_user_data);
+ current_offset = prev_offset;
+ byte_count = prev_byte_count;
+ } break;
+
+ // ================================================================
+ //
// Relocarions with addends
case 4: {
@@ -1446,7 +1484,7 @@ void unit_write(Pool *pool, i64 unit, u16 target, i64 io_out, void *io_user_data
printf("%08llx sym %-2d type %-2d add %-2lld", rela_offset, rela_sym, rela_type, rela_addent);
printf("\n");
}
-
+
printf("\n");
io_seek(f, prev_offset, IO_SEEK_BEGIN, io_user_data);
@@ -1455,7 +1493,7 @@ void unit_write(Pool *pool, i64 unit, u16 target, i64 io_out, void *io_user_data
} break;
// ================================================================
-
+
default:;
}
}
@@ -1478,7 +1516,7 @@ void unit_write(Pool *pool, i64 unit, u16 target, i64 io_out, void *io_user_data
symbols[symbol_index]);
// ================================================================
-
+
io_close(f, io_user_data);
}
}
@@ -1731,9 +1769,9 @@ int main(int argc, char **argv) {
i64 u = u_new();
u_add(u, main);
u_entry_point(u, main);
- // l_static(u, "/lib/x86_64-linux-gnu/libc.a");
- l_static(u, "libtest.a");
-
+ l_static(u, "/lib/x86_64-linux-gnu/libc.a");
+ // l_static(u, "libtest.a");
+
printf("Writing ELF x86_64 executable...\n");
u_elf_x86_64(u, "test_foo");