Bug 31120 - ld-scripts/fill2 fails when bfd_vma is 32 bits
Summary: ld-scripts/fill2 fails when bfd_vma is 32 bits
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.42
: P2 normal
Target Milestone: 2.42
Assignee: Alan Modra
URL:
Keywords:
: 31195 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-12-07 04:26 UTC by Alan Modra
Modified: 2024-01-05 04:59 UTC (History)
2 users (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 Alan Modra 2023-12-07 04:26:38 UTC
regexp_diff match failure
regexp "^  0x00000020 00010203 04050607 04050607 04050607 ................$"
line   "  0x00000020 00010203 04050607 ffffffff ffffffff ................"
FAIL: ld-scripts/fill2

The reason for the failure is that FILL ($0001020304050607) in fil2.t has the value read by strtoul (via scan_bfd_vma in ldlex.l), and strtoul returns -1 on overflow.
Comment 1 Alan Modra 2023-12-28 23:06:07 UTC
*** Bug 31195 has been marked as a duplicate of this bug. ***
Comment 2 Sourceware Commits 2024-01-05 02:31:04 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

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

commit c217aed574216e6af34188ac8a9bf019539e415d
Author: Alan Modra <amodra@gmail.com>
Date:   Sun Dec 31 14:09:10 2023 +1030

    PR31120, ld-scripts/fill2 fails when bfd_vma is 32 bits
    
    The ld lexer converts strings to integers without overflow checking,
    so I don't think there is any problem in truncating an integer that
    exceeds the size of a bfd_vma rather than using (bfd_vma) -1.
    
            PR 31120
            * ldlex.l: Don't use bfd_scan_vma for integer conversion, use
            strtoull.
Comment 3 Alan Modra 2024-01-05 04:59:29 UTC
Fixed