Bug 28826 - [2.38 Regression] ld segfaults building xen
Summary: [2.38 Regression] ld segfaults building xen
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.38
: P2 normal
Target Milestone: 2.38
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-27 11:12 UTC by Matthias Klose
Modified: 2022-02-09 11:11 UTC (History)
1 user (show)

See Also:
Host:
Target: x86_64-linux-gnu
Build:
Last reconfirmed:


Attachments
Likely fix (415 bytes, patch)
2022-01-28 04:04 UTC, Alan Modra
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Klose 2022-01-27 11:12:58 UTC
seen with the 2.38 branch 20220123 and 20220126,

https://bugs.debian.org/1004269
https://bugs.launchpad.net/ubuntu/+source/binutils/+bug/1958389

The Debian report contains the more useful stack trace.  The Ubuntu report suggests that this is only seen on Intel hardware, not AMD hardware.
Comment 1 H.J. Lu 2022-01-27 14:21:50 UTC
I can build xen-4.16.0 on Fedora 35.  Please provide ALL inputs so that
I can reproduce it.
Comment 2 Alan Modra 2022-01-28 04:04:45 UTC
Created attachment 13937 [details]
Likely fix

From the backtrace in https://bugs.debian.org/1004269 it is clear that the problem is triggered by commit e86fc4a5bc37 in which a new extrap field was added to coffcode.h combined_entry_type but is not used on anything except rs6000 coff targets.
Comment 3 Alan Modra 2022-01-28 04:08:53 UTC
HJ, you likely can reproduce the failue with an asan build of binutils, or using MALLOC_PERTURB_.  I haven't tested the patch yet.
Comment 4 H.J. Lu 2022-01-28 04:41:02 UTC
Works for me:

/export/build/gnu/tools-build/binutils-asan/build-x86_64-linux/ld/ld-new -mi386pep --subsystem=10 --image-base=0xffff82d040000000 --stack=0,0 --heap=0,0 --section-alignment=0x200000 --file-alignment=0x20 --major-image-version=4 --minor-image-version=16 --major-os-version=2 --minor-os-version=0 --major-subsystem-version=2 --minor-subsystem-version=0 --build-id=sha1 -T efi.lds -N prelink.o /export/gnu/import/git/gitlab/xen/xen/.xen.efi.1r.o /export/gnu/import/git/gitlab/xen/xen/.xen.efi.1s.o -b pe-x86-64 efi/buildid.o -o /export/gnu/import/git/gitlab/xen/xen/xen.efi

=================================================================
==1616314==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 862212 byte(s) in 133 object(s) allocated from:
    #0 0x7f3fbb6e791f in __interceptor_malloc (/lib64/libasan.so.6+0xae91f)
    #1 0xb4844b in xmalloc /export/gnu/import/git/gitlab/x86-binutils/libiberty/xmalloc.c:149

SUMMARY: AddressSanitizer: 862212 byte(s) leaked in 133 allocation(s).
[hjl@gnu-tgl-2 x86]$
Comment 5 Sourceware Commits 2022-01-28 06:32:23 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

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

commit 07c9f243b3a12cc6749bc02ee7b165859979348b
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Jan 28 14:29:34 2022 +1030

    PR28826 x86_64 ld segfaults building xen
    
    Fallout from commit e86fc4a5bc37
    
            PR 28826
            * coffgen.c (coff_write_alien_symbol): Init dummy to zeros.
Comment 6 Sourceware Commits 2022-02-05 08:29:46 UTC
The binutils-2_38-branch branch has been updated by Alan Modra <amodra@sourceware.org>:

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

commit 61ecfbda44fb8d165f01cac3d704a5e9fd321795
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Jan 28 14:29:34 2022 +1030

    PR28826 x86_64 ld segfaults building xen
    
    Fallout from commit e86fc4a5bc37
    
            PR 28826
            * coffgen.c (coff_write_alien_symbol): Init dummy to zeros.
    
    (cherry picked from commit 07c9f243b3a12cc6749bc02ee7b165859979348b)
Comment 7 Alan Modra 2022-02-09 11:11:12 UTC
Fixed mainline and 2.38 branch