Page MenuHomePhabricator

[MC] Allow Stackmap sections after DWARF in MachO.

Authored by lhames on Mar 8 2020, 10:12 PM.



Mixing stackmaps and DWARF in a single file triggers an assertion in
MCMachOStreamer as stackmap sections are emitted in AsmPrinter::emitEndOfAsmFile
after the DWARF sections have already been emitted.

Since it should be safe to emit stackmap sections after DWARF sections this
patch relaxes the assertion to allow that.

Diff Detail

Event Timeline

lhames created this revision.Mar 8 2020, 10:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 8 2020, 10:12 PM
aprantl accepted this revision.Mar 9 2020, 8:42 AM

Doing it this way should be fine, too.

This revision is now accepted and ready to land.Mar 9 2020, 8:42 AM

Doing it this way should be fine, too.

Adrian, can you comment on why we want the assert there? Preferably in the code as well :)

The order in which we switch to the sections initially influences the section ordering in the Mach-O file. I'm having trouble recalling the details right now, but there was *something* that was sensitive to having a debug info section between two non-debuginfo sections, which would result in -g changing the non-debug part of the object file. I'll see if I can dig it up and comment in the code.

lhames added a comment.Mar 9 2020, 5:37 PM

Ok. I'm going to land this to unblock people who are hitting this assertion.

Adrian: I think your suggestion was to switch to the stackmap section early, since it is only switching late that triggers this assertion? I didn't end up digging too far into this option because the StackMaps instances are hidden members of the target-specific AsmPrinter subclasses: At the moment there's no way to know whether a stackmap section will be needed in the generic AsmPrinter code.

If emitting or switching to the stackmap section is the right thing to do then I could add an AsmPrinter hook for that.

Alternatively, if switching to a section that is ultimately unused is safe, I could just unconditionally switch to the stackmap section early in the AsmPrinter.

What do you think?

This revision was automatically updated to reflect the committed changes.