[PATCH] D41619: [llvm-objcopy] Use physical instead of virtual address when aligning and placing sections in binary

Jake Ehrlich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 9 12:19:53 PST 2018


jakehehrlich added a comment.

After some further testing (read, writing strange assembly files and linker scripts) it seems like segments are indeed layed out to create a proper memory image (Owen's current recommendation) however allocated sections that are not in segments are pushed to alignment regardless of address. So I believe your change would be consistent with that. I'm not sure how I got the idea that these were being pushed to alignment especially considering that I explicitly checked to see if it was creating a memory image or if it was pushing to alignment. I believe at the time of writing that test (was like the second non-trivial feature added) I was using yaml2obj to produce sections to test that on and I must not have used program headers.

So my current recommendation is that segments be laid out such that the lowest physical address is assigned offset zero and subsequent segments are assigned offsets by subtracting the lowest physical address from their physical address. Sections are then written out as they currently are. The front part of the first segment still needs to be chopped off by adding/subtracting Diff from all the needed values so that the first section is properly handled.

I think in a nut shell the segments should be laid out the way the loader would lay them out and the section layout should basically stay the same. Thanks for getting to the bottom of this Owen!


https://reviews.llvm.org/D41619





More information about the llvm-commits mailing list