Bug 26482 - ASAN error: in _bfd_xcoff_sizeof_headers bfd/coff-rs6000.c:2585
Summary: ASAN error: in _bfd_xcoff_sizeof_headers bfd/coff-rs6000.c:2585
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:36 UTC by Martin Liska
Modified: 2020-08-25 13:44 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed: 2020-08-25 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:36: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=powerpc-aix5.1 CFLAGS="-g -O2 -fsanitize=address,undefined -Wno-error" CXXLAGS="-g -O2 -fsanitize=address,undefined -Wno-error" LDFLAGS="-ldl"
Target: powerpc-aix5.1
PASS: -l: test
Executing on host: sh -c {./ld-new   -L/home/mliska/Programming/binutils/ld/testsuite/ld-misc  -e 0 --defsym foo=1 tmpdir/start.o tmpdir/libfoo.a -o tmpdir/dump tmpdir/dummy.o  2>&1}  /dev/null dump.tmp (timeout = 300)
==36732==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6030000005d0 at pc 0x000000569c5a bp 0x7fffffffb810 sp 0x7fffffffb808
    #0 0x569c59 in _bfd_xcoff_sizeof_headers /home/mliska/Programming/binutils/bfd/coff-rs6000.c:2585
    #1 0x499401 in fold_name /home/mliska/Programming/binutils/ld/ldexp.c:703
    #2 0x499401 in exp_fold_tree_1 /home/mliska/Programming/binutils/ld/ldexp.c:1242
    #3 0x497ee0 in fold_binary /home/mliska/Programming/binutils/ld/ldexp.c:564
    #4 0x497ee0 in exp_fold_tree_1 /home/mliska/Programming/binutils/ld/ldexp.c:1040
    #5 0x497bc1 in fold_binary /home/mliska/Programming/binutils/ld/ldexp.c:530
    #6 0x497bc1 in exp_fold_tree_1 /home/mliska/Programming/binutils/ld/ldexp.c:1040
    #7 0x49a108 in exp_fold_tree_1 /home/mliska/Programming/binutils/ld/ldexp.c:1059
    #8 0x450b5f in lang_size_sections_1 /home/mliska/Programming/binutils/ld/ldlang.c:6099
    #9 0x46f27f in one_lang_size_sections_pass /home/mliska/Programming/binutils/ld/ldlang.c:6278
    #10 0x46f27f in lang_size_sections /home/mliska/Programming/binutils/ld/ldlang.c:6390
    #11 0x480350 in lang_process /home/mliska/Programming/binutils/ld/ldlang.c:8160
    #12 0x4114f2 in main /home/mliska/Programming/binutils/ld/ldmain.c:494
    #13 0x7ffff6adacc9 in __libc_start_main (/lib64/libc.so.6+0x26cc9)
    #14 0x413899 in _start (/dev/shm/viq6a6j8/ld/ld-new+0x413899)
Comment 1 Sourceware Commits 2020-08-25 13:38:32 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

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

commit a93ba4c0cf1d6ffa46b493643460730265455e4c
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Aug 25 16:15:27 2020 +0930

    PR26482, ASAN: _bfd_xcoff_sizeof_headers coff-rs6000.c:2585
    
            PR 26482
            * coff-rs6000.c (_bfd_xcoff_sizeof_headers): Ignore sections that
            won't be output.
Comment 2 Alan Modra 2020-08-25 13:44:11 UTC
Fixed