Consider this simple code:
class X {
int i_;
public:
X();
};
void f() {
X x;
}
The stack frame of f is 32-byte long with GCC, which is unnecessarily long. The return address and x just need 12 bytes and 16-byte alignment should be required…
I am trying to get class name with the extension (e.g. Employee.cs or Employee.aspx.cs) in my code. I was able to get the name of the class without the extension but does anybody know how can i also get extension of the class??
This is what i did to…
I had some problem when I learned about assembly code.
I use "compiler explorer" that is a website that supporting a lot of compiler.
I made a simple code and compiled it as x86-64 gcc.
:
int sum(int a, int b)
{
return a + b;
}
int…
Assume we are passing arguments to a subroutine using the stack frame as follows:
addi $sp, $sp, -8
sw $s0, 0($sp)
jal sub
lw $s1, 4($sp)
addi $sp, $sp, 8
sub: lw $t0, 0($sp)
... do stuff ...
sw $t1, 4($sp)
jr $ra
I understand the concepts of…
Intoduction
I'm creating a statically typed language where all variables are treated as static global variables. Therefore the amount of memory required is known at compile time (similar to how Fortran 66 works). I've observed that the structure of…
I've written the following function to play around with inline assembly a bit and print out various registers:
void run(void)
{
long rsp, rbp;
asm("mov %%rsp, %0;" "mov %%rbp, %1;" : "=r" (rsp), "=r" (rbp));
printf("Middle\n%%rsp =…
Would the following work as a way to approximate the stack position of the current frame?
int main(int argc, char *argv[])
{
char a = 'a';
printf("The current stack is around: %p\n", &a);
...
}
I would think this would give be where…
I understand that for C at least the stack frame and return address are written to the stack every time the recursive function is called, but is there an obscure way of making it not run out of memory? Obviously this is purely a hypothetical…
When I'm at a breakpoint in my Java app under Eclipse debugger, I click on another frame in the stack frame list (on the same thread), expecting to be able to view some of my variables. There's only one variable, this, and when I reveal what it…
addi $sp, $sp, -32 # stack frame is 32 bytes long
sw $ra, 20($sp) # save return address
sw $fp, 16($sp) # save frame pointer
addi $fp, $sp, 28 # set up frame pointer
sw $a0, 0($fp) # save argument (n)
I'm a bit lost…
I have the following source code (in a file named vuln.cpp) in C:
#include
#include
int main(int argc, char ** argv)
{
char real[20];
char pass[20] = "dddddddddddddddd";
if(argc < 2)
{
…
I was reading assembly tutorials and got stuck on stack operations and function calls. As said here, when fuction A calls function B, it passes first 4 arguments in registers(by value or pointer) and next ones are passed via stack. Also, caller…
I was going through the stack frame, so every function call gets pushed into stack frame and popped when completed, so when the if block is executed does it gets pushed onto stack frame, or will it get executed in current method stack entry?
I'm interested in how the stack works and have a problem with understanding how the stack frame destruction occurs. I'm playing with code below:
public class Container
{
public unsafe int* t1;
public unsafe int* t2;
public unsafe int*…
I'm new to assembly lang and I'm a bit confused on some things. For an assignment, I'm given a C program and asked to asked to put breakpoints at two points and count the stack frames and their locations.
This is the code :
int swap_n_add(int *xp,…