[PATCH] D92098: [obj2yaml] - Don't crash when dumping an object with no sections.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 26 00:56:14 PST 2020


grimar added inline comments.


================
Comment at: llvm/test/tools/obj2yaml/ELF/eshnum.yaml:27
+  Type:   ET_REL
+  EShNum: 0x0
+Sections:
----------------
grimar wrote:
> MaskRay wrote:
> > The following may be slightly better:
> > ```
> > --- !ELF
> > FileHeader:
> >   Class:  ELFCLASS64
> >   Data:   ELFDATA2LSB
> >   Type:   ET_REL
> > SectionHeaderTable:
> >   NoHeaders: true
> > ```
> We currently don't emit the `SectionHeaderTable`. Though I guess it might be reasonable to do it when sections are out of order or when there is no section header.
BTW, 

```
--- !ELF
FileHeader:
  Class:  ELFCLASS64
  Data:   ELFDATA2LSB
  Type:   ET_REL
SectionHeaderTable:
  NoHeaders: true
```

is not correct. In this case we have e_shnum = 0. So we should read the number of sections from
the sh_size member of the initial entry in section header table (see test case header comment).

I.e. I think the output here should be the same as YAML input.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92098/new/

https://reviews.llvm.org/D92098



More information about the llvm-commits mailing list