mirror of
https://github.com/reactos/reactos.git
synced 2024-10-31 20:02:55 +00:00
[OBJ2BIN] Add support for IMAGE_REL_I386_REL16
Also return error in case of unknown relocation type.
This commit is contained in:
parent
5367ae5760
commit
77d69c68b8
|
@ -42,6 +42,7 @@
|
|||
#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
|
||||
|
||||
#define IMAGE_REL_I386_ABSOLUTE 0x0001
|
||||
#define IMAGE_REL_I386_REL16 0x0002
|
||||
#define IMAGE_REL_I386_DIR32 0x0006
|
||||
|
||||
#pragma pack(push,2)
|
||||
|
|
|
@ -13,7 +13,7 @@ Usage(void)
|
|||
}
|
||||
|
||||
static
|
||||
void
|
||||
int
|
||||
RelocateSection(
|
||||
char *pData,
|
||||
IMAGE_SECTION_HEADER *pSectionHeader,
|
||||
|
@ -46,6 +46,11 @@ RelocateSection(
|
|||
*p16 += (WORD)(pSymbols[pReloc->SymbolTableIndex].Value + iOffset);
|
||||
break;
|
||||
|
||||
case IMAGE_REL_I386_REL16:
|
||||
p16 = (void*)(pSection + nOffset);
|
||||
*p16 += (WORD)(pSymbols[pReloc->SymbolTableIndex].Value + iOffset);
|
||||
break;
|
||||
|
||||
case IMAGE_REL_I386_DIR32:
|
||||
p32 = (void*)(pSection + nOffset);
|
||||
*p32 += (DWORD)(pSymbols[pReloc->SymbolTableIndex].Value + iOffset);
|
||||
|
@ -54,10 +59,13 @@ RelocateSection(
|
|||
default:
|
||||
printf("Unknown relocation type %u, address 0x%x\n",
|
||||
pReloc->Type, (unsigned)pReloc->VirtualAddress);
|
||||
return 0;
|
||||
}
|
||||
|
||||
pReloc++;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -136,10 +144,15 @@ int main(int argc, char *argv[])
|
|||
if ((strcmp((char*)pSectionHeader->Name, ".text") == 0) &&
|
||||
(pSectionHeader->SizeOfRawData != 0))
|
||||
{
|
||||
RelocateSection(pData,
|
||||
if (!RelocateSection(pData,
|
||||
pSectionHeader,
|
||||
pSymbols,
|
||||
nBaseAddress);
|
||||
nBaseAddress))
|
||||
{
|
||||
free(pData);
|
||||
fclose(pDestFile);
|
||||
return -7;
|
||||
}
|
||||
|
||||
/* Write the section to the destination file */
|
||||
if (!fwrite(pData + pSectionHeader->PointerToRawData,
|
||||
|
|
Loading…
Reference in a new issue