[obj2yaml] - Fix the issue with dumping empty sections when dumping program headers.
authorGeorgii Rymar <grimar@accesssoftek.com>
Tue, 7 Apr 2020 15:20:51 +0000 (18:20 +0300)
committerGeorgii Rymar <grimar@accesssoftek.com>
Wed, 22 Apr 2020 09:36:00 +0000 (12:36 +0300)
commit317c4913c642f8f7fa0fb150fd5e656b59f20a4a
treec80336292de5207367719716e970c8bfa5cdd828
parent0736d1ccf32ba4e6fe860942d8a6d05f964f058e
[obj2yaml] - Fix the issue with dumping empty sections when dumping program headers.

Imagine we have:

```
ProgramHeaders:
  - Type:  PT_LOAD
    Flags: [ PF_W, PF_R ]
    Sections:
      - Section: .bar
    VAddr: 0x2000
Sections:
  - Name:    .foo
    Type:    SHT_PROGBITS
    Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
    Address: 0x1000
  - Name:    .bar
    Type:    SHT_PROGBITS
    Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
    Address: 0x2000
```

Both `.foo` and `.bar` share the same starting file offset,
but `VA(.foo)` < `VA(PT_LOAD)`, we should not include it into segment.

This patch fixes the issue.

Differential revision: https://reviews.llvm.org/D77652
llvm/test/Object/obj2yaml.test
llvm/test/tools/obj2yaml/program-headers.yaml
llvm/tools/obj2yaml/elf2yaml.cpp