Comment 3 for bug 1248642

Revision history for this message
Kate Alhola (kate-alhola) wrote :

The issue is that for some reason it gets libpthread.so.0 referenced but not listed as in a.out NEDED section

1. Conpile std::string s; commented out, it works, do objdump -pR a.out
Dynamic Section:
  NEEDED libGL.so.1
  NEEDED libc.so.6
Version References:
  required from libc.so.6:
    0x09691a75 0x00 02 GLIBC_2.2.5

2. Do same thing the std::string line active , notice that libpthreas.so.0 is not NEEDED but it is in version referennces and there is __pthread_key_create symbol and you got the bug
Dynamic Section:
  NEEDED libGL.so.1
  NEEDED libstdc++.so.6
  NEEDED libgcc_s.so.1
  NEEDED libc.so.6
Version References:
  required from libgcc_s.so.1:
    0x0b792650 0x00 06 GCC_3.0
  required from libpthread.so.0:
    0x09691a75 0x00 04 GLIBC_2.2.5
  required from libc.so.6:
    0x09691a75 0x00 03 GLIBC_2.2.5
  required from libstdc++.so.6:
    0x056bafd3 0x00 05 CXXABI_1.3
    0x08922974 0x00 02 GLIBCXX_3.4

DYNAMIC RELOCATION RECORDS
OFFSET TYPE VALUE
0000000000600ff8 R_X86_64_GLOB_DAT __gmon_start__
0000000000601018 R_X86_64_JUMP_SLOT _ZNSsC1Ev
0000000000601020 R_X86_64_JUMP_SLOT glEnable
0000000000601028 R_X86_64_JUMP_SLOT __gmon_start__
0000000000601030 R_X86_64_JUMP_SLOT __libc_start_main
0000000000601038 R_X86_64_JUMP_SLOT _ZNSsD1Ev
0000000000601040 R_X86_64_JUMP_SLOT __pthread_key_create

3. Add call to pthread , it woirks again
 #include <pthread.h>
#include <string>
#include <GL/gl.h>
int main(int argc, char *argv[]) {
  std::string s;
 glEnable(GL_LIGHT0);
 int i=pthread_getconcurrency();
}

And objdump looks now
Dynamic Section:
  NEEDED libGL.so.1
  NEEDED libstdc++.so.6
  NEEDED libgcc_s.so.1
  NEEDED libpthread.so.0
  NEEDED libc.so.6