mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2025-01-31 22:13:43 +00:00
Update for recent BFD changes to symbol and reloc reading. Rename
all uses of get_symtab_upper_bound to bfd_get_symtab_upper_bound. Also: * coffgrok.c (symcount): Change to long. (do_sections_p1): Check for error return from bfd_get_reloc_upper_bound. Change relcount to long, and check for error from bfd_canonicalize_reloc. (coff_grok): Change storage to long. Check for error from bfd_get_symtab_upper_bound and bfd_canonicalize_symtab. * nlmconv.c (main): Change symcount, newsymalloc, newsymcount, and i to long. Check for error from bfd_get_symtab_upper_bound and bfd_canonicalize_symtab. (copy_sections): Change reloc_size and reloc_count to long. Check for error from bfd_get_reloc_upper_bound and bfd_canonicalize_reloc. (mangle_relocs, i386_mangle_relocs, alpha_mangle_relocs): Change reloc_count_ptr argument to long *. Make corresponding changes to variables loaded from *reloc_count_ptr. * nm.c (display_rel_file): Change storage and symcount to long. Check for errors from bfd_get_symtab_upper_bound and bfd_canonicalize_symtab. * objcopy.c (filter_symbols): Change symcount, src_count and dst_count to long. (copy_object): Change symcount to long. Pass another argument to fprintf. Check for errors from bfd_get_symtab_upper_bound and bfd_canonicalize_symtab. (copy_section): Change relcount to long. Check for errors from bfd_get_reloc_upper_bound and bfd_canonicalize_reloc. (mark_symbols_used_in_relocations): Change relcount and i to long. Check for errors form bfd_get_reloc_upper_bound and bfd_canonicalize_reloc. * objdump.c (storage): Remove global variable. (symcount): Changed to long. (slurp_symtab): New local variable storage. Check for errors from bfd_get_symtab_upper_bound and bfd_canonicalize_symtab. (remove_useless_symbols): Change return value and count to long. (objdump_print_address): Change min, max, thisplace and i to long. (disassemble_data): Change i to long. (dump_symbols): Change count to long. (dump_relocs): Change relcount to long. Check for errors from bfd_ret_reloc_upper_bound and bfd_canonicalize_reloc. (display_info_table): Add casts when passing LONGEST_ARCH for printf %* argument.
This commit is contained in:
parent
6c00b04ff8
commit
ae5d2ff573
@ -1,3 +1,49 @@
|
|||||||
|
Wed Mar 30 15:52:40 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
|
||||||
|
|
||||||
|
Update for recent BFD changes to symbol and reloc reading. Rename
|
||||||
|
all uses of get_symtab_upper_bound to bfd_get_symtab_upper_bound.
|
||||||
|
Also:
|
||||||
|
* coffgrok.c (symcount): Change to long.
|
||||||
|
(do_sections_p1): Check for error return from
|
||||||
|
bfd_get_reloc_upper_bound. Change relcount to long, and check for
|
||||||
|
error from bfd_canonicalize_reloc.
|
||||||
|
(coff_grok): Change storage to long. Check for error from
|
||||||
|
bfd_get_symtab_upper_bound and bfd_canonicalize_symtab.
|
||||||
|
* nlmconv.c (main): Change symcount, newsymalloc, newsymcount, and
|
||||||
|
i to long. Check for error from bfd_get_symtab_upper_bound and
|
||||||
|
bfd_canonicalize_symtab.
|
||||||
|
(copy_sections): Change reloc_size and reloc_count to long. Check
|
||||||
|
for error from bfd_get_reloc_upper_bound and
|
||||||
|
bfd_canonicalize_reloc.
|
||||||
|
(mangle_relocs, i386_mangle_relocs, alpha_mangle_relocs): Change
|
||||||
|
reloc_count_ptr argument to long *. Make corresponding changes to
|
||||||
|
variables loaded from *reloc_count_ptr.
|
||||||
|
* nm.c (display_rel_file): Change storage and symcount to long.
|
||||||
|
Check for errors from bfd_get_symtab_upper_bound and
|
||||||
|
bfd_canonicalize_symtab.
|
||||||
|
* objcopy.c (filter_symbols): Change symcount, src_count and
|
||||||
|
dst_count to long.
|
||||||
|
(copy_object): Change symcount to long. Pass another argument to
|
||||||
|
fprintf. Check for errors from bfd_get_symtab_upper_bound and
|
||||||
|
bfd_canonicalize_symtab.
|
||||||
|
(copy_section): Change relcount to long. Check for errors from
|
||||||
|
bfd_get_reloc_upper_bound and bfd_canonicalize_reloc.
|
||||||
|
(mark_symbols_used_in_relocations): Change relcount and i to long.
|
||||||
|
Check for errors form bfd_get_reloc_upper_bound and
|
||||||
|
bfd_canonicalize_reloc.
|
||||||
|
* objdump.c (storage): Remove global variable.
|
||||||
|
(symcount): Changed to long.
|
||||||
|
(slurp_symtab): New local variable storage. Check for errors from
|
||||||
|
bfd_get_symtab_upper_bound and bfd_canonicalize_symtab.
|
||||||
|
(remove_useless_symbols): Change return value and count to long.
|
||||||
|
(objdump_print_address): Change min, max, thisplace and i to long.
|
||||||
|
(disassemble_data): Change i to long.
|
||||||
|
(dump_symbols): Change count to long.
|
||||||
|
(dump_relocs): Change relcount to long. Check for errors from
|
||||||
|
bfd_ret_reloc_upper_bound and bfd_canonicalize_reloc.
|
||||||
|
(display_info_table): Add casts when passing LONGEST_ARCH for
|
||||||
|
printf %* argument.
|
||||||
|
|
||||||
Tue Mar 29 14:59:04 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
|
Tue Mar 29 14:59:04 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
|
||||||
|
|
||||||
* nm.c (display_archive): Close each archive element after it has
|
* nm.c (display_archive): Close each archive element after it has
|
||||||
|
@ -116,23 +116,23 @@ static const char *select_output_format PARAMS ((enum bfd_architecture,
|
|||||||
static void setup_sections PARAMS ((bfd *, asection *, PTR));
|
static void setup_sections PARAMS ((bfd *, asection *, PTR));
|
||||||
static void copy_sections PARAMS ((bfd *, asection *, PTR));
|
static void copy_sections PARAMS ((bfd *, asection *, PTR));
|
||||||
static void mangle_relocs PARAMS ((bfd *, asection *, arelent ***,
|
static void mangle_relocs PARAMS ((bfd *, asection *, arelent ***,
|
||||||
bfd_size_type *, char *,
|
long *, char *,
|
||||||
bfd_size_type));
|
bfd_size_type));
|
||||||
static void i386_mangle_relocs PARAMS ((bfd *, asection *, arelent ***,
|
static void i386_mangle_relocs PARAMS ((bfd *, asection *, arelent ***,
|
||||||
bfd_size_type *, char *,
|
long *, char *,
|
||||||
bfd_size_type));
|
bfd_size_type));
|
||||||
static void alpha_mangle_relocs PARAMS ((bfd *, asection *, arelent ***,
|
static void alpha_mangle_relocs PARAMS ((bfd *, asection *, arelent ***,
|
||||||
bfd_size_type *, char *,
|
long *, char *,
|
||||||
bfd_size_type));
|
bfd_size_type));
|
||||||
/* start-sanitize-powerpc-netware */
|
/* start-sanitize-powerpc-netware */
|
||||||
static void powerpc_build_stubs PARAMS ((bfd *, asymbol ***, unsigned int *));
|
static void powerpc_build_stubs PARAMS ((bfd *, asymbol ***, long *));
|
||||||
static void powerpc_resolve_stubs PARAMS ((bfd *, bfd *));
|
static void powerpc_resolve_stubs PARAMS ((bfd *, bfd *));
|
||||||
static void powerpc_mangle_relocs PARAMS ((bfd *, asection *, arelent ***,
|
static void powerpc_mangle_relocs PARAMS ((bfd *, asection *, arelent ***,
|
||||||
bfd_size_type *, char *,
|
long *, char *,
|
||||||
bfd_size_type));
|
bfd_size_type));
|
||||||
/* end-sanitize-powerpc-netware */
|
/* end-sanitize-powerpc-netware */
|
||||||
static void default_mangle_relocs PARAMS ((bfd *, asection *, arelent ***,
|
static void default_mangle_relocs PARAMS ((bfd *, asection *, arelent ***,
|
||||||
bfd_size_type *, char *,
|
long *, char *,
|
||||||
bfd_size_type));
|
bfd_size_type));
|
||||||
static char *link_inputs PARAMS ((struct string_list *, char *));
|
static char *link_inputs PARAMS ((struct string_list *, char *));
|
||||||
static const char *choose_temp_base_try PARAMS ((const char *,
|
static const char *choose_temp_base_try PARAMS ((const char *,
|
||||||
@ -161,12 +161,13 @@ main (argc, argv)
|
|||||||
bfd *inbfd;
|
bfd *inbfd;
|
||||||
bfd *outbfd;
|
bfd *outbfd;
|
||||||
asymbol **newsyms, **outsyms;
|
asymbol **newsyms, **outsyms;
|
||||||
unsigned int symcount, newsymalloc, newsymcount;
|
long symcount, newsymalloc, newsymcount;
|
||||||
|
long symsize;
|
||||||
asection *text_sec, *bss_sec, *data_sec;
|
asection *text_sec, *bss_sec, *data_sec;
|
||||||
bfd_vma vma;
|
bfd_vma vma;
|
||||||
bfd_size_type align;
|
bfd_size_type align;
|
||||||
asymbol *endsym;
|
asymbol *endsym;
|
||||||
unsigned int i;
|
long i;
|
||||||
char inlead, outlead;
|
char inlead, outlead;
|
||||||
boolean gotstart, gotexit, gotcheck;
|
boolean gotstart, gotexit, gotcheck;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
@ -357,8 +358,13 @@ main (argc, argv)
|
|||||||
if (! bfd_set_file_flags (outbfd, bfd_get_file_flags (inbfd)))
|
if (! bfd_set_file_flags (outbfd, bfd_get_file_flags (inbfd)))
|
||||||
bfd_fatal (bfd_get_filename (outbfd));
|
bfd_fatal (bfd_get_filename (outbfd));
|
||||||
|
|
||||||
symbols = (asymbol **) xmalloc (get_symtab_upper_bound (inbfd));
|
symsize = bfd_get_symtab_upper_bound (inbfd);
|
||||||
|
if (symsize < 0)
|
||||||
|
bfd_fatal (input_file);
|
||||||
|
symbols = (asymbol **) xmalloc (symsize);
|
||||||
symcount = bfd_canonicalize_symtab (inbfd, symbols);
|
symcount = bfd_canonicalize_symtab (inbfd, symbols);
|
||||||
|
if (symcount < 0)
|
||||||
|
bfd_fatal (input_file);
|
||||||
|
|
||||||
/* Make sure we have a .bss section. */
|
/* Make sure we have a .bss section. */
|
||||||
bss_sec = bfd_get_section_by_name (outbfd, NLM_UNINITIALIZED_DATA_NAME);
|
bss_sec = bfd_get_section_by_name (outbfd, NLM_UNINITIALIZED_DATA_NAME);
|
||||||
@ -1193,7 +1199,7 @@ copy_sections (inbfd, insec, data_ptr)
|
|||||||
asection *outsec;
|
asection *outsec;
|
||||||
bfd_size_type size;
|
bfd_size_type size;
|
||||||
PTR contents;
|
PTR contents;
|
||||||
bfd_size_type reloc_size;
|
long reloc_size;
|
||||||
|
|
||||||
/* FIXME: We don't want to copy the .reginfo section of an ECOFF
|
/* FIXME: We don't want to copy the .reginfo section of an ECOFF
|
||||||
file. However, I don't have a good way to describe this section.
|
file. However, I don't have a good way to describe this section.
|
||||||
@ -1224,13 +1230,17 @@ copy_sections (inbfd, insec, data_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
reloc_size = bfd_get_reloc_upper_bound (inbfd, insec);
|
reloc_size = bfd_get_reloc_upper_bound (inbfd, insec);
|
||||||
|
if (reloc_size < 0)
|
||||||
|
bfd_fatal (bfd_get_filename (inbfd));
|
||||||
if (reloc_size != 0)
|
if (reloc_size != 0)
|
||||||
{
|
{
|
||||||
arelent **relocs;
|
arelent **relocs;
|
||||||
bfd_size_type reloc_count;
|
long reloc_count;
|
||||||
|
|
||||||
relocs = (arelent **) xmalloc (reloc_size);
|
relocs = (arelent **) xmalloc (reloc_size);
|
||||||
reloc_count = bfd_canonicalize_reloc (inbfd, insec, relocs, symbols);
|
reloc_count = bfd_canonicalize_reloc (inbfd, insec, relocs, symbols);
|
||||||
|
if (reloc_count < 0)
|
||||||
|
bfd_fatal (bfd_get_filename (inbfd));
|
||||||
mangle_relocs (outbfd, insec, &relocs, &reloc_count, (char *) contents,
|
mangle_relocs (outbfd, insec, &relocs, &reloc_count, (char *) contents,
|
||||||
size);
|
size);
|
||||||
|
|
||||||
@ -1272,7 +1282,7 @@ mangle_relocs (outbfd, insec, relocs_ptr, reloc_count_ptr, contents,
|
|||||||
bfd *outbfd;
|
bfd *outbfd;
|
||||||
asection *insec;
|
asection *insec;
|
||||||
arelent ***relocs_ptr;
|
arelent ***relocs_ptr;
|
||||||
bfd_size_type *reloc_count_ptr;
|
long *reloc_count_ptr;
|
||||||
char *contents;
|
char *contents;
|
||||||
bfd_size_type contents_size;
|
bfd_size_type contents_size;
|
||||||
{
|
{
|
||||||
@ -1309,15 +1319,15 @@ default_mangle_relocs (outbfd, insec, relocs_ptr, reloc_count_ptr, contents,
|
|||||||
bfd *outbfd;
|
bfd *outbfd;
|
||||||
asection *insec;
|
asection *insec;
|
||||||
arelent ***relocs_ptr;
|
arelent ***relocs_ptr;
|
||||||
bfd_size_type *reloc_count_ptr;
|
long *reloc_count_ptr;
|
||||||
char *contents;
|
char *contents;
|
||||||
bfd_size_type contents_size;
|
bfd_size_type contents_size;
|
||||||
{
|
{
|
||||||
if (insec->output_offset != 0)
|
if (insec->output_offset != 0)
|
||||||
{
|
{
|
||||||
bfd_size_type reloc_count;
|
long reloc_count;
|
||||||
register arelent **relocs;
|
register arelent **relocs;
|
||||||
register bfd_size_type i;
|
register long i;
|
||||||
|
|
||||||
reloc_count = *reloc_count_ptr;
|
reloc_count = *reloc_count_ptr;
|
||||||
relocs = *relocs_ptr;
|
relocs = *relocs_ptr;
|
||||||
@ -1353,11 +1363,11 @@ i386_mangle_relocs (outbfd, insec, relocs_ptr, reloc_count_ptr, contents,
|
|||||||
bfd *outbfd;
|
bfd *outbfd;
|
||||||
asection *insec;
|
asection *insec;
|
||||||
arelent ***relocs_ptr;
|
arelent ***relocs_ptr;
|
||||||
bfd_size_type *reloc_count_ptr;
|
long *reloc_count_ptr;
|
||||||
char *contents;
|
char *contents;
|
||||||
bfd_size_type contents_size;
|
bfd_size_type contents_size;
|
||||||
{
|
{
|
||||||
bfd_size_type reloc_count, i;
|
long reloc_count, i;
|
||||||
arelent **relocs;
|
arelent **relocs;
|
||||||
|
|
||||||
reloc_count = *reloc_count_ptr;
|
reloc_count = *reloc_count_ptr;
|
||||||
@ -1508,11 +1518,11 @@ alpha_mangle_relocs (outbfd, insec, relocs_ptr, reloc_count_ptr, contents,
|
|||||||
bfd *outbfd;
|
bfd *outbfd;
|
||||||
asection *insec;
|
asection *insec;
|
||||||
register arelent ***relocs_ptr;
|
register arelent ***relocs_ptr;
|
||||||
bfd_size_type *reloc_count_ptr;
|
long *reloc_count_ptr;
|
||||||
char *contents;
|
char *contents;
|
||||||
bfd_size_type contents_size;
|
bfd_size_type contents_size;
|
||||||
{
|
{
|
||||||
bfd_size_type old_reloc_count;
|
long old_reloc_count;
|
||||||
arelent **old_relocs;
|
arelent **old_relocs;
|
||||||
register arelent **relocs;
|
register arelent **relocs;
|
||||||
|
|
||||||
@ -1652,14 +1662,14 @@ static void
|
|||||||
powerpc_build_stubs (inbfd, symbols_ptr, symcount_ptr)
|
powerpc_build_stubs (inbfd, symbols_ptr, symcount_ptr)
|
||||||
bfd *inbfd;
|
bfd *inbfd;
|
||||||
asymbol ***symbols_ptr;
|
asymbol ***symbols_ptr;
|
||||||
unsigned int *symcount_ptr;
|
long *symcount_ptr;
|
||||||
{
|
{
|
||||||
asection *stub_sec;
|
asection *stub_sec;
|
||||||
asection *got_sec;
|
asection *got_sec;
|
||||||
unsigned int got_base;
|
unsigned int got_base;
|
||||||
unsigned int i;
|
long i;
|
||||||
unsigned int symcount;
|
long symcount;
|
||||||
unsigned int stubcount;
|
long stubcount;
|
||||||
|
|
||||||
/* Make a section to hold stubs. We don't set SEC_HAS_CONTENTS for
|
/* Make a section to hold stubs. We don't set SEC_HAS_CONTENTS for
|
||||||
the section to prevent copy_sections from reading from it. */
|
the section to prevent copy_sections from reading from it. */
|
||||||
@ -1722,7 +1732,9 @@ powerpc_build_stubs (inbfd, symbols_ptr, symcount_ptr)
|
|||||||
/* Define the `.' symbol to be in the stub section. */
|
/* Define the `.' symbol to be in the stub section. */
|
||||||
sym->section = stub_sec;
|
sym->section = stub_sec;
|
||||||
sym->value = stubcount * POWERPC_STUB_SIZE;
|
sym->value = stubcount * POWERPC_STUB_SIZE;
|
||||||
sym->flags = BSF_LOCAL;
|
/* We set the BSF_DYNAMIC flag here so that we can check it when
|
||||||
|
we are mangling relocs. FIXME: This is a hack. */
|
||||||
|
sym->flags = BSF_LOCAL | BSF_DYNAMIC;
|
||||||
|
|
||||||
/* Add this stub to the linked list. */
|
/* Add this stub to the linked list. */
|
||||||
item = (struct powerpc_stub *) xmalloc (sizeof (struct powerpc_stub));
|
item = (struct powerpc_stub *) xmalloc (sizeof (struct powerpc_stub));
|
||||||
@ -1835,14 +1847,14 @@ powerpc_mangle_relocs (outbfd, insec, relocs_ptr, reloc_count_ptr, contents,
|
|||||||
bfd *outbfd;
|
bfd *outbfd;
|
||||||
asection *insec;
|
asection *insec;
|
||||||
register arelent ***relocs_ptr;
|
register arelent ***relocs_ptr;
|
||||||
bfd_size_type *reloc_count_ptr;
|
long *reloc_count_ptr;
|
||||||
char *contents;
|
char *contents;
|
||||||
bfd_size_type contents_size;
|
bfd_size_type contents_size;
|
||||||
{
|
{
|
||||||
const reloc_howto_type *toc_howto;
|
const reloc_howto_type *toc_howto;
|
||||||
bfd_size_type reloc_count;
|
long reloc_count;
|
||||||
register arelent **relocs;
|
register arelent **relocs;
|
||||||
register bfd_size_type i;
|
register long i;
|
||||||
|
|
||||||
toc_howto = bfd_reloc_type_lookup (insec->owner, BFD_RELOC_PPC_TOC16);
|
toc_howto = bfd_reloc_type_lookup (insec->owner, BFD_RELOC_PPC_TOC16);
|
||||||
if (toc_howto == (reloc_howto_type *) NULL)
|
if (toc_howto == (reloc_howto_type *) NULL)
|
||||||
@ -1893,13 +1905,14 @@ powerpc_mangle_relocs (outbfd, insec, relocs_ptr, reloc_count_ptr, contents,
|
|||||||
& rel->howto->dst_mask));
|
& rel->howto->dst_mask));
|
||||||
bfd_put_32 (outbfd, val, (bfd_byte *) contents + rel->address);
|
bfd_put_32 (outbfd, val, (bfd_byte *) contents + rel->address);
|
||||||
|
|
||||||
/* If this reloc is against a symbol whose name begins
|
/* If this reloc is against an stubbed symbol and the
|
||||||
with a `.', and the next instruction is
|
next instruction is
|
||||||
cror 31,31,31
|
cror 31,31,31
|
||||||
then we replace the next instruction with
|
then we replace the next instruction with
|
||||||
lwz r2,20(r1)
|
lwz r2,20(r1)
|
||||||
This reloads the TOC pointer after a call. */
|
This reloads the TOC pointer after a stub call. */
|
||||||
if (bfd_asymbol_name (sym)[0] == '.'
|
if (bfd_asymbol_name (sym)[0] == '.'
|
||||||
|
&& (sym->flags & BSF_DYNAMIC) != 0
|
||||||
&& (bfd_get_32 (outbfd,
|
&& (bfd_get_32 (outbfd,
|
||||||
(bfd_byte *) contents + rel->address + 4)
|
(bfd_byte *) contents + rel->address + 4)
|
||||||
== 0x4ffffb82)) /* cror 31,31,31 */
|
== 0x4ffffb82)) /* cror 31,31,31 */
|
||||||
|
@ -505,9 +505,9 @@ display_rel_file (abfd, archive_bfd)
|
|||||||
bfd *abfd;
|
bfd *abfd;
|
||||||
bfd *archive_bfd;
|
bfd *archive_bfd;
|
||||||
{
|
{
|
||||||
unsigned int storage;
|
long storage;
|
||||||
asymbol **syms;
|
asymbol **syms;
|
||||||
unsigned int symcount = 0;
|
long symcount = 0;
|
||||||
|
|
||||||
if (!(bfd_get_file_flags (abfd) & HAS_SYMS))
|
if (!(bfd_get_file_flags (abfd) & HAS_SYMS))
|
||||||
{
|
{
|
||||||
@ -515,7 +515,9 @@ display_rel_file (abfd, archive_bfd)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
storage = get_symtab_upper_bound (abfd);
|
storage = bfd_get_symtab_upper_bound (abfd);
|
||||||
|
if (storage < 0)
|
||||||
|
bfd_fatal (bfd_get_filename (abfd));
|
||||||
if (storage == 0)
|
if (storage == 0)
|
||||||
{
|
{
|
||||||
nosymz:
|
nosymz:
|
||||||
@ -527,6 +529,8 @@ display_rel_file (abfd, archive_bfd)
|
|||||||
syms = (asymbol **) xmalloc (storage);
|
syms = (asymbol **) xmalloc (storage);
|
||||||
|
|
||||||
symcount = bfd_canonicalize_symtab (abfd, syms);
|
symcount = bfd_canonicalize_symtab (abfd, syms);
|
||||||
|
if (symcount < 0)
|
||||||
|
bfd_fatal (bfd_get_filename (abfd));
|
||||||
if (symcount == 0)
|
if (symcount == 0)
|
||||||
{
|
{
|
||||||
free (syms);
|
free (syms);
|
||||||
|
@ -178,10 +178,10 @@ static unsigned int
|
|||||||
filter_symbols (abfd, osyms, isyms, symcount)
|
filter_symbols (abfd, osyms, isyms, symcount)
|
||||||
bfd *abfd;
|
bfd *abfd;
|
||||||
asymbol **osyms, **isyms;
|
asymbol **osyms, **isyms;
|
||||||
unsigned long symcount;
|
long symcount;
|
||||||
{
|
{
|
||||||
register asymbol **from = isyms, **to = osyms;
|
register asymbol **from = isyms, **to = osyms;
|
||||||
unsigned int src_count = 0, dst_count = 0;
|
long src_count = 0, dst_count = 0;
|
||||||
|
|
||||||
for (; src_count < symcount; src_count++)
|
for (; src_count < symcount; src_count++)
|
||||||
{
|
{
|
||||||
@ -229,7 +229,7 @@ copy_object (ibfd, obfd)
|
|||||||
bfd *ibfd;
|
bfd *ibfd;
|
||||||
bfd *obfd;
|
bfd *obfd;
|
||||||
{
|
{
|
||||||
unsigned int symcount;
|
long symcount;
|
||||||
|
|
||||||
if (!bfd_set_format (obfd, bfd_get_format (ibfd)))
|
if (!bfd_set_format (obfd, bfd_get_format (ibfd)))
|
||||||
{
|
{
|
||||||
@ -272,7 +272,8 @@ copy_object (ibfd, obfd)
|
|||||||
if (!bfd_copy_private_bfd_data (ibfd, obfd))
|
if (!bfd_copy_private_bfd_data (ibfd, obfd))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s: %s: error copying private BFD data: %s\n",
|
fprintf (stderr, "%s: %s: error copying private BFD data: %s\n",
|
||||||
program_name, bfd_errmsg (bfd_get_error ()));
|
program_name, bfd_get_filename (obfd),
|
||||||
|
bfd_errmsg (bfd_get_error ()));
|
||||||
status = 1;
|
status = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -290,8 +291,20 @@ copy_object (ibfd, obfd)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
osympp = isympp = (asymbol **) xmalloc (get_symtab_upper_bound (ibfd));
|
long symsize;
|
||||||
|
|
||||||
|
symsize = bfd_get_symtab_upper_bound (ibfd);
|
||||||
|
if (symsize < 0)
|
||||||
|
{
|
||||||
|
nonfatal (bfd_get_filename (ibfd));
|
||||||
|
}
|
||||||
|
|
||||||
|
osympp = isympp = (asymbol **) xmalloc (symsize);
|
||||||
symcount = bfd_canonicalize_symtab (ibfd, isympp);
|
symcount = bfd_canonicalize_symtab (ibfd, isympp);
|
||||||
|
if (symcount < 0)
|
||||||
|
{
|
||||||
|
nonfatal (bfd_get_filename (ibfd));
|
||||||
|
}
|
||||||
|
|
||||||
if (strip_symbols == strip_debug || discard_locals != locals_undef)
|
if (strip_symbols == strip_debug || discard_locals != locals_undef)
|
||||||
{
|
{
|
||||||
@ -560,7 +573,7 @@ copy_section (ibfd, isection, obfd)
|
|||||||
bfd *obfd;
|
bfd *obfd;
|
||||||
{
|
{
|
||||||
arelent **relpp;
|
arelent **relpp;
|
||||||
int relcount;
|
long relcount;
|
||||||
sec_ptr osection;
|
sec_ptr osection;
|
||||||
bfd_size_type size;
|
bfd_size_type size;
|
||||||
|
|
||||||
@ -578,17 +591,30 @@ copy_section (ibfd, isection, obfd)
|
|||||||
if (size == 0 || osection == 0)
|
if (size == 0 || osection == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (strip_symbols == strip_all
|
if (strip_symbols == strip_all)
|
||||||
|| bfd_get_reloc_upper_bound (ibfd, isection) == 0)
|
|
||||||
{
|
|
||||||
bfd_set_reloc (obfd, osection, (arelent **) NULL, 0);
|
bfd_set_reloc (obfd, osection, (arelent **) NULL, 0);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
relpp = (arelent **) xmalloc (bfd_get_reloc_upper_bound (ibfd, isection));
|
long relsize;
|
||||||
|
|
||||||
|
relsize = bfd_get_reloc_upper_bound (ibfd, isection);
|
||||||
|
if (relsize < 0)
|
||||||
|
{
|
||||||
|
nonfatal (bfd_get_filename (ibfd));
|
||||||
|
}
|
||||||
|
if (relsize == 0)
|
||||||
|
bfd_set_reloc (obfd, osection, (arelent **) NULL, 0);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
relpp = (arelent **) xmalloc (relsize);
|
||||||
relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, isympp);
|
relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, isympp);
|
||||||
|
if (relcount < 0)
|
||||||
|
{
|
||||||
|
nonfatal (bfd_get_filename (ibfd));
|
||||||
|
}
|
||||||
bfd_set_reloc (obfd, osection, relpp, relcount);
|
bfd_set_reloc (obfd, osection, relpp, relcount);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
isection->_cooked_size = isection->_raw_size;
|
isection->_cooked_size = isection->_raw_size;
|
||||||
isection->reloc_done = true;
|
isection->reloc_done = true;
|
||||||
@ -626,15 +652,22 @@ mark_symbols_used_in_relocations (ibfd, isection, symbols)
|
|||||||
sec_ptr isection;
|
sec_ptr isection;
|
||||||
asymbol **symbols;
|
asymbol **symbols;
|
||||||
{
|
{
|
||||||
|
long relsize;
|
||||||
arelent **relpp;
|
arelent **relpp;
|
||||||
unsigned int relcount, i;
|
long relcount, i;
|
||||||
|
|
||||||
/* Ignore an input section with no corresponding output section. */
|
/* Ignore an input section with no corresponding output section. */
|
||||||
if (isection->output_section == NULL)
|
if (isection->output_section == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
relpp = (arelent **) xmalloc (bfd_get_reloc_upper_bound (ibfd, isection));
|
relsize = bfd_get_reloc_upper_bound (ibfd, isection);
|
||||||
|
if (relsize < 0)
|
||||||
|
bfd_fatal (bfd_get_filename (ibfd));
|
||||||
|
|
||||||
|
relpp = (arelent **) xmalloc (relsize);
|
||||||
relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, symbols);
|
relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, symbols);
|
||||||
|
if (relcount < 0)
|
||||||
|
bfd_fatal (bfd_get_filename (ibfd));
|
||||||
|
|
||||||
/* Examine each symbol used in a relocation. If it's not one of the
|
/* Examine each symbol used in a relocation. If it's not one of the
|
||||||
special bfd section symbols, then mark it with BSF_KEEP. */
|
special bfd section symbols, then mark it with BSF_KEEP. */
|
||||||
|
@ -64,11 +64,8 @@ char *machine = (char *) NULL;
|
|||||||
/* The symbol table. */
|
/* The symbol table. */
|
||||||
asymbol **syms;
|
asymbol **syms;
|
||||||
|
|
||||||
/* Number of bytes allocated for `syms'. */
|
|
||||||
unsigned int storage;
|
|
||||||
|
|
||||||
/* Number of symbols in `syms'. */
|
/* Number of symbols in `syms'. */
|
||||||
unsigned int symcount = 0;
|
long symcount = 0;
|
||||||
|
|
||||||
/* Forward declarations. */
|
/* Forward declarations. */
|
||||||
|
|
||||||
@ -179,6 +176,7 @@ slurp_symtab (abfd)
|
|||||||
bfd *abfd;
|
bfd *abfd;
|
||||||
{
|
{
|
||||||
asymbol **sy = (asymbol **) NULL;
|
asymbol **sy = (asymbol **) NULL;
|
||||||
|
long storage;
|
||||||
|
|
||||||
if (!(bfd_get_file_flags (abfd) & HAS_SYMS))
|
if (!(bfd_get_file_flags (abfd) & HAS_SYMS))
|
||||||
{
|
{
|
||||||
@ -186,13 +184,18 @@ slurp_symtab (abfd)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
storage = get_symtab_upper_bound (abfd);
|
storage = bfd_get_symtab_upper_bound (abfd);
|
||||||
|
if (storage < 0)
|
||||||
|
bfd_fatal (bfd_get_filename (abfd));
|
||||||
|
|
||||||
if (storage)
|
if (storage)
|
||||||
{
|
{
|
||||||
sy = (asymbol **) xmalloc (storage);
|
sy = (asymbol **) xmalloc (storage);
|
||||||
}
|
}
|
||||||
symcount = bfd_canonicalize_symtab (abfd, sy);
|
symcount = bfd_canonicalize_symtab (abfd, sy);
|
||||||
if (symcount <= 0)
|
if (symcount < 0)
|
||||||
|
bfd_fatal (bfd_get_filename (abfd));
|
||||||
|
if (symcount == 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s: %s: Invalid symbol table\n",
|
fprintf (stderr, "%s: %s: Invalid symbol table\n",
|
||||||
program_name, bfd_get_filename (abfd));
|
program_name, bfd_get_filename (abfd));
|
||||||
@ -205,10 +208,10 @@ slurp_symtab (abfd)
|
|||||||
COUNT is the number of elements in SYMBOLS.
|
COUNT is the number of elements in SYMBOLS.
|
||||||
Return the number of useful symbols. */
|
Return the number of useful symbols. */
|
||||||
|
|
||||||
int
|
long
|
||||||
remove_useless_symbols (symbols, count)
|
remove_useless_symbols (symbols, count)
|
||||||
asymbol **symbols;
|
asymbol **symbols;
|
||||||
int count;
|
long count;
|
||||||
{
|
{
|
||||||
register asymbol **in_ptr = symbols, **out_ptr = symbols;
|
register asymbol **in_ptr = symbols, **out_ptr = symbols;
|
||||||
|
|
||||||
@ -267,9 +270,9 @@ objdump_print_address (vma, info)
|
|||||||
constantly churned by code doing heavy memory accesses. */
|
constantly churned by code doing heavy memory accesses. */
|
||||||
|
|
||||||
/* Indices in `syms'. */
|
/* Indices in `syms'. */
|
||||||
unsigned int min = 0;
|
long min = 0;
|
||||||
unsigned int max = symcount;
|
long max = symcount;
|
||||||
unsigned int thisplace;
|
long thisplace;
|
||||||
|
|
||||||
bfd_signed_vma vardiff;
|
bfd_signed_vma vardiff;
|
||||||
|
|
||||||
@ -308,7 +311,7 @@ objdump_print_address (vma, info)
|
|||||||
/* If this symbol isn't global, search for one with the same value
|
/* If this symbol isn't global, search for one with the same value
|
||||||
that is. */
|
that is. */
|
||||||
bfd_vma val = syms[thisplace]->value;
|
bfd_vma val = syms[thisplace]->value;
|
||||||
int i;
|
long i;
|
||||||
if (syms[thisplace]->flags & (BSF_LOCAL|BSF_DEBUGGING))
|
if (syms[thisplace]->flags & (BSF_LOCAL|BSF_DEBUGGING))
|
||||||
for (i = thisplace - 1; i >= 0; i--)
|
for (i = thisplace - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
@ -344,7 +347,7 @@ objdump_print_address (vma, info)
|
|||||||
no way to tell what's desired without looking at the relocation
|
no way to tell what's desired without looking at the relocation
|
||||||
table. */
|
table. */
|
||||||
struct objdump_disasm_info *aux;
|
struct objdump_disasm_info *aux;
|
||||||
int i;
|
long i;
|
||||||
|
|
||||||
aux = (struct objdump_disasm_info *) info->application_data;
|
aux = (struct objdump_disasm_info *) info->application_data;
|
||||||
if ((aux->abfd->flags & HAS_RELOC)
|
if ((aux->abfd->flags & HAS_RELOC)
|
||||||
@ -413,7 +416,7 @@ void
|
|||||||
disassemble_data (abfd)
|
disassemble_data (abfd)
|
||||||
bfd *abfd;
|
bfd *abfd;
|
||||||
{
|
{
|
||||||
bfd_size_type i;
|
long i;
|
||||||
unsigned int (*print) () = 0; /* Old style */
|
unsigned int (*print) () = 0; /* Old style */
|
||||||
disassembler_ftype disassemble = 0; /* New style */
|
disassembler_ftype disassemble = 0; /* New style */
|
||||||
struct disassemble_info disasm_info;
|
struct disassemble_info disasm_info;
|
||||||
@ -1065,8 +1068,7 @@ static void
|
|||||||
dump_symbols (abfd)
|
dump_symbols (abfd)
|
||||||
bfd *abfd;
|
bfd *abfd;
|
||||||
{
|
{
|
||||||
|
long count;
|
||||||
unsigned int count;
|
|
||||||
asymbol **current = syms;
|
asymbol **current = syms;
|
||||||
|
|
||||||
printf ("SYMBOL TABLE:\n");
|
printf ("SYMBOL TABLE:\n");
|
||||||
@ -1097,11 +1099,13 @@ dump_relocs (abfd)
|
|||||||
bfd *abfd;
|
bfd *abfd;
|
||||||
{
|
{
|
||||||
arelent **relpp;
|
arelent **relpp;
|
||||||
unsigned int relcount;
|
long relcount;
|
||||||
asection *a;
|
asection *a;
|
||||||
|
|
||||||
for (a = abfd->sections; a != (asection *) NULL; a = a->next)
|
for (a = abfd->sections; a != (asection *) NULL; a = a->next)
|
||||||
{
|
{
|
||||||
|
long relsize;
|
||||||
|
|
||||||
if (a == &bfd_abs_section)
|
if (a == &bfd_abs_section)
|
||||||
continue;
|
continue;
|
||||||
if (a == &bfd_und_section)
|
if (a == &bfd_und_section)
|
||||||
@ -1119,7 +1123,11 @@ dump_relocs (abfd)
|
|||||||
|
|
||||||
printf ("RELOCATION RECORDS FOR [%s]:", a->name);
|
printf ("RELOCATION RECORDS FOR [%s]:", a->name);
|
||||||
|
|
||||||
if (bfd_get_reloc_upper_bound (abfd, a) == 0)
|
relsize = bfd_get_reloc_upper_bound (abfd, a);
|
||||||
|
if (relsize < 0)
|
||||||
|
bfd_fatal (bfd_get_filename (abfd));
|
||||||
|
|
||||||
|
if (relsize == 0)
|
||||||
{
|
{
|
||||||
printf (" (none)\n\n");
|
printf (" (none)\n\n");
|
||||||
}
|
}
|
||||||
@ -1127,10 +1135,12 @@ dump_relocs (abfd)
|
|||||||
{
|
{
|
||||||
arelent **p;
|
arelent **p;
|
||||||
|
|
||||||
relpp = (arelent **) xmalloc (bfd_get_reloc_upper_bound (abfd, a));
|
relpp = (arelent **) xmalloc (relsize);
|
||||||
/* Note that this must be done *before* we sort the syms table. */
|
/* Note that this must be done *before* we sort the syms table. */
|
||||||
relcount = bfd_canonicalize_reloc (abfd, a, relpp, syms);
|
relcount = bfd_canonicalize_reloc (abfd, a, relpp, syms);
|
||||||
if (relcount == 0)
|
if (relcount < 0)
|
||||||
|
bfd_fatal (bfd_get_filename (abfd));
|
||||||
|
else if (relcount == 0)
|
||||||
{
|
{
|
||||||
printf (" (none)\n\n");
|
printf (" (none)\n\n");
|
||||||
}
|
}
|
||||||
@ -1253,7 +1263,7 @@ display_info_table (first, last)
|
|||||||
extern bfd_target *bfd_target_vector[];
|
extern bfd_target *bfd_target_vector[];
|
||||||
|
|
||||||
/* Print heading of target names. */
|
/* Print heading of target names. */
|
||||||
printf ("\n%*s", LONGEST_ARCH, " ");
|
printf ("\n%*s", (int) LONGEST_ARCH, " ");
|
||||||
for (t = first; t++ < last && bfd_target_vector[t];)
|
for (t = first; t++ < last && bfd_target_vector[t];)
|
||||||
printf ("%s ", bfd_target_vector[t]->name);
|
printf ("%s ", bfd_target_vector[t]->name);
|
||||||
putchar ('\n');
|
putchar ('\n');
|
||||||
@ -1261,7 +1271,8 @@ display_info_table (first, last)
|
|||||||
for (a = (int) bfd_arch_obscure + 1; a < (int) bfd_arch_last; a++)
|
for (a = (int) bfd_arch_obscure + 1; a < (int) bfd_arch_last; a++)
|
||||||
if (strcmp (bfd_printable_arch_mach (a, 0), "UNKNOWN!") != 0)
|
if (strcmp (bfd_printable_arch_mach (a, 0), "UNKNOWN!") != 0)
|
||||||
{
|
{
|
||||||
printf ("%*s ", LONGEST_ARCH - 1, bfd_printable_arch_mach (a, 0));
|
printf ("%*s ", (int) LONGEST_ARCH - 1,
|
||||||
|
bfd_printable_arch_mach (a, 0));
|
||||||
for (t = first; t++ < last && bfd_target_vector[t];)
|
for (t = first; t++ < last && bfd_target_vector[t];)
|
||||||
{
|
{
|
||||||
bfd_target *p = bfd_target_vector[t];
|
bfd_target *p = bfd_target_vector[t];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user