Changeset 425 for Whitix/branches/hybrid/kernel
- Timestamp:
- 05/05/08 16:09:04 (7 months ago)
- Files:
-
- 1 modified
-
Whitix/branches/hybrid/kernel/module.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Whitix/branches/hybrid/kernel/module.c
r421 r425 74 74 } 75 75 76 int ModuleSymbolResolve(struct Module* module )76 int ModuleSymbolResolve(struct Module* module, int sec) 77 77 { 78 78 int i; 79 79 struct ElfReloc* reloc; 80 struct ElfReloc* relTable=(struct ElfReloc*)(module->loadAddr+module->sectionHeaders[sec].shOffset); 81 DWORD relSize=module->sectionHeaders[sec].shSize/sizeof(struct ElfReloc); 80 82 81 for (i=0; i< module->relSize/(sizeof(struct ElfReloc)); i++)83 for (i=0; i<relSize; i++) 82 84 { 83 reloc=& module->relTable[i];85 reloc=&relTable[i]; 84 86 85 unsigned long* relAddr=(unsigned long*)(module->loadAddr+module->sectionHeaders[ module->sectionHeaders[ module->relSection].shInfo ].shOffset+reloc->addr);87 unsigned long* relAddr=(unsigned long*)(module->loadAddr+module->sectionHeaders[ module->sectionHeaders[sec].shInfo ].shOffset+reloc->addr); 86 88 int symTabIdx=ELF_R_SYM(reloc->info); 87 89 struct ElfSymbol* symbol=&module->symTable[symTabIdx]; … … 146 148 module->textAddr=loadAddr+sectionHeaders[i].shOffset; 147 149 148 if (sectionHeaders[i].shType == SEC_TYPE_REL)149 {150 if (!module->relTable)151 module->relTable=(struct ElfReloc*)(loadAddr+sectionHeaders[i].shOffset);152 module->relSize+=sectionHeaders[i].shSize;153 154 if (!module->relSection)155 module->relSection=i;156 }157 158 150 /* Save the symbol table off for resolving later. */ 159 151 if (sectionHeaders[i].shType == SEC_TYPE_SYMTAB) 152 160 153 { 161 154 module->symTable=loadAddr+sectionHeaders[i].shOffset; … … 167 160 } 168 161 169 /* Resolve entries in the module file. */ 170 if (ModuleSymbolResolve(module) < 0) 171 return -EINVAL; 162 for (i=0; i<elfHeader->shEntries; i++) 163 { 164 if (sectionHeaders[i].shType == SEC_TYPE_REL) 165 /* Resolve entries in the module file. */ 166 if (ModuleSymbolResolve(module, i) < 0) 167 return -EINVAL; 168 } 172 169 173 170 /* Find the init and exit functions, using the symbol and string table addresses. */
