[PATCH] D78005: [yaml2obj] - Reimplement how tool calculates memory sizes of segments.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 4 02:07:58 PDT 2020


grimar planned changes to this revision.
grimar marked 2 inline comments as done.
grimar added inline comments.


================
Comment at: llvm/test/tools/yaml2obj/ELF/program-header-nobits.yaml:188-189
+## This segment includes the first section only.
+# NOOFFSET-NEXT: LOAD 0x000000 0x0000000200000000 0x0000000200000000 0x0001c8 0x0001c9
+# OFFSET-NEXT:   LOAD 0x000158 0x0000000200000158 0x0000000200000158 0x000070 0x000071
+
----------------
jhenderson wrote:
> Just to make sure I'm clear - the file space in these last cases is due to the file header and program header table? It might be worth mentioning this somewhere in the comments.
> the file space in these last cases is due to the file header and program header table?
Nah :( 

It's because after adding 2 program headers in the last update, sections offset have changed.
The offset of the first section was previously 0x158, but now it is 0x1c8.

The following piece still assumes it is 0x158.

```
## Set file offsets of segments to the offset of the first section to show
## that with a non-zero offset we still calculate memory and file sizes properly.
# RUN: yaml2obj %s --docnum=3 -DOFFSET=0x158 -DVADDR=0x200000158 -o %t6
# RUN: llvm-readelf --sections --segments %t6 | FileCheck %s --check-prefixes=COMMON,OFFSET
```
And 0x1c8 - 0x158 = 0x70.

So techinally all values are calculated correctly, but it does not do what comment says now.
Going to fix it again. 


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

https://reviews.llvm.org/D78005





More information about the llvm-commits mailing list