mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 23:03:27 +08:00
arch/addrenv: Change text write enable/disable to generic mprot
Implement a generic access rights modification procedure instead of the procedures that only do one thing (enable/disable write) to one section (text).
This commit is contained in:
@@ -30,12 +30,17 @@
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "libelf.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ELF_TEXT_WRE (PROT_READ | PROT_WRITE | PROT_EXEC)
|
||||
#define ELF_TEXT_WRD (PROT_READ | PROT_EXEC)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Constant Data
|
||||
****************************************************************************/
|
||||
@@ -175,7 +180,8 @@ int elf_addrenv_select(FAR struct elf_loadinfo_s *loadinfo)
|
||||
|
||||
/* Allow write access to .text */
|
||||
|
||||
ret = up_addrenv_text_enable_write(&loadinfo->addrenv);
|
||||
ret = up_addrenv_mprot(&loadinfo->addrenv, loadinfo->textalloc,
|
||||
loadinfo->textsize, ELF_TEXT_WRE);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: up_addrenv_text_enable_write failed: %d\n", ret);
|
||||
@@ -207,7 +213,8 @@ int elf_addrenv_restore(FAR struct elf_loadinfo_s *loadinfo)
|
||||
|
||||
/* Remove write access to .text */
|
||||
|
||||
ret = up_addrenv_text_disable_write(&loadinfo->addrenv);
|
||||
ret = up_addrenv_mprot(&loadinfo->addrenv, loadinfo->textalloc,
|
||||
loadinfo->textsize, ELF_TEXT_WRD);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: up_addrenv_text_disable_write failed: %d\n", ret);
|
||||
|
||||
Reference in New Issue
Block a user