On Mar 13, 2011, at 12:05 PM, Jack Howarth wrote: > On Sun, Mar 13, 2011 at 11:55:02AM -0700, Chris Lattner wrote: >> >> On Mar 13, 2011, at 11:26 AM, Jack Howarth wrote: >> >>>> Yes, I agree that this is a better solution. This error was put into the >>>> linker to detect some overflow conditions for part of the code that >>>> expected the section number to only be a byte. It is likely that "things >>>> worked" only out of luck before. >>>> >>>> -Chris >>> >>> Chris, >>> Is there any documentation or example code on how to properly use >>> subsections in mach-o? >>> My fear is that we are moving from one poorly documented technique to >>> another which may well >>> have it own slate of hidden bugs. >> >> I'm not sure what you mean here Jack. ld64 is open source on the darwin >> page, and if you have all the developer bits installed, the format is >> "documented" in /usr/include/mach-o/. It's pretty clear all around that you >> can only have 256 sections. >> >> -Chris > > Chris, > The mach-o reference has a cryptic mention of MH_SUBSECTIONS_VIA_SYMBOLS in > > http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/MachORuntime/Reference/reference.html > > MH_SUBSECTIONS_VIA_SYMBOLS—The sections of the object file can be divided > into individual blocks. These blocks are dead-stripped if they are not used > by other code. See Linking for details.
Right, "subsections via symbols" is the concept of slicing up a section into "atoms" based on public labels. The linker uses this to do dead code elimination etc. I don't think this helps you at all though. I don't understand why you can't put arbitrary data into a single section. This is what the -sectcreate flag to the linker does, so it is simple, already supported, and tested. -Chris > > Although I don't think this helps us at all because none of the GNU_LTO > sections contain symbols. This is why I > am still perplexed by this assembler change. We followed the rules Nick > suggested of placing all of these GNU_LTO > sections at the end of the file and none contain symbols. In that case, it > would really seem that the assembler is > now blindly counting sections without respect to whether any of them actually > contain symbols. > Jack