20 #include "pedigree/kernel/Log.h" 21 #include "pedigree/kernel/linker/Elf.h" 22 #include "pedigree/kernel/linker/KernelElf.h" 32 #define R_386_GLOB_DAT 6 33 #define R_386_JMP_SLOT 7 34 #define R_386_RELATIVE 8 35 #define R_386_GOTOFF 9 36 #define R_386_GOTPC 10 43 if (pSh && pSh->addr == 0)
47 uint32_t address = ((pSh) ? pSh->addr : loadBase) + rel.offset;
50 uint32_t A = *
reinterpret_cast<uint32_t *
>(address);
58 if (!m_pDynamicSymbolTable)
59 pSymbols =
reinterpret_cast<ElfSymbol_t *
>(m_pSymbolTable);
61 pSymbols = m_pDynamicSymbolTable;
63 const char *pStringTable = 0;
64 if (!m_pDynamicStringTable)
65 pStringTable =
reinterpret_cast<const char *
>(m_pStringTable);
67 pStringTable = m_pDynamicStringTable;
70 if (pSymbols && ST_TYPE(pSymbols[R_SYM(rel.info)].info) == 3)
74 int shndx = pSymbols[R_SYM(rel.info)].shndx;
78 else if (R_TYPE(rel.info) != R_386_RELATIVE)
81 const char *pStr = pStringTable + pSymbols[R_SYM(rel.info)].name;
86 if (R_TYPE(rel.info) == R_386_COPY)
92 if (S == 0 && StringLength(pStr))
94 "Relocation failed for symbol \"" 95 << pStr <<
"\" (relocation=" << R_TYPE(rel.info) <<
")");
98 WARNING(
"Weak relocation == 0 [undefined] for \"" << pStr <<
"\".");
101 if (S == 0 && (R_TYPE(rel.info) != R_386_RELATIVE))
107 uint32_t B = loadBase;
110 switch (R_TYPE(rel.info))
125 result = *
reinterpret_cast<uintptr_t *
>(S);
131 ERROR(
"Relocation not supported: " <<
Dec << R_TYPE(rel.info));
135 uint32_t *pResult =
reinterpret_cast<uint32_t *
>(address);
144 ERROR(
"The ARM architecture does not use RELA entries!");
uintptr_t EXPORTED_PUBLIC lookup(const HashedStringView &name, Elf *pElf, Policy policy=LocalFirst, Binding *pBinding=0)
static KernelElf & instance()
bool applyRelocation(ElfRel_t rel, ElfSectionHeader_t *pSh, SymbolTable *pSymtab=0, uintptr_t loadBase=0, SymbolTable::Policy policy=SymbolTable::LocalFirst)