Added DT_DEBUG, DT_TEXTREL,DT_FLAGS,DT_NEEDED

This commit is contained in:
georgemoralis 2023-06-09 18:10:40 +03:00
parent 94dff9b980
commit 6e0cf378d2
3 changed files with 34 additions and 0 deletions

View File

@ -246,6 +246,29 @@ void Linker::LoadDynamicInfo(Module* m)
LOG_WARN_IF(debug_loader, "DT_SCE_SYMENT is NOT 0x18 should check!");
}
break;
case DT_DEBUG:
m->dynamic_info->debug = dyn->d_un.d_val;
break;
case DT_TEXTREL:
m->dynamic_info->textrel = dyn->d_un.d_val;
break;
case DT_FLAGS:
m->dynamic_info->flags = dyn->d_un.d_val;
if (m->dynamic_info->flags != 0x04) //this value should always be DF_TEXTREL (0x04)
{
LOG_WARN_IF(debug_loader, "DT_FLAGS is NOT 0x04 should check!");
}
break;
case DT_NEEDED://Offset of the library string in the string table to be linked in.
if (m->dynamic_info->str_table != nullptr)//in theory this should already be filled from about just make a test case
{
m->dynamic_info->needed.push_back(m->dynamic_info->str_table + dyn->d_un.d_val);
}
else
{
LOG_ERROR_IF(debug_loader, "DT_NEEDED str table is not loaded should check!");
}
break;
default:
LOG_INFO_IF(debug_loader, "unsupported dynamic tag ..........: {:#018x}\n", dyn->d_tag);
}

View File

@ -45,6 +45,13 @@ struct DynamicModuleInfo
elf_relocation* relocation_table = nullptr;
u64 relocation_table_size = 0;
u64 relocation_table_entries_size = 0;
u64 debug = 0;
u64 textrel = 0;
u64 flags = 0;
std::vector<const char*> needed;
};
class Linker

View File

@ -325,13 +325,17 @@ struct elf_program_id_header
};
constexpr s64 DT_NULL = 0;
constexpr s64 DT_NEEDED = 0x00000001;
constexpr s64 DT_RELA = 0x00000007;
constexpr s64 DT_INIT = 0x0000000c;
constexpr s64 DT_FINI = 0x0000000d;
constexpr s64 DT_DEBUG = 0x00000015;
constexpr s64 DT_TEXTREL = 0x00000016;
constexpr s64 DT_INIT_ARRAY = 0x00000019;
constexpr s64 DT_FINI_ARRAY = 0x0000001a;
constexpr s64 DT_INIT_ARRAYSZ = 0x0000001b;
constexpr s64 DT_FINI_ARRAYSZ = 0x0000001c;
constexpr s64 DT_FLAGS = 0x0000001e;
constexpr s64 DT_PREINIT_ARRAY = 0x00000020;
constexpr s64 DT_PREINIT_ARRAYSZ = 0x00000021;
constexpr s64 DT_SCE_HASH = 0x61000025;