* section.c (bfd_get_section_contents): Return zero filled buffer

if section has no contents.
This commit is contained in:
Peter Schauer 1993-12-30 15:51:16 +00:00
parent f161923490
commit 1adbf66264
2 changed files with 38 additions and 27 deletions

View file

@ -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) 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, * elf.c (bfd_elf_generic_reloc): If this is not an inplace reloc,

View file

@ -39,7 +39,7 @@ SECTION
INODE INODE
Section Input, Section Output, Sections, Sections Section Input, Section Output, Sections, Sections
SUBSECTION SUBSECTION
Section Input Section input
When a BFD is opened for reading, the section structures are When a BFD is opened for reading, the section structures are
created and attached to the BFD. created and attached to the BFD.
@ -73,7 +73,7 @@ INODE
Section Output, typedef asection, Section Input, Sections Section Output, typedef asection, Section Input, Sections
SUBSECTION SUBSECTION
Section Output Section output
To write a new object style BFD, the various sections to be To write a new object style BFD, the various sections to be
written have to be created. They are attached to the BFD in written have to be created. They are attached to the BFD in
@ -114,7 +114,7 @@ SUBSECTION
SUBSECTION SUBSECTION
Seclets Seclets
The data within a section is stored in a <<seclet>>. These The data within a section is stored in a @dfn{seclet}. These
are much like the fixups in <<gas>>. The seclet abstraction are much like the fixups in <<gas>>. The seclet abstraction
allows a section to grow and shrink within itself. allows a section to grow and shrink within itself.
@ -420,10 +420,9 @@ DOCDD
INODE INODE
section prototypes, , typedef asection, Sections section prototypes, , typedef asection, Sections
SUBSECTION 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.
<<libbfd>>.
*/ */
/* /*
@ -434,13 +433,13 @@ SYNOPSIS
asection *bfd_get_section_by_name(bfd *abfd, CONST char *name); asection *bfd_get_section_by_name(bfd *abfd, CONST char *name);
DESCRIPTION DESCRIPTION
Run through the provided @var{abfd} and return the one of the Run through @var{abfd} and return the one of the
<<asection>>s whose name matches @var{name}, otherwise NULL. <<asection>>s whose name matches @var{name}, otherwise <<NULL>>.
@xref{Sections}, for more information. @xref{Sections}, for more information.
This should only be used in special cases; the normal way to process 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 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 <<strcmp>> on the name (or better yet, base it on the section flags
or something else) for each section. or something else) for each section.
*/ */
@ -468,16 +467,16 @@ DESCRIPTION
Create a new empty section called @var{name} Create a new empty section called @var{name}
and attach it to the end of the chain of sections for the 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 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. section chain.
It has the funny name since this is the way it used to be It has the funny name since this is the way it used to be
before it was rewritten.... before it was rewritten....
Possible errors are: Possible errors are:
o invalid_operation - o <<invalid_operation>> -
If output has already started for this BFD. If output has already started for this BFD.
o no_memory - o <<no_memory>> -
If obstack alloc fails. If obstack alloc fails.
*/ */
@ -508,9 +507,9 @@ DESCRIPTION
the chain of sections for @var{abfd}. Create a new section even if there the chain of sections for @var{abfd}. Create a new section even if there
is already a section with that name. is already a section with that name.
Returns NULL and sets bfd_error on error; possible errors are: Return <<NULL>> and set <<bfd_error>> on error; possible errors are:
o invalid_operation - If output has already started for @var{abfd}. o <<invalid_operation>> - If output has already started for @var{abfd}.
o no_memory - If obstack alloc fails. o <<no_memory>> - If obstack alloc fails.
*/ */
sec_ptr sec_ptr
@ -578,10 +577,10 @@ SYNOPSIS
asection *bfd_make_section(bfd *, CONST char *name); asection *bfd_make_section(bfd *, CONST char *name);
DESCRIPTION DESCRIPTION
Like <<bfd_make_section_anyway>>, but return NULL (without setting Like <<bfd_make_section_anyway>>, but return <<NULL>> (without setting
bfd_error) without changing the section chain if there is already a 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 section named @var{name}. If there is an error, return <<NULL>> and set
bfd_error. <<bfd_error>>.
*/ */
sec_ptr sec_ptr
@ -628,10 +627,10 @@ SYNOPSIS
DESCRIPTION DESCRIPTION
Set the attributes of the section @var{sec} in the BFD Set the attributes of the section @var{sec} in the BFD
@var{abfd} to the value @var{flags}. Returns <<true>> on success, @var{abfd} to the value @var{flags}. Return <<true>> on success,
<<false>> on error. Possible error returns are: <<false>> on error. Possible error returns are:
o invalid operation - o <<invalid_operation>> -
The section cannot have one or more of the attributes The section cannot have one or more of the attributes
requested. For example, a .bss section in <<a.out>> may not requested. For example, a .bss section in <<a.out>> may not
have the <<SEC_HAS_CONTENTS>> field set. have the <<SEC_HAS_CONTENTS>> field set.
@ -719,8 +718,8 @@ DESCRIPTION
ok, then <<true>> is returned, else <<false>>. ok, then <<true>> is returned, else <<false>>.
Possible error returns: Possible error returns:
o invalid_operation - o <<invalid_operation>> -
Writing has started to the BFD, so setting the size is invalid Writing has started to the BFD, so setting the size is invalid.
*/ */
@ -767,7 +766,7 @@ DESCRIPTION
Normally <<true>> is returned, else <<false>>. Possible error Normally <<true>> is returned, else <<false>>. Possible error
returns are: returns are:
o no_contents - o <<no_contents>> -
The output section does not have the <<SEC_HAS_CONTENTS>> The output section does not have the <<SEC_HAS_CONTENTS>>
attribute, so nothing can be written to it. attribute, so nothing can be written to it.
o and some more too o and some more too
@ -854,9 +853,10 @@ DESCRIPTION
offset of @var{offset} from the start of the input section, offset of @var{offset} from the start of the input section,
and is read for @var{count} bytes. and is read for @var{count} bytes.
If the contents of a constuctor with the <<SEC_CONSTUCTOR>> If the contents of a constructor with the <<SEC_CONSTRUCTOR>>
flag set are requested, then the @var{location} is filled with flag set are requested or if the section does not have the
zeroes. If no errors occur, <<true>> is returned, else <<SEC_HAS_CONTENTS>> flag set, then the @var{location} is filled
with zeroes. If no errors occur, <<true>> is returned, else
<<false>>. <<false>>.
@ -894,6 +894,12 @@ DEFUN(bfd_get_section_contents,(abfd, section, location, offset, count),
/* Don't bother. */ /* Don't bother. */
return true; return true;
if ((section->flags & SEC_HAS_CONTENTS) == 0)
{
memset(location, 0, (unsigned)count);
return true;
}
return BFD_SEND (abfd, _bfd_get_section_contents, return BFD_SEND (abfd, _bfd_get_section_contents,
(abfd, section, location, offset, count)); (abfd, section, location, offset, count));
} }