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
memory-management linux memory-address


source to share


No one has answered this question yet

Check out similar questions:

4800
How do I find all files containing specific text in Linux?
1773
How to symbolize a file in Linux?
1528
How to change the output echo color in Linux
1324
How do I prompt for Yes / No / Cancel input in a Linux shell script?
1101
How to copy a folder with files to another folder in Unix / Linux?
1101
How to chmod a folder and all its subfolders and files in Linux Ubuntu Terminal?
27
How do I access physical addresses from user space in Linux?
2
Memory card - device file in linux kernel
1
Getting physical memory for pid display on linux
0
What is the rationale for mapping the Linux kernel to as much RAM as possible in a direct mapping (linear mapping) area?



All Articles
Loading...
X
Show
Funny
Dev
Pics