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…
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 =…
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…
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…
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…
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…
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…
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…
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…
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…
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…
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,…
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 +…
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…