/* * Scan the dynamic section for RELA, RELASZ entries
*/
li r6, 0
li r7, 0
li r8, 0
1: lwz r5, 0(r11) /* ELF_Dyn.d_tag */
cmpwi r5, 0 /* End of ELF_Dyn[] */
beq eodyn
cmpwi r5, DT_RELA
bne relasz
lwz r7, 4(r11) /* r7 = rela.link */
b skip
relasz:
cmpwi r5, DT_RELASZ
bne relaent
lwz r8, 4(r11) /* r8 = Total Rela relocs size */
b skip
relaent:
cmpwi r5, DT_RELAENT
bne skip
lwz r6, 4(r11) /* r6 = Size of one Rela reloc */ skip:
addi r11, r11, 8
b 1b
eodyn: /* End of Dyn Table scan */
/* Check if we have found all the entries */
cmpwi r7, 0
beq done
cmpwi r8, 0
beq done
cmpwi r6, 0
beq done
/* * Work out the current offset from the link time address of .rela * section. * cur_offset[r7] = rela.run[r9] - rela.link [r7] * _stext.link[r12] = _stext.run[r10] - cur_offset[r7] * final_offset[r3] = _stext.final[r3] - _stext.link[r12]
*/
subf r7, r7, r9 /* cur_offset */
subf r12, r7, r10
subf r3, r12, r3 /* final_offset */
subf r8, r6, r8 /* relaz -= relaent */ /* * Scan through the .rela table and process each entry * r9 - points to the current .rela table entry * r13 - points to the symbol table
*/
/* * Check if we have a relocation based on symbol * r5 will hold the value of the symbol.
*/
applyrela:
lwz r4, 4(r9) /* r4 = rela.r_info */
srwi r5, r4, 8 /* ELF32_R_SYM(r_info) */
cmpwi r5, STN_UNDEF /* sym == STN_UNDEF ? */
beq get_type /* value = 0 */ /* Find the value of the symbol at index(r5) */
slwi r5, r5, 4 /* r5 = r5 * sizeof(Elf32_Sym) */
add r12, r13, r5 /* r12 = &__dyn_sym[Index] */
/* * GNU ld has a bug, where dynamic relocs based on * STB_LOCAL symbols, the value should be assumed * to be zero. - Alan Modra
*/ /* XXX: Do we need to check if we are using GNU ld ? */
lbz r5, 12(r12) /* r5 = dyn_sym[Index].st_info */
extrwi r5, r5, 4, 24 /* r5 = ELF32_ST_BIND(r5) */
cmpwi r5, STB_LOCAL /* st_value = 0, ld bug */
beq get_type /* We have r5 = 0 */
lwz r5, 4(r12) /* r5 = __dyn_sym[Index].st_value */
get_type: /* Load the relocation type to r4 */
extrwi r4, r4, 8, 24 /* r4 = ELF32_R_TYPE(r_info) = ((char*)r4)[3] */
/* Store half word */
store_half:
sthx r0, r4, r7 /* memory[r4+r7] = (u16)r0 */
nxtrela: /* * We have to flush the modified instructions to the * main storage from the d-cache. And also, invalidate the * cached instructions in i-cache which has been modified. * * We delay the sync / isync operation till the end, since * we won't be executing the modified instructions until * we return from here.
*/
dcbst r4,r7
sync /* Ensure the data is flushed before icbi */
icbi r4,r7
unknown_type:
cmpwi r8, 0 /* relasz = 0 ? */
ble done
add r9, r9, r6 /* move to next entry in the .rela table */
subf r8, r6, r8 /* relasz -= relaent */
b applyrela
done:
sync /* Wait for the flush to finish */
isync /* Discard prefetched instructions */
blr
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.