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 1/8] Bfd: Don't abort in cases where the size of a reloc is 3 bytes.


On Mon, 16 Jul 2018, John Darrington wrote:

> * bfd/reloc.c (_bfd_clear_contents): Handle the case where size == 3.
> ---
>  bfd/reloc.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/bfd/reloc.c b/bfd/reloc.c
> index 68bc8a8..3b42915 100644
> --- a/bfd/reloc.c
> +++ b/bfd/reloc.c
> @@ -1636,6 +1636,11 @@ _bfd_clear_contents (reloc_howto_type *howto,
>      case 2:
>        x = bfd_get_16 (input_bfd, location);
>        break;
> +    case 3:
> +      x = bfd_get_8 (input_bfd, location);
> +      x <<= 16;
> +      x |= bfd_get_16 (input_bfd, location + 1);
> +      break;
>      case 4:
>        x = bfd_get_32 (input_bfd, location);
>        break;
> @@ -1670,6 +1675,10 @@ _bfd_clear_contents (reloc_howto_type *howto,
>      case 2:
>        bfd_put_16 (input_bfd, x, location);
>        break;
> +    case 3:
> +      bfd_put_16 (input_bfd, x, location + 1);
> +      bfd_put_8 (input_bfd, x >> 16, location);
> +      break;

You're open-coding a 24-bit get/put from 8- and 16-bit parts,
but you need to handle endianness, not (in part) forcing
big-endian as is done here, in generic code.

Maybe alternatives with conditionals using bfd_big_endian(abfd)
or bfd_little_endian(abfd) is sufficient.

>      case 4:
>        bfd_put_32 (input_bfd, x, location);
>        break;
> --
> 2.1.4
>


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