From 8e2f54bcee7e3e8315d4a39a302eaf8e4389e07d Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 30 May 2017 06:34:05 -0700 Subject: [PATCH] Add bfd_get_file_size to get archive element size We can't use stat() to get archive element size. Add bfd_get_file_size to get size for both normal files and archive elements. bfd/ PR binutils/21519 * bfdio.c (bfd_get_file_size): New function. * bfd-in2.h: Regenerated. Conflict:1.remove changelog; 2.the folder binutils/ does not exist. Reference:https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8e2f54bcee7e3e8315d4a39a302eaf8e4389e07d --- gdb-7.6.patch | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/gdb-7.6.patch b/gdb-7.6.patch index 106d164..b29ccc9 100644 --- a/gdb-7.6.patch +++ b/gdb-7.6.patch @@ -22,6 +22,49 @@ tar xvzmf gdb-7.6.tar.gz \ exit 0 +--- gdb-7.6/bfd/bfd-in2.h ++++ gdb-7.6/bfd/bfd-in2.h +@@ -1242,6 +1242,8 @@ long bfd_get_mtime (bfd *abfd); + + file_ptr bfd_get_size (bfd *abfd); + ++file_ptr bfd_get_file_size (bfd *abfd); ++ + void *bfd_mmap (bfd *abfd, void *addr, bfd_size_type len, + int prot, int flags, file_ptr offset, + void **map_addr, bfd_size_type *map_len); +--- gdb-7.6/bfd/bfdio.c ++++ gdb-7.6/bfd/bfdio.c +@@ -434,6 +434,29 @@ bfd_get_size (bfd *abfd) + return buf.st_size; + } + ++/* ++FUNCTION ++ bfd_get_file_size ++ ++SYNOPSIS ++ file_ptr bfd_get_file_size (bfd *abfd); ++ ++DESCRIPTION ++ Return the file size (as read from file system) for the file ++ associated with BFD @var{abfd}. It supports both normal files ++ and archive elements. ++ ++*/ ++ ++file_ptr ++bfd_get_file_size (bfd *abfd) ++{ ++ if (abfd->my_archive != NULL ++ && !bfd_is_thin_archive (abfd->my_archive)) ++ return arelt_size (abfd); ++ ++ return bfd_get_size (abfd); ++} + + /* + FUNCTION --- gdb-7.6/libiberty/Makefile.in.orig +++ gdb-7.6/libiberty/Makefile.in @@ -175,6 +175,7 @@ REQUIRED_OFILES = \ -- 2.27.0