This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] ARM: plt_size functions need to read instructions in right byte order


On Mon, Oct 20, 2014 at 10:16:18PM -0700, Victor Kamensky wrote:
>	* elf32-arm.c (read_code32): New function to read 32 bit
>	arm instruction.
>	(read_code16): New function to read 16 bit thumb instrution.
>	(elf32_arm_plt0_size, elf32_arm_plt_size) change code to use
>	read_code32, read_code16 to read instruction to deal with
>	BE8 arm case.

OK, with a few minor nits fixed:

> +  if ((elf_elfheader(abfd)->e_flags) & EF_ARM_BE8)
> +    {
> +       /*
> +	* V7 BE8 code is always little endian
> +	*/
> +       retval = bfd_getl32(addr);
> +    }
> +  else
> +    {
> +       retval = H_GET_32(abfd, addr);
> +    }
> +  return retval;

Please write this as:

  if ((elf_elfheader (abfd)->e_flags & EF_ARM_BE8) != 0)
    /* V7 BE8 code is always little endian.  */
    retval = bfd_getl32 (addr);
  else
    retval = bfd_get_32 (abfd, addr);
  return retval;

Note: space before open parens in function/macro call, comment
formatting, no braces for single line block, and H_GET_32 is
technically wrong.  I know you didn't introduce the use of H_GET_32,
but that function is supposed to be for reading headers or other
metadata.  bfd_get_32 is the correct function for section data.

Similarly for read_code16.

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]