Skip to main content

Questions tagged [stack-pointer]

The register that points to the current location in the call-stack. Details vary by CPU architecture, but implicit use by push/pop instructions is common. (Please also include an architecture tag!)

stack-pointer
20 votes
2 answers
1k views

How to prepare stack pointer for bare metal Rust?

I'm trying to write an x86 bootloader and operating system completely in Rust (no separate assembly files, only inline assembly within Rust). My bootloader works completely as intended within the QEMU ...
suman's user avatar
  • 305
1 vote
1 answer
89 views

How to get the stack pointer and return address and restore them to a previous state

I'm trying to implement a poor man's call with current continuation for a program written in C. I can "easily" access and memcpy the relevant part of the C stack (obviously, that's not ...
Stefan's user avatar
  • 28.2k
2 votes
2 answers
91 views

If the stack grows downwards, how does it not overlap with other stuff in the address space?

I realized I never really thought of this. If I made a large enough recursive call chain, wouldn't the stack eventually grow down enough that it will overlap with other things, like shared libraries (...
natitati's user avatar
  • 167
1 vote
1 answer
153 views

ARM Cortex-M PC and SP values - reset behavior

I am trying to understand the ARM cortex-M hardware behavior on reset; particularly how the SP and PC values are written upon a cold start or hard reset. Basically, it would seem the hardware (aka PE ...
NeedToKnow's user avatar
5 votes
1 answer
90 views

Why does the Stack Pointer in MIPS Typically Start at 0x7FFFFFFC but not 0x80000000?

According to Patterson & Hennessy's Computer Organization and Design (MIPS Edition), the stack pointer $sp is typically initialized to 0x7FFFFFFC. the stack pointer $sp is always pointing at the ...
Flandia Yingman's user avatar
1 vote
1 answer
91 views

Using end of memory address as process stack pointer value causing INVPC hard fault

In STM32L432KC(arm cortex-m4+FPU) there are two ram memory blocks. Following is a snippet from the linker script I use. _e_ram2_stack = ORIGIN(RAM2) + LENGTH(RAM2); _e_ram_stack = ORIGIN(RAM ) + ...
zenprogrammer's user avatar
0 votes
0 answers
37 views

How Stack is filled and how ESP behaves during stack overflow exploitation

I sent the following string using python to the vulnerable application buffer = prefix + overflow + return_addr (of JMP ESP) + NOPs + shellcode The above buffer string successfully gave me the reverse ...
Fantastic_bug's user avatar
3 votes
0 answers
81 views

Clang ignores -mstack-alignment=XX flag

This is related to an issue described in this question -- a reproducible example can be found there, as well as a description of the environment (briefly: Apple Silicon with macOS Sonoma and clang 15)....
swineone's user avatar
  • 2,684
0 votes
1 answer
113 views

Cortex M4 stacking and unstacking with a diferent stack pointer

It is possible to achieve this in a cortex-m4? What i mean is having PSP only on that intervals, and all the rest MSP when there is an interrupt? The objective is just to do the stacking and ...
AB3's user avatar
  • 3
0 votes
0 answers
62 views

I can't use RSP to reference the end of the stack

in my system (x86_64), when I'm using GDB, both RBP and RSP point to the same memory address after pushing a new stack frame, therefore I can't reference the end of the stack with the register RSP ...
strjak's user avatar
  • 5
1 vote
1 answer
75 views

STM8 Assembly startup code: Access Core registers to initialize stack pointer

I am currently trying to write startup code in assembly for an STM8 without any vendor libraries. More specifically, I am using an STM8S103f3p6. I am still inexperienced in assembly and with startup ...
Alex's user avatar
  • 69
0 votes
1 answer
46 views

Frame, Stack Frame in process Stacking Unstacking

Stacking process When I talked about the stacking process I was talking about the frame that it would store the data of CPU registers like PC(Program counter) or LR but the advisor said it wasn't and ...
tta's user avatar
  • 1
0 votes
1 answer
72 views

Stack pointer add on loop

Learning some reverse engineering and I came across some examples of loops in x86 assembly 00401036 mov [ebp+var_4], 0 0040103D mov [ebp+var_8], 0 00401044 loc_401044: 00401044 ...
Kenneth Cox's user avatar
1 vote
0 answers
310 views

STM32 and SP value at startup: should the reset handler set SP manually?

I am experiencing a sporadic bug on some STM32F7s. While usually SP register takes its initial value from reset vector (stored in persistent read-only memory), sometimes it is initially set to an ...
Giuseppe Guerrini's user avatar
2 votes
0 answers
139 views

What happens in the CPU if I pop / push all the stack?

I am doing an energy profile of an ARM processor for an academic project. I managed to measure the power consumption of several assembly instructions by running them in a ~200 insts loop, e.g.: .rept ...
Alessandro Bertulli's user avatar

15 30 50 per page
1
2 3 4 5
12