Add support for the S/390 .machinemode pseudo-op to GAS.

Resolves: #986031
This commit is contained in:
Nick Clifton 2013-07-19 13:46:30 +01:00
parent 9aa667ddde
commit cc4bf7386b
2 changed files with 214 additions and 1 deletions

View File

@ -0,0 +1,207 @@
diff -rcp ../binutils-2.23.2.orig/gas/ChangeLog gas/ChangeLog
*** ../binutils-2.23.2.orig/gas/ChangeLog 2013-07-19 12:55:22.375756756 +0100
--- gas/ChangeLog 2013-07-19 13:01:50.274744487 +0100
***************
*** 136,141 ****
--- 136,153 ----
* config/tc-aarch64.c (aarch64_archs): Rename 'armv8' to 'armv8-a'.
+ 2012-09-06 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
+
+ * config/tc-s390.c (set_highgprs_p): New variable.
+ (s390_machinemode): New function.
+ (md_pseudo_table): Add new pseudo command machinemode.
+ (md_parse_option): Set set_highgprs_p to TRUE if -mzarch was
+ specified on command line.
+ (s390_elf_final_processing): Set the highgprs flag in the ELF
+ header depending on set_highgprs_p.
+
+ * doc/c-s390.texi: Document new pseudo machinemode.
+
2012-08-17 Nagajyothi Eggone <nagajyothi.eggone@amd.com>
* config/tc-i386.c (cpu_arch): Add CPU_BTVER1_FLAGS and
diff -rcp ../binutils-2.23.2.orig/gas/config/tc-s390.c gas/config/tc-s390.c
*** ../binutils-2.23.2.orig/gas/config/tc-s390.c 2013-07-19 12:55:22.390756755 +0100
--- gas/config/tc-s390.c 2013-07-19 13:01:01.537746029 +0100
*************** static int s390_arch_size = 0;
*** 44,49 ****
--- 44,53 ----
static unsigned int current_cpu = S390_OPCODE_MAXCPU - 1;
static unsigned int current_mode_mask = 0;
+ /* Set to TRUE if the highgprs flag in the ELF header needs to be set
+ for the output file. */
+ static bfd_boolean set_highgprs_p = FALSE;
+
/* Whether to use user friendly register names. Default is TRUE. */
#ifndef TARGET_REG_NAMES_P
#define TARGET_REG_NAMES_P TRUE
*************** static void s390_bss (int);
*** 86,91 ****
--- 90,96 ----
static void s390_insn (int);
static void s390_literals (int);
static void s390_machine (int);
+ static void s390_machinemode (int);
const pseudo_typeS md_pseudo_table[] =
{
*************** const pseudo_typeS md_pseudo_table[] =
*** 101,106 ****
--- 106,112 ----
{ "ltorg", s390_literals, 0 },
{ "string", stringer, 8 + 1 },
{ "machine", s390_machine, 0 },
+ { "machinemode", s390_machinemode, 0 },
{ NULL, NULL, 0 }
};
*************** md_parse_option (int c, char *arg)
*** 409,415 ****
current_mode_mask = 1 << S390_OPCODE_ESA;
else if (arg != NULL && strcmp (arg, "zarch") == 0)
! current_mode_mask = 1 << S390_OPCODE_ZARCH;
else if (arg != NULL && strncmp (arg, "arch=", 5) == 0)
{
--- 415,425 ----
current_mode_mask = 1 << S390_OPCODE_ESA;
else if (arg != NULL && strcmp (arg, "zarch") == 0)
! {
! if (s390_arch_size == 32)
! set_highgprs_p = TRUE;
! current_mode_mask = 1 << S390_OPCODE_ZARCH;
! }
else if (arg != NULL && strncmp (arg, "arch=", 5) == 0)
{
*************** s390_machine (int ignore ATTRIBUTE_UNUSE
*** 1863,1868 ****
--- 1873,1955 ----
demand_empty_rest_of_line ();
}
+ /* The .machinemode pseudo op allows to switch to a different
+ architecture mode in the asm listing. The current architecture
+ mode setting can be stored on a stack with .machinemode push and
+ restored with .machinemode pop. */
+
+ static void
+ s390_machinemode (int ignore ATTRIBUTE_UNUSED)
+ {
+ char *mode_string;
+ #define MAX_HISTORY 100
+ static unsigned int *mode_history;
+ static int curr_hist;
+
+ SKIP_WHITESPACE ();
+
+ if (*input_line_pointer == '"')
+ {
+ int len;
+ mode_string = demand_copy_C_string (&len);
+ }
+ else
+ {
+ char c;
+ mode_string = input_line_pointer;
+ c = get_symbol_end ();
+ mode_string = xstrdup (mode_string);
+ *input_line_pointer = c;
+ }
+
+ if (mode_string != NULL)
+ {
+ unsigned int old_mode_mask = current_mode_mask;
+ char *p;
+
+ for (p = mode_string; *p != 0; p++)
+ *p = TOLOWER (*p);
+
+ if (strcmp (mode_string, "push") == 0)
+ {
+ if (mode_history == NULL)
+ mode_history = xmalloc (MAX_HISTORY * sizeof (*mode_history));
+
+ if (curr_hist >= MAX_HISTORY)
+ as_bad (_(".machinemode stack overflow"));
+ else
+ mode_history[curr_hist++] = current_mode_mask;
+ }
+ else if (strcmp (mode_string, "pop") == 0)
+ {
+ if (curr_hist <= 0)
+ as_bad (_(".machinemode stack underflow"));
+ else
+ current_mode_mask = mode_history[--curr_hist];
+ }
+ else
+ {
+ if (strcmp (mode_string, "esa") == 0)
+ current_mode_mask = 1 << S390_OPCODE_ESA;
+ else if (strcmp (mode_string, "zarch") == 0)
+ {
+ if (s390_arch_size == 32)
+ set_highgprs_p = TRUE;
+ current_mode_mask = 1 << S390_OPCODE_ZARCH;
+ }
+ else if (strcmp (mode_string, "zarch_nohighgprs") == 0)
+ current_mode_mask = 1 << S390_OPCODE_ZARCH;
+ else
+ as_bad (_("invalid machine `%s'"), mode_string);
+ }
+
+ if (current_mode_mask != old_mode_mask)
+ s390_setup_opcodes ();
+ }
+
+ demand_empty_rest_of_line ();
+ }
+
char *
md_atof (int type, char *litp, int *sizep)
{
*************** tc_s390_regname_to_dw2regnum (char *regn
*** 2381,2386 ****
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;
}
--- 2468,2473 ----
void
s390_elf_final_processing (void)
{
! if (set_highgprs_p)
elf_elfheader (stdoutput)->e_flags |= EF_S390_HIGH_GPRS;
}
diff -rcp ../binutils-2.23.2.orig/gas/doc/c-s390.texi gas/doc/c-s390.texi
*** ../binutils-2.23.2.orig/gas/doc/c-s390.texi 2013-07-19 12:55:21.966756769 +0100
--- gas/doc/c-s390.texi 2013-07-19 12:57:35.845752534 +0100
*************** restored with @code{.machine pop}. Be a
*** 873,878 ****
--- 873,891 ----
to be put into double quotes in case it contains characters not
appropriate for identifiers. So you have to write @code{"z9-109"}
instead of just @code{z9-109}.
+
+ @cindex @code{.machinemode} directive, s390
+ @item .machinemode string
+ This directive allows to change the architecture mode for which code
+ is being generated. @code{string} may be @code{esa}, @code{zarch},
+ @code{zarch_nohighgprs}, @code{push}, or @code{pop}.
+ @code{.machinemode zarch_nohighgprs} can be used to prevent the
+ @code{highgprs} flag from being set in the ELF header of the output
+ file. This is useful in situations where the code is gated with a
+ runtime check which makes sure that the code is only executed on
+ kernels providing the @code{highgprs} feature.
+ @code{.machinemode push} saves the currently selected mode, which may
+ be restored with @code{.machinemode pop}.
@end table
@node s390 Floating Point

View File

@ -27,7 +27,7 @@ Name: %{?cross}binutils%{?_with_debug:-debug}
# official binutils release happens (2.24.0) we will be able to restore # official binutils release happens (2.24.0) we will be able to restore
# Version to an honest value and everything will be good again. # Version to an honest value and everything will be good again.
Version: 2.23.88.0.1 Version: 2.23.88.0.1
Release: 7%{?dist} Release: 8%{?dist}
License: GPLv3+ License: GPLv3+
Group: Development/Tools Group: Development/Tools
URL: http://sources.redhat.com/binutils URL: http://sources.redhat.com/binutils
@ -70,6 +70,8 @@ Patch17: binutils-2.23.2-bfd-texinfo-fixes.patch
Patch18: binutils-2.23.2-dwz-alt-debuginfo.patch Patch18: binutils-2.23.2-dwz-alt-debuginfo.patch
# Correct bug introduced by patch 16 # Correct bug introduced by patch 16
Patch19: binutils-2.23.2-aarch64-em.patch Patch19: binutils-2.23.2-aarch64-em.patch
# Add support for the .machinemode pseudo-op to the S/390 assembler.
patch20: binutils-2.23.2-s390-gas-machinemode.patch
Provides: bundled(libiberty) Provides: bundled(libiberty)
@ -194,6 +196,7 @@ using libelf instead of BFD.
%patch17 -p0 -b .bfd-texinfo~ %patch17 -p0 -b .bfd-texinfo~
%patch18 -p0 -b .dwz~ %patch18 -p0 -b .dwz~
%patch19 -p0 -b .aarch64~ %patch19 -p0 -b .aarch64~
%patch20 -p0 -b .machinemode~
# We cannot run autotools as there is an exact requirement of autoconf-2.59. # We cannot run autotools as there is an exact requirement of autoconf-2.59.
@ -493,6 +496,9 @@ exit 0
%endif # %{isnative} %endif # %{isnative}
%changelog %changelog
* Fri Jul 19 2013 Nick Clifton <nickc@redhat.com> - 2.23.88.0.1-8
- Add support for the S/390 .machinemode pseudo-op to GAS. (#986031)
* Fri Jul 07 2013 Nick Clifton <nickc@redhat.com> - 2.23.88.0.1-7 * Fri Jul 07 2013 Nick Clifton <nickc@redhat.com> - 2.23.88.0.1-7
- Add a requirement for libstdc++-static when running the GOLD testsuite. - Add a requirement for libstdc++-static when running the GOLD testsuite.