How to get a reliable Linux x86_64 bit memory card
I have a very simple program for adding two variables, written in c. I am running it on a Linux machine. I want to see all memory references / virtual addresses that are referenced during program execution. From the program I am getting the virtual address (somehow), but I don’t know which address belongs to user space and which one belongs to kernel space.
I've used some helpers (none served the purpose):
- Getting a memory card for each device in Linux:
sudo cat /proc/iomem
- for more:
sudo cat /proc/vmallocinfo
- Process memory card:
pmap -x pids
- The memory area of the process:
cat /proc/pid/maps
.
For 32 bits, I know Linux only uses 4 segments:
- 2 segments (code and data / stack) for KERNEL SPACE from
[0xC000 0000]
(3 GB) to[0xFFFF FFFF]
(4 GB) - 2 segments (code and data / stack) for USER SPACE from
[0x0000 0000]
(0 GB) to[0xBFFF FFFF]
(3 GB)
But I want to know the similar range for 64 bits.
MY code
#include <stdio.h>
#include <stdlib.h>
int main(){
int a = 1, b = 2, c;
void *ptr;
c = a + b;
ptr = malloc(8);
printf("Result %d %p \n", c, ptr);
return 0;
}
Bonus: if possible, find out the virtual address for user code, library space and system / kernel space as well.
+3
source to share
No one has answered this question yet
Check out similar questions: