mirror of
git://sourceware.org/git/glibc.git
synced 2024-11-27 03:41:23 +08:00
Use hidden visibility for early static PIE code
Extern symbol access in position independent code usually involves GOT indirection which needs RELATIVE reloc in a static linked PIE. (On some targets this is avoided e.g. because the linker can relax a GOT access to a pc-relative access, but this is not generally true.) Code that runs before static PIE self relocation must avoid relying on dynamic relocations which can be ensured by using hidden visibility. However we cannot just make all symbols hidden: On i386, all calls to IFUNC functions must go through PLT and calls to hidden functions CANNOT go through PLT in PIE since EBX used in PIE PLT may not be set up for local calls to hidden IFUNC functions. This patch aims to make symbol references hidden in code that is used before and by _dl_relocate_static_pie when building a static PIE libc. Note: for an object that is used in the startup code, its references and definition may not have consistent visibility: it is only forced hidden in the startup code. This is needed for fixing bug 27072. Co-authored-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
parent
04af1eb313
commit
47618209d0
@ -15,6 +15,10 @@
|
||||
License along with the GNU C Library; if not, see
|
||||
<https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Mark symbols hidden in static PIE for early self relocation to work. */
|
||||
#if BUILD_PIE_DEFAULT
|
||||
# pragma GCC visibility push(hidden)
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
@ -17,6 +17,8 @@
|
||||
<https://www.gnu.org/licenses/>. */
|
||||
|
||||
#if ENABLE_STATIC_PIE
|
||||
/* Mark symbols hidden in static PIE for early self relocation to work. */
|
||||
# pragma GCC visibility push(hidden)
|
||||
#include <unistd.h>
|
||||
#include <ldsodefs.h>
|
||||
#include "dynamic-link.h"
|
||||
|
@ -19,6 +19,12 @@
|
||||
/* This file defines some things that for the dynamic linker are defined in
|
||||
rtld.c and dl-sysdep.c in ways appropriate to bootstrap dynamic linking. */
|
||||
|
||||
#include <string.h>
|
||||
/* Mark symbols hidden in static PIE for early self relocation to work.
|
||||
Note: string.h may have ifuncs which cannot be hidden on i686. */
|
||||
#if BUILD_PIE_DEFAULT
|
||||
# pragma GCC visibility push(hidden)
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <libintl.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -18,6 +18,10 @@
|
||||
License along with the GNU C Library; if not, see
|
||||
<https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Mark symbols hidden in static PIE for early self relocation to work. */
|
||||
#if BUILD_PIE_DEFAULT
|
||||
# pragma GCC visibility push(hidden)
|
||||
#endif
|
||||
#include <startup.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -19,6 +19,10 @@
|
||||
/* This file is used in the static libc. For the shared library,
|
||||
dl-sysdep.c defines and initializes __libc_enable_secure. */
|
||||
|
||||
/* Mark symbols hidden in static PIE for early self relocation to work. */
|
||||
#if BUILD_PIE_DEFAULT
|
||||
# pragma GCC visibility push(hidden)
|
||||
#endif
|
||||
#include <startup.h>
|
||||
#include <libc-internal.h>
|
||||
|
||||
|
@ -15,6 +15,10 @@
|
||||
License along with the GNU C Library; if not, see
|
||||
<https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Mark symbols hidden in static PIE for early self relocation to work. */
|
||||
#if BUILD_PIE_DEFAULT
|
||||
# pragma GCC visibility push(hidden)
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <libc-internal.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -17,6 +17,11 @@
|
||||
<https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef SHARED
|
||||
|
||||
/* Mark symbols hidden in static PIE for early self relocation to work. */
|
||||
# if BUILD_PIE_DEFAULT
|
||||
# pragma GCC visibility push(hidden)
|
||||
# endif
|
||||
# include <ldsodefs.h>
|
||||
# include <cpu-features.c>
|
||||
|
||||
|
@ -16,6 +16,11 @@
|
||||
<https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef SHARED
|
||||
|
||||
/* Mark symbols hidden in static PIE for early self relocation to work. */
|
||||
# if BUILD_PIE_DEFAULT
|
||||
# pragma GCC visibility push(hidden)
|
||||
# endif
|
||||
/* Define I386_USE_SYSENTER to support syscall during startup in static
|
||||
PIE. */
|
||||
# include <startup.h>
|
||||
|
Loading…
Reference in New Issue
Block a user