Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of Program memory Space allocation under CentOS

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you the CentOS program memory space allocation example analysis, I believe that most people do not know much, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!

Let's take a look at a simple piece of code:

[cpp] view plaincopy views the code chip derived to my code chip # include # include int main () {printf ("% d\ n", getpid ()) on CODE; while (1);}

Running result:

At this time, open another terminal, type cat / proc/10073/maps, and the following display appears:

[cpp] view plaincopy views the code chip derived from my code chip on CODE 08048000-08049000 r-xp 00000000 fd:01 14844 / home/Alex/DaNei/Interview/a.out 08049000-0804a000 Rafael p 00000000 fd:01 14844 / home/Alex/DaNei/Interview/a.out 0804a000-0804b000 rw-p 00001000 fd:01 14844 / home/Alex/DaNei/Interview/a.out 4427b000-4429a000 r-xp 00000000 fd:01 3917 / usr/lib/ld -2.17.so 4429a000-4429b000 Rmurmurp 0001e000 fd:01 393917 / usr/lib/ld-2.17.so 4429b000-4429c000 rw-p 0001f000 fd:01 393917 / usr/lib/ld-2.17.so 442a3000-4445b000 r-xp 00000000 fd:01 393918 / usr/lib/libc-2.17.so 4445b000-4445c000-p 001b8000 fd:01 393918 / usr/lib/libc-2.17.so 4445c000-4445e000 Rmuri p 001b8000 fd:01 393918 / usr/lib/libc-2.17.so 4445e000-4445f000 rw-p 001ba000 fd:01 393918 / usr/lib/libc-2.17.so 4445f000-44462000 rw-p 00000000 00:00 0 b7752000-b7753000 rw-p 00000000 00:00 0 b7769000-b776b000 rw-p 00000000 00:00 0 b776b000-b776c000 r-xp 00000000 00:00 0 [vdso] bfe13000-bfe34000 rw-p 00000000 00:00 0 [stack]

In fact, the first line is the memory space occupied by the code area, 804800-804900. In fact, almost all linux program code segments start from 804800, the second line is the memory space occupied by the global stack area, the third line is the memory space occupied by the heap space, and the last line is the memory space occupied by the local stack.

At the same time, we will find that except that the permission of the code snippet is r-xp (readable-unwritable-executable-private protection), the other three are unexecutable.

The above is all the contents of the article "sample Analysis of Program memory Space allocation under CentOS". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report