Bug 26521 - A Floating point exception in elf.c:12840:31
Summary: A Floating point exception in elf.c:12840:31
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.36
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 27131 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-08-22 01:43 UTC by zhouan
Modified: 2020-12-31 12:52 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
FPE-_bfd_elf_write_secondary_reloc_section-elf-12840 (2.34 KB, application/zip)
2020-08-22 01:43 UTC, zhouan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description zhouan 2020-08-22 01:43:12 UTC
Created attachment 12789 [details]
FPE-_bfd_elf_write_secondary_reloc_section-elf-12840

## System info

Ubuntu x86_64, clang 6.0, binutils (2.36 d1ce973eb377f19240005665258ce1d89bd064b5)

## Configure

CFLAGS="-g -fsanitize=address" LDFLAGS="-fsanitize=address" ./configure

## Command line

./binutils/strip-new -s -g -S -d -w -x -X -v -o /dev/null @@

## AddressSanitizer output

```
AddressSanitizer:DEADLYSIGNAL
=================================================================
==14746==ERROR: AddressSanitizer: FPE on unknown address 0x00000069c05c (pc 0x00000069c05c bp 0x7ffde12578d0 sp 0x7ffde1257720 T0)
    #0 0x69c05b in _bfd_elf_write_secondary_reloc_section /home/seviezhou/binutils/bfd/elf.c:12840:31
    #1 0x642b07 in bfd_elf64_write_relocs /home/seviezhou/binutils/bfd/./elfcode.h:1002:8
    #2 0x5d7bbc in bfd_map_over_sections /home/seviezhou/binutils/bfd/section.c:1379:5
    #3 0x6847f0 in _bfd_elf_write_object_contents /home/seviezhou/binutils/bfd/elf.c:6657:3
    #4 0x5cf909 in bfd_close /home/seviezhou/binutils/bfd/opncls.c:775:13
    #5 0x51e9d4 in copy_file /home/seviezhou/binutils/binutils/objcopy.c:3846:51
    #6 0x5143d8 in strip_main /home/seviezhou/binutils/binutils/objcopy.c:4826:7
    #7 0x5143d8 in main /home/seviezhou/binutils/binutils/objcopy.c:6024
    #8 0x7fa7b3be6b96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
    #9 0x41ac99 in _start (/home/seviezhou/binutils/binutils/strip-new+0x41ac99)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: FPE /home/seviezhou/binutils/bfd/elf.c:12840:31 in _bfd_elf_write_secondary_reloc_section
==14746==ABORTING
```
Comment 1 cvs-commit@gcc.gnu.org 2020-09-03 15:12:17 UTC
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ac267c754cecd2bbbfc71feb9ca8ec84f6754cb4

commit ac267c754cecd2bbbfc71feb9ca8ec84f6754cb4
Author: Nick Clifton <nickc@redhat.com>
Date:   Thu Sep 3 16:11:43 2020 +0100

    Fix a division by zero error when processing secondary relocs in a fuzzed input file.
    
            PR 26521
            * elf.c (_bfd_elf_write_secondary_reloc_section): Check for
            secondary reloc sections with a zero sh_entsize field.
Comment 2 Nick Clifton 2020-09-03 15:13:24 UTC
Hi Zhouan,

  Thanks for reporting this problem.  I have checked in a patch to add
  a test for a potential division by zero and made it report an error
  instead.

Cheers
  Nick
Comment 3 Alan Modra 2020-12-31 12:52:28 UTC
*** Bug 27131 has been marked as a duplicate of this bug. ***