Lowest and highest memory address in c?

Is there a way to print the lowest and highest memory address that the operating system can address in c?

+3
source share
5 answers

No, this is not a hallmark of standard C. No matter what solution you need, you will need to specify the OS.

If you have a specific OS, keep this in mind. But it's hard for me to wonder why this matters. There was no need to write C programs, so perhaps you could enlighten us.

Based on your comment:

I'm curious, "if every process gets an address space in memory, can I print the top address and bottom address of this process?"

, . , , , . , , x86, 4G, "" ( ).

( , ).

, - .

+3

Linux , /proc/[PID]/maps; . proc (5). :

$ cat /proc/self/maps
08048000-0804f000 r-xp 00000000 03:01 63119      /bin/cat
0804f000-08050000 rw-p 00006000 03:01 63119      /bin/cat
08050000-08071000 rw-p 08050000 00:00 0          [heap]
b7c58000-b7e09000 r--p 00000000 03:05 243564     /usr/lib/locale/locale-archive
b7e09000-b7e0a000 rw-p b7e09000 00:00 0
b7e0a000-b7f39000 r-xp 00000000 03:01 63497      /lib/libc-2.7.so
b7f39000-b7f3a000 r--p 0012f000 03:01 63497      /lib/libc-2.7.so
b7f3a000-b7f3c000 rw-p 00130000 03:01 63497      /lib/libc-2.7.so
b7f3c000-b7f40000 rw-p b7f3c000 00:00 0
b7f5b000-b7f5c000 rw-p b7f5b000 00:00 0
b7f5c000-b7f76000 r-xp 00000000 03:01 63276      /lib/ld-2.7.so
b7f76000-b7f78000 rw-p 00019000 03:01 63276      /lib/ld-2.7.so
bfc83000-bfc98000 rw-p bffeb000 00:00 0          [stack]
ffffe000-fffff000 r-xp 00000000 00:00 0          [vdso]

0xfffff000, 0xfffff000 - 1.

+3

, 32- () [0x00000000, 0xFFFFFFFF]. , . , , , , , ..

, , , .

, 0x0010F444 () , .

+3

. , , , .

0

- , - . , " C", ?

, , - . - brk (2)/sbrk (2). , .

0
source

Source: https://habr.com/ru/post/1722174/


All Articles