Correctly align sections.

We have to align the start, not the end.

This should fix crashes on systems where memcpy enforces the expected
alignment.

llvm-svn: 247599
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 6d1c94e..f33257e 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -704,12 +704,14 @@
     uintX_t Align = Sec->getAlign();
     uintX_t Size = Sec->getSize();
     if (Sec->getFlags() & SHF_ALLOC) {
+      VA = RoundUpToAlignment(VA, Align);
       Sec->setVA(VA);
-      VA += RoundUpToAlignment(Size, Align);
+      VA += Size;
     }
+    FileOff = RoundUpToAlignment(FileOff, Align);
     Sec->setFileOffset(FileOff);
     if (Sec->getType() != SHT_NOBITS)
-      FileOff += RoundUpToAlignment(Size, Align);
+      FileOff += Size;
   }
 
   // Add a PHDR for the dynamic table.