Bug 26433 - UBSAN error: bfd/elf32-avr.c:4109:17:
Summary: UBSAN error: bfd/elf32-avr.c:4109:17:
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.34
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-20 12:15 UTC by Martin Liska
Modified: 2020-08-26 16:45 UTC (History)
1 user (show)

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


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:15:38 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=avr-elf CFLAGS="-g -O2 -fsanitize=address,undefined -Wno-error" CXXLAGS="-g -O2 -fsanitize=address,undefined -Wno-error" LDFLAGS="-ldl"
Target: avr-elf
FAIL: AVR .avr.prop, single .org test.
Executing on host: sh -c {./ld-new   -L/home/mliska/Programming/binutils/ld/testsuite/ld-avr  -mavrxmega2 --relax -o tmpdir/dump tmpdir/avr-prop-2.o  2>&1}  /dev/null dump.tmp (timeout = 300)
/home/mliska/Programming/binutils/bfd/elf32-avr.c:4109:17: runtime error: load of misaligned address 0x603000000dc9 for type 'uint32_t', which requires 4 byte alignment

--------------------------------------------------------------------------------
UBSAN error: bfd/elf32-avr.c:4159:43: 
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=avr-elf CFLAGS="-g -O2 -fsanitize=address,undefined -Wno-error" CXXLAGS="-g -O2 -fsanitize=address,undefined -Wno-error" LDFLAGS="-ldl"
Target: avr-elf
FAIL: AVR .avr.prop, multiple .org test.
Executing on host: sh -c {./ld-new   -L/home/mliska/Programming/binutils/ld/testsuite/ld-avr  -mavrxmega2 --relax -o tmpdir/dump tmpdir/avr-prop-3.o  2>&1}  /dev/null dump.tmp (timeout = 300)
/home/mliska/Programming/binutils/bfd/elf32-avr.c:4159:43: runtime error: load of misaligned address 0x603000000df9 for type 'uint32_t', which requires 4 byte alignment
Comment 1 cvs-commit@gcc.gnu.org 2020-08-26 16:44:29 UTC
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:

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

commit 8c51f2f291a5459e1eabd000b2c52e5de52b4c56
Author: Nick Clifton <nickc@redhat.com>
Date:   Wed Aug 26 17:43:39 2020 +0100

    Fix sanitization problems in the BFD library when running the linker testsuite for the AVR target.
    
            PR 26433
            * elf32-avr.c (avr_final_link_relocate):  Fix undefined shift
            behaviour.
            (avr_elf32_load_records_from_section): Use bfd_get_16 and
            bfd_get_32 to load values from potentially unaligned pointers.
Comment 2 Nick Clifton 2020-08-26 16:45:21 UTC
Hi Martin,

  This problem should now be fixed.

Cheers
  Nick