开发者

gcc: __DATA,__const vs __TEXT,__const

开发者 https://www.devze.com 2022-12-13 02:51 出处:网络
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 initializ开发者_开发百科e

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 initializ开发者_开发百科ed 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


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消