Questions tagged [stack-frame]

Use stackframe for questions related to debugging unterminated function calls.

A stackframe is a list of functions that have been invoked but have not yet returned a value

References

291 questions
1
vote
1 answer

Does the System V ABI on Ubuntu place the return address within the caller function's frame or the callee function's frame?

My system : Ubuntu 22.04.3 running on x86_64. GCC version 11.4.0 I'm asking this because it seems like there are two different representations of the return address as far as the frame it is within ( caller or callee ) is concerned. This is what…
alessio solari
  • 313
  • 1
  • 6
1
vote
0 answers

Understanding the order of local variable(s) on the stack frame

The C standard doesn't specify the layout of variables on the stack but I want to understand how local variables are arranged by the gcc compiler. A simple example is given below void fun(int a, int b, int c, int d, char *pass) { int flag =…
noob_user
  • 87
  • 7
1
vote
1 answer

Stack frame size

If I'm looking at the objdump of a C program and this is the Mips breakdown of my int binomial(int n, int k) function, if I allocate the 40 bytes, is that how large/the size of the stack frame or does it depend on the code and how many are used…
Zuja Plays
  • 11
  • 2
1
vote
0 answers

assembly epilogue composition

I'm learning assembly, and I tried compiling the following C code into assembly with GCC with optimization disabled (https://godbolt.org/z/4cz3ocfa5) void f() { int x = 1; int y = 2; int z = 3; } int main() { f(); return…
Guanwei HU
  • 55
  • 4
1
vote
1 answer

the stack pointer doesn't point to the top of the stack

This is a basic C code for a basic function call: int multiply(int num, int k) { return num * k; } int main(int argc, char** argv) { int k = multiply(5,2); } When I tried diassembling this code using the tool available at godbolt.org…
1
vote
1 answer

How go back to another stack frame? C

EDIT: thank alot Im understanding now that I should use gdb I ask for understand how stack frame working and how change things exit(0) and goto its not option How can change that fun 'sec' will return to main? the output will be: print start…
1
vote
0 answers

how dwarf format caculate provious sp pointer

this is example is from dwarf document. How Can I caculate provious sp(r7) pointer,I mean It didnot save sp somewhere since sp is a callee-save register. The architectural ABI committee specifies that the stack pointer (R7) is the same as the…
radong
  • 29
  • 2
1
vote
1 answer

Understanding 16-byte padding and function prolog in x64 assembly

In x64 assembly, the stack frame, according to Microsoft, should be 16-byte aligned The stack will always be maintained 16-byte aligned, except within the prolog (for example, after the return address is pushed), and except where indicated in…
1
vote
1 answer

C# System.Diagnostics.StackFrame.GetFileName always return null

I used the following code to get the name of the source code's file StackTrace trace = new StackTrace(true); string fileName = string.Empty; foreach (var frame in trace.GetFrames()) { string fileToCheck = frame.GetFileName(); if…
1
vote
0 answers

Is it possible to get the source code of the current (multiline) statement using the stack frame?

I'm interested in being able to use code like this to obtain 3 or (3, 7) (the lines containing the current statement), however, f_lineno returns 6 because that is where the actual execution is happening. I was hoping to find the bounds of the…
Bea Steers
  • 11
  • 1
1
vote
2 answers

How do Stack frames work for recursive functions?

I have trouble understanding stack frames for recursive functions. Not sure if this is the right place to ask but I have tried finding examples and I still don't understand it. For example I have this recursive function for a list: def…
PScott
  • 11
  • 3
1
vote
1 answer

Can %rbp be converted to Caller-saved?

I'm a freshman to the assembly field. I'm wondering why %rbp is prescribed for callee-saved. Because I think the frame pointer describes the beginning of the current frame, aka the caller, so the task to save this value should belong to the caller,…
li tang
  • 21
  • 1
  • 5
1
vote
2 answers

Why are parameters allocated below the frame pointer instead of above?

I have tried to understand this basing on a square function in c++ at godbolt.org . Clearly, return, parameters and local variables use “rbp - alignment” for this function. Could someone please explain how this is possible? What then would rbp +…
1
vote
0 answers

Why does the Visual Studio Compiler use "mov esp,ebp" / "pop ebp" instead of "leave"?

Why does the Visual Studio Compiler use mov esp,ebp ; pop ebp instead of using leave? leave : 1 byte MOV ESP, EBP / POP EBP : 3 bytes
1
vote
1 answer

Does the prologue of a function can write outside of its frame?

I'm currently trying to analyse the assembly of an old video game from N64. In order to do so, I'm using some N64 debugger to read and understand the underlying MIPS code. In one of the calls I'm looking at, the prologue is defined as follows: ADDIR…