S/390: Add support for pgste marker
This patch adds a new S/390 specific segment type: PT_S390_PGSTE. For binaries marked with that segment the kernel will allocate 4k page tables. The only user so far will be qemu. ld/ChangeLog: 2017-06-23 Andreas Krebbel <krebbel@linux.vnet.ibm.com> * Makefile.in: Add s390.em as build dependency. * emulparams/elf64_s390.sh (EXTRA_EM_FILE): Add s390.em. * emultempl/s390.em: New file. * gen-doc.texi: Add documentation for --s390-pgste option. * ld.texinfo: Likewise. include/ChangeLog: 2017-06-23 Andreas Krebbel <krebbel@linux.vnet.ibm.com> * elf/s390.h (PT_S390_PGSTE): Define macro. binutils/ChangeLog: 2017-06-23 Andreas Krebbel <krebbel@linux.vnet.ibm.com> * readelf.c (get_s390_segment_type): Add support for the new segment type PT_S390_PGSTE. (get_segment_type): Call get_s390_segment_type. elfcpp/ChangeLog: 2017-06-23 Andreas Krebbel <krebbel@linux.vnet.ibm.com> * elfcpp.h (enum PT): Add PT_S390_PGSTE to enum. bfd/ChangeLog: 2017-06-23 Andreas Krebbel <krebbel@linux.vnet.ibm.com> * elf-s390.h: New file. * elf64-s390.c (struct elf_s390_link_hash_table): Add params field. (elf_s390_additional_program_headers): New function. (elf_s390_modify_segment_map): New function. (bfd_elf_s390_set_options): New function. (elf_backend_additional_program_headers) (elf_backend_modify_segment_map): Add macro definitions.
This commit is contained in:
parent
790ba5c898
commit
b4cbbe8f72
10 changed files with 217 additions and 1 deletions
29
bfd/elf-s390.h
Normal file
29
bfd/elf-s390.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/* S/390-specific support for ELF.
|
||||||
|
Copyright (C) 2017 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
||||||
|
MA 02110-1301, USA. */
|
||||||
|
|
||||||
|
/* Used to pass info between ld and bfd. */
|
||||||
|
struct s390_elf_params
|
||||||
|
{
|
||||||
|
/* Tell the kernel to allocate 4k page tables. */
|
||||||
|
int pgste;
|
||||||
|
};
|
||||||
|
|
||||||
|
bfd_boolean bfd_elf_s390_set_options (struct bfd_link_info *info,
|
||||||
|
struct s390_elf_params *params);
|
|
@ -25,6 +25,7 @@
|
||||||
#include "libbfd.h"
|
#include "libbfd.h"
|
||||||
#include "elf-bfd.h"
|
#include "elf-bfd.h"
|
||||||
#include "elf/s390.h"
|
#include "elf/s390.h"
|
||||||
|
#include "elf-s390.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
|
/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
|
||||||
|
@ -660,6 +661,9 @@ struct elf_s390_link_hash_table
|
||||||
|
|
||||||
/* Small local sym cache. */
|
/* Small local sym cache. */
|
||||||
struct sym_cache sym_cache;
|
struct sym_cache sym_cache;
|
||||||
|
|
||||||
|
/* Options passed from the linker. */
|
||||||
|
struct s390_elf_params *params;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Get the s390 ELF linker hash table from a link_info structure. */
|
/* Get the s390 ELF linker hash table from a link_info structure. */
|
||||||
|
@ -3966,6 +3970,70 @@ elf64_s390_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
|
||||||
return elf_s390_merge_obj_attributes (ibfd, info);
|
return elf_s390_merge_obj_attributes (ibfd, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We may add a PT_S390_PGSTE program header. */
|
||||||
|
|
||||||
|
static int
|
||||||
|
elf_s390_additional_program_headers (bfd *abfd ATTRIBUTE_UNUSED,
|
||||||
|
struct bfd_link_info *info)
|
||||||
|
{
|
||||||
|
struct elf_s390_link_hash_table *htab;
|
||||||
|
|
||||||
|
htab = elf_s390_hash_table (info);
|
||||||
|
return htab->params->pgste;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Add the PT_S390_PGSTE program header. */
|
||||||
|
|
||||||
|
static bfd_boolean
|
||||||
|
elf_s390_modify_segment_map (bfd *abfd ATTRIBUTE_UNUSED,
|
||||||
|
struct bfd_link_info *info)
|
||||||
|
{
|
||||||
|
struct elf_s390_link_hash_table *htab;
|
||||||
|
struct elf_segment_map *m, *pm = NULL;
|
||||||
|
|
||||||
|
htab = elf_s390_hash_table (info);
|
||||||
|
if (!htab->params->pgste)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
/* If there is already a PT_S390_PGSTE header, avoid adding
|
||||||
|
another. */
|
||||||
|
m = elf_seg_map (abfd);
|
||||||
|
while (m && m->p_type != PT_S390_PGSTE)
|
||||||
|
{
|
||||||
|
pm = m;
|
||||||
|
m = m->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
m = (struct elf_segment_map *)
|
||||||
|
bfd_zalloc (abfd, sizeof (struct elf_segment_map));
|
||||||
|
if (m == NULL)
|
||||||
|
return FALSE;
|
||||||
|
m->p_type = PT_S390_PGSTE;
|
||||||
|
m->count = 0;
|
||||||
|
m->next = NULL;
|
||||||
|
if (pm)
|
||||||
|
pm->next = m;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bfd_boolean
|
||||||
|
bfd_elf_s390_set_options (struct bfd_link_info *info,
|
||||||
|
struct s390_elf_params *params)
|
||||||
|
{
|
||||||
|
struct elf_s390_link_hash_table *htab;
|
||||||
|
|
||||||
|
htab = elf_s390_hash_table (info);
|
||||||
|
htab->params = params;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Why was the hash table entry size definition changed from
|
/* Why was the hash table entry size definition changed from
|
||||||
ARCH_SIZE/8 to 4? This breaks the 64 bit dynamic linker and
|
ARCH_SIZE/8 to 4? This breaks the 64 bit dynamic linker and
|
||||||
this is the only reason for the s390_elf64_size_info structure. */
|
this is the only reason for the s390_elf64_size_info structure. */
|
||||||
|
@ -4046,6 +4114,8 @@ const struct elf_size_info s390_elf64_size_info =
|
||||||
#define elf_backend_plt_sym_val elf_s390_plt_sym_val
|
#define elf_backend_plt_sym_val elf_s390_plt_sym_val
|
||||||
#define elf_backend_add_symbol_hook elf_s390_add_symbol_hook
|
#define elf_backend_add_symbol_hook elf_s390_add_symbol_hook
|
||||||
#define elf_backend_sort_relocs_p elf_s390_elf_sort_relocs_p
|
#define elf_backend_sort_relocs_p elf_s390_elf_sort_relocs_p
|
||||||
|
#define elf_backend_additional_program_headers elf_s390_additional_program_headers
|
||||||
|
#define elf_backend_modify_segment_map elf_s390_modify_segment_map
|
||||||
|
|
||||||
#define bfd_elf64_mkobject elf_s390_mkobject
|
#define bfd_elf64_mkobject elf_s390_mkobject
|
||||||
#define elf_backend_object_p elf_s390_object_p
|
#define elf_backend_object_p elf_s390_object_p
|
||||||
|
|
|
@ -3725,6 +3725,16 @@ get_arm_segment_type (unsigned long type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
get_s390_segment_type (unsigned long type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case PT_S390_PGSTE: return "S390_PGSTE";
|
||||||
|
default: return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
get_mips_segment_type (unsigned long type)
|
get_mips_segment_type (unsigned long type)
|
||||||
{
|
{
|
||||||
|
@ -3858,6 +3868,10 @@ get_segment_type (unsigned long p_type)
|
||||||
case EM_TI_C6000:
|
case EM_TI_C6000:
|
||||||
result = get_tic6x_segment_type (p_type);
|
result = get_tic6x_segment_type (p_type);
|
||||||
break;
|
break;
|
||||||
|
case EM_S390:
|
||||||
|
case EM_S390_OLD:
|
||||||
|
result = get_s390_segment_type (p_type);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
result = NULL;
|
result = NULL;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -515,7 +515,9 @@ enum PT
|
||||||
// Platform architecture compatibility information
|
// Platform architecture compatibility information
|
||||||
PT_AARCH64_ARCHEXT = 0x70000000,
|
PT_AARCH64_ARCHEXT = 0x70000000,
|
||||||
// Exception unwind tables
|
// Exception unwind tables
|
||||||
PT_AARCH64_UNWIND = 0x70000001
|
PT_AARCH64_UNWIND = 0x70000001,
|
||||||
|
// 4k page table size
|
||||||
|
PT_S390_PGSTE = 0x70000000,
|
||||||
};
|
};
|
||||||
|
|
||||||
// The valid bit flags found in the Phdr p_flags field.
|
// The valid bit flags found in the Phdr p_flags field.
|
||||||
|
|
|
@ -37,6 +37,9 @@
|
||||||
|
|
||||||
#define EF_S390_HIGH_GPRS 0x00000001
|
#define EF_S390_HIGH_GPRS 0x00000001
|
||||||
|
|
||||||
|
/* Request 4k page table size. */
|
||||||
|
#define PT_S390_PGSTE (PT_LOPROC + 0)
|
||||||
|
|
||||||
/* Relocation types. */
|
/* Relocation types. */
|
||||||
|
|
||||||
START_RELOC_NUMBERS (elf_s390_reloc_type)
|
START_RELOC_NUMBERS (elf_s390_reloc_type)
|
||||||
|
|
|
@ -3502,6 +3502,7 @@ eelf64_ia64_vms.c: $(srcdir)/emulparams/elf64_ia64_vms.sh \
|
||||||
$(srcdir)/scripttempl/ia64vms.sc ${GEN_DEPENDS}
|
$(srcdir)/scripttempl/ia64vms.sc ${GEN_DEPENDS}
|
||||||
|
|
||||||
eelf64_s390.c: $(srcdir)/emulparams/elf64_s390.sh \
|
eelf64_s390.c: $(srcdir)/emulparams/elf64_s390.sh \
|
||||||
|
$(srcdir)/emultempl/s390.em \
|
||||||
$(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
|
$(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
|
||||||
|
|
||||||
eelf64_sparc.c: $(srcdir)/emulparams/elf64_sparc.sh \
|
eelf64_sparc.c: $(srcdir)/emulparams/elf64_sparc.sh \
|
||||||
|
|
|
@ -12,6 +12,7 @@ TEMPLATE_NAME=elf32
|
||||||
GENERATE_SHLIB_SCRIPT=yes
|
GENERATE_SHLIB_SCRIPT=yes
|
||||||
GENERATE_PIE_SCRIPT=yes
|
GENERATE_PIE_SCRIPT=yes
|
||||||
NO_SMALL_DATA=yes
|
NO_SMALL_DATA=yes
|
||||||
|
EXTRA_EM_FILE=s390
|
||||||
IREL_IN_PLT=
|
IREL_IN_PLT=
|
||||||
|
|
||||||
# Treat a host that matches the target with the possible exception of "x"
|
# Treat a host that matches the target with the possible exception of "x"
|
||||||
|
|
64
ld/emultempl/s390.em
Normal file
64
ld/emultempl/s390.em
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
# This shell script emits a C file. -*- C -*-
|
||||||
|
# Copyright (C) 2017 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is part of the GNU Binutils.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 3 of the license, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; see the file COPYING3. If not,
|
||||||
|
# see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
# This file is sourced from elf-generic.em, and defines S/390
|
||||||
|
# specific routines.
|
||||||
|
#
|
||||||
|
fragment <<EOF
|
||||||
|
|
||||||
|
#include "ldctor.h"
|
||||||
|
#include "elf-s390.h"
|
||||||
|
|
||||||
|
static struct s390_elf_params params = { 0 };
|
||||||
|
|
||||||
|
/* This is a convenient point to tell BFD about target specific flags.
|
||||||
|
After the output has been created, but before inputs are read. */
|
||||||
|
static void
|
||||||
|
s390_elf_create_output_section_statements (void)
|
||||||
|
{
|
||||||
|
if (!bfd_elf_s390_set_options (&link_info, ¶ms))
|
||||||
|
einfo ("%F%P: can not init BFD: %E\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Define some shell vars to insert bits of code into the standard elf
|
||||||
|
# parse_args and list_options functions.
|
||||||
|
#
|
||||||
|
PARSE_AND_LIST_PROLOGUE='
|
||||||
|
#define OPTION_PGSTE 301
|
||||||
|
'
|
||||||
|
|
||||||
|
PARSE_AND_LIST_LONGOPTS='
|
||||||
|
{ "s390-pgste", no_argument, NULL, OPTION_PGSTE},
|
||||||
|
'
|
||||||
|
|
||||||
|
PARSE_AND_LIST_OPTIONS='
|
||||||
|
fprintf (file, _(" --s390-pgste Tell the kernel to "
|
||||||
|
"allocate 4k page tables\n"));
|
||||||
|
'
|
||||||
|
|
||||||
|
PARSE_AND_LIST_ARGS_CASES='
|
||||||
|
case OPTION_PGSTE:
|
||||||
|
params.pgste = 1;
|
||||||
|
break;
|
||||||
|
'
|
||||||
|
|
||||||
|
LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=s390_elf_create_output_section_statements
|
|
@ -21,6 +21,7 @@
|
||||||
@set POWERPC
|
@set POWERPC
|
||||||
@set POWERPC64
|
@set POWERPC64
|
||||||
@set Renesas
|
@set Renesas
|
||||||
|
@set S/390
|
||||||
@set SPU
|
@set SPU
|
||||||
@set TICOFF
|
@set TICOFF
|
||||||
@set WIN32
|
@set WIN32
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
@set POWERPC
|
@set POWERPC
|
||||||
@set POWERPC64
|
@set POWERPC64
|
||||||
@set Renesas
|
@set Renesas
|
||||||
|
@set S/390
|
||||||
@set SPU
|
@set SPU
|
||||||
@set TICOFF
|
@set TICOFF
|
||||||
@set WIN32
|
@set WIN32
|
||||||
|
@ -158,6 +159,9 @@ in the section entitled ``GNU Free Documentation License''.
|
||||||
@ifset POWERPC64
|
@ifset POWERPC64
|
||||||
* PowerPC64 ELF64:: ld and PowerPC64 64-bit ELF Support
|
* PowerPC64 ELF64:: ld and PowerPC64 64-bit ELF Support
|
||||||
@end ifset
|
@end ifset
|
||||||
|
@ifset S/390
|
||||||
|
* S/390 ELF:: ld and S/390 ELF Support
|
||||||
|
@end ifset
|
||||||
@ifset SPU
|
@ifset SPU
|
||||||
* SPU ELF:: ld and SPU ELF Support
|
* SPU ELF:: ld and SPU ELF Support
|
||||||
@end ifset
|
@end ifset
|
||||||
|
@ -6565,6 +6569,9 @@ functionality are not listed.
|
||||||
@ifset POWERPC64
|
@ifset POWERPC64
|
||||||
* PowerPC64 ELF64:: @command{ld} and PowerPC64 64-bit ELF Support
|
* PowerPC64 ELF64:: @command{ld} and PowerPC64 64-bit ELF Support
|
||||||
@end ifset
|
@end ifset
|
||||||
|
@ifset S/390
|
||||||
|
* S/390 ELF:: @command{ld} and S/390 ELF Support
|
||||||
|
@end ifset
|
||||||
@ifset SPU
|
@ifset SPU
|
||||||
* SPU ELF:: @command{ld} and SPU ELF Support
|
* SPU ELF:: @command{ld} and SPU ELF Support
|
||||||
@end ifset
|
@end ifset
|
||||||
|
@ -7600,6 +7607,30 @@ default behaviour.
|
||||||
@end ifclear
|
@end ifclear
|
||||||
@end ifset
|
@end ifset
|
||||||
|
|
||||||
|
@ifset S/390
|
||||||
|
@ifclear GENERIC
|
||||||
|
@raisesections
|
||||||
|
@end ifclear
|
||||||
|
|
||||||
|
@node S/390 ELF
|
||||||
|
@section @command{ld} and S/390 ELF Support
|
||||||
|
|
||||||
|
@cindex S/390 ELF options
|
||||||
|
@table @option
|
||||||
|
|
||||||
|
@cindex S/390
|
||||||
|
@kindex --s390-pgste
|
||||||
|
@item --s390-pgste
|
||||||
|
This option marks the result file with a @code{PT_S390_PGSTE}
|
||||||
|
segment. The Linux kernel is supposed to allocate 4k page tables for
|
||||||
|
binaries marked that way.
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@ifclear GENERIC
|
||||||
|
@lowersections
|
||||||
|
@end ifclear
|
||||||
|
@end ifset
|
||||||
|
|
||||||
@ifset SPU
|
@ifset SPU
|
||||||
@ifclear GENERIC
|
@ifclear GENERIC
|
||||||
@raisesections
|
@raisesections
|
||||||
|
|
Loading…
Add table
Reference in a new issue