Blame SOURCES/gdb-rhbz1420304-s390x-29of35.patch

e1d87d
commit b4cbbe8f7294070cc93a71ace78f134965ddad82
e1d87d
Author: Andreas Krebbel <krebbel@linux.vnet.ibm.com>
e1d87d
Date:   Thu Jun 8 17:24:50 2017 +0200
e1d87d
e1d87d
    S/390: Add support for pgste marker
e1d87d
    
e1d87d
    This patch adds a new S/390 specific segment type: PT_S390_PGSTE.  For
e1d87d
    binaries marked with that segment the kernel will allocate 4k page
e1d87d
    tables.  The only user so far will be qemu.
e1d87d
    
e1d87d
    ld/ChangeLog:
e1d87d
    
e1d87d
    2017-06-23  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
e1d87d
    
e1d87d
            * Makefile.in: Add s390.em as build dependency.
e1d87d
            * emulparams/elf64_s390.sh (EXTRA_EM_FILE): Add s390.em.
e1d87d
            * emultempl/s390.em: New file.
e1d87d
            * gen-doc.texi: Add documentation for --s390-pgste option.
e1d87d
            * ld.texinfo: Likewise.
e1d87d
    
e1d87d
    include/ChangeLog:
e1d87d
    
e1d87d
    2017-06-23  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
e1d87d
    
e1d87d
            * elf/s390.h (PT_S390_PGSTE): Define macro.
e1d87d
    
e1d87d
    binutils/ChangeLog:
e1d87d
    
e1d87d
    2017-06-23  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
e1d87d
    
e1d87d
            * readelf.c (get_s390_segment_type): Add support for the new
e1d87d
            segment type PT_S390_PGSTE.
e1d87d
            (get_segment_type): Call get_s390_segment_type.
e1d87d
    
e1d87d
    elfcpp/ChangeLog:
e1d87d
    
e1d87d
    2017-06-23  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
e1d87d
    
e1d87d
            * elfcpp.h (enum PT): Add PT_S390_PGSTE to enum.
e1d87d
    
e1d87d
    bfd/ChangeLog:
e1d87d
    
e1d87d
    2017-06-23  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
e1d87d
    
e1d87d
            * elf-s390.h: New file.
e1d87d
            * elf64-s390.c (struct elf_s390_link_hash_table): Add params
e1d87d
            field.
e1d87d
            (elf_s390_additional_program_headers): New function.
e1d87d
            (elf_s390_modify_segment_map): New function.
e1d87d
            (bfd_elf_s390_set_options): New function.
e1d87d
            (elf_backend_additional_program_headers)
e1d87d
            (elf_backend_modify_segment_map): Add macro definitions.
e1d87d
e1d87d
--- /dev/null
e1d87d
+++ b/bfd/elf-s390.h
e1d87d
@@ -0,0 +1,29 @@
e1d87d
+/* S/390-specific support for ELF.
e1d87d
+   Copyright (C) 2017 Free Software Foundation, Inc.
e1d87d
+
e1d87d
+   This file is part of BFD, the Binary File Descriptor library.
e1d87d
+
e1d87d
+   This program is free software; you can redistribute it and/or modify
e1d87d
+   it under the terms of the GNU General Public License as published by
e1d87d
+   the Free Software Foundation; either version 3 of the License, or
e1d87d
+   (at your option) any later version.
e1d87d
+
e1d87d
+   This program is distributed in the hope that it will be useful,
e1d87d
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
e1d87d
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e1d87d
+   GNU General Public License for more details.
e1d87d
+
e1d87d
+   You should have received a copy of the GNU General Public License
e1d87d
+   along with this program; if not, write to the Free Software
e1d87d
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
e1d87d
+   MA 02110-1301, USA.  */
e1d87d
+
e1d87d
+/* Used to pass info between ld and bfd.  */
e1d87d
+struct s390_elf_params
e1d87d
+{
e1d87d
+  /* Tell the kernel to allocate 4k page tables.  */
e1d87d
+  int pgste;
e1d87d
+};
e1d87d
+
e1d87d
+bfd_boolean bfd_elf_s390_set_options (struct bfd_link_info *info,
e1d87d
+				      struct s390_elf_params *params);
e1d87d
--- a/bfd/elf64-s390.c
e1d87d
+++ b/bfd/elf64-s390.c
e1d87d
@@ -25,6 +25,7 @@
e1d87d
 #include "libbfd.h"
e1d87d
 #include "elf-bfd.h"
e1d87d
 #include "elf/s390.h"
e1d87d
+#include "elf-s390.h"
e1d87d
 #include <stdarg.h>
e1d87d
 
e1d87d
 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
e1d87d
@@ -660,6 +661,9 @@ struct elf_s390_link_hash_table
e1d87d
 
e1d87d
   /* Small local sym cache.  */
e1d87d
   struct sym_cache sym_cache;
e1d87d
+
e1d87d
+  /* Options passed from the linker.  */
e1d87d
+  struct s390_elf_params *params;
e1d87d
 };
e1d87d
 
e1d87d
 /* Get the s390 ELF linker hash table from a link_info structure.  */
e1d87d
@@ -3966,6 +3970,70 @@ elf64_s390_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
e1d87d
   return elf_s390_merge_obj_attributes (ibfd, info);
e1d87d
 }
e1d87d
 
e1d87d
+/* We may add a PT_S390_PGSTE program header.  */
e1d87d
+
e1d87d
+static int
e1d87d
+elf_s390_additional_program_headers (bfd *abfd ATTRIBUTE_UNUSED,
e1d87d
+				     struct bfd_link_info *info)
e1d87d
+{
e1d87d
+  struct elf_s390_link_hash_table *htab;
e1d87d
+
e1d87d
+  htab = elf_s390_hash_table (info);
e1d87d
+  return htab->params->pgste;
e1d87d
+}
e1d87d
+
e1d87d
+
e1d87d
+/* Add the PT_S390_PGSTE program header.  */
e1d87d
+
e1d87d
+static bfd_boolean
e1d87d
+elf_s390_modify_segment_map (bfd *abfd ATTRIBUTE_UNUSED,
e1d87d
+			     struct bfd_link_info *info)
e1d87d
+{
e1d87d
+  struct elf_s390_link_hash_table *htab;
e1d87d
+  struct elf_segment_map *m, *pm = NULL;
e1d87d
+
e1d87d
+  htab = elf_s390_hash_table (info);
e1d87d
+  if (!htab->params->pgste)
e1d87d
+    return TRUE;
e1d87d
+
e1d87d
+  /* If there is already a PT_S390_PGSTE header, avoid adding
e1d87d
+     another.  */
e1d87d
+  m = elf_seg_map (abfd);
e1d87d
+  while (m && m->p_type != PT_S390_PGSTE)
e1d87d
+    {
e1d87d
+      pm = m;
e1d87d
+      m = m->next;
e1d87d
+    }
e1d87d
+
e1d87d
+  if (m)
e1d87d
+    return TRUE;
e1d87d
+
e1d87d
+  m = (struct elf_segment_map *)
e1d87d
+    bfd_zalloc (abfd, sizeof (struct elf_segment_map));
e1d87d
+  if (m == NULL)
e1d87d
+    return FALSE;
e1d87d
+  m->p_type = PT_S390_PGSTE;
e1d87d
+  m->count = 0;
e1d87d
+  m->next = NULL;
e1d87d
+  if (pm)
e1d87d
+    pm->next = m;
e1d87d
+
e1d87d
+  return TRUE;
e1d87d
+}
e1d87d
+
e1d87d
+bfd_boolean
e1d87d
+bfd_elf_s390_set_options (struct bfd_link_info *info,
e1d87d
+			  struct s390_elf_params *params)
e1d87d
+{
e1d87d
+  struct elf_s390_link_hash_table *htab;
e1d87d
+
e1d87d
+  htab = elf_s390_hash_table (info);
e1d87d
+  htab->params = params;
e1d87d
+
e1d87d
+  return TRUE;
e1d87d
+}
e1d87d
+
e1d87d
+
e1d87d
 /* Why was the hash table entry size definition changed from
e1d87d
    ARCH_SIZE/8 to 4? This breaks the 64 bit dynamic linker and
e1d87d
    this is the only reason for the s390_elf64_size_info structure.  */
e1d87d
@@ -4046,6 +4114,8 @@ const struct elf_size_info s390_elf64_size_info =
e1d87d
 #define elf_backend_plt_sym_val		      elf_s390_plt_sym_val
e1d87d
 #define elf_backend_add_symbol_hook           elf_s390_add_symbol_hook
e1d87d
 #define elf_backend_sort_relocs_p             elf_s390_elf_sort_relocs_p
e1d87d
+#define elf_backend_additional_program_headers elf_s390_additional_program_headers
e1d87d
+#define elf_backend_modify_segment_map	      elf_s390_modify_segment_map
e1d87d
 
e1d87d
 #define bfd_elf64_mkobject		elf_s390_mkobject
e1d87d
 #define elf_backend_object_p		elf_s390_object_p
e1d87d
--- a/include/elf/s390.h
e1d87d
+++ b/include/elf/s390.h
e1d87d
@@ -37,6 +37,9 @@
e1d87d
 
e1d87d
 #define EF_S390_HIGH_GPRS        0x00000001
e1d87d
 
e1d87d
+/* Request 4k page table size.  */
e1d87d
+#define PT_S390_PGSTE (PT_LOPROC + 0)
e1d87d
+
e1d87d
 /* Relocation types.  */
e1d87d
 
e1d87d
 START_RELOC_NUMBERS (elf_s390_reloc_type)