]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
s390x: Set .got sh_entsize only if .got size > 0
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 23 Nov 2020 13:06:51 +0000 (05:06 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 23 Nov 2020 13:13:55 +0000 (05:13 -0800)
bfd/

PR ld/26918
* elf64-s390.c (elf_s390_finish_dynamic_sections): Set .got
sh_entsize only if .got size > 0.

ld:

PR ld/26918
* testsuite/ld-s390/pr26918-1.d: New file.
* testsuite/ld-s390/pr26918-1.s: Likewise.
* testsuite/ld-s390/s390.exp: Run all *.d tests.

bfd/ChangeLog
bfd/elf64-s390.c
ld/ChangeLog
ld/testsuite/ld-s390/pr26918-1.d [new file with mode: 0644]
ld/testsuite/ld-s390/pr26918-1.s [new file with mode: 0644]
ld/testsuite/ld-s390/s390.exp

index 36a048a872a307118f32ea098442935580599bb1..6a552c701bdea713429b481e8236d32ba4d98041 100644 (file)
@@ -1,3 +1,9 @@
+2020-11-23  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/26918
+       * elf64-s390.c (elf_s390_finish_dynamic_sections): Set .got
+       sh_entsize only if .got size > 0.
+
 2020-11-21  Nelson Chu  <nelson.chu@sifive.com>
 
        * elfnn-riscv.c (_bfd_riscv_relax_section):  Add a new relax pass
index 41b19bcd2cedb0441bd616a338fff303e7dd7b2d..d6a46b1d8c4bc4dd8b7c064a146c2dfb6787a6a5 100644 (file)
@@ -3547,7 +3547,7 @@ elf_s390_finish_dynamic_sections (bfd *output_bfd,
          bfd_put_64 (output_bfd, (bfd_vma) 0,
                      htab->elf.hgot->root.u.def.section->contents + 16);
        }
-      if (elf_section_data (htab->elf.splt->output_section) != NULL)
+      if (htab->elf.sgot != NULL && htab->elf.sgot->size > 0)
        elf_section_data (htab->elf.sgot->output_section)
          ->this_hdr.sh_entsize = 8;
     }
index 2ee87783bd2b55315fa5a5d5959d12dca1bbc4fe..2d687f9ed30628f2c698af5701c7173579c3a31a 100644 (file)
@@ -1,3 +1,10 @@
+2020-11-23  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/26918
+       * testsuite/ld-s390/pr26918-1.d: New file.
+       * testsuite/ld-s390/pr26918-1.s: Likewise.
+       * testsuite/ld-s390/s390.exp: Run all *.d tests.
+
 2020-11-23  Shahab Vahedi  <shahab@synopsys.org>
 
        * testsuite/ld-arc/tls_ie-01.d: Use a more general pattern.
diff --git a/ld/testsuite/ld-s390/pr26918-1.d b/ld/testsuite/ld-s390/pr26918-1.d
new file mode 100644 (file)
index 0000000..147ed98
--- /dev/null
@@ -0,0 +1,5 @@
+#as: -m64 -mzarch -march=z900
+#ld: -m elf64_s390 -e start -static
+#readelf: -r --wide
+
+There are no relocations in this file.
diff --git a/ld/testsuite/ld-s390/pr26918-1.s b/ld/testsuite/ld-s390/pr26918-1.s
new file mode 100644 (file)
index 0000000..980bc41
--- /dev/null
@@ -0,0 +1,19 @@
+       .machinemode zarch
+       .machine "z900"
+.text
+       .align  8
+.globl start
+       .type   start, @function
+start:
+       larl    %r1,foo@GOTENT
+       lg      %r1,0(%r1)
+       lgf     %r2,0(%r1)
+       br      %r14
+       .size   start, .-start
+.globl foo
+.bss
+       .align  4
+       .type   foo, @object
+       .size   foo, 4
+foo:
+       .zero   4
index 660cf4b8b075f331f9194ae691fd021ee71f874c..ee3438e8a7e7b9d46af9e298006542697f470019 100644 (file)
@@ -95,3 +95,10 @@ if [istarget "s390x-*-*"] {
     run_ld_link_tests $s390tests
     run_ld_link_tests $s390xtests
 }
+
+set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
+foreach t $test_list {
+    # We need to strip the ".d", but can leave the dirname.
+    verbose [file rootname $t]
+    run_dump_test [file rootname $t]
+}