[yaml2obj] Simplify p_filesz/p_memsz computing
authorFangrui Song <maskray@google.com>
Mon, 9 Sep 2019 16:45:17 +0000 (16:45 +0000)
committerFangrui Song <maskray@google.com>
Mon, 9 Sep 2019 16:45:17 +0000 (16:45 +0000)
commitc28f3e6e2c3ef1323ed18d4c485681bb4ff72ced
tree61ae67185fae95bd78b5bcfc29f558f0a0587c31
parent2b7089949eda508203eb23c835d6a295eb00b46b
[yaml2obj] Simplify p_filesz/p_memsz computing

This fixes a bug as well. When "FileSize:" (p_filesz) is specified and
different from the actual value, the following code probably should not
use PHeader.p_filesz:

  if (SHeader->sh_offset == PHeader.p_offset + PHeader.p_filesz)
    PHeader.p_memsz += SHeader->sh_size;

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D67256

llvm-svn: 371420
llvm/lib/ObjectYAML/ELFEmitter.cpp
llvm/test/tools/yaml2obj/program-header-size-offset.yaml