tags:

views:

70

answers:

3

According to the Mac OS X ABI Mach-O File Format Reference, __DATA,__const holds Initialized relocatable constant variables. I poked around a bit and it looks like gcc places initialized const structures and arrays in __DATA, __const. Why not __TEXT,__const, though?

Koi8rModel and CI_nsJSCID, for example, are initialized const structures, whereas AlignStrings is an array.

nm -m MinefieldNoPic.app/Contents/MacOS/firefox-bin |grep Koi8rModel
000000010156ce80 (__DATA,__const) non-external _Koi8rModel

nm -m MinefieldNoPic.app/Contents/MacOS/firefox-bin |grep CI_nsJSCID
0000000101441060 (__DATA,__const) non-external __ZL10CI_nsJSCID

nm -m MinefieldNoPic.app/Contents/MacOS/firefox-bin |grep AlignStrings
000000010154f8c0 (__DATA,__const) non-external __ZL13sAlignStrings
+1  A: 

Classically, TEXT in this context means "code". It does seem Mac OS X throws things around, but as pointed out by other posters, what you find is what you should expect on your platform.

unwind
Not quite true, non relocatable initialized data actuallay belongs to the __TEXT, __const section. http://developer.apple.com/mac/library/DOCUMENTATION/DeveloperTools/Conceptual/MachORuntime/Reference/reference.html#//apple_ref/doc/uid/TP40000895-CH248-95908
drhirsch
A: 

The __TEXT, __const section is for non-relocatable initialized constant data. An example would be a jumtable. Relocatable read-only data, like the examples you gave, go to __DATA, __const.

drhirsch
A: 

I just realized that my question contained the answer. __DATA,__const is for relocatable bits indeed but the reason the bits in my question are relocatable is because they are pointers and thus need to be fixed up at runtime.

wagerlabs