]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Tidy elf_segment_map allocation
authorAlan Modra <amodra@gmail.com>
Fri, 5 Oct 2018 12:47:00 +0000 (22:17 +0930)
committerAlan Modra <amodra@gmail.com>
Mon, 8 Oct 2018 09:56:08 +0000 (20:26 +1030)
commit00bee008e9f7d0b3adf3278962450944653787f8
tree880a8f4d14409add15b6d0ea01faaf491caefae2
parentc258c396faa626a4c7929a5ec97ee9b294073c5e
Tidy elf_segment_map allocation

This cleans up elf_segment_map allocation when the section array is
empty.  "amt += (to - from - 1) * sizeof (asection *)", when "to" and
"from" are unsigned int results in an unsigned value inside the
parentheses.  When "to" and "from" are equal on a 64-bit host,
0xffffffff * 8 is added to "amt", not -8 as desired.

The patch also renames a variable for consistency with other functions
using a similar index.

* elf.c (make_mapping): Cope with zero size array at end of
struct elf_segment_map.
(_bfd_elf_map_sections_to_segments): Likewise.
(rewrite_elf_program_header, copy_elf_program_header): Likewise.
(_bfd_elf_map_sections_to_segments): Rename phdr_index to hdr_index.
bfd/ChangeLog
bfd/elf.c