core/linux/os.c
/* With KEEP_SYMBOLS_FOR_LIBC_BACKTRACE our __errno_location gets interpreted
 * in the code cache and on x64 we hit an assert on our own segment use
 * in get_thread_private_dcontext():
 *   "no support yet for application using non-NPTL segment"
 * That is now relaxed for code in the DR library.
 * FIXME: though we used to use this for the app too: presumably we don't
 * need that anymore, since having our own private copy is just as good
 * to isolate DR errno changes from app errno uses.
 * Update: i#238/PR 499179: this isolates usage in our library, but not
 * when we call libc routines.  Also, even when not "hidden", we control
 * the app's errno but not libc's: b/c __errno_location is no longer weak?
 */
With KEEP_SYMBOLS_FOR_LIBC_BACKTRACE our __errno_location gets interpreted
in the code cache and on x64 we hit an assert on our own segment use
in get_thread_private_dcontext():
"no support yet for application using non-NPTL segment"
That is now relaxed for code in the DR library.
FIXME: though we used to use this for the app too: presumably we don't
need that anymore, since having our own private copy is just as good
to isolate DR errno changes from app errno uses.
Update: i#238/PR 499179: this isolates usage in our library, but not
when we call libc routines.
With KEEP_SYMBOLS_FOR_LIBC_BACKTRACE our __errno_location gets interpreted in the code cache and on x64 we hit an assert on our own segment use in get_thread_private_dcontext () : " no support yet for application using non - NPTL segment " That is now relaxed for code in the DR library . FIXME : though we used to use this for the app too : presumably we don ' t need that anymore since having our own private copy is just as good to isolate DR errno changes from app errno uses . Update : i#238 / PR 499179 : this isolates usage in our library but not when we call libc routines .
__attribute__ ((visibility ("hidden")))
int *
__errno_location(void) {
    dcontext_t *dcontext = get_thread_private_dcontext();
    if (dcontext == NULL)
        return &init_errno;
    else {
        return &(dcontext->upcontext_ptr->errno);
    }
}
__attribute__ ( ( visibility ( " " ) ) ) int * __errno_location ( void ) { dcontext_t * dcontext = get_thread_private_dcontext ( ) ; if ( dcontext == NULL ) return & init_errno ; else { return & ( dcontext -> upcontext_ptr -> errno ) ; } }
With KEEP_SYMBOLS_FOR_LIBC_BACKTRACE our __errno_location gets interpreted
 in the code cache and on x64 we hit an assert on our own segment use
 in get_thread_private_dcontext():
   "no support yet for application using non-NPTL segment"
 That is now relaxed for code in the DR library.
With KEEP_SYMBOLS_FOR_LIBC_BACKTRACE our __errno_location gets interpreted in the code cache and on x64 we hit an assert on our own segment use in get_thread_private_dcontext () : " no support yet for application using non - NPTL segment " That is now relaxed for code in the DR library .
/* Each dynamo thread should have a separate errno */ /* WARNING: init_errno is in data segment so can be RO! */