aboutsummaryrefslogtreecommitdiff
path: root/bfd/libbfd.c
diff options
context:
space:
mode:
authorJohn Gilmore <gnu@cygnus>1992-10-15 09:00:09 +0000
committerJohn Gilmore <gnu@cygnus>1992-10-15 09:00:09 +0000
commitf8e01940189dfd4a06f8818d4442ce6d39fd9539 (patch)
tree6100ef7299d0808978b22575fea4c1c4df1ea80d /bfd/libbfd.c
parentdac4929a6d43b500b573166e53a6706789c7cad1 (diff)
downloadgdb-f8e01940189dfd4a06f8818d4442ce6d39fd9539.zip
gdb-f8e01940189dfd4a06f8818d4442ce6d39fd9539.tar.gz
gdb-f8e01940189dfd4a06f8818d4442ce6d39fd9539.tar.bz2
* aout-adobe.c, aoutf1.h, archive.c, bout.c, coff-rs6000.c,
coffcode.h, elf.c, ieee.c, libaout.h, libbfd.c, oasys.c, sco-core.c: Lint: Second argument of bfd_seek is always file_ptr. Third argument is SEEK_SET or SEEK_CUR. Result is always 0 or -1.
Diffstat (limited to 'bfd/libbfd.c')
-rw-r--r--bfd/libbfd.c183
1 files changed, 109 insertions, 74 deletions
diff --git a/bfd/libbfd.c b/bfd/libbfd.c
index 394ac5e..f48b78f 100644
--- a/bfd/libbfd.c
+++ b/bfd/libbfd.c
@@ -18,14 +18,19 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-/* $Id$ */
-
#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
-/** Dummies for targets that don't want or need to implement
- certain operations */
+/*
+SECTION
+ libbfd
+
+DESCRIPTION
+ This file contains various routines which are used within BFD.
+ They are not intended for export, but are documented here for
+ completeness.
+*/
boolean
DEFUN(_bfd_dummy_new_section_hook,(ignore, ignore_newsect),
@@ -125,10 +130,18 @@ DEFUN(zalloc,(size),
}
#endif
-/*proto-internal* bfd_xmalloc
-bfd_xmalloc -- Like malloc, but exit if no more memory.
-*; PROTO(PTR, bfd_xmalloc,( bfd_size_type size));
+/*
+INTERNAL_FUNCTION
+ bfd_xmalloc
+
+SYNOPSIS
+ PTR bfd_xmalloc( bfd_size_type size);
+
+DESCRIPTION
+ Like malloc, but exit if no more memory.
+
*/
+
/** There is major inconsistency in how running out of memory is handled.
Some routines return a NULL, and set bfd_error to no_memory.
However, obstack routines can't do this ... */
@@ -137,11 +150,10 @@ bfd_xmalloc -- Like malloc, but exit if no more memory.
DEFUN(PTR bfd_xmalloc,(size),
bfd_size_type size)
{
- static char no_memory_message[] = "Virtual memory exhausted!\n";
+ static CONST char no_memory_message[] = "Virtual memory exhausted!\n";
PTR ptr;
if (size == 0) size = 1;
ptr = (PTR)malloc(size);
- if (ptr == NULL)
if (!ptr)
{
write (2, no_memory_message, sizeof(no_memory_message)-1);
@@ -189,9 +201,18 @@ DEFUN(bfd_write,(ptr, size, nitems, abfd),
return fwrite (ptr, 1, (int)(size*nitems), bfd_cache_lookup(abfd));
}
-/*proto-internal* bfd_write_bigendian_4byte_int
+/*
+INTERNAL_FUNCTION
+ bfd_write_bigendian_4byte_int
+
+SYNOPSIS
+ void bfd_write_bigendian_4byte_int(bfd *abfd, int i);
+
+DESCRIPTION
+ Writes a 4 byte integer to the outputing bfd, in big endian
+ mode regardless of what else is going on. This is usefull in
+ archives.
-*; PROTO(void, bfd_write_bigendian_4byte_int,( bfd *abfd, int i));
*/
void
DEFUN(bfd_write_bigendian_4byte_int,(abfd, i),
@@ -307,60 +328,69 @@ DEFUN(bfd_add_to_string_table,(table, new_string, table_length, free_ptr),
functions in swap.h #ifdef __GNUC__.
Gprof them later and find out. */
-/*proto*
-*i bfd_put_size
-*i bfd_get_size
-These macros as used for reading and writing raw data in sections;
-each access (except for bytes) is vectored through the target format
-of the BFD and mangled accordingly. The mangling performs any
-necessary endian translations and removes alignment restrictions.
-*+
-#define bfd_put_8(abfd, val, ptr) \
- (*((char *)ptr) = (char)val)
-#define bfd_get_8(abfd, ptr) \
- (*((char *)ptr))
-#define bfd_put_16(abfd, val, ptr) \
- BFD_SEND(abfd, bfd_putx16, (val,ptr))
-#define bfd_get_16(abfd, ptr) \
- BFD_SEND(abfd, bfd_getx16, (ptr))
-#define bfd_put_32(abfd, val, ptr) \
- BFD_SEND(abfd, bfd_putx32, (val,ptr))
-#define bfd_get_32(abfd, ptr) \
- BFD_SEND(abfd, bfd_getx32, (ptr))
-#define bfd_put_64(abfd, val, ptr) \
- BFD_SEND(abfd, bfd_putx64, (val, ptr))
-#define bfd_get_64(abfd, ptr) \
- BFD_SEND(abfd, bfd_getx64, (ptr))
-*-
-*-*/
-
-/*proto*
-*i bfd_h_put_size
-*i bfd_h_get_size
-These macros have the same function as their @code{bfd_get_x}
-bretherin, except that they are used for removing information for the
-header records of object files. Believe it or not, some object files
-keep their header records in big endian order, and their data in little
-endan order.
-*+
-#define bfd_h_put_8(abfd, val, ptr) \
- (*((char *)ptr) = (char)val)
-#define bfd_h_get_8(abfd, ptr) \
- (*((char *)ptr))
-#define bfd_h_put_16(abfd, val, ptr) \
- BFD_SEND(abfd, bfd_h_putx16,(val,ptr))
-#define bfd_h_get_16(abfd, ptr) \
- BFD_SEND(abfd, bfd_h_getx16,(ptr))
-#define bfd_h_put_32(abfd, val, ptr) \
- BFD_SEND(abfd, bfd_h_putx32,(val,ptr))
-#define bfd_h_get_32(abfd, ptr) \
- BFD_SEND(abfd, bfd_h_getx32,(ptr))
-#define bfd_h_put_64(abfd, val, ptr) \
- BFD_SEND(abfd, bfd_h_putx64,(val, ptr))
-#define bfd_h_get_64(abfd, ptr) \
- BFD_SEND(abfd, bfd_h_getx64,(ptr))
-*-
-*-*/
+/*
+FUNCTION
+ bfd_put_size
+FUNCTION
+ bfd_get_size
+
+DESCRIPTION
+ These macros as used for reading and writing raw data in
+ sections; each access (except for bytes) is vectored through
+ the target format of the BFD and mangled accordingly. The
+ mangling performs any necessary endian translations and
+ removes alignment restrictions.
+
+.#define bfd_put_8(abfd, val, ptr) \
+. (*((char *)ptr) = (char)val)
+.#define bfd_get_8(abfd, ptr) \
+. (*((char *)ptr))
+.#define bfd_put_16(abfd, val, ptr) \
+. BFD_SEND(abfd, bfd_putx16, (val,ptr))
+.#define bfd_get_16(abfd, ptr) \
+. BFD_SEND(abfd, bfd_getx16, (ptr))
+.#define bfd_put_32(abfd, val, ptr) \
+. BFD_SEND(abfd, bfd_putx32, (val,ptr))
+.#define bfd_get_32(abfd, ptr) \
+. BFD_SEND(abfd, bfd_getx32, (ptr))
+.#define bfd_put_64(abfd, val, ptr) \
+. BFD_SEND(abfd, bfd_putx64, (val, ptr))
+.#define bfd_get_64(abfd, ptr) \
+. BFD_SEND(abfd, bfd_getx64, (ptr))
+
+*/
+
+/*
+FUNCTION
+ bfd_h_put_size
+FUNCTION
+ bfd_h_get_size
+
+DESCRIPTION
+ These macros have the same function as their <<bfd_get_x>>
+ bretherin, except that they are used for removing information
+ for the header records of object files. Believe it or not,
+ some object files keep their header records in big endian
+ order, and their data in little endan order.
+
+.#define bfd_h_put_8(abfd, val, ptr) \
+. (*((char *)ptr) = (char)val)
+.#define bfd_h_get_8(abfd, ptr) \
+. (*((char *)ptr))
+.#define bfd_h_put_16(abfd, val, ptr) \
+. BFD_SEND(abfd, bfd_h_putx16,(val,ptr))
+.#define bfd_h_get_16(abfd, ptr) \
+. BFD_SEND(abfd, bfd_h_getx16,(ptr))
+.#define bfd_h_put_32(abfd, val, ptr) \
+. BFD_SEND(abfd, bfd_h_putx32,(val,ptr))
+.#define bfd_h_get_32(abfd, ptr) \
+. BFD_SEND(abfd, bfd_h_getx32,(ptr))
+.#define bfd_h_put_64(abfd, val, ptr) \
+. BFD_SEND(abfd, bfd_h_putx64,(val, ptr))
+.#define bfd_h_get_64(abfd, ptr) \
+. BFD_SEND(abfd, bfd_h_getx64,(ptr))
+
+*/
bfd_vma
DEFUN(_do_getb16,(addr),
@@ -532,8 +562,8 @@ DEFUN(bfd_generic_get_section_contents, (abfd, section, location, offset, count)
{
if (count == 0)
return true;
- if ((bfd_size_type)(offset+count) > section->size
- || bfd_seek(abfd,(file_ptr)( section->filepos + offset), SEEK_SET) == -1
+ if ((bfd_size_type)(offset+count) > section->_raw_size
+ || bfd_seek(abfd, (file_ptr)(section->filepos + offset), SEEK_SET) == -1
|| bfd_read(location, (bfd_size_type)1, count, abfd) != count)
return (false); /* on error */
return (true);
@@ -553,19 +583,24 @@ DEFUN(bfd_generic_set_section_contents, (abfd, section, location, offset, count)
{
if (count == 0)
return true;
- if ((bfd_size_type)(offset+count) > section->size
+ if ((bfd_size_type)(offset+count) > bfd_get_section_size_after_reloc(section)
|| bfd_seek(abfd, (file_ptr)(section->filepos + offset), SEEK_SET) == -1
|| bfd_write(location, (bfd_size_type)1, count, abfd) != count)
return (false); /* on error */
return (true);
}
-/*proto-internal*
-*i bfd_log2
-Return the log base 2 of the value supplied, rounded up. eg an arg
-of 1025 would return 11.
-*; PROTO(bfd_vma, bfd_log2,(bfd_vma x));
-*-*/
+/*
+INTERNAL_FUNCTION
+ bfd_log2
+
+DESCRIPTION
+ Return the log base 2 of the value supplied, rounded up. eg an
+ arg of 1025 would return 11.
+
+SYNOPSIS
+ bfd_vma bfd_log2(bfd_vma x);
+*/
bfd_vma bfd_log2(x)
bfd_vma x;