@@ -87,12 +87,12 @@ eodyn: /* End of Dyn Table scan */
* 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]
+ * _stext.link[r11] = _stext.run[r10] - cur_offset[r7]
+ * final_offset[r3] = _stext.final[r3] - _stext.link[r11]
*/
subf r7, r7, r9 /* cur_offset */
- subf r12, r7, r10
- subf r3, r12, r3 /* final_offset */
+ subf r11, r7, r10
+ subf r3, r11, r3 /* final_offset */
subf r8, r6, r8 /* relaz -= relaent */
/*
@@ -101,6 +101,21 @@ eodyn: /* End of Dyn Table scan */
* r13 - points to the symbol table
*/
+#ifdef CONFIG_MODVERSIONS
+ /*
+ * Treat R_PPC_RELATIVE relocations differently when they target the
+ * interval [__start___kcrctab, __stop___kcrctab_gpl_future): in this
+ * case, the relocated quantities are CRC pseudo-symbols, which should
+ * be preserved as-is, rather than be modified to take the runtime
+ * offset into account.
+ */
+ lwz r10, (p_kcrc_start - 0b)(r12)
+ lwz r11, (p_kcrc_stop - 0b)(r12)
+ subf r12, r7, r12 /* link time addr of 0b */
+ add r10, r10, r12
+ add r11, r11, r12
+#endif
+
/*
* Check if we have a relocation based on symbol
* r5 will hold the value of the symbol.
@@ -135,7 +150,15 @@ get_type:
bne hi16
lwz r4, 0(r9) /* r_offset */
lwz r0, 8(r9) /* r_addend */
+#ifdef CONFIG_MODVERSIONS
+ cmplw r4, r10
+ blt do_add
+ cmplw r4, r11
+ blt skip_add
+do_add:
+#endif
add r0, r0, r3 /* final addend */
+skip_add:
stwx r0, r4, r7 /* memory[r4+r7]) = (u32)r0 */
b nxtrela /* continue */
@@ -207,3 +230,8 @@ p_dyn: .long __dynamic_start - 0b
p_rela: .long __rela_dyn_start - 0b
p_sym: .long __dynamic_symtab - 0b
p_st: .long _stext - 0b
+
+#ifdef CONFIG_MODVERSIONS
+p_kcrc_start: .long __start___kcrctab - 0b
+p_kcrc_stop: .long __stop___kcrctab_gpl_future - 0b
+#endif