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

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 22 01:13:58 PDT 2020


jhenderson added a comment.

Not sure where, but my analysis of the test case suggests there's still a bug in the calculation.



================
Comment at: llvm/test/tools/yaml2obj/ELF/program-header-nobits.yaml:27
+## This segment includes sections 1 to 6.
+# NOOFFSET-NEXT: LOAD 0x000000 0x0000000200000000 0x0000000200000000 0x000220 0x000510
+# OFFSET-NEXT:   LOAD 0x000158 0x0000000200000158 0x0000000200000158 0x0000c8 0x0003b8
----------------
I might be failing at counting, but shouldn't MemSiz here be 0x4f0? (i.e. 0x2000003f0 + 0x100 - 0x200000000 == Final section address + final section size - base address).


================
Comment at: llvm/test/tools/yaml2obj/ELF/program-header-nobits.yaml:28
+# NOOFFSET-NEXT: LOAD 0x000000 0x0000000200000000 0x0000000200000000 0x000220 0x000510
+# OFFSET-NEXT:   LOAD 0x000158 0x0000000200000158 0x0000000200000158 0x0000c8 0x0003b8
+## This segment includes sections 1 to 5.
----------------
(Same here, but for 0x398 rather than 0x3b8).


================
Comment at: llvm/test/tools/yaml2obj/ELF/program-header-nobits.yaml:30-31
+## This segment includes sections 1 to 5.
+# NOOFFSET-NEXT: LOAD 0x000000 0x0000000200000000 0x0000000200000000 0x000220 0x000410
+# OFFSET-NEXT:   LOAD 0x000158 0x0000000200000158 0x0000000200000158 0x0000c8 0x0002b8
+## This segment includes sections 1 to 4 + the .filler chunk.
----------------
Same off by 0x20 problem here.


================
Comment at: llvm/test/tools/yaml2obj/ELF/program-header-nobits.yaml:33-34
+## This segment includes sections 1 to 4 + the .filler chunk.
+# NOOFFSET-NEXT: LOAD 0x000000 0x0000000200000000 0x0000000200000000 0x000200 0x000220
+# OFFSET-NEXT:   LOAD 0x000158 0x0000000200000158 0x0000000200000158 0x0000a8 0x0000c8
+## This segment includes the first two sections.
----------------
FileSize here looks like it should be 0x220, matching the memory size (which looks to be correct). It looks like the .nobits2 section is not being allocated file space, even though there's something non-nobits appearing after it. Please correct my understanding if I've misunderstood something. Same problem with the OFFSET case (off by 0x20 in file size).


================
Comment at: llvm/test/tools/yaml2obj/ELF/program-header-nobits.yaml:35
+# OFFSET-NEXT:   LOAD 0x000158 0x0000000200000158 0x0000000200000158 0x0000a8 0x0000c8
+## This segment includes the first two sections.
+# NOOFFSET-NEXT: LOAD 0x000000 0x0000000200000000 0x0000000200000000 0x00015a 0x00015a
----------------
I was slightly surprised to not see a case for sections 1 to 4 or 1 to 3, but I assume that's because the 1 to 6 and 1 to 5 are essentially equivalent?


================
Comment at: llvm/test/tools/yaml2obj/ELF/program-header-nobits.yaml:137
+    Size:   0x1D0
+    Offset: 0x220
+  - Name:  .nobits4
----------------
Am I right in thinking that this is unnecessary now? The fill chunk should cause this section to be placed after it, and if my counting is correct, that'll result in it appearing at 0x220 naturally.


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

https://reviews.llvm.org/D78005





More information about the llvm-commits mailing list