Bug 10151 - libbfd: adr2errline resolution does not work for 32bit programs on x86_64 plattforms
Summary: libbfd: adr2errline resolution does not work for 32bit programs on x86_64 pla...
Status: RESOLVED INVALID
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.19
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-13 10:51 UTC by Elmar Stellnberger
Modified: 2009-05-20 10:36 UTC (History)
1 user (show)

See Also:
Host: x86_64
Target: i686-pc-linux-gnu
Build: ELF32, Intel 80386
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Elmar Stellnberger 2009-05-13 10:51:11 UTC
Using the addr2errline sample program from
http://linuxgazette.net/151/misc/melinte/addr2line.c
I get the following results:

> gcc addr2errline.c -o addr2errline -lbfd -liberty -lz
> ./addr2errline getlineno 0x804b335 0x804b2aa
main [getlineno.c:61]
ThisLine [getlineno.c:49]

> gcc -m32 addr2errline.c -o addr2errline -lbfd -liberty -lz
> ./addr2errline getlineno 0x804b335 0x804b2aa
>  ** no result, nothing found, 0 lines of output **

It does not depend on the library version. If I link against old 32bit bfd &
liberty librays from x86_32 days of OpenSuse10.1 it does not work either.
Perhaps this is some general incompatibility of 32/64bit plattforms.

Debugging addr2errline.c I found that the error turns out at the following
point:
slurp_symtab(bfd *abfd)
{
...
    if ((bfd_get_file_flags(abfd) & HAS_SYMS) == 0)
        return -1;

binutils-2.19-9.3
Comment 1 H.J. Lu 2009-05-18 18:11:48 UTC
I don't think you can use -m32 with bfd on Linux/x86-64 unless
you are using 32bit binutils header files.
Comment 2 Elmar Stellnberger 2009-05-20 10:36:23 UTC
thx. That was in deed the issue.
... although it should not be too hard to provide common headers for both 32 & 
64bit targets as the only differences are the following lines in bfd.h:

#define BFD_DEFAULT_TARGET_SIZE 32

#define BFD_HOST_64BIT_LONG 0
#define BFD_HOST_64BIT_LONG_LONG 1
#if 1
#define BFD_HOST_64_BIT long long
#define BFD_HOST_U_64_BIT unsigned long long
#endif

or that respectively:

#define BFD_DEFAULT_TARGET_SIZE 64

#define BFD_HOST_64BIT_LONG 1
#define BFD_HOST_64BIT_LONG_LONG 0
#define BFD_HOST_64_BIT long
#define BFD_HOST_U_64_BIT unsigned long