]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
s390: Correct setting of highgprs flag in ELF output
authorJens Remus <jremus@linux.ibm.com>
Fri, 1 Mar 2024 11:45:14 +0000 (12:45 +0100)
committerJens Remus <jremus@linux.ibm.com>
Fri, 1 Mar 2024 11:45:14 +0000 (12:45 +0100)
commit9c021aef485a27ad32974a69e9cb042baef2fe0c
tree094d627cce039050382061433239cfaf8bf61fba
parentdd327181e96b8bc4d9bd97aa8d3d7fe01bf29628
s390: Correct setting of highgprs flag in ELF output

The combination of an architecture size of 32 bits and z/Architecture
mode requires the highgprs flag to be set in the ELF output. It causes
the high-halves of the general purpose registers (GPRs) to be preserved
at run-time, so that the code can use 64-bit GPRs.

The architecture size of 32 bits can either be the default in case of
a default architecture name of "s390" or due to specification of the
option -m31 (to generate the 31-bit file format).
The z/Architecture mode can either be the default or due to
specification of the option -mzarch (to assemble for z/Architecture
mode). It can also be selected using the pseudo commands
".machinemode zarch" and ".machinemode zarch_nohighgprs". The latter
not causing the highgprs flag to be set.

The highgprs flag was only set when the following s390-specific
assembler options were given in the following specific order:
"-m31 -mzarch".

The highgprs flag was erroneously not set when:
- the order of above options was inverse (i.e. "-mzarch -m31"),
- the architecture mode defaulted to z/Architecture mode and
  option "-m31" was specified,
- the architecture size defaulted to 32 bits due to a default
  architecture name of "s390" and option -mzarch was specified,
- the architecture size defaulted to 32 bits and the architecture
  mode defaulted to z/Architecture due to the specified processor
  (e.g. "-march=z900" or follow-on processor).

Determine whether to set the highgprs flag in init_default_arch() after
having processed all assembler options in md_parse_option(). This
ensures the flag is set in all of the above cases it was erroneously not
set. Add test cases for highgprs flag, including ones that use
.machinemode to switch the architecture mode.

gas/
* config/tc-s390.c: Correct setting of highgprs flag in ELF
output.
* testsuite/gas/s390/s390.exp: Add test cases for highgprs
flag.
* testsuite/gas/s390/blank.s: Empty assembler source used in
test cases for "highgprs" flag.
* testsuite/gas/s390/esa-highgprs-0.d: Add test case for
highgprs flag.
* testsuite/gas/s390/zarch-highgprs-0.d: Likewise.
* testsuite/gas/s390/zarch-highgprs-1.d: Likewise.
* testsuite/gas/s390/esa-highgprs-machinemode-0.s: Add test case
for highgprs flag when using .machinemode to switch
architecture mode.
* testsuite/gas/s390/esa-highgprs-machinemode-0.d: Likewise.
* testsuite/gas/s390/esa-highgprs-machinemode-1.s: Likewise.
* testsuite/gas/s390/esa-highgprs-machinemode-1.d: Likewise.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
gas/config/tc-s390.c
gas/testsuite/gas/s390/blank.s [new file with mode: 0644]
gas/testsuite/gas/s390/esa-highgprs-0.d [new file with mode: 0644]
gas/testsuite/gas/s390/esa-highgprs-machinemode-0.d [new file with mode: 0644]
gas/testsuite/gas/s390/esa-highgprs-machinemode-0.s [new file with mode: 0644]
gas/testsuite/gas/s390/esa-highgprs-machinemode-1.d [new file with mode: 0644]
gas/testsuite/gas/s390/esa-highgprs-machinemode-1.s [new file with mode: 0644]
gas/testsuite/gas/s390/s390.exp
gas/testsuite/gas/s390/zarch-highgprs-0.d [new file with mode: 0644]
gas/testsuite/gas/s390/zarch-highgprs-1.d [new file with mode: 0644]