• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Are C++ vtables shared or private memory?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Are C++ vtables shared or private memory?


  • Subject: Re: Are C++ vtables shared or private memory?
  • From: Jonas Maebe <email@hidden>
  • Date: Thu, 10 Sep 2009 23:18:09 +0200


On 10 Sep 2009, at 22:36, Jens Alfke wrote:

Does "__DATA,__const" mean that the vtables are actually in a read- only section, so they just get mapped in as shared memory? (And if so, how does that work? I thought vtables had to be fixed up at load time since they're full of pointers to relocatable code.)

There are two different kinds of const sections under Mac OS X:
* __DATA,__const (aka .const_data in the assembler): this is read-only data that the dynamic linker may have to relocate on startup
* __TEXT,__const (aka .const in the assembler): this is read-only data that cannot contain any relocations


I don't know the sharing properties though (although I assume that .const_data indeed cannot be shared). The description of .const and .const_data in the assembler manual are also a bit confusing/out of date:

***
.const
This is equivalent to .section __TEXT,__const

The compiler places all data declared const and all jump tables it generates for switch statements in this section.
***


That last line is only relevant to PPC code (and possibly ARM). On PPC/ PPC64, jump tables do not contain absolute target addresses, but offsets between the label at the start of the jump table and the destination. Since those offsets are constant, they can be put in the .const section since they don't have to be relocated. i386 and (I think) x86_64 have absolute target addresses in their jump tables. Don't know about ARM.

***
.const_data
This is equivalent to .section __DATA, __const, regular.

This section is of type regular and has no attributes. This section is used when dynamic code is being compiled for const data that must be initialized.
***


I *assume* that "data that must be initialized" refers to "must be relocated on startup". That last sentence sounds a bit weird to me though.


Jonas _______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Are C++ vtables shared or private memory? (From: Jens Alfke <email@hidden>)

  • Prev by Date: Are C++ vtables shared or private memory?
  • Next by Date: Re: Singletons cause static analyzer warning
  • Previous by thread: Are C++ vtables shared or private memory?
  • Next by thread: How the heck do I add a dependent project's build result in 3.2?
  • Index(es):
    • Date
    • Thread