tbaeder / rpms / gdb

Forked from rpms/gdb 2 years ago
Clone
Jan Kratochvil 4f1de05
commit 79c12faeea57e61364b6a7a3e411b096edce989c
Jan Kratochvil 4f1de05
Author: Andreas Krebbel <krebbel@linux.vnet.ibm.com>
Jan Kratochvil 4f1de05
Date:   Fri Jul 28 17:59:25 2017 +0200
Jan Kratochvil 4f1de05
Jan Kratochvil 4f1de05
    S/390: Fix segfault when linking -shared -nostartfiles
Jan Kratochvil 4f1de05
    
Jan Kratochvil 4f1de05
    Regression-tested on s390x.
Jan Kratochvil 4f1de05
    
Jan Kratochvil 4f1de05
    bfd/ChangeLog:
Jan Kratochvil 4f1de05
    
Jan Kratochvil 4f1de05
    2017-07-28  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
Jan Kratochvil 4f1de05
    
Jan Kratochvil 4f1de05
            * elf32-s390.c (elf_s390_finish_dynamic_sections): Add NULL
Jan Kratochvil 4f1de05
            pointer check for htab->elf.irelplt.
Jan Kratochvil 4f1de05
            * elf64-s390.c (elf_s390_finish_dynamic_sections): Likewise.
Jan Kratochvil 4f1de05
Jan Kratochvil 4f1de05
--- a/bfd/elf32-s390.c
Jan Kratochvil 4f1de05
+++ b/bfd/elf32-s390.c
Jan Kratochvil 4f1de05
@@ -3941,7 +3941,9 @@ elf_s390_finish_dynamic_sections (bfd *output_bfd,
Jan Kratochvil 4f1de05
 	      break;
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
 	    case DT_PLTRELSZ:
Jan Kratochvil 4f1de05
-	      dyn.d_un.d_val = htab->elf.srelplt->size + htab->elf.irelplt->size;
Jan Kratochvil 4f1de05
+	      dyn.d_un.d_val = htab->elf.srelplt->size;
Jan Kratochvil 4f1de05
+	      if (htab->elf.irelplt)
Jan Kratochvil 4f1de05
+		dyn.d_un.d_val += htab->elf.irelplt->size;
Jan Kratochvil 4f1de05
 	      break;
Jan Kratochvil 4f1de05
 	    }
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
--- a/bfd/elf64-s390.c
Jan Kratochvil 4f1de05
+++ b/bfd/elf64-s390.c
Jan Kratochvil 4f1de05
@@ -3745,7 +3745,9 @@ elf_s390_finish_dynamic_sections (bfd *output_bfd,
Jan Kratochvil 4f1de05
 	      break;
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
 	    case DT_PLTRELSZ:
Jan Kratochvil 4f1de05
-	      dyn.d_un.d_val = htab->elf.srelplt->size + htab->elf.irelplt->size;
Jan Kratochvil 4f1de05
+	      dyn.d_un.d_val = htab->elf.srelplt->size;
Jan Kratochvil 4f1de05
+	      if (htab->elf.irelplt)
Jan Kratochvil 4f1de05
+		dyn.d_un.d_val += htab->elf.irelplt->size;
Jan Kratochvil 4f1de05
 	      break;
Jan Kratochvil 4f1de05
 
Jan Kratochvil 4f1de05
 	    case DT_RELASZ:
Jan Kratochvil 4f1de05
@@ -3756,7 +3758,9 @@ elf_s390_finish_dynamic_sections (bfd *output_bfd,
Jan Kratochvil 4f1de05
 		 linker script arranges for .rela.plt to follow all
Jan Kratochvil 4f1de05
 		 other relocation sections, we don't have to worry
Jan Kratochvil 4f1de05
 		 about changing the DT_RELA entry.  */
Jan Kratochvil 4f1de05
-	      dyn.d_un.d_val -= htab->elf.srelplt->size + htab->elf.irelplt->size;
Jan Kratochvil 4f1de05
+	      dyn.d_un.d_val -= htab->elf.srelplt->size;
Jan Kratochvil 4f1de05
+	      if (htab->elf.irelplt)
Jan Kratochvil 4f1de05
+		dyn.d_un.d_val -= htab->elf.irelplt->size;
Jan Kratochvil 4f1de05
 	      break;
Jan Kratochvil 4f1de05
 	    }
Jan Kratochvil 4f1de05