summaryrefslogtreecommitdiff
path: root/bfd/elf64-hppa.c
diff options
context:
space:
mode:
authorJohn David Anglin <danglin@gcc.gnu.org>2016-01-31 11:52:24 -0500
committerJohn David Anglin <danglin@gcc.gnu.org>2016-01-31 11:52:24 -0500
commit6d4b2867f8441c7bf75dfef6b3c95a10241f9709 (patch)
treea0bc3682f4afd2f9e1fb83d49e87104e6dbb15e0 /bfd/elf64-hppa.c
parentd9e3b590692e62d83c21e39ec6641c4c09e70e4c (diff)
Fix /usr/bin/ld: final link failed: File truncated error on hppa.
Diffstat (limited to 'bfd/elf64-hppa.c')
-rw-r--r--bfd/elf64-hppa.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index 5a397b4ad7..3021ed603d 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