mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-07-24 18:32:38 +08:00
Comment bfd_get_section_limit_octets and bfd_get_section_alloc_size
* bfd.c (bfd_get_section_limit_octets): Add comment. (bfd_get_section_alloc_size): Likewise. * libbfd.c (_bfd_generic_get_section_contents): Use bfd_get_section_limit_octets. * section.c (bfd_get_section_contents): Likewise. * bfd-in2.h: Regenerate.
This commit is contained in:
@ -6946,6 +6946,8 @@ bfd_set_asymbol_name (asymbol *sy, const char *name)
|
|||||||
sy->name = name;
|
sy->name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* For input sections return the original size on disk of the
|
||||||
|
section. For output sections return the current size. */
|
||||||
static inline bfd_size_type
|
static inline bfd_size_type
|
||||||
bfd_get_section_limit_octets (const bfd *abfd, const asection *sec)
|
bfd_get_section_limit_octets (const bfd *abfd, const asection *sec)
|
||||||
{
|
{
|
||||||
@ -6962,6 +6964,9 @@ bfd_get_section_limit (const bfd *abfd, const asection *sec)
|
|||||||
/ bfd_octets_per_byte (abfd, sec));
|
/ bfd_octets_per_byte (abfd, sec));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* For input sections return the larger of the current size and the
|
||||||
|
original size on disk of the section. For output sections return
|
||||||
|
the current size. */
|
||||||
static inline bfd_size_type
|
static inline bfd_size_type
|
||||||
bfd_get_section_alloc_size (const bfd *abfd, const asection *sec)
|
bfd_get_section_alloc_size (const bfd *abfd, const asection *sec)
|
||||||
{
|
{
|
||||||
|
@ -502,6 +502,8 @@ CODE_FRAGMENT
|
|||||||
. sy->name = name;
|
. sy->name = name;
|
||||||
.}
|
.}
|
||||||
.
|
.
|
||||||
|
.{* For input sections return the original size on disk of the
|
||||||
|
. section. For output sections return the current size. *}
|
||||||
.static inline bfd_size_type
|
.static inline bfd_size_type
|
||||||
.bfd_get_section_limit_octets (const bfd *abfd, const asection *sec)
|
.bfd_get_section_limit_octets (const bfd *abfd, const asection *sec)
|
||||||
.{
|
.{
|
||||||
@ -518,6 +520,9 @@ CODE_FRAGMENT
|
|||||||
. / bfd_octets_per_byte (abfd, sec));
|
. / bfd_octets_per_byte (abfd, sec));
|
||||||
.}
|
.}
|
||||||
.
|
.
|
||||||
|
.{* For input sections return the larger of the current size and the
|
||||||
|
. original size on disk of the section. For output sections return
|
||||||
|
. the current size. *}
|
||||||
.static inline bfd_size_type
|
.static inline bfd_size_type
|
||||||
.bfd_get_section_alloc_size (const bfd *abfd, const asection *sec)
|
.bfd_get_section_alloc_size (const bfd *abfd, const asection *sec)
|
||||||
.{
|
.{
|
||||||
|
10
bfd/libbfd.c
10
bfd/libbfd.c
@ -943,15 +943,7 @@ _bfd_generic_get_section_contents (bfd *abfd,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We do allow reading of a section after bfd_final_link has
|
sz = bfd_get_section_limit_octets (abfd, section);
|
||||||
written the contents out to disk. In that situation, rawsize is
|
|
||||||
just a stale version of size, so ignore it. Otherwise we must be
|
|
||||||
reading an input section, where rawsize, if different to size,
|
|
||||||
is the on-disk size. */
|
|
||||||
if (abfd->direction != write_direction && section->rawsize != 0)
|
|
||||||
sz = section->rawsize;
|
|
||||||
else
|
|
||||||
sz = section->size;
|
|
||||||
if (offset + count < count
|
if (offset + count < count
|
||||||
|| offset + count > sz
|
|| offset + count > sz
|
||||||
|| (abfd->my_archive != NULL
|
|| (abfd->my_archive != NULL
|
||||||
|
@ -1550,10 +1550,7 @@ bfd_get_section_contents (bfd *abfd,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (abfd->direction != write_direction && section->rawsize != 0)
|
sz = bfd_get_section_limit_octets (abfd, section);
|
||||||
sz = section->rawsize;
|
|
||||||
else
|
|
||||||
sz = section->size;
|
|
||||||
if ((bfd_size_type) offset > sz
|
if ((bfd_size_type) offset > sz
|
||||||
|| count > sz - offset
|
|| count > sz - offset
|
||||||
|| count != (size_t) count)
|
|| count != (size_t) count)
|
||||||
|
Reference in New Issue
Block a user