How is temp data stored on the stack frame

Magna
Int test(){
    char buff[10]

    printf("Enter text: ");

    gets(buff);

    puts(buff);
}

I don't know how to phrase this question but I'm trying to understand how values are stored on on the buffer allocated for local variables on the stack frame.

---------------
Return Address
---------------
old ebp
---------------
local variables
--------------- 

Is each block 4 bytes and divided in to 4 1 bytes?

------------------
 00 | 40 | 06 | 06
------------------
 ff | ff | de | 70 
------------------

Through gdb I saw the buffer allocated for test was 0x10

I entered sssssssss:

x/x $rbp = 0xffffde70
x/x $rbp + 8 = 0x00400606
x/s $rbp - 16 = "sssssssss"
x/s $rbp - 8 = "\ns"
x/s $rbp - 4 = ""

So how are the characters(in hex) that I entered stored? like how many on each block. It's a 64 system.

 -----------------
 00 | 40 | 06 | 06
------------------
 ff | ff | de | 70 
------------------
    |    |    | 
------------------
    |    |    | s
------------------
 s  | s  | s  | s
------------------
 s  | s  | s  | s 
------------------
4386427

From a strict C point of view we don't know.

The standard doesn't specify such things. The standard doesn't even mention the concept of a stack. From a standard point of view the code is executed on an abstract machine (i.e. no description of how the machine does it. Only what the machine must do).

So how it is done depends on the specific implementation and it (may) differ from system to system.

You need to find the ABI document for the system you are using. The ABI document will describe how it is done on your system.

See en.wikipedia.org/wiki/Application_binary_interface

Maybe read Where is the x86-64 System V ABI documented?

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to insert data to temp Table in stored procedure with another procedure?

Seeing data stored on the stack

stack data frame by rows

how are integers stored in stack

How are arrays stored on the stack?

how variables are stored on stack?

How to correctly update the user stored data in a full stack app?

Where are the stack frames and the data in it stored?

Stack/Unstack Pandas Data Frame

how to stack the same data frame in itself and change a value in a column per stack in r

How many calls will be stored in stack?

How is the pushd directory stack stored?

How to interpret this stack frame in my control stack?

Send csv data to stored procedure and insert into #temp table

Using ApplicationIntent=ReadOnly with stored procedures which insert data to temp tables

T-SQL - populating data in temp table in stored procedure.

Getting the correct data to be stored into temp table by comparing timerange

Is there a symbol table for local variables stored within a stack frame?

How to select from data frame using column orders stored in two another data frames in R?

How to convert the type of a column stored in a data.frame within a data.table column

How can I find the record from a data set that is most similar to a test record, that is stored in another data frame?

Look up data frame with values stored in another data frame

Only the last stored data is shown in a stack view

Reading Pandas data frame stored with Feather into R

Subsetting columns of a data frame that are stored into variables

Transforming pandas data frame using stack function

Stack a named Date list to data.frame

split a data frame by group and stack horizontally

R stack levels of factor variables into a data frame