I've an address in memory and I want to find out the permissions (r/w/x) of that memory address.
E.g.
char *s = "hello";
Here, the string literal "hello" is stored in read-only memory. When running the program through gdb, is there a possibility to check out the permissions for that memory address (whether only read is permitted or etc) ?
You can first find where
s
is pointing to:and then find the section in which it's in:
and look for the
READONLY
flag.Alternatively, look into
/proc/PID/maps
wherePID
is the pid of the process you're debugging and you can get withinfo proc
.