ld: Check for ELF input before accessing ELF section data
commit b209b5a6b8
accesses ELF section data without checking if input is
ELF. It caused:
sh: line 1: 1355479 Segmentation fault (core dumped) /export/build/gnu/tools-build/binutils-gitlab-x32/build-x86_64-linux-gnux32/ld/ld-new -o tmpdir/pe-x86-64-1 -z norelro -L/export/gnu/import/git/gitlab/x86-binutils/ld/testsuite/ld-x86-64 -m elf_x86_64 --entry=begin tmpdir/pe-x86-64-1a.obj tmpdir/pe-x86-64-1b.obj tmpdir/pe-x86-64-1c.obj 2>&1
FAIL: Build pe-x86-64-1
on Linux/x86-64 with PE/x86-64 inputs. Add check for ELF input before
accessing ELF section data.
* ldelfgen.c (add_link_order_input_section): Check for ELF input
before accessing ELF section data.
This commit is contained in:
parent
844bf810cf
commit
b634d11d61
@ -1,3 +1,8 @@
|
||||
2021-01-13 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* ldelfgen.c (add_link_order_input_section): Check for ELF input
|
||||
before accessing ELF section data.
|
||||
|
||||
2021-01-13 Alan Modra <amodra@gmail.com>
|
||||
|
||||
* Makefile.in: Regenerate.
|
||||
|
@ -79,7 +79,8 @@ add_link_order_input_section (lang_input_section_type *is,
|
||||
os_info->isec[os_info->count].idx = os_info->count;
|
||||
os_info->count++;
|
||||
s = is->section;
|
||||
if ((s->flags & SEC_LINKER_CREATED) == 0
|
||||
if (s->owner->xvec->flavour == bfd_target_elf_flavour
|
||||
&& (s->flags & SEC_LINKER_CREATED) == 0
|
||||
&& elf_section_data (s) != NULL
|
||||
&& elf_linked_to_section (s) != NULL)
|
||||
os_info->ordered++;
|
||||
|
Loading…
Reference in New Issue
Block a user