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

How to run a linux program at a specified address

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of how the linux program runs at the specified address, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this linux program how to run the article at the specified address. Let's take a look at it.

We know that the address of the program is different every time it runs, and the reason why linux has such a design may be for security reasons, which is not conducive to hackers' attacks.

Let's look at a simple program:

# include

# include

Int main (int argc, char* argv [])

{

Int first = 0

Int * p = malloc (1024)

Printf ("paired% p\ n", p)

Return 0

}

Obviously, the address of the program is different every time!

Is there any way to make the same program run at the same address every time?

When you see here, you may ask why you let the program run at the same address every time. Does this not go against the original intention of OS design? Yes, this does go against the original intention of the linux kernel design. However, it is inevitable that strange requirements will not be encountered in the actual project. For example, some app needs to be run on the specified address due to historical reasons, so you need to turn off the randomization of the address space. For example, if you encounter a random address crash problem, you can also use this method to debug.

To cut the crap, let's take a look at the way address space is randomized and turned off.

Echo 0 > / proc/sys/kernel/randomize_va_space

Or

Sudo sysctl-w kernel.randomize_va_space=0

After turning it off, let's take a look at the test results of the program:

This is the end of the article on "how to run the linux program at a specified address". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how the linux program runs at the specified address". If you want to learn more, you are 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

Internet Technology

Wechat

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

12
Report