Bug 26469 - UBSAN error: bfd/elflink.c:8742:7:
Summary: UBSAN error: bfd/elflink.c:8742:7:
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.34
: P2 normal
Target Milestone: 2.36
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-20 12:32 UTC by Martin Liska
Modified: 2020-08-27 23:08 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed: 2020-08-27 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liska 2020-08-20 12:32:07 UTC
The following fails when I build binutils with:
configure --build=x86_64-linux --disable-nls --disable-gdb --disable-gdbserver --disable-sim --disable-readline --disable-libdecnumber --enable-obsolete --target=mep-elf CFLAGS="-g -O2 -fsanitize=address,undefined -Wno-error" CXXLAGS="-g -O2 -fsanitize=address,undefined -Wno-error" LDFLAGS="-ldl"
Target: mep-elf
FAIL: assembling relocs-refs
Executing on host: /dev/shm/8p3qrweg/ld/ld-new relocs-junk1.o relocs-syms.o relocs-junk2.o relocs-refs.o --defsym __stack=0x1ffff0 --defsym __sbss_end=0x1000 -e 1233 -EL -o relocs.x    (timeout = 300)
/home/mliska/Programming/binutils/bfd/elflink.c:8742:7: runtime error: shift exponent 6148914691236511722 is too large for 64-bit type 'long unsigned int'
Comment 1 Sourceware Commits 2020-08-27 12:36:33 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

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

commit 4b69ce9b9121090ac42cf8fa20b949bbd9afff95
Author: Alan Modra <amodra@gmail.com>
Date:   Thu Aug 27 21:44:41 2020 +0930

    PR26469 UBSAN: elflink.c:8742 shift exponent 6148914691236511722
    
            PR 26469
            * elflink.c: Include limits.h.
            (CHAR_BIT): Provide fallback define.
            (set_symbol_value): Correct complex reloc comment.
            (undefined_reference): Set bfd_error.
            (BINARY_OP_HEAD, BINARY_OP_TAIL): Split out from..
            (BINARY_OP): ..this.
            (eval_symbol): Limit shifts.  Force unsigned for left shift.
            Catch divide by zero.
            * configure.ac (AC_CHECK_HEADERS): Combine, sort and add limits.h.
            * configure: Regenerate.
            * config.in: Regenerate.
Comment 2 Alan Modra 2020-08-27 23:08:21 UTC
Fixed