]> granicus.if.org Git - llvm/commit
[yaml2obj] Set p_align to the maximum sh_addralign of contained sections
authorFangrui Song <maskray@google.com>
Tue, 10 Sep 2019 09:16:34 +0000 (09:16 +0000)
committerFangrui Song <maskray@google.com>
Tue, 10 Sep 2019 09:16:34 +0000 (09:16 +0000)
commite6608fd47d2dc3aa7323cf9320da745f39c55f3c
tree8279446407cb01ba0a9e0384db1c1871e8cd5bc4
parent591903131ec8b4c37d0ddf3d5507a64db06eb4aa
[yaml2obj] Set p_align to the maximum sh_addralign of contained sections

The address difference between two sections in a PT_LOAD is a constant.
Consider a hypothetical case (pagesize can be very small, say, 4).

```
.text     sh_addralign=4
.text.hot sh_addralign=16
```

If we set p_align to 4, the PT_LOAD will be loaded at an address which
is a multiple of 4. The address of .text.hot is guaranteed to be a
multiple of 4, but not necessarily a multiple of 16.

This patch deletes the constraint

  if (SHeader->sh_offset == PHeader.p_offset)

Reviewed By: grimar, jhenderson

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371501 91177308-0d34-0410-b5e6-96231b3b80d8
lib/ObjectYAML/ELFEmitter.cpp
test/tools/yaml2obj/program-header-align.yaml