[PATCH]: Add format attributes and fix exposed bugs

Ian Lance Taylor ian@airs.com
Mon Jun 20 23:35:00 GMT 2005


"Kaveh R. Ghazi" <ghazi@caipclassic.rutgers.edu> writes:

> @@ -2353,7 +2353,7 @@ elf_xtensa_relocate_section (bfd *output
>  		error_message = vsprint_msg (error_message, ": %s",
>  					     strlen (name) + 2, name);
>  	      else
> -		error_message = vsprint_msg (error_message, ": (%s+0x%x)",
> +		error_message = vsprint_msg (error_message, ": (%s+0x%lx)",
>  					     strlen (name) + 22,
>  					     name, rel->r_addend);

Note that rel->r_addend has type bfd_vma, and thus neither %x nor %lx
is correct.  Correctness requires using bfd_sprintf_vma, or, simpler,
casting the argument to vsprint_msg.  Casting is always safe because
in the context of an Xtensa ELF file, the r_addend value has only 32
significant bits.

> @@ -237,11 +237,11 @@ print_insn_ia64 (bfd_vma memaddr, struct
>  	    if (str)
>  	      (*info->fprintf_func) (info->stream, "%s", str);
>  	    else if (odesc->flags & IA64_OPND_FLAG_DECIMAL_SIGNED)
> -	      (*info->fprintf_func) (info->stream, "%lld", value);
> +	      (*info->fprintf_func) (info->stream, "%lld", (long long) value);
>  	    else if (odesc->flags & IA64_OPND_FLAG_DECIMAL_UNSIGNED)
> -	      (*info->fprintf_func) (info->stream, "%llu", value);
> +	      (*info->fprintf_func) (info->stream, "%llu", (long long) value);
>  	    else
> -	      (*info->fprintf_func) (info->stream, "0x%llx", value);
> +	      (*info->fprintf_func) (info->stream, "0x%llx", (long long) value);
>  	    break;
>  
>  	  case IA64_OPND_CLASS_REL:

I'm not convinced that it is OK to use 'long long' here.  Maybe all
ia64 compilers support long long, though.

In general, the patch looks good, although I didn't look at every
single case.

Ian



More information about the Binutils mailing list