This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/21913] static binaries SIGSEGV in __brk when host's gcc is pie-by-default (i386)


https://sourceware.org/bugzilla/show_bug.cgi?id=21913

--- Comment #9 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, hjl/pr21913/master has been created
        at  99dd28489e425c6f654126871f89d514331aa69f (commit)

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=99dd28489e425c6f654126871f89d514331aa69f

commit 99dd28489e425c6f654126871f89d514331aa69f
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Jul 19 14:32:42 2017 -0700

    i386: Add <startup.h> [BZ #21913]

    On Linux/i386, there are 3 ways to make a system call:

    1. call *%gs:SYSINFO_OFFSET.  This requires TLS initialization.
    2. call *_dl_sysinfo.  This requires relocation of _dl_sysinfo.
    3. int $0x80.  This is slower than #2 and #3, but works everywhere.

    When an object file is compiled with PIC, #1 is prefered since it is
    faster than #3 and doesn't require relocation of _dl_sysinfo.  For
    dynamic executables, ld.so initializes TLS.  However, for static
    executables, before TLS is initialized by __libc_setup_tls, #3 should
    be used for syscalls.

    This patch adds <startup.h> which defines _startup_fatal and defaults
    it to __libc_fatal.  It replaces __libc_fatal with _startup_fatal in
    static executables where it is called before __libc_setup_tls is called.
    This header file is included in all files containing functions which are
    called before __libc_setup_tls is called.  On Linux/i386, when PIE is
    enabled by default, _startup_fatal is turned into ABORT_INSTRUCTION and
    I386_USE_SYSENTER is defined to 0 so that "int $0x80" is used for system
    calls before __libc_setup_tls is called.

        [BZ #21913]
        * config.h.in (BUILD_PIE_DEFAULT): New.
        * csu/libc-tls.c: Include <startup.h>.
        * elf/dl-tunables.c: Likewise.
        * sysdeps/unix/sysv/linux/i386/brk.c: Likewise.
        * csu/libc-tls.c: Include <startup.h>.
        (__libc_setup_tls): Call _startup_fatal instead of __libc_fatal.
        * sysdeps/generic/startup.h: New file.
        * sysdeps/unix/sysv/linux/i386/startup.h: Likewise.

-----------------------------------------------------------------------

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]