. is the result of an fopen on the filename. *}
. char *iostream;
.
-. {* Is the file being cached *}
+. {* Is the file descriptor being cached? That is, can it be closed as
+. needed, and re-opened when accessed later? *}
.
. boolean cacheable;
.
. struct bout_data_struct *bout_data;
. struct sun_core_struct *sun_core_data;
. struct trad_core_struct *trad_core_data;
-. struct hppa_data_struct *hppa_data;
+. struct som_data_struct *som_data;
. struct hpux_core_struct *hpux_core_data;
. struct sgi_core_struct *sgi_core_data;
+. struct lynx_core_struct *lynx_core_data;
+. struct osf_core_struct *osf_core_data;
. PTR any;
. } tdata;
.
#include "coff/sym.h"
#include "libcoff.h"
#include "libecoff.h"
+#undef obj_symbols
+#include "libelf.h"
#undef strerror
extern char *strerror();
-
-CONST short _bfd_host_big_endian = 0x0100;
- /* Accessing the above as (*(char*)&_bfd_host_big_endian), will
- return 1 if the host is big-endian, 0 otherwise.
- (assuming that a short is two bytes long!!! FIXME)
- (See HOST_IS_BIG_ENDIAN_P in bfd.h.) */
-\f
/** Error handling
o - Most functions return nonzero on success (check doc for
precise semantics); 0 or NULL on error.
DESCRIPTION
Set the maximum size of objects to be optimized using the GP
- register under MIPS ECOFF. This is typically set by the -G
- argument to the compiler, assembler or linker.
+ register under ECOFF or MIPS ELF. This is typically set by
+ the -G argument to the compiler, assembler or linker.
*/
void
{
if (abfd->xvec->flavour == bfd_target_ecoff_flavour)
ecoff_data (abfd)->gp_size = i;
+ else if (abfd->xvec->flavour == bfd_target_elf_flavour)
+ elf_gp_size (abfd) = i;
+}
+
+/*
+FUNCTION
+ bfd_scan_vma
+
+DESCRIPTION
+ Converts, like strtoul, a numerical expression as a
+ string into a bfd_vma integer, and returns that integer.
+ (Though without as many bells and whistles as strtoul.)
+ The expression is assumed to be unsigned (i.e. positive).
+ If given a base, it is used as the base for conversion.
+ A base of 0 causes the function to interpret the string
+ in hex if a leading "0x" or "0X" is found, otherwise
+ in octal if a leading zero is found, otherwise in decimal.
+
+ Overflow is not detected.
+
+SYNOPSIS
+ bfd_vma bfd_scan_vma(CONST char *string, CONST char **end, int base);
+*/
+
+bfd_vma
+DEFUN(bfd_scan_vma,(string, end, base),
+ CONST char *string AND
+ CONST char **end AND
+ int base)
+{
+ bfd_vma value;
+ int digit;
+
+ /* Let the host do it if possible. */
+ if (sizeof(bfd_vma) <= sizeof(unsigned long))
+ return (bfd_vma) strtoul (string, 0, base);
+
+ /* A negative base makes no sense, and we only need to go as high as hex. */
+ if ((base < 0) || (base > 16))
+ return (bfd_vma) 0;
+
+ if (base == 0)
+ {
+ if (string[0] == '0')
+ {
+ if ((string[1] == 'x') || (string[1] == 'X'))
+ base = 16;
+ /* XXX should we also allow "0b" or "0B" to set base to 2? */
+ else
+ base = 8;
+ }
+ else
+ base = 10;
+ }
+ if ((base == 16) &&
+ (string[0] == '0') && ((string[1] == 'x') || (string[1] == 'X')))
+ string += 2;
+ /* XXX should we also skip over "0b" or "0B" if base is 2? */
+
+/* Speed could be improved with a table like hex_value[] in gas. */
+#define HEX_VALUE(c) \
+ (isxdigit(c) ? \
+ (isdigit(c) ? \
+ (c - '0') : \
+ (10 + c - (islower(c) ? 'a' : 'A'))) : \
+ 42)
+
+ for (value = 0; (digit = HEX_VALUE(*string)) < base; string++)
+ {
+ value = value * base + digit;
+ }
+
+ if (end)
+ *end = string;
+
+ return value;
}
/*
/* Return a new BFD. All BFD's are allocated through this routine. */
-bfd *new_bfd PARAMS ((void))
+bfd *
+new_bfd PARAMS ((void))
{
bfd *nbfd;
nbfd->output_has_begun = false;
nbfd->section_count = 0;
nbfd->usrdata = (PTR)NULL;
- nbfd->sections = (asection *)NULL;
nbfd->cacheable = false;
nbfd->flags = NO_FLAGS;
nbfd->mtime_set = false;
-
return nbfd;
}
/* Allocate a new BFD as a member of archive OBFD. */
-bfd *new_bfd_contained_in(obfd)
-bfd *obfd;
+bfd *
+new_bfd_contained_in (obfd)
+ bfd *obfd;
{
- bfd *nbfd = new_bfd();
- nbfd->xvec = obfd->xvec;
- nbfd->my_archive = obfd;
- nbfd->direction = read_direction;
- nbfd->target_defaulted = obfd->target_defaulted;
- return nbfd;
+ bfd *nbfd;
+
+ nbfd = new_bfd();
+ nbfd->xvec = obfd->xvec;
+ nbfd->my_archive = obfd;
+ nbfd->direction = read_direction;
+ nbfd->target_defaulted = obfd->target_defaulted;
+ return nbfd;
}
/*
If the caller desires that this file descriptor be cached by BFD
(opened as needed, closed as needed to free descriptors for
other opens), with the supplied @var{fd} used as an initial
- file descriptor (but subject to closure at any time), set
- bfd->cacheable nonzero in the returned BFD. The default is to
+ file descriptor (but subject to closure at any time), call
+ bfd_set_cacheable(bfd, 1) on the returned BFD. The default is to
assume no cacheing; the file descriptor will remain open until
bfd_close, and will not be affected by BFD operations on other
files.
bfd_create
SYNOPSIS
- bfd *bfd_create(CONST char *filename, bfd *template);
+ bfd *bfd_create(CONST char *filename, bfd *templ);
DESCRIPTION
This routine creates a new BFD in the manner of
*/
bfd *
-DEFUN(bfd_create,(filename, template),
+DEFUN(bfd_create,(filename, templ),
CONST char *filename AND
- bfd *template)
+ bfd *templ)
{
bfd *nbfd = new_bfd();
if (nbfd == (bfd *)NULL) {
return (bfd *)NULL;
}
nbfd->filename = filename;
- if(template) {
- nbfd->xvec = template->xvec;
+ if(templ) {
+ nbfd->xvec = templ->xvec;
}
nbfd->direction = no_direction;
bfd_set_format(nbfd, bfd_object);