int klp_enable_patch(struct klp_patch *);
 int klp_disable_patch(struct klp_patch *);
 
+void arch_klp_init_object_loaded(struct klp_patch *patch,
+                                struct klp_object *obj);
+
 /* Called from the module loader during module coming/going states */
 int klp_module_coming(struct module *mod);
 void klp_module_going(struct module *mod);
 
 
        objname = klp_is_module(obj) ? obj->name : "vmlinux";
 
-       module_disable_ro(pmod);
        /* For each klp relocation section */
        for (i = 1; i < pmod->klp_info->hdr.e_shnum; i++) {
                sec = pmod->klp_info->sechdrs + i;
                        break;
        }
 
-       module_enable_ro(pmod, true);
        return ret;
 }
 
                                    func->old_sympos ? func->old_sympos : 1);
 }
 
+/* Arches may override this to finish any remaining arch-specific tasks */
+void __weak arch_klp_init_object_loaded(struct klp_patch *patch,
+                                       struct klp_object *obj)
+{
+}
+
 /* parts of the initialization that is done only when the object is loaded */
 static int klp_init_object_loaded(struct klp_patch *patch,
                                  struct klp_object *obj)
        struct klp_func *func;
        int ret;
 
+       module_disable_ro(patch->mod);
        ret = klp_write_object_relocations(patch->mod, obj);
-       if (ret)
+       if (ret) {
+               module_enable_ro(patch->mod, true);
                return ret;
+       }
+
+       arch_klp_init_object_loaded(patch, obj);
+       module_enable_ro(patch->mod, true);
 
        klp_for_each_func(obj, func) {
                ret = klp_find_object_symbol(obj->name, func->old_name,