Avoid duplicated code.

This also fixes the linker script accounting for the ELF header in
some places but not in others.

llvm-svn: 282173
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 6cdf097..e42240f 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1148,11 +1148,7 @@
 
 // Assign VAs (addresses at run-time) to output sections.
 template <class ELFT> void Writer<ELFT>::assignAddresses() {
-  uintX_t VA = Config->ImageBase;
-  if (!Config->OFormatBinary)
-    VA +=
-        Out<ELFT>::ElfHeader->getSize() + Out<ELFT>::ProgramHeaders->getSize();
-
+  uintX_t VA = Config->ImageBase + getHeaderSize<ELFT>();
   uintX_t ThreadBssOffset = 0;
   for (OutputSectionBase<ELFT> *Sec : OutputSections) {
     uintX_t Alignment = Sec->getAlignment();