diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2021-01-13 06:48:07 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2021-01-13 06:48:20 -0800 |
commit | b634d11d61e3236f4602e9461dba67d1320f65e3 (patch) | |
tree | 37f33ef6d13473a3bbe4604419104398138fe0de /ld | |
parent | 844bf810cf9feebe50772c29d72256ec3c872270 (diff) | |
download | gdb-b634d11d61e3236f4602e9461dba67d1320f65e3.zip gdb-b634d11d61e3236f4602e9461dba67d1320f65e3.tar.gz gdb-b634d11d61e3236f4602e9461dba67d1320f65e3.tar.bz2 |
ld: Check for ELF input before accessing ELF section data
commit b209b5a6b8a 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.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 5 | ||||
-rw-r--r-- | ld/ldelfgen.c | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 49e580d..2dad0b9 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -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. diff --git a/ld/ldelfgen.c b/ld/ldelfgen.c index 8014e22..47e7a2a 100644 --- a/ld/ldelfgen.c +++ b/ld/ldelfgen.c @@ -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++; |