aboutsummaryrefslogtreecommitdiff
path: root/binutils/dwarf.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2010-11-21 21:27:15 +0000
committerH.J. Lu <hjl.tools@gmail.com>2010-11-21 21:27:15 +0000
commit3284fe0c5e852fb8a3a06630c161b9633b9f6682 (patch)
tree92eae22c1b78113a96791d1ad8de502b918b5949 /binutils/dwarf.c
parentf84854b643db17f4f06a8164114152b0bc001803 (diff)
downloadgdb-3284fe0c5e852fb8a3a06630c161b9633b9f6682.zip
gdb-3284fe0c5e852fb8a3a06630c161b9633b9f6682.tar.gz
gdb-3284fe0c5e852fb8a3a06630c161b9633b9f6682.tar.bz2
Add and use elfcomm.c/elfcomm.h.
2010-11-21 H.J. Lu <hongjiu.lu@intel.com> PR binutils/12235 * elfcomm.c: New. * elfcomm.h: Likewise. * Makefile.am (HFILES): Add elfcomm.h. (CFILES): Add elfcomm.c. (ELFLIBS): New. (readelf_SOURCES): Add $(ELFLIBS). (elfedit_SOURCES): Likewise. (objdump_SOURCES): Likewise. * Makefile.in: Regenerated. * dwarf.c: Include "elfcomm.h". (byte_get): Removed. (byte_get_little_endian): Likewise. (byte_get_big_endian): Likewise. (byte_get_signed): Likewise. (error): Likewise. (warn): Likewise. * dwarf.h (dwarf_vma): Defined with HOST_WIDEST_INT. (dwarf_size_type): Likewise. (byte_get): Removed. (byte_get_signed): Likewise. (byte_get_little_endian): Likewise. (byte_get_big_endian): Likewise. (error): Likewise. (warn): Likewise. * elfedit.c: Include "elfcomm.h". Don't include "aout/ar.h". Call error () instead of non_fatal (). (streq): Removed. (strneq): Likewise. (const_strneq): Likewise. (non_fatal): Likewise. (BYTE_GET): Likewise. (BYTE_PUT): Likewise. (byte_get): Likewise. (byte_put): Likewise. (byte_get_little_endian): Likewise. (byte_get_big_endian): Likewise. (byte_put_little_endian): Likewise. (byte_put_big_endian): Likewise. (adjust_relative_path): Likewise. (archive_info): Likewise. (setup_archive): Likewise. (release_archive): Likewise. (setup_nested_archive): Likewise. (get_archive_member_name): Likewise. (get_archive_member_name_at): Likewise. (make_qualified_name): Likewise. * objdump.c: Include "elfcomm.h". * readelf.c: Include "elfcomm.h". Don't include "aout/ar.h". (BYTE_GET): Removed. (BYTE_GET_SIGNED): Removed. (streq): Likewise. (strneq): Likewise. (const_strneq): Likewise. (byte_put): Likewise. (byte_put_little_endian): Likewise. (byte_put_big_endian): Likewise. (adjust_relative_path): Likewise. (archive_info): Likewise. (setup_archive): Likewise. (release_archive): Likewise. (setup_nested_archive): Likewise. (get_archive_member_name): Likewise. (get_archive_member_name_at): Likewise. (make_qualified_name): Likewise.
Diffstat (limited to 'binutils/dwarf.c')
-rw-r--r--binutils/dwarf.c142
1 files changed, 1 insertions, 141 deletions
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 369304b..c986ca7 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -23,6 +23,7 @@
#include "libiberty.h"
#include "bfd.h"
#include "bucomm.h"
+#include "elfcomm.h"
#include "elf/common.h"
#include "dwarf2.h"
#include "dwarf.h"
@@ -64,125 +65,6 @@ int do_wide;
#define FLAG_DEBUG_LINES_RAW 1
#define FLAG_DEBUG_LINES_DECODED 2
-dwarf_vma (*byte_get) (unsigned char *, int);
-
-dwarf_vma
-byte_get_little_endian (unsigned char *field, int size)
-{
- switch (size)
- {
- case 1:
- return *field;
-
- case 2:
- return ((unsigned int) (field[0]))
- | (((unsigned int) (field[1])) << 8);
-
- case 3:
- return ((unsigned long) (field[0]))
- | (((unsigned long) (field[1])) << 8)
- | (((unsigned long) (field[2])) << 16);
-
- case 4:
- return ((unsigned long) (field[0]))
- | (((unsigned long) (field[1])) << 8)
- | (((unsigned long) (field[2])) << 16)
- | (((unsigned long) (field[3])) << 24);
-
- case 8:
- if (sizeof (dwarf_vma) == 8)
- return ((dwarf_vma) (field[0]))
- | (((dwarf_vma) (field[1])) << 8)
- | (((dwarf_vma) (field[2])) << 16)
- | (((dwarf_vma) (field[3])) << 24)
- | (((dwarf_vma) (field[4])) << 32)
- | (((dwarf_vma) (field[5])) << 40)
- | (((dwarf_vma) (field[6])) << 48)
- | (((dwarf_vma) (field[7])) << 56);
- else if (sizeof (dwarf_vma) == 4)
- /* We want to extract data from an 8 byte wide field and
- place it into a 4 byte wide field. Since this is a little
- endian source we can just use the 4 byte extraction code. */
- return ((unsigned long) (field[0]))
- | (((unsigned long) (field[1])) << 8)
- | (((unsigned long) (field[2])) << 16)
- | (((unsigned long) (field[3])) << 24);
-
- default:
- error (_("Unhandled data length: %d\n"), size);
- abort ();
- }
-}
-
-dwarf_vma
-byte_get_big_endian (unsigned char *field, int size)
-{
- switch (size)
- {
- case 1:
- return *field;
-
- case 2:
- return ((unsigned int) (field[1])) | (((int) (field[0])) << 8);
-
- case 3:
- return ((unsigned long) (field[2]))
- | (((unsigned long) (field[1])) << 8)
- | (((unsigned long) (field[0])) << 16);
-
- case 4:
- return ((unsigned long) (field[3]))
- | (((unsigned long) (field[2])) << 8)
- | (((unsigned long) (field[1])) << 16)
- | (((unsigned long) (field[0])) << 24);
-
- case 8:
- if (sizeof (dwarf_vma) == 8)
- return ((dwarf_vma) (field[7]))
- | (((dwarf_vma) (field[6])) << 8)
- | (((dwarf_vma) (field[5])) << 16)
- | (((dwarf_vma) (field[4])) << 24)
- | (((dwarf_vma) (field[3])) << 32)
- | (((dwarf_vma) (field[2])) << 40)
- | (((dwarf_vma) (field[1])) << 48)
- | (((dwarf_vma) (field[0])) << 56);
- else if (sizeof (dwarf_vma) == 4)
- {
- /* Although we are extracing data from an 8 byte wide field,
- we are returning only 4 bytes of data. */
- field += 4;
- return ((unsigned long) (field[3]))
- | (((unsigned long) (field[2])) << 8)
- | (((unsigned long) (field[1])) << 16)
- | (((unsigned long) (field[0])) << 24);
- }
-
- default:
- error (_("Unhandled data length: %d\n"), size);
- abort ();
- }
-}
-
-dwarf_vma
-byte_get_signed (unsigned char *field, int size)
-{
- dwarf_vma x = byte_get (field, size);
-
- switch (size)
- {
- case 1:
- return (x ^ 0x80) - 0x80;
- case 2:
- return (x ^ 0x8000) - 0x8000;
- case 4:
- return (x ^ 0x80000000) - 0x80000000;
- case 8:
- return x;
- default:
- abort ();
- }
-}
-
static int
size_of_encoded_value (int encoding)
{
@@ -5020,28 +4902,6 @@ xcrealloc (void *ptr, size_t nmemb, size_t size)
}
void
-error (const char *message, ...)
-{
- va_list args;
-
- va_start (args, message);
- fprintf (stderr, _("%s: Error: "), program_name);
- vfprintf (stderr, message, args);
- va_end (args);
-}
-
-void
-warn (const char *message, ...)
-{
- va_list args;
-
- va_start (args, message);
- fprintf (stderr, _("%s: Warning: "), program_name);
- vfprintf (stderr, message, args);
- va_end (args);
-}
-
-void
free_debug_memory (void)
{
unsigned int i;