aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-01-01 13:52:26 +1030
committerAlan Modra <amodra@gmail.com>2022-01-01 14:22:09 +1030
commitaebb3d543da4d411d3d767912193c3849f59ff99 (patch)
tree3386516764a12f078d71548b68e8080f3dcfc337 /bfd
parentbb67763979c2084af185a8bf6ead4a05a50e7b9d (diff)
downloadgdb-aebb3d543da4d411d3d767912193c3849f59ff99.zip
gdb-aebb3d543da4d411d3d767912193c3849f59ff99.tar.gz
gdb-aebb3d543da4d411d3d767912193c3849f59ff99.tar.bz2
ubsan: integer overflow in section filepos subtraction
* elf.c (assign_file_positions_for_non_load_sections): Avoid signed integer overflow.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/elf.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 92c06f2..d8a270d 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -6289,8 +6289,7 @@ assign_file_positions_for_non_load_sections (bfd *abfd,
Elf_Internal_Shdr *hdr = &elf_section_data (sect)->this_hdr;
if (hdr->sh_type != SHT_NOBITS)
{
- p->p_filesz = (sect->filepos - m->sections[0]->filepos
- + hdr->sh_size);
+ p->p_filesz = sect->filepos - p->p_offset + hdr->sh_size;
/* NB: p_memsz of the loadable PT_NOTE segment
should be the same as p_filesz. */
if (p->p_type == PT_NOTE