[Xcb] Thread safety of XCB.

Uli Schlachter psychon at znc.in
Wed Oct 3 12:53:35 PDT 2012


Hi,

On 03.10.2012 21:44, John Found wrote:
> On Wed, 3 Oct 2012 08:32:50 -0700
> Josh Triplett <josh at joshtriplett.org> wrote:
>> On Wed, Oct 03, 2012 at 01:08:42PM +0300, John Found wrote:
>>> What option -pthread actually do? Should I simply import some functions from libpthread.so or
>>> I must call some of them? Some initialization function maybe? 
>>> Or it means some flags in the interpreter segment set?
>>
>> Anything that causes your final ELF executable to have a direct
>> dependency ("NEEDED" in objdump -x output) on libpthread.so should
>> suffice; I think on most platforms -pthread does nothing more than
>> -lpthread, though on some platforms it does have some added semantics.
>>
>> - Josh Triplett
> 
> There is no NEEDED dynamic sections in FASM generated ELF binaries.
>
> Regardless of this absence, the version that uses libpthread for thread 
> management still works fine with XLib and the version that uses sys_clone,
> crashes miserably. 
> So, the conclusion is that this NEEDED section is not the cause of the
> problem.
> Here is what "objdump -x FreshProgram" returns:
[...]

I think objdump won't help here. Try readelf:

$ readelf -d /bin/bash

Dynamic section at offset 0xe4de0 contains 27 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libtinfo.so.5]
 0x0000000000000001 (NEEDED)             Shared library: [libdl.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000000000000c (INIT)               0x41f148
 0x000000000000000d (FINI)               0x4af8ac
 0x0000000000000019 (INIT_ARRAY)         0x6e4dc8
 0x000000000000001b (INIT_ARRAYSZ)       8 (bytes)
 0x000000000000001a (FINI_ARRAY)         0x6e4dd0
 0x000000000000001c (FINI_ARRAYSZ)       8 (bytes)
 0x0000000000000004 (HASH)               0x400298
 0x000000006ffffef5 (GNU_HASH)           0x4044c0
 0x0000000000000005 (STRTAB)             0x4147f8
 0x0000000000000006 (SYMTAB)             0x407bc8
 0x000000000000000a (STRSZ)              33822 (bytes)
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000015 (DEBUG)              0x0
 0x0000000000000003 (PLTGOT)             0x6e4fe8
 0x0000000000000002 (PLTRELSZ)           4824 (bytes)
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000017 (JMPREL)             0x41de70
 0x0000000000000007 (RELA)               0x41ddb0
 0x0000000000000008 (RELASZ)             192 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x000000006ffffffe (VERNEED)            0x41dd20
 0x000000006fffffff (VERNEEDNUM)         2
 0x000000006ffffff0 (VERSYM)             0x41cc16
 0x0000000000000000 (NULL)               0x0


Cheers,
Uli
-- 
- Buck, when, exactly, did you lose your mind?
- Three months ago. I woke up one morning married to a pineapple.
  An ugly pineapple... But I loved her.


More information about the Xcb mailing list