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 6/9] [bfd] Introduce new section flag: SEC_ELF_OCTETS


On Sun, Nov 17, 2019 at 12:21:27AM +0100, Christian Eggers wrote:
> +unsigned int
> +bfd_section_octets_per_byte (const asection *sec)
> +{
> +  unsigned int opb = bfd_octets_per_byte (sec->owner);

If sec can be be the absolute section (and I think it can) then
sec->owner will be NULL and this will segfault.  Instead of adding a
new function, I think you'd be better off adding a section parameter
to bfd_octets_per_byte and allow it to be NULL.  This will also force
you to at least look at all current uses of bfd_octets_per_byte and
perhaps see other places where you want the semantics of your new
function.

Some style nits need fixing.  There are repeated occurrences of the
following in the whole series.

> -  loc = input_section->output_offset * bfd_octets_per_byte (output_bfd);
> +  loc = input_section->output_offset
> +        * bfd_section_octets_per_byte (output_section);

Add extra parens here so that auto-formatting tools indent correctly:
  loc = (input_section->output_offset
	 * bfd_section_octets_per_byte (output_section));
Also indent with tabs.

> +  /* For sections where relocations are in octets, output_base and output_offset
> +   * must also be converted to octets. */

Comment style is wrong.  We don't do comment blocks with asterisks
down the left.  Also, two spaces after a full stop.

> +  if (bfd_get_flavour (abfd) == bfd_target_elf_flavour &&
> +      (symbol->section->flags & SEC_ELF_OCTETS))
> +    relocation += (output_base + symbol->section->output_offset) *
> +                   bfd_octets_per_byte (abfd);

No operators at end of line.  '&&' and '*' belong on the next line.

-- 
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]