📄 loadelflib.c
字号:
default: printErr ("Unsupported relocation type %d\n", ELF32_R_TYPE (relocCmd.r_info)); status = ERROR; break; } } return (status); }/********************************************************************************* elfSparcAddr32Reloc - perform the R_PPC_ADDR32 relocation* * This routine handles the R_PPC_ADDR32 relocation (word32, S + A).** RETURNS : OK or ERROR if computed value can't be written down in target* memory.*/LOCAL STATUS elfSparc32Reloc ( void * pAdrs, /* relocation address */ Elf32_Rela * pRelocCmd, /* points to a relocation structure */ SYM_INFO_TBL symInfoTbl /* array of absolute symbol values */ ) { UINT32 value; /* relocation value */ value = (UINT32)symInfoTbl [ELF32_R_SYM (pRelocCmd->r_info)].pAddr + pRelocCmd->r_addend; *((UINT32 *)pAdrs) = value; return (OK); }/********************************************************************************* elfSparcAddr24Reloc - perform the R_PPC_ADDR24 relocation* * This routine handles the R_PPC_ADDR24 relocation (low24, S + A).** RETURNS : OK or ERROR if computed value can't be written down in target* memory.*/LOCAL STATUS elfSparc16Reloc ( void * pAdrs, /* relocation address */ Elf32_Rela * pRelocCmd, /* points to a relocation structure */ SYM_INFO_TBL symInfoTbl /* array of absolute symbol values */ ) { UINT32 value; /* relocation value */ value = (UINT32)symInfoTbl [ELF32_R_SYM (pRelocCmd->r_info)].pAddr + pRelocCmd->r_addend; *((UINT16 *)pAdrs) = (UINT16) value; return (OK); }/********************************************************************************* elfSparcAddr8Reloc - perform the R_PPC_ADDR16 relocation* * This routine handles the R_PPC_ADDR16 relocation (half16, S + A).** RETURNS : OK or ERROR if computed value can't be written down in target* memory.*/LOCAL STATUS elfSparc8Reloc ( void * pAdrs, /* relocation address */ Elf32_Rela * pRelocCmd, /* points to a relocation structure */ SYM_INFO_TBL symInfoTbl /* array of absolute symbol values */ ) { UINT32 value; /* relocation value */ value = (UINT32)symInfoTbl [ELF32_R_SYM (pRelocCmd->r_info)].pAddr + pRelocCmd->r_addend; *((UINT8 *)pAdrs) = (UINT8) value; return (OK); }/********************************************************************************* elfSparcAddr16LoReloc - perform the R_PPC_ADDR16_LO relocation* * This routine handles the R_PPC_ADDR16_LO relocation (half16, #lo(S + A)).** RETURNS : OK or ERROR if computed value can't be written down in target* memory.*/LOCAL STATUS elfSparcDisp32Reloc ( void * pAdrs, /* relocation address */ Elf32_Rela * pRelocCmd, /* points to a relocation structure */ SYM_INFO_TBL symInfoTbl /* array of absolute symbol values */ ) { UINT32 value; /* relocation value */ UINT32 tmpVal; /* holds temporary calculation results */ value = (UINT32) symInfoTbl [ELF32_R_SYM (pRelocCmd->r_info)].pAddr + pRelocCmd->r_addend - ((UINT32) pAdrs); *((UINT32 *)pAdrs) = value; return (OK); }/********************************************************************************* elfSparcAddr16HiReloc - perform the R_PPC_ADDR16_HI relocation* * This routine handles the R_PPC_ADDR16_HI relocation (half16, #hi(S + A)).** RETURNS : OK or ERROR if computed value can't be written down in target* memory.*/LOCAL STATUS elfSparcDisp16Reloc ( void * pAdrs, /* relocation address */ Elf32_Rela * pRelocCmd, /* points to a relocation structure */ SYM_INFO_TBL symInfoTbl /* array of absolute symbol values */ ) { UINT32 value; /* relocation value */ value = (UINT32) symInfoTbl [ELF32_R_SYM (pRelocCmd->r_info)].pAddr + pRelocCmd->r_addend - ((UINT32) pAdrs); *((UINT32 *)pAdrs) = value; return (OK); }/********************************************************************************* elfSparcAddr16HaReloc - perform the R_PPC_ADDR16_HA relocation* * This routine handles the R_PPC_ADDR16_HA relocation (half16, #ha(S + A)).** RETURNS : OK or ERROR if computed value can't be written down in target* memory.*/LOCAL STATUS elfSparcDisp8Reloc ( void * pAdrs, /* relocation address */ Elf32_Rela * pRelocCmd, /* points to a relocation structure */ SYM_INFO_TBL symInfoTbl /* array of absolute symbol values */ ) { UINT32 value; /* relocation value */ value = (UINT32) symInfoTbl [ELF32_R_SYM (pRelocCmd->r_info)].pAddr + pRelocCmd->r_addend - ((UINT32) pAdrs); *((UINT32 *)pAdrs) = value; return (OK); }/********************************************************************************* elfSparcAddr14Reloc - perform the R_PPC_ADDR14 relocation* * This routine handles the R_PPC_ADDR14 relocation (low14, (S + A) >> 2).** RETURNS : OK or ERROR if computed value can't be written down in target* memory.*/LOCAL STATUS elfSparcWDisp30Reloc ( void * pAdrs, /* relocation address */ Elf32_Rela * pRelocCmd, /* points to a relocation structure */ SYM_INFO_TBL symInfoTbl /* array of absolute symbol values */ ) { unsigned int value, tmpVal; value = ((UINT32)symInfoTbl [ELF32_R_SYM (pRelocCmd->r_info)].pAddr + pRelocCmd->r_addend - ((UINT32)pAdrs))>>2; tmpVal = *((UINT32 *) pAdrs); tmpVal &= (unsigned int)0xc0000000; tmpVal |= (unsigned int)value; *((UINT32 *)pAdrs) = (UINT32) tmpVal; return (OK); }/********************************************************************************* elfSparcRel24Reloc - perform the R_PPC_REL24 relocation* * This routine handles the R_PPC_REL24 relocation (low24, (S + A - P) >> 2).** RETURNS : OK or ERROR if computed value can't be written down in target* memory.*/LOCAL STATUS elfSparcWDisp22Reloc ( void * pAdrs, /* relocation address */ Elf32_Rela * pRelocCmd, /* points to a relocation structure */ SYM_INFO_TBL symInfoTbl /* array of absolute symbol values */ ) { unsigned int value, tmpVal; value = ((UINT32)symInfoTbl [ELF32_R_SYM (pRelocCmd->r_info)].pAddr + pRelocCmd->r_addend - ((UINT32)pAdrs))>>2; tmpVal = *((UINT32 *) pAdrs); tmpVal &= (unsigned int)0xffc00000; tmpVal |= (unsigned int)value; *((UINT32 *)pAdrs) = (UINT32) tmpVal; return (OK); }/********************************************************************************* elfSparcRel14Reloc - perform the R_PPC_REL14 relocation* * This routine handles the R_PPC_REL14 relocation (low14, (S + A - P) >> 2).** RETURNS : OK or ERROR if computed value can't be written down in target* memory.*/LOCAL STATUS elfSparcHi22Reloc ( void * pAdrs, /* relocation address */ Elf32_Rela * pRelocCmd, /* points to a relocation structure */ SYM_INFO_TBL symInfoTbl /* array of absolute symbol values */ ) { unsigned int value, tmpVal; value = ((UINT32)symInfoTbl [ELF32_R_SYM (pRelocCmd->r_info)].pAddr + pRelocCmd->r_addend)>>10; tmpVal = *((UINT32 *) pAdrs); tmpVal &= (unsigned int)0xffc00000; tmpVal |= (unsigned int)value; *((UINT32 *)pAdrs) = (UINT32) tmpVal; return (OK); }/********************************************************************************* elfSparcUaddr32Reloc - perform the R_PPC_UADDR32 relocation* * This routine handles the R_PPC_UADDR32 relocation (word32, S + A).** RETURNS : OK or ERROR if computed value can't be written down in target* memory.*/LOCAL STATUS elfSparc22Reloc ( void * pAdrs, /* relocation address */ Elf32_Rela * pRelocCmd, /* points to a relocation structure */ SYM_INFO_TBL symInfoTbl /* array of absolute symbol values */ ) { unsigned int value, tmpVal; value = (UINT32)symInfoTbl [ELF32_R_SYM (pRelocCmd->r_info)].pAddr + pRelocCmd->r_addend; tmpVal = *((UINT32 *) pAdrs); tmpVal &= (unsigned int)0xffc00000; tmpVal |= (unsigned int)value; *((UINT32 *)pAdrs) = (UINT32) tmpVal; return (OK); }/********************************************************************************* elfSparcUaddr16Reloc - perform the R_PPC_UADDR16 relocation* * This routine handles the R_PPC_UADDR16 relocation (half16, S + A).** RETURNS : OK or ERROR if computed value can't be written down in target* memory.*/LOCAL STATUS elfSparc13Reloc ( void * pAdrs, /* relocation address */ Elf32_Rela * pRelocCmd, /* points to a relocation structure */ SYM_INFO_TBL symInfoTbl /* array of absolute symbol values */ ) { unsigned int value, tmpVal; value = (UINT32)symInfoTbl [ELF32_R_SYM (pRelocCmd->r_info)].pAddr + pRelocCmd->r_addend; tmpVal = *((UINT32 *) pAdrs); tmpVal &= (unsigned int)0xfffe0000; tmpVal |= (unsigned int)value; *((UINT32 *)pAdrs) = (UINT32) tmpVal; return (OK); }/********************************************************************************* elfSparcRel32Reloc - perform the R_PPC_REL32 relocation* * This routine handles the R_PPC_REL32 relocation (word32, S + A - P).** RETURNS : OK or ERROR if computed value can't be written down in target* memory.*/LOCAL STATUS elfSparcLo10Reloc ( void * pAdrs, /* relocation address */ Elf32_Rela * pRelocCmd, /* points to a relocation structure */ SYM_INFO_TBL symInfoTbl /* array of absolute symbol values */ ) { unsigned int value, tmpVal; value = ((UINT32)symInfoTbl [ELF32_R_SYM (pRelocCmd->r_info)].pAddr + pRelocCmd->r_addend) & 0x3ff; tmpVal = *((UINT32 *) pAdrs); tmpVal &= (unsigned int)0xfffffc00; tmpVal |= (unsigned int)value; *((UINT32 *)pAdrs) = tmpVal; return (OK); }/********************************************************************************* elfSparcEmbNaddr32Reloc - perform the R_PPC_EMB_NADDR32 relocation* * This routine handles the R_PPC_EMB_NADDR32 relocation (uword32, A - S).** RETURNS : OK or ERROR if computed value can't be written down in target* memory.*/LOCAL STATUS elfSparcPc10Reloc ( void * pAdrs, /* relocation address */ Elf32_Rela * pRelocCmd, /* points to a relocation structure */ SYM_INFO_TBL symInfoTbl /* array of absolute symbol values */ ) { unsigned int value, tmpVal; value = ((UINT32)symInfoTbl [ELF32_R_SYM (pRelocCmd->r_info)].pAddr + pRelocCmd->r_addend - ((UINT32)pAdrs))&0x3ff; tmpVal = *((UINT32 *) pAdrs); tmpVal &= (unsigned int)0xfffffc00; tmpVal |= (unsigned int)value; *((UINT32 *)pAdrs) = (UINT32) tmpVal; return (OK); }/********************************************************************************* elfSparcEmbNaddr16Reloc - perform the R_PPC_EMB_NADDR16 relocation* * This routine handles the R_PPC_EMB_NADDR16 relocation (uhalf16, A - S).** RETURNS : OK or ERROR if computed value can't be written down in target* memory.*/LOCAL STATUS elfSparcPc22Reloc ( void * pAdrs, /* relocation address */ Elf32_Rela * pRelocCmd, /* points to a relocation structure */ SYM_INFO_TBL symInfoTbl /* array of absolute symbol values */ ) { unsigned int value, tmpVal; value = ((UINT32)symInfoTbl [ELF32_R_SYM (pRelocCmd->r_info)].pAddr + pRelocCmd->r_addend - ((UINT32)pAdrs))>>10; tmpVal = *((UINT32 *) pAdrs); tmpVal &= (unsigned int)0xffc00000; tmpVal |= (unsigned
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -