Add bfd_get_bits() and bfd_put_bits().

This commit is contained in:
Nick Clifton 2000-12-21 18:20:04 +00:00
parent dafc8383e8
commit 8c603c85a1
5 changed files with 83 additions and 18 deletions

View File

@ -1,3 +1,10 @@
2000-12-21 Richard Sandiford <rsandifo@redhat.com>
* libbfd.c (bfd_get_bits): Added
(bfd_put_bits): Likewise
* bfd-in.h: Declared the above.
* bfd-in2.h: Regenerated.
2000-12-20 Kazu Hirata <kazu@hxi.com>
* targets.c: Fix formatting.

View File

@ -538,6 +538,11 @@ void bfd_putb32 PARAMS ((bfd_vma, unsigned char *));
void bfd_putl32 PARAMS ((bfd_vma, unsigned char *));
void bfd_putb16 PARAMS ((bfd_vma, unsigned char *));
void bfd_putl16 PARAMS ((bfd_vma, unsigned char *));
/* Byte swapping routines which take size and endiannes as arguments. */
bfd_vma bfd_get_bits PARAMS ((bfd_byte *, int, boolean));
void bfd_put_bits PARAMS ((bfd_vma, bfd_byte *, int, boolean));
/* Externally visible ECOFF routines. */

View File

@ -538,6 +538,11 @@ void bfd_putb32 PARAMS ((bfd_vma, unsigned char *));
void bfd_putl32 PARAMS ((bfd_vma, unsigned char *));
void bfd_putb16 PARAMS ((bfd_vma, unsigned char *));
void bfd_putl16 PARAMS ((bfd_vma, unsigned char *));
/* Byte swapping routines which take size and endiannes as arguments. */
bfd_vma bfd_get_bits PARAMS ((bfd_byte *, int, boolean));
void bfd_put_bits PARAMS ((bfd_vma, bfd_byte *, int, boolean));
/* Externally visible ECOFF routines. */
@ -1303,7 +1308,7 @@ bfd_set_section_flags PARAMS ((bfd *abfd, asection *sec, flagword flags));
void
bfd_map_over_sections PARAMS ((bfd *abfd,
void (*func)(bfd *abfd,
void (*func) (bfd *abfd,
asection *sect,
PTR obj),
PTR obj));
@ -3186,13 +3191,13 @@ core_file_matches_executable_p
(bfd_assert (__FILE__,__LINE__), NULL))
#endif
#define BFD_SEND_FMT(bfd, message, arglist) \
(((bfd)->xvec->message[(int)((bfd)->format)]) arglist)
(((bfd)->xvec->message[(int) ((bfd)->format)]) arglist)
#ifdef DEBUG_BFD_SEND
#undef BFD_SEND_FMT
#define BFD_SEND_FMT(bfd, message, arglist) \
(((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \
(((bfd)->xvec->message[(int)((bfd)->format)]) arglist) : \
(((bfd)->xvec->message[(int) ((bfd)->format)]) arglist) : \
(bfd_assert (__FILE__,__LINE__), NULL))
#endif
enum bfd_flavour {
@ -3481,7 +3486,7 @@ const char **
bfd_target_list PARAMS ((void));
const bfd_target *
bfd_search_for_target PARAMS ((int (* search_func)(const bfd_target *, void *), void *));
bfd_search_for_target PARAMS ((int (* search_func) (const bfd_target *, void *), void *));
boolean
bfd_check_format PARAMS ((bfd *abfd, bfd_format format));

View File

@ -1190,6 +1190,54 @@ bfd_putl64 (data, addr)
BFD_FAIL();
#endif
}
void
bfd_put_bits (data, addr, bits, big_p)
bfd_vma data;
bfd_byte *addr;
int bits;
boolean big_p;
{
int i;
int bytes;
if (bits % 8 != 0)
abort ();
bytes = bits / 8;
for (i = 0; i < bytes; i++)
{
int index = big_p ? bytes - i - 1 : i;
addr[index] = (bfd_byte) data;
data >>= 8;
}
}
bfd_vma
bfd_get_bits (addr, bits, big_p)
bfd_byte *addr;
int bits;
boolean big_p;
{
bfd_vma data;
int i;
int bytes;
if (bits % 8 != 0)
abort ();
data = 0;
bytes = bits / 8;
for (i = 0; i < bytes; i++)
{
int index = big_p ? i : bytes - i - 1;
data = (data << 8) | addr[index];
}
return data;
}
/* Default implementation */

View File

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2000-12-18 10:57-0800\n"
"POT-Creation-Date: 2000-12-21 10:12-0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -1425,12 +1425,12 @@ msgstr ""
msgid "not mapping: env var not set\n"
msgstr ""
#: libbfd.c:1335
#: libbfd.c:1383
#, c-format
msgid "%s: compiled for a big endian system and target is little endian"
msgstr ""
#: libbfd.c:1337
#: libbfd.c:1385
#, c-format
msgid "%s: compiled for a little endian system and target is big endian"
msgstr ""
@ -1864,12 +1864,12 @@ msgstr ""
msgid "som_sizeof_headers unimplemented"
msgstr ""
#: srec.c:301
#: srec.c:300
#, c-format
msgid "%s:%d: Unexpected character `%s' in S-record file\n"
msgstr ""
#: syms.c:974
#: syms.c:968
msgid "Unsupported .stab relocation"
msgstr ""