diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c
index 71061621e8bfb..cec270e427acc 100644
--- a/bfd/elfxx-sparc.c
+++ b/bfd/elfxx-sparc.c
@@ -1647,7 +1647,12 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
 
 	  if (h != NULL
 	      && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
-	    break;
+	    {
+	      if (!htab->elf.sgot
+		  && !_bfd_elf_create_got_section (htab->elf.dynobj, info))
+		return false;
+	      break;
+	    }
 	  /* Fall through.  */
 
 	case R_SPARC_DISP8:
diff --git a/ld/testsuite/ld-sparc/got-def.s b/ld/testsuite/ld-sparc/got-def.s
new file mode 100644
index 0000000000000..efca9109dfcb1
--- /dev/null
+++ b/ld/testsuite/ld-sparc/got-def.s
@@ -0,0 +1,15 @@
+	.text
+.LLGETPC0:
+	retl
+	 add	%o7, %l7, %l7
+	.global got
+	.type got, #function
+	.proc   04
+got:
+	save    %sp, -160, %sp
+	sethi	%hi(_GLOBAL_OFFSET_TABLE_-4), %l7
+	call	.LLGETPC0
+	 add	%l7, %lo(_GLOBAL_OFFSET_TABLE_+4), %l7
+	mov	%l7, %o0
+	ret
+	 restore
diff --git a/ld/testsuite/ld-sparc/sparc.exp b/ld/testsuite/ld-sparc/sparc.exp
index 9d684899ee2c2..3e21ed738c443 100644
--- a/ld/testsuite/ld-sparc/sparc.exp
+++ b/ld/testsuite/ld-sparc/sparc.exp
@@ -94,6 +94,10 @@ set sparctests {
     {"32-bit: TLS -fpie" "-melf32_sparc -pie tmpdir/libtlslib32.so" ""
      "--32 -K PIC" {tlspie32.s}
      {{objdump -drj.text tlspie32.dd}} "tlspie32"}
+    {"32-bit: GOT definition"
+     "-melf32_sparc" ""
+     "--32 -K PIC" {got-def.s}
+     {} "got-def"}
     {"32-bit: GOTDATA relocations"
      "-shared -melf32_sparc --hash-style=sysv" ""
      "--32 -K PIC" {gotop32.s}
@@ -134,6 +138,10 @@ set sparc64tests {
      "-melf64_sparc -pie -Ttext-segment=0x100000 tmpdir/libtlslib64.so" ""
      "--64 -Av9 -K PIC" {tlspie64.s}
      {{objdump -drj.text tlspie64.dd}} "tlspie64"}
+    {"64-bit: GOT definition"
+     "-melf64_sparc" ""
+     "--64 -Av9 -K PIC" {got-def.s}
+     {} "got-def"}
     {"64-bit: GOTDATA relocations"
      "-shared -melf64_sparc --hash-style=sysv" ""
      "--64 -Av9 -K PIC" {gotop64.s}
