[PATCH] D19416: [ELF] - Align sections file offsets correctly.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 26 04:28:32 PDT 2016
grimar added inline comments.
================
Comment at: ELF/Writer.cpp:1667-1670
@@ +1666,6 @@
+
+ // Relocatable output does not have program headers
+ // and does not need any other offset adjusting.
+ if (Config->Relocatable || !(Sec->getFlags() & SHF_ALLOC))
+ return Off;
+
----------------
ruiu wrote:
> For relocatable output, do we even have to adjust file offset?
Did not find anywhere that we should not do that for -r. But gold and bfd both do that, so I guess yes,
probably there is no special rules for relocation outputs.
================
Comment at: ELF/Writer.cpp:1672-1679
@@ +1671,10 @@
+
+ uintX_t PageSize = Target->PageSize;
+ uintX_t VA = Sec->getVA();
+ uintX_t Mask = PageSize - 1;
+ if ((VA & Mask) != (Off & Mask)) {
+ uintX_t Val = ((Off & ~Mask) | (VA & Mask));
+ Off = Val < Off ? (Val + PageSize) : Val;
+ }
+ return Off;
+}
----------------
ruiu wrote:
> Can this be
>
> return alignTo(Off, PageSize, Sec->getVA())?
I think yes.
http://reviews.llvm.org/D19416
More information about the llvm-commits
mailing list