diff options
author | Jan Beulich <jbeulich@suse.com> | 2024-04-26 14:23:14 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2024-04-26 14:23:14 +0200 |
commit | 6fde04116b4b835fa9ec3b3497fcac4e4a0637e2 (patch) | |
tree | f0c4791cd8db1be9172fb2d20ad6c2fb771acb63 /binutils/objcopy.c | |
parent | cd0dbe767775fdbfdc875a14f9080fdea0841c92 (diff) | |
download | binutils-6fde04116b4b835fa9ec3b3497fcac4e4a0637e2.zip binutils-6fde04116b4b835fa9ec3b3497fcac4e4a0637e2.tar.gz binutils-6fde04116b4b835fa9ec3b3497fcac4e4a0637e2.tar.bz2 |
objcopy: check input flavor before setting PE/COFF section alignment
coff_section_data() and elf_section_data() use the same underlying
field. The pointer being non-NULL therefore isn't sufficient to know
that pei_section_data() can validly be used on the incoming object.
Apparently in 64-bit-host builds the resulting memory corruption is
benign, whereas in 32-bit-host builds a segmentation fault occurs upon
de-referencing pei_section_data()'s return value.
Diffstat (limited to 'binutils/objcopy.c')
-rw-r--r-- | binutils/objcopy.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/binutils/objcopy.c b/binutils/objcopy.c index e8ca1374..26f9d4a 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -4317,6 +4317,7 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg) if (p != NULL) alignment = p->alignment; else if (pe_section_alignment != (bfd_vma) -1 + && bfd_get_flavour (ibfd) == bfd_target_coff_flavour && bfd_get_flavour (obfd) == bfd_target_coff_flavour) { alignment = power_of_two (pe_section_alignment); |