diff options
author | Alan Modra <amodra@gmail.com> | 2018-02-26 08:16:24 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2018-02-26 10:51:12 +1030 |
commit | 6838f2bed6459514c1b0c549e6aa3fc7dbb1d7ec (patch) | |
tree | 6a208a96143d2826c120abb1083e21e501a5e609 /bfd | |
parent | df5f2391f7b2e3cab7e677ab7dadd02aef06e269 (diff) | |
download | gdb-6838f2bed6459514c1b0c549e6aa3fc7dbb1d7ec.zip gdb-6838f2bed6459514c1b0c549e6aa3fc7dbb1d7ec.tar.gz gdb-6838f2bed6459514c1b0c549e6aa3fc7dbb1d7ec.tar.bz2 |
Segfault on phdrs allocated but not created
A number of ARM tests show results like:
ld-new: no address assigned to the veneers output section .gnu.sgstubs
ld-new: can not size stub section: invalid operation
ld-new: warning: cannot find entry symbol _start; defaulting to 0000000000010074
ld-new: tmpdir/cmse-veneers-no-gnu_sgstubs: warning: allocated section `.text' not in segment
Segmentation fault
PASS: Secure gateway veneers: no .gnu.sgstubs section
The PASS despite the segv shows the danger of using "#..." to match
error output. This patch doesn't try to fix the testuite, but does
prevent the segfault.
* elf.c (assign_file_positions_except_relocs): Don't segfault
when actual number of phdrs is less than allocated. Delete
outdated comment. Formatting.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 6 | ||||
-rw-r--r-- | bfd/elf.c | 12 |
2 files changed, 11 insertions, 7 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 68527a3..15aa4ee 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,11 @@ 2018-02-26 Alan Modra <amodra@gmail.com> + * elf.c (assign_file_positions_except_relocs): Don't segfault + when actual number of phdrs is less than allocated. Delete + outdated comment. Formatting. + +2018-02-26 Alan Modra <amodra@gmail.com> + * elf-m10300.c, * elf-s390-common.c, * elf32-arc.c, * elf32-cris.c, * elf32-dlx.c, * elf32-frv.c, * elf32-i370.c, * elf32-lm32.c, * elf32-m32r.c, * elf32-m68hc1x.c, * elf32-m68k.c, @@ -6127,9 +6127,7 @@ assign_file_positions_except_relocs (bfd *abfd, } /* Write out the program headers. */ - alloc = elf_program_header_size (abfd) / bed->s->sizeof_phdr; - - /* Sort the program headers into the ordering required by the ELF standard. */ + alloc = elf_elfheader (abfd)->e_phnum; if (alloc == 0) return TRUE; @@ -6151,14 +6149,14 @@ assign_file_positions_except_relocs (bfd *abfd, alloc)) && tdata->phdr[1].p_type == PT_LOAD && (tdata->phdr[1].p_vaddr > tdata->phdr[0].p_vaddr - || (tdata->phdr[1].p_vaddr + tdata->phdr[1].p_memsz) - < (tdata->phdr[0].p_vaddr + tdata->phdr[0].p_memsz))) + || (tdata->phdr[1].p_vaddr + tdata->phdr[1].p_memsz + < tdata->phdr[0].p_vaddr + tdata->phdr[0].p_memsz))) { /* The fix for this error is usually to edit the linker script being used and set up the program headers manually. Either that or leave room for the headers at the start of the SECTIONS. */ - _bfd_error_handler (_("\ -%pB: error: PHDR segment not covered by LOAD segment"), + _bfd_error_handler (_("%pB: error: PHDR segment not covered" + " by LOAD segment"), abfd); return FALSE; } |