Bug 26419

Summary: ASAN error: in mn10300_elf_relax_section bfd/elf-m10300.c:3942
Product: binutils Reporter: Martin Liska <mliska>
Component: binutilsAssignee: Alan Modra <amodra>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 2.34   
Target Milestone: 2.36   
Host: Target:
Build: Last reconfirmed: 2020-08-25 00:00:00

Description Martin Liska 2020-08-20 12:05:46 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=am33_2.0-linux CFLAGS="-g -O2 -fsanitize=address,undefined -Wno-error" CXXLAGS="-g -O2 -fsanitize=address,undefined -Wno-error" LDFLAGS="-ldl"
Target: am33_2.0-linux
PASS: difference of two same-section symbols
Executing on host: sh -c {./ld-new   -o tmpdir/i112045-3.x  -L/home/mliska/Programming/binutils/ld/testsuite/ld-mn10300 -relax -Ttext 100 tmpdir/i112045-3.o  2>&1}  /dev/null ld.tmp (timeout = 300)
==50495==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000258f at pc 0x00000058d960 bp 0x7fffffffb580 sp 0x7fffffffb578
    #0 0x58d95f in mn10300_elf_relax_section /home/mliska/Programming/binutils/bfd/elf-m10300.c:3942
    #1 0x4538f5 in lang_size_sections_1 /home/mliska/Programming/binutils/ld/ldlang.c:6072
    #2 0x452ae6 in lang_size_sections_1 /home/mliska/Programming/binutils/ld/ldlang.c:6048
    #3 0x45361b in lang_size_sections_1 /home/mliska/Programming/binutils/ld/ldlang.c:5810
    #4 0x472b42 in one_lang_size_sections_pass /home/mliska/Programming/binutils/ld/ldlang.c:6278
    #5 0x472b42 in lang_size_sections /home/mliska/Programming/binutils/ld/ldlang.c:6390
    #6 0x472b42 in lang_relax_sections /home/mliska/Programming/binutils/ld/ldlang.c:7659
    #7 0x4d4ead in ldelf_map_segments /home/mliska/Programming/binutils/ld/ldelfgen.c:40
    #8 0x48384d in lang_process /home/mliska/Programming/binutils/ld/ldlang.c:8164
    #9 0x413dda in main /home/mliska/Programming/binutils/ld/ldmain.c:494
    #10 0x7ffff6adacc9 in __libc_start_main (/lib64/libc.so.6+0x26cc9)
    #11 0x416329 in _start (/dev/shm/yipk5tlw/ld/ld-new+0x416329)
Comment 1 cvs-commit@gcc.gnu.org 2020-08-25 13:37:56 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

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

commit b8ff233b54d66c5dce5a6d1409fe57e7ea359f43
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Aug 25 09:37:23 2020 +0930

    PR26419, ASAN: mn10300_elf_relax_section elf-m10300.c:3943
    
            PR 26419
            * elf-m10300.c (mn10300_elf_relax_section): Don't attempt access
            before start of section.
Comment 2 Alan Modra 2020-08-25 13:40:35 UTC
Fixed