Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8535433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:25:48+00:00 2026-06-11T10:25:48+00:00

If I run a program, just like #include <stdio.h> int main(int argc, char *argv[],

  • 0

If I run a program, just like

#include <stdio.h>
int main(int argc, char *argv[], char *env[]) {
  printf("My references are at %p, %p, %p\n", &argc, &argv, &env);
}

We can see that those regions are actually in the stack.
But what else is there? If we ran a loop through all the values in Linux 3.5.3 (for example, until segfault) we can see some weird numbers, and kind of two regions, separated by a bunch of zeros, maybe to try to prevent overwriting the environment variables accidentally.

Anyway, in the first region there must be a lot of numbers, such as all the frames for each function call.

How could we distinguish the end of each frame, where the parameters are, where the canary if the compiler added one, return address, CPU status and such?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:25:49+00:00Added an answer on June 11, 2026 at 10:25 am

    The contents of the stack are basically:

    • Whatever the OS passes to the program.
    • Call frames (also called stack frames, activation areas, …)

    What does the OS pass to the program? A typical *nix will pass the environment, arguments to the program, possibly some auxiliary information, and pointers to them to be passed to main().

    In Linux, you’ll see:

    • a NULL
    • the filename for the program.
    • environment strings
    • argument strings (including argv[0])
    • padding full of zeros
    • the auxv array, used to pass information from the kernel to the program
    • pointers to environment strings, ended by a NULL pointer
    • pointers to argument strings, ended by a NULL pointer
    • argc

    Then, below that are stack frames, which contain:

    • arguments
    • the return address
    • possibly the old value of the frame pointer
    • possibly a canary
    • local variables
    • some padding, for alignment purposes

    How do you know which is which in each stack frame? The compiler knows, so it just treats its location in the stack frame appropriately. Debuggers can use annotations for each function in the form of debug info, if available. Otherwise, if there is a frame pointer, you can identify things relative to it: local variables are below the frame pointer, arguments are above the stack pointer. Otherwise, you must use heuristics, things that look like code addresses are probably code addresses, but sometimes this results in incorrect and annoying stack traces.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#include <cv.h> #include <highgui.h> int main(int argc,char** argv[]) { cvNamedWindow(video,CV_WINDOW_AUTOSIZE); CvCapture* capture = cvCreateFileCapture(Input_1.avi);
Just to test, I ran this code #include<unistd.h> #include<stdio.h> #include<stdlib.h> int main() { int
#include <stdio.h> #include <curl/curl.h> int main(void) { CURL *curl; CURLcode res; curl = curl_easy_init();
I just want that my program or method should run at specific date and
To run a program with custom env settings, we do this on Linux $
Here's a simple hello world C program that takes 10 seconds to complete: #include<stdio.h>
I want to design a c# program which can run program a 3rd exe
I get the following error when running mongo-hadoop streaming: java.io.IOException: Cannot run program "mapper.py":
There is a space in the string, but when I run program, it returns
I can run my program outside of a jar file, but I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.