This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Provide stat function for spu overlay manager iovec
- From: Alan Modra <amodra at gmail dot com>
- To: Jiong Wang <jiong dot wang at arm dot com>
- Cc: "nickc at redhat dot com" <nickc at redhat dot com>, "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Tue, 4 Nov 2014 22:33:45 +1030
- Subject: Provide stat function for spu overlay manager iovec
- Authentication-results: sourceware.org; auth=none
- References: <5458AAB8 dot 7050302 at arm dot com>
On Tue, Nov 04, 2014 at 10:30:16AM +0000, Jiong Wang wrote:
> because "sz > (bfd_size_type) bfd_get_size (abfd)"
Ah, I have something similar to fix for spu-elf.
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.
diff --git a/bfd/elf32-spu.c b/bfd/elf32-spu.c
index 13806ad..ebc9e6a 100644
--- a/bfd/elf32-spu.c
+++ b/bfd/elf32-spu.c
@@ -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;
}
--
Alan Modra
Australia Development Lab, IBM