[PATCH] D106942: Consider section flags when adding section

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 4 01:01:23 PDT 2021


mstorsjo added a comment.

In D106942#2921637 <https://reviews.llvm.org/D106942#2921637>, @jhenderson wrote:

> @mstorsjo, could you take a look, please? My COFF knowledge isn't really sufficient to see if there's a better way of doing things. My initial thought is whether a separate later pass should be the one that sets virtual addresses, rather than addSection, but it may not make sense.

I think approach is pragmatically sensible here.

We don't recalculate and set virtual addresses for all sections, only added ones. (We generally can't change the virtual memory layout of the linked image as there are lots of relative addresses encoded anywhere in the section contents without any relocation marker, as those relocations were fixed at link time. So we can remove sections from the end and add new ones at the end, but we generally can't remove ones in the middle leaving a gap.) So if we split out setting addresses to a separate pass, it would only run over the sections that were added, not all of them. So keeping it in `addSection` and just checking the flags to set like this patch does, probably is fine.



================
Comment at: llvm/test/tools/llvm-objcopy/COFF/set-flags-on-setion-added.test:14
+# CHECK-ADD-NEXT:    VirtualSize: 0x9
+# CHECK-ADD-NEXT:    VirtualAddress: 0x9
+
----------------
I don't see any check here that actually verifies that the newly added sections get the right flags here?


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

https://reviews.llvm.org/D106942



More information about the llvm-commits mailing list