This is an archive of the discontinued LLVM Phabricator instance.

[ObjectYAML][DWARF] Make the `PubSection` optional.
ClosedPublic

Authored by Higuoxing on May 28 2020, 6:51 AM.

Details

Summary

This patch helps make the PubSection optional in the DWARF structure.

Diff Detail

Event Timeline

Higuoxing created this revision.May 28 2020, 6:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 28 2020, 6:51 AM
aprantl accepted this revision.May 28 2020, 10:42 AM
This revision is now accepted and ready to land.May 28 2020, 10:42 AM
jhenderson accepted this revision.May 29 2020, 2:33 AM

LGTM, once one comment is addressed.

llvm/test/ObjectYAML/MachO/DWARF-pubsections.yaml
3

perhaps change this line to "section in object files from the DWARF entry of Mach-O YAML inputs".

grimar added inline comments.May 29 2020, 2:39 AM
llvm/lib/ObjectYAML/MachOEmitter.cpp
299

I think you should do this:

...
} else if (0 == strncmp(&Sec.sectname[0], "__debug_pubnames", 16) {
  if (Obj.DWARF.PubNames)
    DWARFYAML::EmitPubSection(OS, *Obj.DWARF.PubNames,  Obj.IsLittleEndian);
} else
....

Otherwise the code will continue doing strncmp for the following else branches, what is
probably not the desired flow.

llvm/tools/obj2yaml/dwarf2yaml.cpp
149

Thoughts (not for this patch):

Looking on this, I seems it would be better to change the dumpPubSection to
something like:

static DWARFYAML::PubSection dumpPubSection(DWARFContext &DCtx, DWARFSection Section, bool IsGNU);

It should simplify the code here and also will allow to switch to return Expected<DWARFYAML::PubSection> later.

Higuoxing marked 2 inline comments as done.May 29 2020, 4:50 AM
Higuoxing added inline comments.
llvm/lib/ObjectYAML/MachOEmitter.cpp
299

Got it! Thanks for the suggestion!

llvm/tools/obj2yaml/dwarf2yaml.cpp
149

Thanks! I will do it later.

This revision was automatically updated to reflect the committed changes.