Thread: /usr/bin/ld: errno: TLS definition in /lib/libc.so.6

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    20

    Post /usr/bin/ld: errno: TLS definition in /lib/libc.so.6

    hello.
    Getting this error when compile my program. I assume that perhaps can be library problem. can any one tell me right answer.........

    Problem is...........
    /usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference in /tmp/ccUV4UJJ.o
    /lib/libc.so.6: could not read symbols: Bad value
    collect2: ld returned 1 exit status
    and all the header file......

    Code:
    #include <netdb.h>
    #include <signal.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <arpa/inet.h>
    #include <fcntl.h>
    #include <syslog.h>
    #include <sys/ioctl.h>
    #ifdef __GLIBC__
    #include <net/if.h>
    #include <netinet/ip.h>
    #include <netinet/tcp.h>
    #else
    #include <stdlib.h> /* some of these were included in the original */
    #include <unistd.h> /* but not really needed */
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <sys/wait.h>
    #include <sys/stat.h>
    #include <netinet/in.h>
    #include <linux/ip.h>
    #include <linux/tcp.h>
    #endif
    
    extern int errno;
    
    #ifndef NOFILE
    #define NOFILE 1024
    #endif

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Simple answer:
    Just include <errno.h> in your source, and remove the extern int errno;

    More detailed answer:
    errno is not always a single int - in this case, the linker is telling you that there is a TLS (Thread local storage) version of errno - so errno is something like this:

    pseudo linux-code
    Code:
    #define errno() *errnofunc()
    
    int *errnofunc() 
    {
        int *errnoptr = get_thread_data(ERRNOPTR);
        return errnoptr;
    }
    --
    Mats


    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Feb 2009
    Posts
    9
    Well, on old programs, one often meets
    symbol errno, version GLIBC_2.0 not defined in file libc.so.6 with link time reference
    error, so I made a little library with
    Code:
    extern int (* __errno_location);
    int errno()
    {
      return(*__errno_location);
        }
    and preload this library with LD_PRELOAD. This always me to use olds programs like Maple 5 or 7 on recent linux (Debian Etch for instance). But since libc 2.7 there is errors if I try to recompile this library, looking what gcc -E gives to #include <errno.h> and i=errno(); I change this program to
    Code:
    extern int *__errno_location (void) __attribute__ ((__nothrow__)) __attribute__ ((__const__));
    int errno ()
    {
      return((*__errno_location ()));
        }
    good compilation but
    Code:
    $ gcc -shared -Wl,-soname,lib-errno -o lib-errno.so lib-errno.o
    give
    errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS definition in lib-errno.o section .tex
    I try to find your pseudo code or something like in the includes files but I fails. Do you have a suggestion?

    Sorry if you think I stool the thread, but I thought it's the same subject.

    Really sorry for my English, I'm French and try to write good English but... see the result

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    We have a rule about waking old (dead) threads. A moderator may want to split this off into a new thread.

    Further, I'm not sure what the actual QUESTION is that you want answered - or are you just stating something?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Feb 2009
    Posts
    9
    Sorry, I make a new thread and make my question more «precise»...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  3. DLL compiling question
    By Noose in forum Windows Programming
    Replies: 2
    Last Post: 12-16-2004, 07:16 AM
  4. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM