Provide stat function for spu overlay manager iovec
authorAlan Modra <amodra@gmail.com>
Tue, 4 Nov 2014 03:09:38 +0000 (13:39 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 4 Nov 2014 12:06:13 +0000 (22:36 +1030)
Commit f54498b4 broke spu-elf, specifically the change "Do not try to
load a string table bigger than the file", because bfd_get_size
returns zero for the spu built-in overlay manager bfd.

* elf32-spu.c (ovl_mgr_stat): New function.
(spu_elf_open_builtin_lib): Pass to bfd_openr_iovec.

bfd/ChangeLog
bfd/elf32-spu.c

index 0222d32..c8e23ba 100644 (file)
@@ -1,3 +1,8 @@
+2014-11-04  Alan Modra  <amodra@gmail.com>
+
+       * elf32-spu.c (ovl_mgr_stat): New function.
+       (spu_elf_open_builtin_lib): Pass to bfd_openr_iovec.
+
 2014-11-03  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * elf32-avr.c (elf32_avr_relax_delete_bytes): During linker
index 13806ad..ebc9e6a 100644 (file)
@@ -1828,6 +1828,18 @@ ovl_mgr_pread (struct bfd *abfd ATTRIBUTE_UNUSED,
   return count;
 }
 
+static int
+ovl_mgr_stat (struct bfd *abfd ATTRIBUTE_UNUSED,
+             void *stream,
+             struct stat *sb)
+{
+  struct _ovl_stream *os = (struct _ovl_stream *) stream;
+
+  memset (sb, 0, sizeof (*sb));
+  sb->st_size = (const char *) os->end - (const char *) os->start;
+  return 0;
+}
+
 bfd_boolean
 spu_elf_open_builtin_lib (bfd **ovl_bfd, const struct _ovl_stream *stream)
 {
@@ -1837,7 +1849,7 @@ spu_elf_open_builtin_lib (bfd **ovl_bfd, const struct _ovl_stream *stream)
                              (void *) stream,
                              ovl_mgr_pread,
                              NULL,
-                             NULL);
+                             ovl_mgr_stat);
   return *ovl_bfd != NULL;
 }