diff options
author | Jens Remus <jremus@linux.ibm.com> | 2024-03-01 12:45:14 +0100 |
---|---|---|
committer | Jens Remus <jremus@linux.ibm.com> | 2024-03-01 12:45:14 +0100 |
commit | 9c021aef485a27ad32974a69e9cb042baef2fe0c (patch) | |
tree | 094d627cce039050382061433239cfaf8bf61fba /gas | |
parent | dd327181e96b8bc4d9bd97aa8d3d7fe01bf29628 (diff) | |
download | gdb-9c021aef485a27ad32974a69e9cb042baef2fe0c.zip gdb-9c021aef485a27ad32974a69e9cb042baef2fe0c.tar.gz gdb-9c021aef485a27ad32974a69e9cb042baef2fe0c.tar.bz2 |
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>
Diffstat (limited to 'gas')
-rw-r--r-- | gas/config/tc-s390.c | 14 | ||||
-rw-r--r-- | gas/testsuite/gas/s390/blank.s | 0 | ||||
-rw-r--r-- | gas/testsuite/gas/s390/esa-highgprs-0.d | 24 | ||||
-rw-r--r-- | gas/testsuite/gas/s390/esa-highgprs-machinemode-0.d | 23 | ||||
-rw-r--r-- | gas/testsuite/gas/s390/esa-highgprs-machinemode-0.s | 2 | ||||
-rw-r--r-- | gas/testsuite/gas/s390/esa-highgprs-machinemode-1.d | 23 | ||||
-rw-r--r-- | gas/testsuite/gas/s390/esa-highgprs-machinemode-1.s | 3 | ||||
-rw-r--r-- | gas/testsuite/gas/s390/s390.exp | 12 | ||||
-rw-r--r-- | gas/testsuite/gas/s390/zarch-highgprs-0.d | 24 | ||||
-rw-r--r-- | gas/testsuite/gas/s390/zarch-highgprs-1.d | 24 |
10 files changed, 143 insertions, 6 deletions
diff --git a/gas/config/tc-s390.c b/gas/config/tc-s390.c index cfe98b5..55a5873 100644 --- a/gas/config/tc-s390.c +++ b/gas/config/tc-s390.c @@ -47,7 +47,7 @@ static unsigned int current_flags = S390_INSTR_FLAG_FACILITY_MASK; 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. */ + for the output file. The default is picked in init_default_arch(). */ static bool set_highgprs_p = false; /* Whether to use user friendly register names. Default is TRUE. */ @@ -221,6 +221,7 @@ size_t md_longopts_size = sizeof (md_longopts); static void init_default_arch (void) { + /* Default architecture size. */ if (strcmp (default_arch, "s390") == 0) { if (s390_arch_size == 0) @@ -234,6 +235,7 @@ init_default_arch (void) else as_fatal (_("Invalid default architecture, broken assembler.")); + /* Default current architecture mode. */ if (current_mode_mask == 0) { /* Default to z/Architecture mode if the CPU supports it. */ @@ -242,6 +244,10 @@ init_default_arch (void) else current_mode_mask = 1 << S390_OPCODE_ZARCH; } + + /* Determine whether the highgprs flag in the ELF header needs to be set. */ + if ((s390_arch_size == 32) && (current_mode_mask & (1 << S390_OPCODE_ZARCH))) + set_highgprs_p = true; } /* Called by TARGET_FORMAT. */ @@ -419,11 +425,7 @@ md_parse_option (int c, const char *arg) 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; - } + current_mode_mask = 1 << S390_OPCODE_ZARCH; else if (arg != NULL && startswith (arg, "arch=")) { diff --git a/gas/testsuite/gas/s390/blank.s b/gas/testsuite/gas/s390/blank.s new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/gas/testsuite/gas/s390/blank.s diff --git a/gas/testsuite/gas/s390/esa-highgprs-0.d b/gas/testsuite/gas/s390/esa-highgprs-0.d new file mode 100644 index 0000000..aa9eff7 --- /dev/null +++ b/gas/testsuite/gas/s390/esa-highgprs-0.d @@ -0,0 +1,24 @@ +#name: s390 highgprs 0 +#source: blank.s +#readelf: -h + +ELF Header: + Magic: 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 + Class: ELF32 + Data: 2's complement, big endian + Version: 1 \(current\) + OS/ABI: UNIX - System V + ABI Version: 0 + Type: REL \(Relocatable file\) + Machine: IBM S/390 + Version: 0x1 + Entry point address: 0x0 + Start of program headers: 0 \(bytes into file\) + Start of section headers: 164 \(bytes into file\) + Flags: 0x0 + Size of this header: 52 \(bytes\) + Size of program headers: 0 \(bytes\) + Number of program headers: 0 + Size of section headers: 40 \(bytes\) + Number of section headers: 7 + Section header string table index: 6 diff --git a/gas/testsuite/gas/s390/esa-highgprs-machinemode-0.d b/gas/testsuite/gas/s390/esa-highgprs-machinemode-0.d new file mode 100644 index 0000000..483342f --- /dev/null +++ b/gas/testsuite/gas/s390/esa-highgprs-machinemode-0.d @@ -0,0 +1,23 @@ +#name: s390 highgprs machinemode 0 +#readelf: -h + +ELF Header: + Magic: 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 + Class: ELF32 + Data: 2's complement, big endian + Version: 1 \(current\) + OS/ABI: UNIX - System V + ABI Version: 0 + Type: REL \(Relocatable file\) + Machine: IBM S/390 + Version: 0x1 + Entry point address: 0x0 + Start of program headers: 0 \(bytes into file\) + Start of section headers: 164 \(bytes into file\) + Flags: 0x0 + Size of this header: 52 \(bytes\) + Size of program headers: 0 \(bytes\) + Number of program headers: 0 + Size of section headers: 40 \(bytes\) + Number of section headers: 7 + Section header string table index: 6 diff --git a/gas/testsuite/gas/s390/esa-highgprs-machinemode-0.s b/gas/testsuite/gas/s390/esa-highgprs-machinemode-0.s new file mode 100644 index 0000000..60d9e3f --- /dev/null +++ b/gas/testsuite/gas/s390/esa-highgprs-machinemode-0.s @@ -0,0 +1,2 @@ +.text + .machinemode zarch_nohighgprs diff --git a/gas/testsuite/gas/s390/esa-highgprs-machinemode-1.d b/gas/testsuite/gas/s390/esa-highgprs-machinemode-1.d new file mode 100644 index 0000000..c1adc16 --- /dev/null +++ b/gas/testsuite/gas/s390/esa-highgprs-machinemode-1.d @@ -0,0 +1,23 @@ +#name: s390 highgprs machinemode 1 +#readelf: -h + +ELF Header: + Magic: 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 + Class: ELF32 + Data: 2's complement, big endian + Version: 1 \(current\) + OS/ABI: UNIX - System V + ABI Version: 0 + Type: REL \(Relocatable file\) + Machine: IBM S/390 + Version: 0x1 + Entry point address: 0x0 + Start of program headers: 0 \(bytes into file\) + Start of section headers: 164 \(bytes into file\) + Flags: 0x1, highgprs + Size of this header: 52 \(bytes\) + Size of program headers: 0 \(bytes\) + Number of program headers: 0 + Size of section headers: 40 \(bytes\) + Number of section headers: 7 + Section header string table index: 6 diff --git a/gas/testsuite/gas/s390/esa-highgprs-machinemode-1.s b/gas/testsuite/gas/s390/esa-highgprs-machinemode-1.s new file mode 100644 index 0000000..c46b95b --- /dev/null +++ b/gas/testsuite/gas/s390/esa-highgprs-machinemode-1.s @@ -0,0 +1,3 @@ +.text + .machinemode zarch + .machinemode esa diff --git a/gas/testsuite/gas/s390/s390.exp b/gas/testsuite/gas/s390/s390.exp index 7fbc7f8..b63c09e 100644 --- a/gas/testsuite/gas/s390/s390.exp +++ b/gas/testsuite/gas/s390/s390.exp @@ -12,6 +12,16 @@ if [expr [istarget "s390-*-*"] || [istarget "s390x-*-*"]] then { run_dump_test "esa-z9-109" "{as -m31} {as -march=z9-109}" run_dump_test "esa-reloc" "{as -m31}" run_dump_test "esa-operands" "{as -m31}" + run_dump_test "esa-highgprs-0" "{as -m31} {as -mesa}" + run_dump_test "esa-highgprs-0" "{as -mesa} {as -m31}" + run_dump_test "esa-highgprs-0" "{as -m31} {as -march=g5}" + run_dump_test "zarch-highgprs-1" "{as -m31} {as -mzarch}" + run_dump_test "zarch-highgprs-1" "{as -mzarch} {as -m31}" + run_dump_test "zarch-highgprs-1" "{as -m31} {as -march=z900}" + run_dump_test "esa-highgprs-machinemode-0" "{as -m31} {as -mesa}" + run_dump_test "esa-highgprs-machinemode-0" "{as -mesa} {as -m31}" + run_dump_test "esa-highgprs-machinemode-1" "{as -m31} {as -mesa}" + run_dump_test "esa-highgprs-machinemode-1" "{as -mesa} {as -m31}" } # # PIC is only supported on ELF targets. @@ -44,6 +54,8 @@ if [expr [istarget "s390-*-*"] || [istarget "s390x-*-*"]] then { run_list_test "machine-parsing-4" "" run_list_test "machine-parsing-5" "" run_list_test "machine-parsing-6" "" + run_dump_test "zarch-highgprs-0" "{as -m64} {as -mzarch}" + run_dump_test "zarch-highgprs-0" "{as -mzarch} {as -m64}" run_dump_test "zarch-omitted-base-index" "{as -m64}" run_list_test "zarch-omitted-base-index-err" "" } diff --git a/gas/testsuite/gas/s390/zarch-highgprs-0.d b/gas/testsuite/gas/s390/zarch-highgprs-0.d new file mode 100644 index 0000000..53cc3e0 --- /dev/null +++ b/gas/testsuite/gas/s390/zarch-highgprs-0.d @@ -0,0 +1,24 @@ +#name: s390x highgprs 0 +#source: blank.s +#readelf: -h + +ELF Header: + Magic: 7f 45 4c 46 02 02 01 00 00 00 00 00 00 00 00 00 + Class: ELF64 + Data: 2's complement, big endian + Version: 1 \(current\) + OS/ABI: UNIX - System V + ABI Version: 0 + Type: REL \(Relocatable file\) + Machine: IBM S/390 + Version: 0x1 + Entry point address: 0x0 + Start of program headers: 0 \(bytes into file\) + Start of section headers: 208 \(bytes into file\) + Flags: 0x0 + Size of this header: 64 \(bytes\) + Size of program headers: 0 \(bytes\) + Number of program headers: 0 + Size of section headers: 64 \(bytes\) + Number of section headers: 7 + Section header string table index: 6 diff --git a/gas/testsuite/gas/s390/zarch-highgprs-1.d b/gas/testsuite/gas/s390/zarch-highgprs-1.d new file mode 100644 index 0000000..d351032 --- /dev/null +++ b/gas/testsuite/gas/s390/zarch-highgprs-1.d @@ -0,0 +1,24 @@ +#name: s390x highgprs 0 +#source: blank.s +#readelf: -h + +ELF Header: + Magic: 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 + Class: ELF32 + Data: 2's complement, big endian + Version: 1 \(current\) + OS/ABI: UNIX - System V + ABI Version: 0 + Type: REL \(Relocatable file\) + Machine: IBM S/390 + Version: 0x1 + Entry point address: 0x0 + Start of program headers: 0 \(bytes into file\) + Start of section headers: 164 \(bytes into file\) + Flags: 0x1, highgprs + Size of this header: 52 \(bytes\) + Size of program headers: 0 \(bytes\) + Number of program headers: 0 + Size of section headers: 40 \(bytes\) + Number of section headers: 7 + Section header string table index: 6 |