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 7788379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:58:50+00:00 2026-06-01T20:58:50+00:00

I try to achieve the following: I’m having a pointer p pointing to an

  • 0

I try to achieve the following: I’m having a pointer p pointing to an address holding again an address (this address is also a valid address). Now I want to have another pointer pp pointing to the address which is the content of p. So I’m doing the following:

// Retrieve the start address
unsigned long long *p = getInitialAddress();

// Let pp point to next address
unsigned long long *pp = (unsigned long long*)(*p);

// Print address
printf("0x%llx %p\n", *p, pp);

This prints for example: 0x7fffedc47a70 0x7fffedc47a70 which is the desired result.

However, putting another printf into the code, like this:

// Retrieve the start address
unsigned long long *p = getInitialAddress();

// Print
printf("%p 0x%llx\n", p, *p);

// Let pp point to next address
unsigned long long *pp = (unsigned long long*)(*p);

// Print address
printf("0x%llx %p\n", *p, pp);

Leads to:

0x7fffacea3660 0x7fffacea3680
0x0 (nil)

And this is not the correct result, because it should be

0x7fffacea3660 0x7fffacea3680
0x7fffacea3680 0x7fffacea3680

So does the printf alter something within the pointers or what is wrong?

Edit: Complete code

unsigned long long* readRBP();

int main(void) {
    // Retrieve the start address
    unsigned long long *p = readRBP();

    // Print
    printf("%p 0x%llx\n", p, *p);

    // Let pp point to next address
    unsigned long long *pp = (unsigned long long*)(*p);

    // Print address
    printf("0x%llx %p\n", *p, pp);

    return 0;
}

unsigned long long* readRBP() {
    unsigned long long rbp;
    __asm__ volatile("mov %%rbp, $0" : "=r"(rbp));
    return (unsigned long long*)rbp;
}

This gets the rbp (Stack base pointer). The content of this pointer is the pointer to the next rbp and so on. This rbp is from readRBP() itself, the next rbp belongs to main and the next one after main is 0x0, i. e. the very beginning.

  • 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-01T20:58:52+00:00Added an answer on June 1, 2026 at 8:58 pm

    The value that readRBP returns is the base pointer for the readRBP function. You then call printf which creates its own stack frame. And that stack frame obliterates the data at *p.

    To see that this is so you can write your code this way round:

    int main(void) {
        // Retrieve the start address
        unsigned long long *p = readRBP();
        unsigned long long pContents = *p
        unsigned long long *pp = (unsigned long long*)(*p);
    
        // Print
        printf("%p 0x%llx %p\n", p, pContents, pp);
    
        return 0;
    }
    

    In other words you gather up all the information into the stack frame of main, before you stomp on it by calling printf.

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

Sidebar

Related Questions

I try that a User can be member of several associations. To achieve this
After failing to achieve this with link_to remote, I decided to try jQuery way.
I try to achieve the following layout with Wordpress 3.2.1: ---> ID 4 (Record
I am creating a linqpad script where I want to achieve the following: 1)
Try loading this normal .jpg file in Internet Explorer 6.0. I get an error
Try the following code public enum Color { Blue=1, Red=2, Green=3 } public List<Color>
Try executing the following in JavaScript: parseInt('01'); //equals 1 parseInt('02'); //equals 2 parseInt('03'); //equals
I am programming in C++ and I'm not sure how to achieve the following:
In C++, how can I achieve the following: // player.h #ifndef PLAYER_H #define PLAYER_H
I am try to convert the following NHibernate query using dyanmic instantiation into an

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.