Bug 24065 - 32-bit objcopy fails with '64-bit address ... out of range ...'
Summary: 32-bit objcopy fails with '64-bit address ... out of range ...'
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.31
: P2 normal
Target Milestone: ---
Assignee: Tamar Christina
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-05 14:44 UTC by Liviu Ionescu
Modified: 2019-01-20 15:34 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2019-01-07 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Liviu Ionescu 2019-01-05 14:44:39 UTC
When running on 32-bit machines, objdump displays an out of range error like:

arm-none-eabi-objcopy: f4b.hex 64-bit address 0x4a2a7708000000 out of range for Intel Hex file

The problem was first reported at:

https://bugs.launchpad.net/gcc-arm-embedded/+bug/1810274

It affects both Windows and Linux 32-bit builds; 64-bit builds seem ok.


The 'arm-none-eabi-objcopy --version' is 2.31.51.20181213, packed with GCC 8.2.1 by Arm and also by GNU MCU Eclipse.

An earlier build of 8.2.0 running on a 32-bit Arch Linux was ok. It showed version 2.31.1.
Comment 1 Tamar Christina 2019-01-07 17:33:12 UTC
Confirmed, this is caused by the change for PR/23699, the code assumes that bfd_vma is always a 64bit value, but it's host dependent.

The result is that on a 32bit system, it always thinks the top bits are set as the top mask bits are gone.

Testing patch.
Comment 2 Sourceware Commits 2019-01-08 12:02:07 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

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

commit a9859e01726d085db79cff88550fdb38e2434e42
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Jan 8 22:21:57 2019 +1030

    PR24065, 32-bit objcopy fails with 64-bit address ... out of range
    
    	PR 23699
    	PR 24065
    	* ihex.c (ihex_write_object_contents): Properly check 32-bit
    	address range.
Comment 3 Sourceware Commits 2019-01-08 15:00:15 UTC
The master branch has been updated by Tamar Christina <tnfchris@sourceware.org>:

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

commit e3ecd631339aaa2a4af57f59f0694671d4ce00ab
Author: Tamar Christina <tamar.christina@arm.com>
Date:   Tue Jan 8 14:52:53 2019 +0000

    Add testcase for PR/24065.
    
    This adds a new testcase for objcopy -O ihex to test
    that it correctly works.
    
    binutils/ChangeLog:
    
    	PR 24065
    	* testsuite/binutils-all/copy-6.d: New test.
    	* testsuite/binutils-all/objcopy.exp: Use it.
Comment 4 Tamar Christina 2019-01-08 15:02:04 UTC
fixed in master.
Comment 5 Liviu Ionescu 2019-01-08 15:15:41 UTC
Thank you, Christina, thank you, Alan.

Since the GNU MCU Eclipse GCC distribution usually follows the Arm distributions, I'll talk to them and, depending on their release plans, I'll either wait for them to get this patch or make a custom GNU MCU Eclipse GCC release.

I'll confirm that the bug was fixed as soon as I'll be able to build my release; Arm may equally confirm it, if they proceed with their release sooner.
Comment 6 Liviu Ionescu 2019-01-20 15:34:34 UTC
Arm replied, but currently they have no ETE for a maintenance release.

In the mean time those interrested on a fixed toolchain can use the GNU MCU Eclipse binaries:

https://github.com/gnu-mcu-eclipse/arm-none-eabi-gcc/releases/tag/v8.2.1-1.2

To avoid any compatibility issues, I used exactly the same sources, but applied the binutils patch.