Created attachment 7524 [details] Proposed patch While linking large file (~2 Gb) with 32-bit ld the following error occurred: ld: final link failed: File truncated Linking the same with 64-bit linker is fine. The failure happened due to call of bfd_seek() function with incorrect negative value of argument "position". The "position" value is incorrectly calculated in _bfd_elf_set_section_contents() with overflow in local variable of type long: bfd_signed_vma pos; [...] pos = hdr->sh_offset + offset; if (bfd_seek (abfd, pos, SEEK_SET) != 0 Both terms of this calculation are of type long long. The result value also is used as long long argument in bfd_seek() call. Using the signed 32-bit type for intermediate result seems to be a bug and causes incorrect processing of large files. Proposed patch is attached.
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "gdb and binutils". The branch, master has been updated via 1b6aeedbb8e8f6c65d228f0dab3dab522d2517bb (commit) from 92b1b67865c719e83d12578e584ca5e20d172eac (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1b6aeedbb8e8f6c65d228f0dab3dab522d2517bb commit 1b6aeedbb8e8f6c65d228f0dab3dab522d2517bb Author: Maria Guseva <m.guseva@samsung.com> Date: Thu Apr 3 11:42:05 2014 +0100 This fixes a problem building large (> 2Gb) binaries on 32-bit hosts. Using a long type instead of long long meant that bfd_seek (SET) could be called with a negative offset. PR ld/16803 * elf.c (_bfd_elf_set_section_contents): Use correct type to hold file position. ----------------------------------------------------------------------- Summary of changes: bfd/ChangeLog | 6 ++++++ bfd/elf.c | 2 +- 2 files changed, 7 insertions(+), 1 deletions(-)
Patch applied.