diff options
author | Alan Modra <amodra@gmail.com> | 2019-08-12 11:15:19 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2019-08-12 13:10:48 +0930 |
commit | 9bb9c115cd3d0b9de97e02cf2e861972010daa6f (patch) | |
tree | b64696766275a96c676ddf954698c0d79efc3e03 /gas | |
parent | b32b0a69fdf24a8b04efe9c2b90c3e830aa0c2c1 (diff) | |
download | gdb-9bb9c115cd3d0b9de97e02cf2e861972010daa6f.zip gdb-9bb9c115cd3d0b9de97e02cf2e861972010daa6f.tar.gz gdb-9bb9c115cd3d0b9de97e02cf2e861972010daa6f.tar.bz2 |
PR24851, gas/testsuite/gas/epiphany/badrelax.s failure with MALLOC_PERTURB_=1
PR 24851
* config/tc-epiphany.c (md_estimate_size_before_relax): Clear
extra opcode bytes when changing from a 2-byte to a 4-byte insn.
Diffstat (limited to 'gas')
-rw-r--r-- | gas/ChangeLog | 6 | ||||
-rw-r--r-- | gas/config/tc-epiphany.c | 39 |
2 files changed, 28 insertions, 17 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 91180f2..68c4002 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +2019-08-12 Alan Modra <amodra@gmail.com> + + PR 24851 + * config/tc-epiphany.c (md_estimate_size_before_relax): Clear + extra opcode bytes when changing from a 2-byte to a 4-byte insn. + 2019-08-09 Jan Beulich <jbeulich@suse.com> * testsuite/gas/i386/ilp32/x86-64-simd-intel.d, diff --git a/gas/config/tc-epiphany.c b/gas/config/tc-epiphany.c index 3117918..5429fa9 100644 --- a/gas/config/tc-epiphany.c +++ b/gas/config/tc-epiphany.c @@ -727,6 +727,8 @@ md_estimate_size_before_relax (fragS *fragP, segT segment) handling to md_convert_frag. */ EPIPHANY_RELAX_TYPES subtype; + const CGEN_INSN *insn; + int i; /* We haven't relaxed this at all, so the relaxation type may be completely wrong. Set the subtype correctly. */ epiphany_relax_frag (segment, fragP, 0); @@ -753,26 +755,29 @@ md_estimate_size_before_relax (fragS *fragP, segT segment) fragP->fr_subtype = subtype; - { - const CGEN_INSN *insn; - int i; - - /* Update the recorded insn. */ + /* Update the recorded insn. */ + for (i = 0, insn = fragP->fr_cgen.insn; i < 4; i++, insn++) + { + if (strcmp (CGEN_INSN_MNEMONIC (insn), + CGEN_INSN_MNEMONIC (fragP->fr_cgen.insn)) == 0 + && CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_RELAXED)) + break; + } - for (i = 0, insn = fragP->fr_cgen.insn; i < 4; i++, insn++) - { - if ((strcmp (CGEN_INSN_MNEMONIC (insn), - CGEN_INSN_MNEMONIC (fragP->fr_cgen.insn)) - == 0) - && CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_RELAXED)) - break; - } + if (i == 4) + abort (); - if (i == 4) - abort (); + /* When changing from a 2-byte to 4-byte insn, don't leave + opcode bytes uninitialised. */ + if (CGEN_INSN_BITSIZE (fragP->fr_cgen.insn) < CGEN_INSN_BITSIZE (insn)) + { + gas_assert (CGEN_INSN_BITSIZE (fragP->fr_cgen.insn) == 16); + gas_assert (CGEN_INSN_BITSIZE (insn) == 32); + fragP->fr_opcode[2] = 0; + fragP->fr_opcode[3] = 0; + } - fragP->fr_cgen.insn = insn; - } + fragP->fr_cgen.insn = insn; } return md_relax_table[fragP->fr_subtype].rlx_length; |