frob_writable_data(&mod->init_layout, set_memory_nx);
  }
  
+ static int module_enforce_rwx_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
+                                      char *secstrings, struct module *mod)
+ {
+       const unsigned long shf_wx = SHF_WRITE|SHF_EXECINSTR;
+       int i;
+ 
+       for (i = 0; i < hdr->e_shnum; i++) {
+               if ((sechdrs[i].sh_flags & shf_wx) == shf_wx)
+                       return -ENOEXEC;
+       }
+ 
+       return 0;
+ }
+ 
  #else /* !CONFIG_STRICT_MODULE_RWX */
 -/* module_{enable,disable}_ro() stubs are in module.h */
  static void module_enable_nx(const struct module *mod) { }
- #endif /*  CONFIG_STRICT_MODULE_RWX */
- static void module_enable_x(const struct module *mod)
 +static void module_enable_ro(const struct module *mod, bool after_init) {}
+ static int module_enforce_rwx_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
+                                      char *secstrings, struct module *mod)
  {
-       frob_text(&mod->core_layout, set_memory_x);
-       frob_text(&mod->init_layout, set_memory_x);
+       return 0;
  }
- #else /* !CONFIG_ARCH_HAS_STRICT_MODULE_RWX */
- static void module_enable_nx(const struct module *mod) { }
- static void module_enable_x(const struct module *mod) { }
- #endif /* CONFIG_ARCH_HAS_STRICT_MODULE_RWX */
- 
+ #endif /*  CONFIG_STRICT_MODULE_RWX */
  
  #ifdef CONFIG_LIVEPATCH
  /*