Forum Topic - GDB pre-built binaries require libpthread: (10 Items)
   
GDB pre-built binaries require libpthread  
I am trying to do some debugging on my system, I have the following error when I run gdb:

/root# gdb
"ldd:FATAL: Could not load library libpthread.so.1"

I have gdb version 7.6 but I have tried others like 6.7. I am using the ntox86-gdb binary downloaded from the Foundry27 
website.

I am running QNX6.5.
My compiler is gcc 4.8.3 in case that's of interest.

I don't understand how it can require libpthread? I thought qnx had all of its pthread stuff in libc? Isnt this a pre-
built binary?

What can I do to resolve this issue?

Ben
Attachment: HTML sf-attachment-mime26412 2.88 KB
Re: GDB pre-built binaries require libpthread  
Are you sure you copied over the right ntox86-gdb? And not a Linux host gdb?

From the nto-gdb-7.6.tar.gz:

$ ntox86-readelf -d ntox86-gdb  | grep NEEDED
 0x00000001 (NEEDED)                     Shared library: [libz.so.2]
 0x00000001 (NEEDED)                     Shared library: [libsocket.so.3]
 0x00000001 (NEEDED)                     Shared library: [libm.so.2]
 0x00000001 (NEEDED)                     Shared library: [libiconv.so.1]
 0x00000001 (NEEDED)                     Shared library: [liblzma.so.5]
 0x00000001 (NEEDED)                     Shared library: [libc.so.3]

No dependency on libpthread in the ntox86-gdb. Can you provide the output from readelf -l on the gdb binary?

Regards,

Ryan Mansfield
RE: GDB pre-built binaries require libpthread  
I absolutely downloaded the right one. Just for clarity sake I downloaded it again.

Nto-gdb-7.6.tar.gz

Extracts to :

host/qnx6/x86/usr/bin/ntox86-gdb

To make it executable I had to chmod +x it.

Then:

qnx:/root/gdb_build/host/qnx6/x86/usr/bin# ./ntox86-gdb 
ldd:FATAL: Could not load library libpthread.so.1

I also did this on it:

qnx:/root/gdb_build/host/qnx6/x86/usr/bin# ntox86-readelf -d ntox86-gdb  | grep NEEDED
 0x00000001 (NEEDED)                     Shared library: [libz.so.2]
 0x00000001 (NEEDED)                     Shared library: [libsocket.so.3]
 0x00000001 (NEEDED)                     Shared library: [libm.so.2]
 0x00000001 (NEEDED)                     Shared library: [libiconv.so.1]
 0x00000001 (NEEDED)                     Shared library: [liblzma.so.5]
 0x00000001 (NEEDED)                     Shared library: [libc.so.3]

And your right it doesn't say that it needs it but when I run it, it fails. 

Here is readelf -l

--------------------------------------------------------

qnx:/root/gdb_build/host/qnx6/x86/usr/bin# readelf -l ntox86-gdb 

Elf file type is EXEC (Executable file)
Entry point 0x804bc48
There are 6 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x08048034 0x00000000 0x000c0 0x000c0 R E 0x4
  INTERP         0x0000f4 0x080480f4 0x00000000 0x00014 0x00014 R   0x1
      [Requesting program interpreter: /usr/lib/ldqnx.so.2]
  LOAD           0x000000 0x08048000 0x08048000 0x3a3d2c 0x3a3d2c R E 0x1000
  LOAD           0x3a4000 0x083ec000 0x083ec000 0x08598 0x21b28 RW  0x1000
  DYNAMIC        0x3a4014 0x083ec014 0x00000000 0x000f0 0x000f0 RW  0x4
  NOTE           0x000108 0x08048108 0x00000000 0x00018 0x00018 R   0x1

 Section to Segment mapping:
  Segment Sections...
   00     
   01     .interp 
   02     .interp .note .hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.dyn .rel.plt .init .plt .text .fini .
rodata .eh_frame 
   03     .ctors .dtors .jcr .dynamic .data .got .bss 
   04     .dynamic 
   05     .note


Let me know what you think

Ben



-----Original Message-----
From: Ryan Mansfield [mailto:community-noreply@qnx.com] 
Sent: Wednesday, 27 August 2014 4:43 PM
To: general-toolchain
Subject: Re: GDB pre-built binaries require libpthread

Are you sure you copied over the right ntox86-gdb? And not a Linux host gdb?

From the nto-gdb-7.6.tar.gz:

$ ntox86-readelf -d ntox86-gdb  | grep NEEDED
 0x00000001 (NEEDED)                     Shared library: [libz.so.2]
 0x00000001 (NEEDED)                     Shared library: [libsocket.so.3]
 0x00000001 (NEEDED)                     Shared library: [libm.so.2]
 0x00000001 (NEEDED)                     Shared library: [libiconv.so.1]
 0x00000001 (NEEDED)                     Shared library: [liblzma.so.5]
 0x00000001 (NEEDED)                     Shared library: [libc.so.3]

No dependency on libpthread in the ntox86-gdb. Can you provide the output from readelf -l on the gdb binary?

Regards,

Ryan Mansfield



_______________________________________________

General
http://community.qnx.com/sf/go/post111566
To cancel your subscription to this discussion, please e-mail general-toolchain-unsubscribe@community.qnx.com
Re: RE: GDB pre-built binaries require libpthread  
Run DL_DEBUG=libs ./ntox86-gdb to see what's trying to load it

I downloaded the posted package and confirmed there's no libpthread being loaded for me.  Perhaps a library dependency 
(e.g one of the NEEDED in the ntox86-gdb) was copied from Linux that has a NEEDED subsequent dependency on libpthread. 
As you mentioned,  QNX binaries shouldn't be depending on libpthread.

Regards,

Ryan Mansfield
RE: RE: GDB pre-built binaries require libpthread  
Here is the output from that:

qnx:/root/gdb_build/host/qnx6/x86/usr/bin# DL_DEBUG=libs ./ntox86-gdb 
libs: load_object: attempt load of libz.so.2
libs: /usr/lib/libz.so.2: found; real path:/usr/lib/libz.so.2
libs: load_elf32: loaded lib at addr b8200000(text) b8210b3c(data)
libs: object libz.so.2 loaded; real soname: libz.so.2 loaded from: /usr/lib/libz.so.2
libs: load_object: attempt load of libsocket.so.3
libs: /lib/libsocket.so.3: found; real path:/lib/libsocket.so.3
libs: load_elf32: loaded lib at addr b8211000(text) b823a94c(data)
libs: object libsocket.so.3 loaded; real soname: libsocket.so.3 loaded from: /lib/libsocket.so.3
libs: load_object: attempt load of libm.so.2
libs: /lib/libm.so.2: found; real path:/lib/libm.so.2
libs: load_elf32: loaded lib at addr b8241000(text) b826ee7c(data)
libs: object libm.so.2 loaded; real soname: libm.so.2 loaded from: /lib/libm.so.2
libs: load_object: attempt load of libiconv.so.1
libs: /usr/local/lib/libiconv.so.1: found; real path:/usr/local/lib/libiconv.so.7
libs: load_elf32: loaded lib at addr b8274000(text) b8359000(data)
libs: object libiconv.so.1 loaded; real soname: libiconv.so.7 loaded from: /usr/local/lib/libiconv.so.7
libs: load_object: attempt load of liblzma.so.5
libs: /usr/local/lib/liblzma.so.5: found; real path:/usr/local/lib/liblzma.so.5
libs: load_elf32: loaded lib at addr b835a000(text) b8379a90(data)
libs: object liblzma.so.5 loaded; real soname: liblzma.so.5 loaded from: /usr/local/lib/liblzma.so.5
libs: load_object: attempt load of libpthread.so.1
ldd:FATAL: Could not load library libpthread.so.1

I did have to source liblzma, I thought I got it from the pkg-add site though.

-----Original Message-----
From: Ryan Mansfield [mailto:community-noreply@qnx.com] 
Sent: Wednesday, 27 August 2014 5:11 PM
To: general-toolchain
Subject: Re: RE: GDB pre-built binaries require libpthread

Run DL_DEBUG=libs ./ntox86-gdb to see what's trying to load it

I downloaded the posted package and confirmed there's no libpthread being loaded for me.  Perhaps a library dependency 
(e.g one of the NEEDED in the ntox86-gdb) was copied from Linux that has a NEEDED subsequent dependency on libpthread. 
As you mentioned,  QNX binaries shouldn't be depending on libpthread.

Regards,

Ryan Mansfield



_______________________________________________

General
http://community.qnx.com/sf/go/post111568
To cancel your subscription to this discussion, please e-mail general-toolchain-unsubscribe@community.qnx.com
RE: RE: GDB pre-built binaries require libpthread  
Yep, I confirmed, it was liblzma that needs it, I Must have got the linux package, where can I find the package for this
?

I tried the  lzmalib-0.0.1.tgz	provided here:

ftp://ftp.netbsd.org/pub/pkgsrc/packages/QNX/i386/6.5.0_head_20110826/All/

But it doesn't have the liblzma.so.5 lib needed by gdb.

Where do you get this package from?



-----Original Message-----
From: Ryan Mansfield [mailto:community-noreply@qnx.com] 
Sent: Wednesday, 27 August 2014 5:11 PM
To: general-toolchain
Subject: Re: RE: GDB pre-built binaries require libpthread

Run DL_DEBUG=libs ./ntox86-gdb to see what's trying to load it

I downloaded the posted package and confirmed there's no libpthread being loaded for me.  Perhaps a library dependency 
(e.g one of the NEEDED in the ntox86-gdb) was copied from Linux that has a NEEDED subsequent dependency on libpthread. 
As you mentioned,  QNX binaries shouldn't be depending on libpthread.

Regards,

Ryan Mansfield



_______________________________________________

General
http://community.qnx.com/sf/go/post111568
To cancel your subscription to this discussion, please e-mail general-toolchain-unsubscribe@community.qnx.com
Re: RE: RE: GDB pre-built binaries require libpthread  
I believe it's packaged as part of QNX 6.6.0. Here's a copy

Regards,

Ryan Mansfield
Attachment: Text liblzma.so.5 193.77 KB
RE: RE: RE: GDB pre-built binaries require libpthread  
Hi Ryan,

Now I am getting a runtime linking error:

unknown symbol: __stack_chk_guard
ldd:FATAL: Could not resolve all symbols


Is there a compatibility issue between 6.6 and 6.5?

Ben

-----Original Message-----
From: Ryan Mansfield [mailto:community-noreply@qnx.com] 
Sent: Wednesday, 27 August 2014 5:58 PM
To: general-toolchain
Subject: Re: RE: RE: GDB pre-built binaries require libpthread

I believe it's packaged as part of QNX 6.6.0. Here's a copy

Regards,

Ryan Mansfield



_______________________________________________

General
http://community.qnx.com/sf/go/post111571
To cancel your subscription to this discussion, please e-mail general-toolchain-unsubscribe@community.qnx.com
Re: RE: RE: RE: GDB pre-built binaries require libpthread  
Yes, the 6.6.0 binaries are built with stack protection that requires support in libc, so 6.6.0 binaries wouldnt run on 
a 6.5.0 system (off the top of my head I think that made it into the 6.5.0SP1 libc). The gdb 7.6 packages posted was 
built and configured for a 6.6.0 system.  

We can post self hosted packages for 6.5.0 but I don't have anything in head to give you at the moment.  Stay tuned. 

You should be able to use the last gdb 7.5 package though, as I believe it was configured for 6.5.0.

Regards,

Ryan Mansfield
RE: RE: RE: RE: GDB pre-built binaries require libpthread  
Ok Ryan thanks,

I got that working. 

So if you feel like it a gdb 7.6 package for QNX6.5 would be fantastic. 

Ben

-----Original Message-----
From: Ryan Mansfield [mailto:community-noreply@qnx.com] 
Sent: Wednesday, 27 August 2014 6:11 PM
To: general-toolchain
Subject: Re: RE: RE: RE: GDB pre-built binaries require libpthread

Yes, the 6.6.0 binaries are built with stack protection that requires support in libc, so 6.6.0 binaries wouldnt run on 
a 6.5.0 system (off the top of my head I think that made it into the 6.5.0SP1 libc). The gdb 7.6 packages posted was 
built and configured for a 6.6.0 system.  

We can post self hosted packages for 6.5.0 but I don't have anything in head to give you at the moment.  Stay tuned. 

You should be able to use the last gdb 7.5 package though, as I believe it was configured for 6.5.0.

Regards,

Ryan Mansfield




_______________________________________________

General
http://community.qnx.com/sf/go/post111573
To cancel your subscription to this discussion, please e-mail general-toolchain-unsubscribe@community.qnx.com