Index: ELF/SyntheticSections.cpp
===================================================================
--- ELF/SyntheticSections.cpp
+++ ELF/SyntheticSections.cpp
@@ -587,10 +587,15 @@
 
 GotSection::GotSection()
     : SyntheticSection(SHF_ALLOC | SHF_WRITE, SHT_PROGBITS,
-                       Target->GotEntrySize, ".got") {}
+                       Target->GotEntrySize, ".got") {
+  // If the target saves the GlobalOffsetTable as the first entry in the .got,
+  // increase NumEntries by  GotHeaderEntriesNum.
+  if (ElfSym::GlobalOffsetTable && !Target->GotBaseSymInGotPlt)
+    NumEntries += Target->GotHeaderEntriesNum;
+}
 
 void GotSection::addEntry(Symbol &Sym) {
-  Sym.GotIndex = Target->GotHeaderEntriesNum + NumEntries;
+  Sym.GotIndex = NumEntries;
   ++NumEntries;
 }
 
@@ -622,7 +627,7 @@
 }
 
 void GotSection::finalizeContents() {
-  Size = (NumEntries + Target->GotHeaderEntriesNum) * Config->Wordsize;
+  Size = NumEntries * Config->Wordsize;
 }
 
 bool GotSection::empty() const {
Index: test/ELF/ppc64_entry_point.s
===================================================================
--- test/ELF/ppc64_entry_point.s
+++ test/ELF/ppc64_entry_point.s
@@ -1,7 +1,7 @@
 # REQUIRES: ppc
 # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t
 # RUN: ld.lld %t -o %t2
-# RUN: llvm-objdump -d %t2 | FileCheck %s
+# RUN: llvm-objdump -D %t2 | FileCheck %s
 
 .text
 .abiversion 2
@@ -31,3 +31,6 @@
 // CHECK-NEXT: 10010004:       00 00 84 38     addi 4, 4, 0
 // CHECK-NEXT: 10010008:       02 00 a0 3c     lis 5, 2
 // CHECK-NEXT: 1001000c:       00 80 a5 38     addi 5, 5, -32768
+// CHECK: Disassembly of section .got:
+// CHECK-NEXT: .got:
+// CHECK-NEXT: 10020000:       00 80 02 10