This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] S/390: Add highgprs flag to elf header for -m31 -mzarch binaries
- From: "Andreas Krebbel" <krebbel at linux dot vnet dot ibm dot com>
- To: binutils at sourceware dot org
- Date: Fri, 15 Jan 2010 10:46:00 +0100
- Subject: [PATCH] S/390: Add highgprs flag to elf header for -m31 -mzarch binaries
Hi,
the attached patch marks binaries built with -m31 -mzarch with the
EF_S390_HIGH_GPRS flag in the e_flags field of the elf header.
Compiling code with -m31 -mzarch will in the future exploit the
presence of 64 bit registers also in 32 bit applications. This
requires the kernel to save/restore the upper halfs of 64 bit
registers and include these values in core dumps. For S/390 the Linux
kernel supports that starting with version 2.6.32 and indicates that
fact in /proc/cpuinfo as "highgprs" and in the AT_HWCAPS field of the
auxiliary vector with the HWCAP_S390_HIGH_GPRS flag.
In order to implement a runtime check as part of the crt1 file it is
also necessary to mark the binaries which is implemented with that
patch.
The patch has been tested on s390. No regressions.
If nobody has objections I will apply the patch next week.
Bye,
-Andreas-
2010-01-15 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* elf32-s390.c (elf32_s390_merge_private_bfd_data): New function.
(bfd_elf32_bfd_merge_private_bfd_data): New macro definition.
2010-01-15 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* readelf.c (get_machine_flags): Handle EF_S390_HIGH_GPRS.
2010-01-15 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* config/tc-s390.c (s390_elf_final_processing): New function.
* config/tc-s390.h (elf_tc_final_processing): New macro definition.
(s390_elf_final_processing): Added prototype.
2010-01-15 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* s390.h (EF_S390_HIGH_GPRS): Added macro definition.
Index: binutils/readelf.c
===================================================================
*** binutils/readelf.c.orig 2010-01-15 10:22:05.000000000 +0100
--- binutils/readelf.c 2010-01-15 10:22:48.000000000 +0100
*************** get_machine_flags (unsigned e_flags, uns
*** 2508,2513 ****
--- 2508,2517 ----
strcat (buf, ", 64-bit doubles");
if (e_flags & E_FLAG_RX_DSP)
strcat (buf, ", dsp");
+
+ case EM_S390:
+ if (e_flags & EF_S390_HIGH_GPRS)
+ strcat (buf, ", highgprs");
}
}
Index: gas/config/tc-s390.c
===================================================================
*** gas/config/tc-s390.c.orig 2010-01-15 10:22:05.000000000 +0100
--- gas/config/tc-s390.c 2010-01-15 10:22:48.000000000 +0100
*************** tc_s390_regname_to_dw2regnum (char *regn
*** 2265,2267 ****
--- 2265,2274 ----
regnum = 33;
return regnum;
}
+
+ void
+ s390_elf_final_processing (void)
+ {
+ if (s390_arch_size == 32 && (current_mode_mask & (1 << S390_OPCODE_ZARCH)))
+ elf_elfheader (stdoutput)->e_flags |= EF_S390_HIGH_GPRS;
+ }
Index: gas/config/tc-s390.h
===================================================================
*** gas/config/tc-s390.h.orig 2010-01-15 10:22:05.000000000 +0100
--- gas/config/tc-s390.h 2010-01-15 10:22:48.000000000 +0100
*************** extern int s390_cie_data_alignment;
*** 95,97 ****
--- 95,101 ----
#define DWARF2_LINE_MIN_INSN_LENGTH 1
#define DWARF2_DEFAULT_RETURN_COLUMN 14
#define DWARF2_CIE_DATA_ALIGNMENT s390_cie_data_alignment
+
+ extern void s390_elf_final_processing (void);
+
+ #define elf_tc_final_processing s390_elf_final_processing
Index: include/elf/s390.h
===================================================================
*** include/elf/s390.h.orig 2010-01-15 10:22:05.000000000 +0100
--- include/elf/s390.h 2010-01-15 10:22:48.000000000 +0100
***************
*** 33,38 ****
--- 33,42 ----
#include "elf/reloc-macros.h"
+ /* Processor specific flags for the ELF header e_flags field. */
+
+ #define EF_S390_HIGH_GPRS 0x00000001
+
/* Relocation types. */
START_RELOC_NUMBERS (elf_s390_reloc_type)
Index: bfd/elf32-s390.c
===================================================================
*** bfd/elf32-s390.c.orig 2010-01-15 10:22:05.000000000 +0100
--- bfd/elf32-s390.c 2010-01-15 10:22:48.000000000 +0100
*************** elf_s390_plt_sym_val (bfd_vma i, const a
*** 3483,3488 ****
--- 3483,3495 ----
return plt->vma + PLT_FIRST_ENTRY_SIZE + i * PLT_ENTRY_SIZE;
}
+ static bfd_boolean
+ elf32_s390_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
+ {
+ elf_elfheader (obfd)->e_flags |= elf_elfheader (ibfd)->e_flags;
+ return TRUE;
+ }
+
#define TARGET_BIG_SYM bfd_elf32_s390_vec
#define TARGET_BIG_NAME "elf32-s390"
*************** elf_s390_plt_sym_val (bfd_vma i, const a
*** 3506,3511 ****
--- 3513,3520 ----
#define bfd_elf32_bfd_reloc_type_lookup elf_s390_reloc_type_lookup
#define bfd_elf32_bfd_reloc_name_lookup elf_s390_reloc_name_lookup
+ #define bfd_elf32_bfd_merge_private_bfd_data elf32_s390_merge_private_bfd_data
+
#define elf_backend_adjust_dynamic_symbol elf_s390_adjust_dynamic_symbol
#define elf_backend_check_relocs elf_s390_check_relocs
#define elf_backend_copy_indirect_symbol elf_s390_copy_indirect_symbol