[binutils-gdb/binutils-2_26-branch] Fix /usr/bin/ld: final link failed: File truncated error on hppa
John David Anglin
danglin@sourceware.org
Mon Feb 1 21:33:00 GMT 2016
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c0c80249ecf53f71ebb01e2d8bb3deb2ba7e3078
commit c0c80249ecf53f71ebb01e2d8bb3deb2ba7e3078
Author: John David Anglin <danglin@gcc.gnu.org>
Date: Mon Feb 1 16:31:58 2016 -0500
Fix /usr/bin/ld: final link failed: File truncated error on hppa
Diff:
---
bfd/ChangeLog | 7 +++++++
bfd/elf32-hppa.c | 9 +++++++++
bfd/elf64-hppa.c | 18 +++++++++++++-----
3 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index dfe60ad..7f09156 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2016-02-01 John David Anglin <danglin@gcc.gnu.org>
+
+ PR ld/19526
+ * elf32-hppa.c (elf32_hppa_final_link): Don't sort non-regular output
+ files.
+ * elf64-hppa.c (elf32_hppa_final_link): Likewise. Remove retval.
+
2016-01-25 Tristan Gingold <gingold@adacore.com>
* version.m4: Bump version to 2.26.0
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index ad40914..3fc1f57 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -3245,6 +3245,8 @@ tpoff (struct bfd_link_info *info, bfd_vma address)
static bfd_boolean
elf32_hppa_final_link (bfd *abfd, struct bfd_link_info *info)
{
+ struct stat buf;
+
/* Invoke the regular ELF linker to do all the work. */
if (!bfd_elf_final_link (abfd, info))
return FALSE;
@@ -3254,6 +3256,13 @@ elf32_hppa_final_link (bfd *abfd, struct bfd_link_info *info)
if (bfd_link_relocatable (info))
return TRUE;
+ /* Do not attempt to sort non-regular files. This is here
+ especially for configure scripts and kernel builds which run
+ tests with "ld [...] -o /dev/null". */
+ if (stat (abfd->filename, &buf) != 0
+ || !S_ISREG(buf.st_mode))
+ return TRUE;
+
return elf_hppa_sort_unwind (abfd);
}
diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index 3b628b4..aa9cfd2 100644
--- a/bfd/elf64-hppa.c
+++ b/bfd/elf64-hppa.c
@@ -2945,7 +2945,7 @@ elf_hppa_record_segment_addrs (bfd *abfd,
static bfd_boolean
elf_hppa_final_link (bfd *abfd, struct bfd_link_info *info)
{
- bfd_boolean retval;
+ struct stat buf;
struct elf64_hppa_link_hash_table *hppa_info = hppa_link_hash_table (info);
if (hppa_info == NULL)
@@ -3029,7 +3029,8 @@ elf_hppa_final_link (bfd *abfd, struct bfd_link_info *info)
info);
/* Invoke the regular ELF backend linker to do all the work. */
- retval = bfd_elf_final_link (abfd, info);
+ if (!bfd_elf_final_link (abfd, info))
+ return FALSE;
elf_link_hash_traverse (elf_hash_table (info),
elf_hppa_remark_useless_dynamic_symbols,
@@ -3037,10 +3038,17 @@ elf_hppa_final_link (bfd *abfd, struct bfd_link_info *info)
/* If we're producing a final executable, sort the contents of the
unwind section. */
- if (retval && !bfd_link_relocatable (info))
- retval = elf_hppa_sort_unwind (abfd);
+ if (bfd_link_relocatable (info))
+ return TRUE;
+
+ /* Do not attempt to sort non-regular files. This is here
+ especially for configure scripts and kernel builds which run
+ tests with "ld [...] -o /dev/null". */
+ if (stat (abfd->filename, &buf) != 0
+ || !S_ISREG(buf.st_mode))
+ return TRUE;
- return retval;
+ return elf_hppa_sort_unwind (abfd);
}
/* Relocate the given INSN. VALUE should be the actual value we want
More information about the Binutils-cvs
mailing list