[all-commits] [llvm/llvm-project] d95f8e: [yaml2obj][MachO] - Fix PubName/PubType handling.

Georgii Rymar via All-commits all-commits at lists.llvm.org
Fri Jun 12 02:04:23 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: d95f8e7aef79393fbb95b8483c9f494da75b1d83
      https://github.com/llvm/llvm-project/commit/d95f8e7aef79393fbb95b8483c9f494da75b1d83
  Author: Georgii Rymar <grimar at accesssoftek.com>
  Date:   2020-06-12 (Fri, 12 Jun 2020)

  Changed paths:
    M llvm/lib/Support/YAMLTraits.cpp
    M llvm/test/ObjectYAML/MachO/DWARF-pubsections.yaml

  Log Message:
  -----------
  [yaml2obj][MachO] - Fix PubName/PubType handling.

`PubName` and `PubType` are optional fields since D80722.

They are defined as:
  Optional<PubSection> PubNames;
  Optional<PubSection> PubTypes;

And initialized in the following way:
  IO.mapOptional("debug_pubnames", DWARF.PubNames);
  IO.mapOptional("debug_pubtypes", DWARF.PubTypes);

But problem is that because of the issue in `YAMLTraits.cpp`,
when there are no `debug_pubnames`/`debug_pubtypes` keys in a YAML description,
they are not initialized to `Optional::None` as the code expects, but they
are initialized to default `PubSection()` instances.

Because of this, the `if` condition in the following code is always true:

if (Obj.DWARF.PubNames)
  Err = DWARFYAML::emitPubSection(OS, *Obj.DWARF.PubNames,
                                  Obj.IsLittleEndian);

What means `emitPubSection` is always called and it writes few values.

This patch fixes the issue. I've reduced `sizeofcmds` by size of data
previously written because of this bug.

Differential revision: https://reviews.llvm.org/D81686




More information about the All-commits mailing list