forked from Imagelibrary/binutils-gdb
* objdump.c: Wrap long lines, init vars separately from decl.
(disassemble_section): Reset require_sec after call to find_symbol_for_address.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2003-11-19 Alan Modra <amodra@bigpond.net.au>
|
||||||
|
|
||||||
|
* objdump.c: Wrap long lines, init vars separately from decl.
|
||||||
|
(disassemble_section): Reset require_sec after call to
|
||||||
|
find_symbol_for_address.
|
||||||
|
|
||||||
2003-11-14 Nick Clifton <nickc@redhat.com>
|
2003-11-14 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
* objdump.c (find_symbol_for_address): Change parameters so
|
* objdump.c (find_symbol_for_address): Change parameters so
|
||||||
@@ -8,7 +14,7 @@
|
|||||||
(objdump_print_addr): Alter parameters passed to
|
(objdump_print_addr): Alter parameters passed to
|
||||||
find_symbol_for_address.
|
find_symbol_for_address.
|
||||||
(objdump_symbol_at_address): Likewise.
|
(objdump_symbol_at_address): Likewise.
|
||||||
(disassemble_address): Likewise. Also use symbol_is_valid
|
(disassemble_section): Likewise. Also use symbol_is_valid
|
||||||
function to check the validity of located symbols.
|
function to check the validity of located symbols.
|
||||||
|
|
||||||
2003-11-13 Tobias Burnus <tobias.burnus@physik.fu-berlin.de>
|
2003-11-13 Tobias Burnus <tobias.burnus@physik.fu-berlin.de>
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ static int exit_status = 0;
|
|||||||
|
|
||||||
static char *default_target = NULL; /* Default at runtime. */
|
static char *default_target = NULL; /* Default at runtime. */
|
||||||
|
|
||||||
/* The following variables are set based on arguments passed on command line. */
|
/* The following variables are set based on arguments passed on the
|
||||||
|
command line. */
|
||||||
static int show_version = 0; /* Show the version number. */
|
static int show_version = 0; /* Show the version number. */
|
||||||
static int dump_section_contents; /* -s */
|
static int dump_section_contents; /* -s */
|
||||||
static int dump_section_headers; /* -h */
|
static int dump_section_headers; /* -h */
|
||||||
@@ -116,7 +117,8 @@ static size_t only_used = 0;
|
|||||||
static const char **include_paths;
|
static const char **include_paths;
|
||||||
static int include_path_count;
|
static int include_path_count;
|
||||||
|
|
||||||
/* Extra info to pass to the section disassembler and address printing function. */
|
/* Extra info to pass to the section disassembler and address printing
|
||||||
|
function. */
|
||||||
struct objdump_disasm_info
|
struct objdump_disasm_info
|
||||||
{
|
{
|
||||||
bfd * abfd;
|
bfd * abfd;
|
||||||
@@ -600,9 +602,9 @@ objdump_print_value (bfd_vma vma, struct disassemble_info *info,
|
|||||||
{
|
{
|
||||||
char buf[30];
|
char buf[30];
|
||||||
char *p;
|
char *p;
|
||||||
struct objdump_disasm_info *aux
|
struct objdump_disasm_info *aux;
|
||||||
= (struct objdump_disasm_info *) info->application_data;
|
|
||||||
|
|
||||||
|
aux = (struct objdump_disasm_info *) info->application_data;
|
||||||
bfd_sprintf_vma (aux->abfd, buf, vma);
|
bfd_sprintf_vma (aux->abfd, buf, vma);
|
||||||
if (! skip_zeroes)
|
if (! skip_zeroes)
|
||||||
p = buf;
|
p = buf;
|
||||||
@@ -650,7 +652,9 @@ objdump_print_symname (bfd *abfd, struct disassemble_info *info,
|
|||||||
of the symbol in sorted_syms. */
|
of the symbol in sorted_syms. */
|
||||||
|
|
||||||
static asymbol *
|
static asymbol *
|
||||||
find_symbol_for_address (bfd_vma vma, struct disassemble_info *info, long *place)
|
find_symbol_for_address (bfd_vma vma,
|
||||||
|
struct disassemble_info *info,
|
||||||
|
long *place)
|
||||||
{
|
{
|
||||||
/* @@ Would it speed things up to cache the last two symbols returned,
|
/* @@ Would it speed things up to cache the last two symbols returned,
|
||||||
and maybe their address ranges? For many processors, only one memory
|
and maybe their address ranges? For many processors, only one memory
|
||||||
@@ -661,14 +665,19 @@ find_symbol_for_address (bfd_vma vma, struct disassemble_info *info, long *place
|
|||||||
long min = 0;
|
long min = 0;
|
||||||
long max = sorted_symcount;
|
long max = sorted_symcount;
|
||||||
long thisplace;
|
long thisplace;
|
||||||
struct objdump_disasm_info * aux = (struct objdump_disasm_info *) info->application_data;
|
struct objdump_disasm_info *aux;
|
||||||
bfd * abfd = aux->abfd;
|
bfd *abfd;
|
||||||
asection * sec = aux->sec;
|
asection *sec;
|
||||||
unsigned int opb = bfd_octets_per_byte (abfd);
|
unsigned int opb;
|
||||||
|
|
||||||
if (sorted_symcount < 1)
|
if (sorted_symcount < 1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
aux = (struct objdump_disasm_info *) info->application_data;
|
||||||
|
abfd = aux->abfd;
|
||||||
|
sec = aux->sec;
|
||||||
|
opb = bfd_octets_per_byte (abfd);
|
||||||
|
|
||||||
/* Perform a binary search looking for the closest symbol to the
|
/* Perform a binary search looking for the closest symbol to the
|
||||||
required value. We are searching the range (min, max]. */
|
required value. We are searching the range (min, max]. */
|
||||||
while (min + 1 < max)
|
while (min + 1 < max)
|
||||||
@@ -826,10 +835,11 @@ objdump_print_addr_with_sym (bfd *abfd, asection *sec, asymbol *sym,
|
|||||||
If SKIP_ZEROES is TRUE, don't output leading zeroes. */
|
If SKIP_ZEROES is TRUE, don't output leading zeroes. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
objdump_print_addr (bfd_vma vma, struct disassemble_info *info,
|
objdump_print_addr (bfd_vma vma,
|
||||||
|
struct disassemble_info *info,
|
||||||
bfd_boolean skip_zeroes)
|
bfd_boolean skip_zeroes)
|
||||||
{
|
{
|
||||||
struct objdump_disasm_info * aux = (struct objdump_disasm_info *) info->application_data;
|
struct objdump_disasm_info *aux;
|
||||||
asymbol *sym;
|
asymbol *sym;
|
||||||
|
|
||||||
if (sorted_symcount < 1)
|
if (sorted_symcount < 1)
|
||||||
@@ -839,6 +849,7 @@ objdump_print_addr (bfd_vma vma, struct disassemble_info *info,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
aux = (struct objdump_disasm_info *) info->application_data;
|
||||||
sym = find_symbol_for_address (vma, info, NULL);
|
sym = find_symbol_for_address (vma, info, NULL);
|
||||||
objdump_print_addr_with_sym (aux->abfd, aux->sec, sym, vma, info,
|
objdump_print_addr_with_sym (aux->abfd, aux->sec, sym, vma, info,
|
||||||
skip_zeroes);
|
skip_zeroes);
|
||||||
@@ -1552,7 +1563,7 @@ static void
|
|||||||
disassemble_section (bfd *abfd, asection *section, void *info)
|
disassemble_section (bfd *abfd, asection *section, void *info)
|
||||||
{
|
{
|
||||||
struct disassemble_info * pinfo = (struct disassemble_info *) info;
|
struct disassemble_info * pinfo = (struct disassemble_info *) info;
|
||||||
struct objdump_disasm_info * paux = (struct objdump_disasm_info *) pinfo->application_data;
|
struct objdump_disasm_info * paux;
|
||||||
unsigned int opb = pinfo->octets_per_byte;
|
unsigned int opb = pinfo->octets_per_byte;
|
||||||
bfd_byte * data = NULL;
|
bfd_byte * data = NULL;
|
||||||
bfd_size_type datasize = 0;
|
bfd_size_type datasize = 0;
|
||||||
@@ -1581,6 +1592,7 @@ disassemble_section (bfd *abfd, asection *section, void *info)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Decide which set of relocs to use. Load them if necessary. */
|
/* Decide which set of relocs to use. Load them if necessary. */
|
||||||
|
paux = (struct objdump_disasm_info *) pinfo->application_data;
|
||||||
if (paux->dynrelbuf)
|
if (paux->dynrelbuf)
|
||||||
{
|
{
|
||||||
rel_pp = paux->dynrelbuf;
|
rel_pp = paux->dynrelbuf;
|
||||||
@@ -1628,7 +1640,6 @@ disassemble_section (bfd *abfd, asection *section, void *info)
|
|||||||
bfd_get_section_contents (abfd, section, data, 0, datasize);
|
bfd_get_section_contents (abfd, section, data, 0, datasize);
|
||||||
|
|
||||||
paux->sec = section;
|
paux->sec = section;
|
||||||
paux->require_sec = TRUE;
|
|
||||||
pinfo->buffer = data;
|
pinfo->buffer = data;
|
||||||
pinfo->buffer_vma = section->vma;
|
pinfo->buffer_vma = section->vma;
|
||||||
pinfo->buffer_length = datasize;
|
pinfo->buffer_length = datasize;
|
||||||
@@ -1661,7 +1672,9 @@ disassemble_section (bfd *abfd, asection *section, void *info)
|
|||||||
printf (_("Disassembly of section %s:\n"), section->name);
|
printf (_("Disassembly of section %s:\n"), section->name);
|
||||||
|
|
||||||
/* Find the nearest symbol forwards from our current position. */
|
/* Find the nearest symbol forwards from our current position. */
|
||||||
|
paux->require_sec = TRUE;
|
||||||
sym = find_symbol_for_address (section->vma + addr_offset, info, &place);
|
sym = find_symbol_for_address (section->vma + addr_offset, info, &place);
|
||||||
|
paux->require_sec = FALSE;
|
||||||
|
|
||||||
/* Disassemble a block of instructions up to the address associated with
|
/* Disassemble a block of instructions up to the address associated with
|
||||||
the symbol we have just found. Then print the symbol and find the
|
the symbol we have just found. Then print the symbol and find the
|
||||||
@@ -1861,12 +1874,15 @@ disassemble_data (bfd *abfd)
|
|||||||
if (relsize > 0)
|
if (relsize > 0)
|
||||||
{
|
{
|
||||||
aux.dynrelbuf = xmalloc (relsize);
|
aux.dynrelbuf = xmalloc (relsize);
|
||||||
aux.dynrelcount = bfd_canonicalize_dynamic_reloc (abfd, aux.dynrelbuf, dynsyms);
|
aux.dynrelcount = bfd_canonicalize_dynamic_reloc (abfd,
|
||||||
|
aux.dynrelbuf,
|
||||||
|
dynsyms);
|
||||||
if (aux.dynrelcount < 0)
|
if (aux.dynrelcount < 0)
|
||||||
bfd_fatal (bfd_get_filename (abfd));
|
bfd_fatal (bfd_get_filename (abfd));
|
||||||
|
|
||||||
/* Sort the relocs by address. */
|
/* Sort the relocs by address. */
|
||||||
qsort (aux.dynrelbuf, aux.dynrelcount, sizeof (arelent *), compare_relocs);
|
qsort (aux.dynrelbuf, aux.dynrelcount, sizeof (arelent *),
|
||||||
|
compare_relocs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1931,7 +1947,9 @@ read_section_stabs (bfd *abfd, const char *sect_name, bfd_size_type *size_ptr)
|
|||||||
using string table section STRSECT_NAME (in `strtab'). */
|
using string table section STRSECT_NAME (in `strtab'). */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_section_stabs (bfd *abfd, const char *stabsect_name, unsigned *string_offset_ptr)
|
print_section_stabs (bfd *abfd,
|
||||||
|
const char *stabsect_name,
|
||||||
|
unsigned *string_offset_ptr)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned file_string_table_offset = 0;
|
unsigned file_string_table_offset = 0;
|
||||||
@@ -2404,7 +2422,9 @@ dump_reloc_set (bfd *abfd, asection *sec, arelent **relpp, long relcount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dump_relocs_in_section (bfd *abfd, asection *section, void *dummy ATTRIBUTE_UNUSED)
|
dump_relocs_in_section (bfd *abfd,
|
||||||
|
asection *section,
|
||||||
|
void *dummy ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
arelent **relpp;
|
arelent **relpp;
|
||||||
long relcount;
|
long relcount;
|
||||||
@@ -2503,7 +2523,9 @@ add_include_path (const char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
adjust_addresses (bfd *abfd ATTRIBUTE_UNUSED, asection *section, void *dummy ATTRIBUTE_UNUSED)
|
adjust_addresses (bfd *abfd ATTRIBUTE_UNUSED,
|
||||||
|
asection *section,
|
||||||
|
void *dummy ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
section->vma += adjust_section_vma;
|
section->vma += adjust_section_vma;
|
||||||
section->lma += adjust_section_vma;
|
section->lma += adjust_section_vma;
|
||||||
|
|||||||
Reference in New Issue
Block a user