This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Patch SH Assembler: Generates error in case of instruction mov#Imm,rd
Hi Andreas,
>> Hi,
>>
>> In case of following instruction for SH,
>> mov #H'0f,r10
>> SH ELF assembler crashes and gives segmentation fault.
>> Instead SH ELF assembler should give error for wrong syntax.
>>
>> Please find patch below which fixes this problem in SH assembler.
>> No new regressions found in DejaGnu testsuite after pacth.
>
> What about
>
> .set foo,3
> mov #foo+1,r10
Good point.
I am revert Anil's patch and applying this one in its place. The
error message generated is not as helpful, but at least it will allow
expressions in the #Imm field.
Cheers
Nick
gas/ChangeLog
2004-02-27 Nick Clifton <nickc@redhat.com>
* config/tc-sh.c (get_operand): Revert previous delta.
(tc_gen_reloc): Check for an unknown reloc type before processing
the addend.
Index: gas/config/tc-sh.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-sh.c,v
retrieving revision 1.93
diff -c -3 -p -r1.93 tc-sh.c
*** gas/config/tc-sh.c 27 Feb 2004 12:21:57 -0000 1.93
--- gas/config/tc-sh.c 27 Feb 2004 13:11:24 -0000
*************** get_operand (char **ptr, sh_operand_info
*** 1426,1433 ****
if (src[0] == '#')
{
- if (! ISDIGIT (src[1]))
- as_bad (_("syntax error in #Imm"));
src++;
*ptr = parse_exp (src, op);
op->type = A_IMM;
--- 1426,1431 ----
*************** tc_gen_reloc (asection *section ATTRIBUT
*** 4193,4202 ****
rel->addend = 0;
rel->howto = bfd_reloc_type_lookup (stdoutput, r_type);
! #ifdef OBJ_ELF
! if (rel->howto->type == R_SH_IND12W)
! rel->addend += fixp->fx_offset - 4;
! #endif
if (rel->howto == NULL)
{
as_bad_where (fixp->fx_file, fixp->fx_line,
--- 4191,4197 ----
rel->addend = 0;
rel->howto = bfd_reloc_type_lookup (stdoutput, r_type);
!
if (rel->howto == NULL)
{
as_bad_where (fixp->fx_file, fixp->fx_line,
*************** tc_gen_reloc (asection *section ATTRIBUT
*** 4206,4211 ****
--- 4201,4210 ----
rel->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_32);
assert (rel->howto != NULL);
}
+ #ifdef OBJ_ELF
+ else if (rel->howto->type == R_SH_IND12W)
+ rel->addend += fixp->fx_offset - 4;
+ #endif
return rel;
}