[BUG] error in global variables strong aliasing

Amir Shalem amir at boom.org.il
Sat Mar 18 19:36:05 UTC 2006


hey,


after commit http://www.uclibc.org/lists/uclibc-cvs/2006-March/009686.html

global variables such as environ, errno, and friends are broken

when compiling against uclibc dynamiclly only.


you can check it out using:


/* errno and _errno are strongly aliased */

extern int errno;

extern int _errno;


int main(void)

{
    errno = 0;

    _errno = 1;

    printf("errno: %d _errno: %d\n", errno, _errno);

    return 0;

}


if you compile this program staticlly you will see same result (=1) in 
both variables,

but if you compile this program dynamiclly you will see diffrent results.


same happens with __environ & environ.


if changing to weak_alias (instead of strong_alias) it works again.


you can simulate this bug by creating a library from:

         int var = 0;

         extern int var2 __attribute__ ((alias ("var")));


and then play with 'var' and 'var2'.


I have manage to reproduce it with gcc 3.4.4 + binutils 2.15 + FreeBSD 6.1,

and using gcc 4.1.0 + binutils 2.16.1 + uClibc 20060317


Amir.





More information about the uClibc mailing list