2

I am currently reading Linux Kernel Development by Robert Love.

In the chapter "15 The Process Address Space" he prints the memory map of a process.

user@machine:~$ pmap 1424
#all the processes mapped memory (skipped for readability)
bfffe000 (8KB)        rwxp (0:00 0)         [ stack ]

The last line shows the stack (as it grows down).
He now states:

The stack is, naturally, readable, writeable and executable - not of much use otherwise.

As far as I know we use the stack for data and code addresses (functions and their parameters/variable).

I do not understand why the stack must be executable?

1 Answer 1

6

That information is outdated, and the stack is typically not executable any more:

00007ffd884fa000    356K rw---   [ stack ]

GCC needs an executable stack if it generates trampolines for nested function calls. These trampolines are small pieces of code generated at runtime, and stored on the stack — so if they are used, the stack needs to be executable. The compiler keeps track of this requirement, and it outputs a flag in binaries (libraries and executables) to indicate whether they need an executable stack. You can see and manipulate the value of this flag using execstack(8).

2
  • Thanks for the answer. I did not have access to a linux machine since I read the chapter and it was really bugging me. Commented Feb 23, 2017 at 11:46
  • On the other hand, inner functions are being used more and more. It's better code.
    – Joshua
    Commented Oct 16, 2018 at 15:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .