This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Bugzilla bug 493 - libbfd seg fault
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Niels Christiansen <nchr at us dot ibm dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Thu, 13 Dec 2001 12:59:47 +1030
- Subject: Re: Bugzilla bug 493 - libbfd seg fault
- References: <OF7D9D3BF1.E78E9B4C-ON85256B21.000B0F08@raleigh.ibm.com>
On Wed, Dec 12, 2001 at 09:04:37PM -0500, Niels Christiansen wrote:
> Alan,
>
> This code works just fine on Linux IA32 and AIX PPC. Adding bfd_init()
> makes no difference. set_default_bfd_target() seems to be a function used
> only by binutils when you want to look at binaries from a different
> platform and is unresolved if I try to use it, so obviously not in the
> library.
Um, OK, set_default_bfd_target is a wrapper in bucomm.c. Applying this
patch:
--- bfdtest.c~ Thu Dec 13 09:55:33 2001
+++ bfdtest.c Thu Dec 13 11:50:07 2001
@@ -22,6 +22,14 @@
printf("Usage: %s kernel-image\n", argv[0]);
exit(1);
}
+
+ bfd_init ();
+ if (! bfd_set_default_target ("powerpc-unknown-linux-gnu"))
+ {
+ perror("bfd_set_default_target");
+ exit(1);
+ }
+
if ((ibfd = (bfd_openr(argv[1], NULL))) == NULL)
{
perror("bfd_openr");
gives me the following
alan@pepper:~/bfdtest$ ./bfdtest bfdtest | tail
_bfd_generic_get_section_contents_in_window
_bfd_elf_reloc_type_class
coff_find_nearest_line
bfd_get_section_by_name
_bfd_elf_link_hash_table_create
bfd_set_arch_info
bfd_elf32_big_generic_vec
__gmon_start__
strcpy@@GLIBC_2.0
bfd_link_hash_lookup