From 1adbf66264852740a0618218f5e9110fcdccafd6 Mon Sep 17 00:00:00 2001 From: Peter Schauer Date: Thu, 30 Dec 1993 15:51:16 +0000 Subject: [PATCH] * section.c (bfd_get_section_contents): Return zero filled buffer if section has no contents. --- bfd/ChangeLog | 5 +++++ bfd/section.c | 60 ++++++++++++++++++++++++++++----------------------- 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index d15df8b9ca4..a0d0f0b1ad9 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +Thu Dec 30 07:41:36 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * section.c (bfd_get_section_contents): Return zero filled buffer + if section has no contents. + Tue Dec 28 12:43:54 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) * elf.c (bfd_elf_generic_reloc): If this is not an inplace reloc, diff --git a/bfd/section.c b/bfd/section.c index 3b9c095ac6d..daccf2eb0cf 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -39,7 +39,7 @@ SECTION INODE Section Input, Section Output, Sections, Sections SUBSECTION - Section Input + Section input When a BFD is opened for reading, the section structures are created and attached to the BFD. @@ -73,7 +73,7 @@ INODE Section Output, typedef asection, Section Input, Sections SUBSECTION - Section Output + Section output To write a new object style BFD, the various sections to be written have to be created. They are attached to the BFD in @@ -114,7 +114,7 @@ SUBSECTION SUBSECTION Seclets - The data within a section is stored in a <>. These + The data within a section is stored in a @dfn{seclet}. These are much like the fixups in <>. The seclet abstraction allows a section to grow and shrink within itself. @@ -420,10 +420,9 @@ DOCDD INODE section prototypes, , typedef asection, Sections SUBSECTION - section prototypes + Section prototypes -These are the functions exported by the section handling part of -<>. +These are the functions exported by the section handling part of BFD. */ /* @@ -434,13 +433,13 @@ SYNOPSIS asection *bfd_get_section_by_name(bfd *abfd, CONST char *name); DESCRIPTION - Run through the provided @var{abfd} and return the one of the - <>s whose name matches @var{name}, otherwise NULL. + Run through @var{abfd} and return the one of the + <>s whose name matches @var{name}, otherwise <>. @xref{Sections}, for more information. This should only be used in special cases; the normal way to process - all sections of a given name is to use bfd_map_over_sections and - strcmp on the name (or better yet, base it on the section flags + all sections of a given name is to use <> and + <> on the name (or better yet, base it on the section flags or something else) for each section. */ @@ -468,16 +467,16 @@ DESCRIPTION Create a new empty section called @var{name} and attach it to the end of the chain of sections for the BFD @var{abfd}. An attempt to create a section with a name which - is already in use, returns its pointer without changing the + is already in use returns its pointer without changing the section chain. It has the funny name since this is the way it used to be before it was rewritten.... Possible errors are: - o invalid_operation - + o <> - If output has already started for this BFD. - o no_memory - + o <> - If obstack alloc fails. */ @@ -508,9 +507,9 @@ DESCRIPTION the chain of sections for @var{abfd}. Create a new section even if there is already a section with that name. - Returns NULL and sets bfd_error on error; possible errors are: - o invalid_operation - If output has already started for @var{abfd}. - o no_memory - If obstack alloc fails. + Return <> and set <> on error; possible errors are: + o <> - If output has already started for @var{abfd}. + o <> - If obstack alloc fails. */ sec_ptr @@ -578,10 +577,10 @@ SYNOPSIS asection *bfd_make_section(bfd *, CONST char *name); DESCRIPTION - Like <>, but return NULL (without setting + Like <>, but return <> (without setting bfd_error) without changing the section chain if there is already a - section named @var{name}. If there is an error, return NULL and set - bfd_error. + section named @var{name}. If there is an error, return <> and set + <>. */ sec_ptr @@ -628,10 +627,10 @@ SYNOPSIS DESCRIPTION Set the attributes of the section @var{sec} in the BFD - @var{abfd} to the value @var{flags}. Returns <> on success, + @var{abfd} to the value @var{flags}. Return <> on success, <> on error. Possible error returns are: - o invalid operation - + o <> - The section cannot have one or more of the attributes requested. For example, a .bss section in <> may not have the <> field set. @@ -719,8 +718,8 @@ DESCRIPTION ok, then <> is returned, else <>. Possible error returns: - o invalid_operation - - Writing has started to the BFD, so setting the size is invalid + o <> - + Writing has started to the BFD, so setting the size is invalid. */ @@ -767,7 +766,7 @@ DESCRIPTION Normally <> is returned, else <>. Possible error returns are: - o no_contents - + o <> - The output section does not have the <> attribute, so nothing can be written to it. o and some more too @@ -854,9 +853,10 @@ DESCRIPTION offset of @var{offset} from the start of the input section, and is read for @var{count} bytes. - If the contents of a constuctor with the <> - flag set are requested, then the @var{location} is filled with - zeroes. If no errors occur, <> is returned, else + If the contents of a constructor with the <> + flag set are requested or if the section does not have the + <> flag set, then the @var{location} is filled + with zeroes. If no errors occur, <> is returned, else <>. @@ -894,6 +894,12 @@ DEFUN(bfd_get_section_contents,(abfd, section, location, offset, count), /* Don't bother. */ return true; + if ((section->flags & SEC_HAS_CONTENTS) == 0) + { + memset(location, 0, (unsigned)count); + return true; + } + return BFD_SEND (abfd, _bfd_get_section_contents, (abfd, section, location, offset, count)); } -- 2.30.2