Linked Questions
18 questions linked to/from Trying to understand gcc option -fomit-frame-pointer
3 votes
0 answers
2k views
What is the benefits of "fomit-frame-pointer"? [duplicate]
"-fomit-frame-pointer" means the way we don't have to pushq %rbp and move %rsp, %rbp; we need to only change the value of %rsp. As far as i think, stack frame dealing with the base pointer ...
0 votes
1 answer
225 views
Assembly code for __rdtsc() in -O0 vs -O3 [duplicate]
I have the following code: #include <x86intrin.h> int main() { return __rdtsc(); } And I tried to compile on my machine (Intel i7-6700 CPU) and objdump g++ -Wall test_tsc.cpp -o test_tsc -...
0 votes
0 answers
166 views
Why function prologue is not showing in function disassembly? [duplicate]
I'm trying to understand how a function call works in assembly language. My understanding is, after calling a function, the callee function first uses a function prologue to create a new stack frame ...
128 votes
7 answers
48k views
How exactly does the callstack work?
I'm trying to get a deeper understanding of how the low level operations of programming languages work and especially how they interact with the OS/CPU. I've probably read every answer in every stack/...
65 votes
2 answers
81k views
Why are RBP and RSP called general-purpose registers?
According to Intel, in x64, the following registers are called general-purpose registers (RAX, RBX, RCX, RDX, RBP, RSI, RDI, RSP and R8-R15). In the article Understanding C by learning assembly, it's ...
9 votes
2 answers
3k views
Why does x86 architecture use two stack registers (esp ; ebp)?
My question is simple, Why do x86 architecture use two stack registers (esp ; ebp)? The length of stack frame has been determined during compile time, then I think we can just use one register (for ...
7 votes
2 answers
2k views
Why is dynamic link required in function activation record? (in static scoped language)
I read that the dynamic link points to the previous activation record ( aka a "stack frame"), so it makes sense in dynamic scoped programming language. But in static scoped programming ...
1 vote
1 answer
2k views
x86-64 GNU Assembly
While investigating a crash, I came across the following code snippet and immediately recognized that the mov instruction should actually be movq to get the correct 64-bit register operation. #elif ...
5 votes
2 answers
1k views
Is the stack frame required for all functions in C on x86-64?
I've made a function to calculate the length of a C string (I'm trying to beat clang's optimizer using -O3). I'm running macOS. _string_length1: push rbp mov rbp, rsp xor rax, rax .body: ...
1 vote
5 answers
2k views
"PUSH" "POP" Or "MOVE"?
When it comes to temporarily storage for an existing value in a register, all modern compilers(at least the ones I experienced) do PUSH and POP instructions. But why not store the data in another ...
1 vote
1 answer
2k views
Why does `-fno-omit-frame-pointer` interfere with ASAN?
During a recent project, I've tested combinations of different compiler flags and sanitizers to evaluate the relevance for debugging my C-code. By testing the impact of these combinations, I stumbled ...
8 votes
1 answer
2k views
How to disable automatic "pass by pointer" optimization in clang++?
I have a function void X(Object o) { .... } When I compile it, I see, that clang changes its signature to void X(Object* o) It is inconvenient, because I use this function from some llvm IR code ...
1 vote
3 answers
1k views
Why does main initialize stack frame when there are no variables
why does this code: #include "stdio.h" int main(void) { puts("Hello, World!"); } decide to initialize a stack frame? Here is the assembly code: .LC0: .string "Hello, World!" main: ...
1 vote
2 answers
2k views
How to calculate the stack frame in assembly within gdb?
I'm trying to explore the debugging of an assembly code (x86, 32bit, C source code). I would like to understand how can I calculate the actual size of the stack frame of particular function in my ...
0 votes
1 answer
314 views
How to find a C stack pointer associated with execution of a CPython stack frame
Update: If it helps narrow down the question for anyone, this question is really more about the CPython API and whether or not I'm missing some way to reach information that I need. I'm not asking ...