diff --git a/src/system/libroot/posix/sys/mman.cpp b/src/system/libroot/posix/sys/mman.cpp index 53ec383990..bcbaee9ed5 100644 --- a/src/system/libroot/posix/sys/mman.cpp +++ b/src/system/libroot/posix/sys/mman.cpp @@ -8,11 +8,13 @@ #include #include +#include #include #include #include +#include #include #include #include @@ -130,8 +132,19 @@ mmap(void* address, size_t length, int protection, int flags, int fd, if ((protection & PROT_EXEC) != 0) areaProtection |= B_EXECUTE_AREA; + // create a name for this area based on calling image + void* addr = __builtin_return_address(0); + char* imageName; + char areaName[B_OS_NAME_LENGTH]; + status_t status = __gRuntimeLoader->get_nearest_symbol_at_address( + addr, NULL, NULL, &imageName, NULL, NULL, NULL, NULL); + if (status == B_OK) + snprintf(areaName, sizeof(areaName), "%s mmap area", imageName); + else + strlcpy(areaName, "mmap area", sizeof(areaName)); + // ask the kernel to map - area_id area = _kern_map_file("mmap area", &address, addressSpec, + area_id area = _kern_map_file(areaName, &address, addressSpec, length, areaProtection, mapping, true, fd, offset); if (area < 0) { __set_errno(area);