diff options
author | Alan Modra <amodra@gmail.com> | 2007-09-12 10:00:15 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2007-09-12 10:00:15 +0000 |
commit | 01a3c21322a91d77e51645f58062b9e63cec1f63 (patch) | |
tree | 39c692f55416117f6fa7d248a4ec7e84be8672af /bfd | |
parent | ec56d5c0f69f681fe8502d22abb63a99e609fb91 (diff) | |
download | gdb-01a3c21322a91d77e51645f58062b9e63cec1f63.zip gdb-01a3c21322a91d77e51645f58062b9e63cec1f63.tar.gz gdb-01a3c21322a91d77e51645f58062b9e63cec1f63.tar.bz2 |
* elf-bfd.h (struct elf_backend_data): Delete elf_backend_sprintf_vma
and elf_backend_fprintf_vma.
(_bfd_elf_sprintf_vma, _bfd_elf_fprintf_vma): Delete.
* elf.c (_bfd_elf_sprintf_vma, _bfd_elf_fprintf_vma): Delete.
* elfxx-target.h (elf_backend_sprintf_vma): Don't define.
(elf_backend_fprintf_vma): Likewise.
(elfNN_bed): Don't init removed fields.
* bfd.c (is32bit): New function.
(bfd_sprintf_vma, bfd_fprintf_vma): Use the above.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 12 | ||||
-rw-r--r-- | bfd/bfd.c | 54 | ||||
-rw-r--r-- | bfd/elf-bfd.h | 11 | ||||
-rw-r--r-- | bfd/elf.c | 57 | ||||
-rw-r--r-- | bfd/elfxx-target.h | 8 |
5 files changed, 49 insertions, 93 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index eb7c625..63cab42 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,15 @@ +2007-09-12 Alan Modra <amodra@bigpond.net.au> + + * elf-bfd.h (struct elf_backend_data): Delete elf_backend_sprintf_vma + and elf_backend_fprintf_vma. + (_bfd_elf_sprintf_vma, _bfd_elf_fprintf_vma): Delete. + * elf.c (_bfd_elf_sprintf_vma, _bfd_elf_fprintf_vma): Delete. + * elfxx-target.h (elf_backend_sprintf_vma): Don't define. + (elf_backend_fprintf_vma): Likewise. + (elfNN_bed): Don't init removed fields. + * bfd.c (is32bit): New function. + (bfd_sprintf_vma, bfd_fprintf_vma): Use the above. + 2007-09-11 Nathan Sidwell <nathan@codesourcery.com> * archures.c: Add bfd_mach_mcf_isa_c_nodiv, @@ -1376,31 +1376,51 @@ bfd_record_phdr (bfd *abfd, return TRUE; } -void -bfd_sprintf_vma (bfd *abfd, char *buf, bfd_vma value) +#ifdef BFD64 +/* Return true iff this target is 32-bit. */ + +static bfd_boolean +is32bit (bfd *abfd) { if (bfd_get_flavour (abfd) == bfd_target_elf_flavour) - get_elf_backend_data (abfd)->elf_backend_sprintf_vma (abfd, buf, value); - else - sprintf_vma (buf, value); + { + const struct elf_backend_data *bed = get_elf_backend_data (abfd); + return bed->s->elfclass == ELFCLASS32; + } + + /* For non-ELF, make a guess based on the target name. */ + return (strstr (bfd_get_target (abfd), "64") == NULL + && strcmp (bfd_get_target (abfd), "mmo") != 0); } +#endif + +/* bfd_sprintf_vma and bfd_fprintf_vma display an address in the + target's address size. */ void -bfd_fprintf_vma (bfd *abfd, void *stream, bfd_vma value) +bfd_sprintf_vma (bfd *abfd ATTRIBUTE_UNUSED, char *buf, bfd_vma value) { - if (bfd_get_flavour (abfd) == bfd_target_elf_flavour) - get_elf_backend_data (abfd)->elf_backend_fprintf_vma (abfd, stream, value); #ifdef BFD64 - /* fprintf_vma() on a 64-bit enabled host will always print a 64-bit - value, but really we want to display the address in the target's - address size. Since we do not have a field in the bfd structure - to tell us this, we take a guess, based on the target's name. */ - else if (strstr (bfd_get_target (abfd), "64") == NULL - && strcmp (bfd_get_target (abfd), "mmo") != 0) - fprintf ((FILE *) stream, "%08lx", (unsigned long) (value & 0xffffffff)); + if (is32bit (abfd)) + { + sprintf (buf, "%08lx", (unsigned long) value & 0xffffffff); + return; + } #endif - else - fprintf_vma ((FILE *) stream, value); + sprintf_vma (buf, value); +} + +void +bfd_fprintf_vma (bfd *abfd ATTRIBUTE_UNUSED, void *stream, bfd_vma value) +{ +#ifdef BFD64 + if (is32bit (abfd)) + { + fprintf ((FILE *) stream, "%08lx", (unsigned long) value & 0xffffffff); + return; + } +#endif + fprintf_vma ((FILE *) stream, value); } /* diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 5dea7f9..08841be 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -953,12 +953,6 @@ struct elf_backend_data char *(*elf_backend_write_core_note) (bfd *abfd, char *buf, int *bufsiz, int note_type, ...); - /* Functions to print VMAs. Special code to handle 64 bit ELF files. */ - void (* elf_backend_sprintf_vma) - (bfd *, char *, bfd_vma); - void (* elf_backend_fprintf_vma) - (bfd *, void *, bfd_vma); - /* This function returns class of a reloc type. */ enum elf_reloc_type_class (*elf_backend_reloc_type_class) (const Elf_Internal_Rela *); @@ -1552,11 +1546,6 @@ extern bfd_boolean _bfd_elf_print_private_bfd_data extern void bfd_elf_print_symbol (bfd *, void *, asymbol *, bfd_print_symbol_type); -extern void _bfd_elf_sprintf_vma - (bfd *, char *, bfd_vma); -extern void _bfd_elf_fprintf_vma - (bfd *, void *, bfd_vma); - extern unsigned int _bfd_elf_eh_frame_address_size (bfd *, asection *); extern bfd_byte _bfd_elf_encode_eh_address @@ -8415,63 +8415,6 @@ bfd_get_elf_phdrs (bfd *abfd, void *phdrs) return num_phdrs; } -void -_bfd_elf_sprintf_vma (bfd *abfd ATTRIBUTE_UNUSED, char *buf, bfd_vma value) -{ -#ifdef BFD64 - Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */ - - i_ehdrp = elf_elfheader (abfd); - if (i_ehdrp == NULL) - sprintf_vma (buf, value); - else - { - if (i_ehdrp->e_ident[EI_CLASS] == ELFCLASS64) - { -#if BFD_HOST_64BIT_LONG - sprintf (buf, "%016lx", value); -#else - sprintf (buf, "%08lx%08lx", _bfd_int64_high (value), - _bfd_int64_low (value)); -#endif - } - else - sprintf (buf, "%08lx", (unsigned long) (value & 0xffffffff)); - } -#else - sprintf_vma (buf, value); -#endif -} - -void -_bfd_elf_fprintf_vma (bfd *abfd ATTRIBUTE_UNUSED, void *stream, bfd_vma value) -{ -#ifdef BFD64 - Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */ - - i_ehdrp = elf_elfheader (abfd); - if (i_ehdrp == NULL) - fprintf_vma ((FILE *) stream, value); - else - { - if (i_ehdrp->e_ident[EI_CLASS] == ELFCLASS64) - { -#if BFD_HOST_64BIT_LONG - fprintf ((FILE *) stream, "%016lx", value); -#else - fprintf ((FILE *) stream, "%08lx%08lx", - _bfd_int64_high (value), _bfd_int64_low (value)); -#endif - } - else - fprintf ((FILE *) stream, "%08lx", - (unsigned long) (value & 0xffffffff)); - } -#else - fprintf_vma ((FILE *) stream, value); -#endif -} - enum elf_reloc_type_class _bfd_elf_reloc_type_class (const Elf_Internal_Rela *rela ATTRIBUTE_UNUSED) { diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h index c803763..f6b6760 100644 --- a/bfd/elfxx-target.h +++ b/bfd/elfxx-target.h @@ -494,12 +494,6 @@ #ifndef elf_backend_write_core_note #define elf_backend_write_core_note NULL #endif -#ifndef elf_backend_sprintf_vma -#define elf_backend_sprintf_vma _bfd_elf_sprintf_vma -#endif -#ifndef elf_backend_fprintf_vma -#define elf_backend_fprintf_vma _bfd_elf_fprintf_vma -#endif #ifndef elf_backend_reloc_type_class #define elf_backend_reloc_type_class _bfd_elf_reloc_type_class #endif @@ -676,8 +670,6 @@ static struct elf_backend_data elfNN_bed = elf_backend_grok_prstatus, elf_backend_grok_psinfo, elf_backend_write_core_note, - elf_backend_sprintf_vma, - elf_backend_fprintf_vma, elf_backend_reloc_type_class, elf_backend_discard_info, elf_backend_ignore_discarded_relocs, |