This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] ARM: plt_size functions need to read instructions in right byte order
- From: Alan Modra <amodra at gmail dot com>
- To: Victor Kamensky <victor dot kamensky at linaro dot org>
- Cc: binutils at sourceware dot org, pinskia at gmail dot com
- Date: Tue, 21 Oct 2014 18:31:23 +1030
- Subject: Re: [PATCH] ARM: plt_size functions need to read instructions in right byte order
- Authentication-results: sourceware.org; auth=none
- References: <1413868578-6761-1-git-send-email-victor dot kamensky at linaro dot org> <1413868578-6761-2-git-send-email-victor dot kamensky at linaro dot org>
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