This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Specify architecture for SPARC gas tests
- From: jose dot marchesi at oracle dot com (Jose E. Marchesi)
- To: Rainer Orth <ro at cebitec dot uni-bielefeld dot de>
- Cc: binutils at sourceware dot org
- Date: Sat, 10 Feb 2018 18:00:28 +0100
- Subject: Re: Specify architecture for SPARC gas tests
- Authentication-results: sourceware.org; auth=none
- References: <yddsha8vnmy.fsf@CeBiTec.Uni-Bielefeld.DE>
Hi Rainer. Thanks for looking at this.
A couple of SPARC gas tests FAIL on Solaris/SPARC (both
sparc-sun-solaris2.11 and sparcv9-sun-solaris2.11):
FAIL: sparc PAUSE
FAIL: sparc CBCOND
FAIL: sparc CFR
FAIL: sparc CRYPTO
FAIL: sparc HPC+VIS3
FAIL: sparc IMA
FAIL: sparc OSA2015 %mwait asr and MWAIT instruction
FAIL: sparc OSA2015 %mcdper asr
FAIL: sparc SPARC5 and VIS4.0
FAIL: OSA2015 crypto instructions
FAIL: SPARC6
FAIL: FPCMPSHL OSA2017 instructions
FAIL: OSA2017 ONADD/ONSUB/ONMUL/ONDIV instructions.
FAIL: OSA2017 RLE instructions
FAIL: sparc64 rdasr
FAIL: sparc64 rdpr
FAIL: sparc64 rdhpr
FAIL: sparc64 wrasr
FAIL: sparc64 wrpr
It turns out there's a common pattern here: failures happen for all
tests that use SPARC ISA extensions beyond sparcv9, e.g. for the sparc
PAUSE test:
regexp_diff match failure
regexp "^ 0: b7 80 40 02 wr %g1, %g2, %pause$"
line " 0: b7 80 40 02 wr %g1, %g2, %asr27"
[...]
regexp_diff match failure
regexp "^ 8: b7 80 20 08 pause 8$"
line " 8: b7 80 20 08 wr 8, %asr27"
[...]
The fix is easy, actually: just as the tests specify the ISA extension
to use as a gas flag, the same needs to be done for objdump. For the
test above, which has -Av9v, this means passing -msparc:v9v to objdump.
Doing so makes all but two (unrelated; to be reported separately)
failures go away.
In GNU/Linux GAS annotates the hardware capabilities when it assembles
an ELF object. From gas/config/tc-sparc.c:sparc_md_end:
#if defined(OBJ_ELF) && !defined(TE_SOLARIS)
hwcaps = hwcap_seen & U0xffffffff;
hwcaps2 = hwcap_seen >> 32;
if (hwcaps)
bfd_elf_add_obj_attr_int (stdoutput, OBJ_ATTR_GNU, Tag_GNU_Sparc_HWCAPS, hwcaps);
if (hwcaps2)
bfd_elf_add_obj_attr_int (stdoutput, OBJ_ATTR_GNU, Tag_GNU_Sparc_HWCAPS2, hwcaps2);
#endif
Then when BFD opens the file, it looks at the GNU object attributes
HWCAPS and HWCAPS2 and determines the opcodes architecture that is
subsequently used by the disassembler. See
bfd/elfxx-spac.c:_bfd_sparc_elf_object_p.
The hwcaps tags are not created in Solaris though, so that's why the
tests are failing... I wonder if it is possible to change the tests so
they use -msparc:MACH only when testing in solaris targets?
Alternatively, I guess we could just change the assembler to add the GNU
object attributes also in solaris...