• R
    add thread-pointer support for pre-2.6 kernels on i386 · 64e32287
    Rich Felker 提交于
    such kernels cannot support threads, but the thread pointer is also
    important for other purposes, most notably stack protector. without a
    valid thread pointer, all code compiled with stack protector will
    crash. the same applies to any use of thread-local storage by
    applications or libraries.
    
    the concept of this patch is to fall back to using the modify_ldt
    syscall, which has been around since linux 1.0, to setup the gs
    segment register. since the kernel does not have a way to
    automatically assign ldt entries, use of slot zero is hard-coded. if
    this fallback path is used, __set_thread_area returns a positive value
    (rather than the usual zero for success, or negative for error)
    indicating to the caller that the thread pointer was successfully set,
    but only for the main thread, and that thread creation will not work
    properly. the code in __init_tp has been changed accordingly to record
    this result for later use by pthread_create.
    64e32287
__init_tls.c 2.6 KB