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: "Niels Christiansen" <nchr at us dot ibm dot com>
- To: Alan Modra <amodra at bigpond dot net dot au>
- Cc: binutils at sources dot redhat dot com
- Date: Wed, 12 Dec 2001 21:48:06 -0500
- Subject: Re: Bugzilla bug 493 - libbfd seg fault
Why powerpc? Anyway, with your patch I still get a seg fault. If I
reverse the condition on the test for bfd_set_default_target(), what I get
is:
[nchris@tollway bfdtest]$ ./bfdtest bfdtest
bfd_set_default_target: Success
[nchris@tollway bfdtest]$
...so that looks okay. Since this is on Linux IA64 I tried using "ia64" in
place of "powerpc"? It works just like "powerpc".
Niels
Alan Modra
<amodra@bigpon To: Niels Christiansen/Austin/IBM@IBMUS
d.net.au> cc: binutils@sources.redhat.com
Subject: Re: Bugzilla bug 493 - libbfd seg fault
12/12/2001
08:29 PM
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