Bug 26448 - UBSAN error: gas/symbols.c:1586:31:
Summary: UBSAN error: gas/symbols.c:1586:31:
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:23 UTC by Martin Liska
Modified: 2020-08-26 14:37 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed: 2020-08-26 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:23:06 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=dlx-elf CFLAGS="-g -O2 -fsanitize=address,undefined -Wno-error" CXXLAGS="-g -O2 -fsanitize=address,undefined -Wno-error" LDFLAGS="-ldl"
Target: dlx-elf
PASS: lhi
Executing on host: sh -c {../as-new    -o tmpdir/load.o /home/mliska/Programming/binutils/gas/testsuite/gas/dlx/load.s 2>&1}  /dev/null dump.tmp (timeout = 300)
/home/mliska/Programming/binutils/gas/symbols.c:1586:31: runtime error: left shift of negative value -20
Comment 1 Sourceware Commits 2020-08-26 13:54:47 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

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

commit d8d6da137d7ececcd0e10c575aa187bb8c9b24e0
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Aug 26 17:39:58 2020 +0930

    PR26448 UBSAN: symbols.c:1586 left shift of negative value
    
    Besides avoiding the UB, this also makes right shifts inside
    expression symbols unsigned, consistent with the way gas evaluates
    expressions in source.
    
            PR 26448
            * symbols.c: Include limits.h.
            (resolve_symbol_value <O_left_shift, O_right_shift>): Do an
            unsigned shift.  Warn if shift count larger than valueT size.
Comment 2 Alan Modra 2020-08-26 14:37:45 UTC
Fixed