1

I was trying to gdb a function, with it's callstack, the calling one falls into address a4734000-a4e93000, so I check the /proc//maps file and found there are:

a4734000-a4e93000 r-xp 00000000 00:00 0 
a4ee0000-a527c000 r-xp 00000000 00:00 0

This doesn't make sense to me, because normally it would show the target binary file that is mapped for the executable addresses. Does anyone know is this some sort of trick? Thanks a lot.

Bill Randerson
  • 1,028
  • 1
  • 11
  • 29

1 Answers1

1

Permission field r-xp contains p, so these mappings are private. Path field is empty, so these mappings are anonymous.

Thus, these are private anonymous mappings, created with MAP_ANON and MAP_PRIVATE flags. They probably were created by malloc(3):

When allocating blocks of memory larger than MMAP_THRESHOLD bytes, the glibc malloc() implementation allocates the memory as a private anonymous mapping using mmap(2).

See also this question and documentation.

Community
  • 1
  • 1
gavv
  • 4,649
  • 1
  • 23
  • 40
  • Thanks to @g-v, great answer. But I still cannot understand why memory created by malloc will have permission "x" on it?? – Bill Randerson Jul 28 '15 at 07:57
  • 1
    See http://pubs.opengroup.org/onlinepubs/009695399/functions/mmap.html and e.g. http://man7.org/linux/man-pages/man2/mprotect.2.html. POSIX: "An implementation may permit accesses other than those specified by prot". Linux: "Whether PROT_EXEC has any effect different from PROT_READ depends on processor architecture, kernel version, and process state". In other words, it's limitation of your hardware (it may not support separate PROT_EXEC flag for a page) or software. – gavv Jul 28 '15 at 08:51