-
May 28th, 2008, 12:51 AM
#1
C++ program memory layout.
Just like a C program memory is divided into four parts: data segment, code segment, stack and heap, I want to know if a C++ program has the same kind of memory layout (in my knowledge the answer is yes, but my knowledge is very very limited)? does it have some other segment outside of the above four? and where are the vtables stored?
I have tried searching the net for an answer to this but didn't find anything relevant. There is a lot of material on Object memory layout but not this.
Will appreciate all informed discussion.
-
May 28th, 2008, 01:22 AM
#2
Re: C++ program memory layout.
Refer "Inside C++ Object Model" by Stanley B. Lippman
to know about this.
Indranil
Never forget to add reputation if the post is useful.
u never know when u make a miracle so go on exploring...
-
May 28th, 2008, 02:50 AM
#3
Re: C++ program memory layout.
Originally Posted by braveYOU
Refer "Inside C++ Object Model" by Stanley B. Lippman
to know about this.
someone please, PLEASE tell me where to say this so that everybody gets to hear it. mod, maybe this should be a part of forum answering guidelines.
I have complained about this n times before and doing so once again. ANYONE ATTEMPTING TO ANSWER A QUESTION MUST READ IT WITH ATTENTION AND BE ABSOLUTELY POSITIVE THAT HE/SHE UNDERSTANDS WHAT IS BEING ASKED BEFORE POSTING A REPLY. if there is a difficulty in understanding the exact question then please post a request for clarification.
I have specifically made it clear in my post that I am looking for the program memory layout as opposed to the object memory layout and someone comes along with a reply to that post refering to "Inside the C++ Object Model" by Lippman, which incidentally I started reading a week back and is on the verge of completing right now.
nowhere in that book, does Lippman devotedly talks about the program memory layout (and neither do I think the answerer means one can find that in this book).
Please (I repeat) read the question carefully.
I
-
May 28th, 2008, 03:11 AM
#4
Re: C++ program memory layout.
I also have limited knowledge in this area, but from what I understand, this is platform dependent, but what you have listed is typical. I reason that it is platform dependent since it is not dictated by the C and C++ standards (if I am not wrong), and you probably could find out by getting the compiler to output in assembly.
-
May 28th, 2008, 03:24 AM
#5
Re: C++ program memory layout.
I agree with laserlight, it is implementation dependent.
As I understand it, both C and C++ only describe how the program should behave, the language says little or nothing about how the behaviour is achieved.
-
May 28th, 2008, 03:25 AM
#6
Re: C++ program memory layout.
Originally Posted by indrajit_p1
Just like a C program memory is divided into four parts: data segment, code segment, stack and heap, I want to know if a C++ program
C++ is a programming language. All that is specified are the rules of the language. It has no specification on the "layout" of the final executable program. That's why you haven't found anything.
In the C++ specification, you won't find terms such as "data segment", "code segment", "heap", or vtables. The only reference to "stack" is in terms of the std::stack container.
What you want to look for is the way your particular compiler/linker/OS lays out an executable program.
Regards,
Paul McKenzie
-
May 28th, 2008, 03:25 AM
#7
Re: C++ program memory layout.
Laserlight,
err...I don't know Assembly. but thanks for u'r thoughts on this anyway.
I
p.s.: Zachheus and Paul, thanks for clarifying the issue for me.
Last edited by indrajit_p1; May 28th, 2008 at 03:28 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|