4

I have a simulation in Matlab Simulink which uses an SO library file with my algo code. I want to know the read/write permissions of a specific memory address using GDB. For example I care about knowing the permissions on the memory of this variable:

(gdb) p &CalValid
$3 = (const WORD *) 0x91f6005c <CalValid>

If I use (gdb) maintenance info sections it shows only the memory space of the matlab process and no the loaded library.

Exec file:

`/appl/matlab2010a32/bin/glnx86/MATLAB', file type elf32-i386.
0x8048134->0x8048147 at 0x00000134: .interp ALLOC LOAD READONLY DATA HAS_CONTENTS
0x8048148->0x8048168 at 0x00000148: .note.ABI-tag ALLOC LOAD READONLY DATA HAS_CONTENTS
...
0x0000->0x00c4 at 0x00001fa0: .comment READONLY HAS_CONTENTS
0x0000->0x0010 at 0x00002064: .gnu_debuglink READONLY HAS_CONTENTS

The reason I need this is because even though the variable is const I have mprotect() elsewhere in the code changing memory permissions of cont variables.

1
  • 2
    AFAIK, there is no built-in command for this. However, if you grab the process ID (info proc), in Linux, you can read the /proc/PID/maps pseudo-file, which reflects the actual memory mappings in the process being debugged; find the address range that contains the symbol, and the third field on that line has the protection mode (rwxsp, where s refers to shared, and p private or copy on write). So, if show configuration in GDB shows --with-python, then you can write a Python extension to GDB to provide this new command for you. Commented Jun 16, 2017 at 23:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.