diff options
author | Mitya Selivanov <automainint@guattari.tech> | 2024-08-01 09:40:56 +0200 |
---|---|---|
committer | Mitya Selivanov <automainint@guattari.tech> | 2024-08-01 09:40:56 +0200 |
commit | 9df822c5c5100412f90785d110deed5a64871254 (patch) | |
tree | a940b7a83c0cd3a9b36e8e99579e603f1cca2407 | |
parent | 8ad151d65fabd2b471cad46835eb2b440329ac37 (diff) | |
download | bxgen-9df822c5c5100412f90785d110deed5a64871254.zip |
Link crti, crtn
-rwxr-xr-x | bxgen.c | 37 |
1 files changed, 17 insertions, 20 deletions
@@ -2629,16 +2629,6 @@ i64 unit_write_in_memory( FAIL("Not implemented", 0); } - if (section.type == SEC_PROGBITS && section.exec && - STR_EQ(section.name.size, name, SECTION_INIT)) { - FAIL("Not implemented", 0); - } - - if (section.type == SEC_PROGBITS && section.exec && - STR_EQ(section.name.size, name, SECTION_FINI)) { - FAIL("Not implemented", 0); - } - if (section.exec) { CHECK(!section.write, "Not implemented", 0); @@ -2720,16 +2710,6 @@ i64 unit_write_in_memory( FAIL("Not implemented", 0); } - if (section.type == SEC_PROGBITS && section.exec && - STR_EQ(section.name.size, name, SECTION_INIT)) { - FAIL("Not implemented", 0); - } - - if (section.type == SEC_PROGBITS && section.exec && - STR_EQ(section.name.size, name, SECTION_FINI)) { - FAIL("Not implemented", 0); - } - if (section.exec) { CHECK(!section.write, "Not implemented", 0); @@ -3142,6 +3122,21 @@ i64 unit_write_in_memory( // // Apply our relocations + #define FIND_(x) \ + do { for (i64 i = 0; i < num_symbols; ++i) \ + if (STR_EQ(linker->symbols[i].name_size, linker->symbols[i].name, #x)) { \ + LOG(INFO, "Found " #x ": 0x%llx", linker->symbols[i].address); \ + break; \ + } } while (0) + + FIND_(_start); + FIND_(__libc_start_main); + FIND_(__tunables_init); + FIND_(__libc_early_init); + FIND_(__ctype_init); + + #undef FIND_ + for (i64 rel_index = 0; rel_index < codegen->num_rels; ++rel_index) { Rel_Entry rel = codegen->rels[rel_index]; @@ -4062,6 +4057,8 @@ b8 link_with_libc(void) { // Add dependencies l_static(u, "c"); l_object(u, "crt1"); + l_object(u, "crti"); + l_object(u, "crtn"); // Write the compilation unit into an executable file. u_elf_x86_64(u, "test_foo"); |