Fix -fsection-anchors on Darwin

Mike Stump
Mon Apr 26 21:56:00 GMT 2010

On Apr 14, 2010, at 8:47 AM, Jack Howarth wrote:
>   Could you update your comments on this? Since it seems unlikely
> that the linker will ever been changed on darwin to support section-anchors,
> it seems to leave on the turning off subsections_via_symbols if we
> wanted to implement section-anchors support on darwin, no?

I don't believe they have changed any, nor has the linker, that leaves just changing the compiler to manage subsections_via_symbols appropriately.

>> If the optimizer wants to jam all the data together into one object  
>> itself, and then write out that object, that would work as well, and  
>> there is something appealing about that.  Also, to get nice codegen and 
>> dead code stripping, I think we want LTO to manage this issue.
> Since it appears that Mach-O LTO will be possible, I assume this can
> be handled through that option.

I'm not an LTO expert, so I can't comment on it, though, if I randomly guessed, yes, it probably could.

On Apr 14, 2010, at 9:00 AM, Jack Howarth wrote:
> This openradar seems to discuss disabling subsections_via_symbols in the
> assembly file but doesn't indicate how to do it from within the compiler...

You say:

int do_subsections;

if (do_subsection)
  printf(". subsections_via_symbols\n");

and then set do_subsections appropriately (when flag_section_anchors is on).   See darwin.c for the one line that needs to be changed.

With that off, the linker should not reorder and slice and dice, or at least, that's the theory.

More information about the Gcc-patches mailing list