public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH] ld.so: Replace (&bootstrap_map) with BOOTSTRAP_MAP
Date: Mon, 02 Oct 2017 22:00:00 -0000	[thread overview]
Message-ID: <CAMe9rOq0m0NtOzj5Gr=6=yA76BAnx3MCqwnUp-TW42uFxabzAg@mail.gmail.com> (raw)
In-Reply-To: <20170929213843.GU2482@gmail.com>

On 9/29/17, H.J. Lu <hjl.tools@gmail.com> wrote:
> (&_dl_main_map) is used instead of (&bootstrap_map) to bootstrap static
> PIE.  Define BOOTSTRAP_MAP with (&_dl_main_map) to avoid hardcode to
> (&bootstrap_map).
>
> Tested on x86-64.  OK for master?
>
>
> H.J.
> ---
> 	* elf/rtld.c (BOOTSTRAP_MAP): New.
> 	(RESOLVE_MAP): Replace (&bootstrap_map) with BOOTSTRAP_MAP.
> 	* sysdeps/hppa/dl-machine.h (ELF_MACHINE_BEFORE_RTLD_RELOC):
> 	Likewise.
> 	* sysdeps/ia64/dl-machine.h (ELF_MACHINE_BEFORE_RTLD_RELOC):
> 	Likewise.
> 	* sysdeps/mips/dl-machine.h (ELF_MACHINE_BEFORE_RTLD_RELOC):
> 	Likewise.
> ---
>  elf/rtld.c                | 3 ++-
>  sysdeps/hppa/dl-machine.h | 2 +-
>  sysdeps/ia64/dl-machine.h | 2 +-
>  sysdeps/mips/dl-machine.h | 2 +-
>  4 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/elf/rtld.c b/elf/rtld.c
> index d8e75c02e6..90505aee7d 100644
> --- a/elf/rtld.c
> +++ b/elf/rtld.c
> @@ -454,7 +454,8 @@ _dl_start (void *arg)
>       Since ld.so must not have any undefined symbols the result
>       is trivial: always the map of ld.so itself.  */
>  #define RTLD_BOOTSTRAP
> -#define RESOLVE_MAP(sym, version, flags) (&bootstrap_map)
> +#define BOOTSTRAP_MAP (&bootstrap_map)
> +#define RESOLVE_MAP(sym, version, flags) BOOTSTRAP_MAP
>  #include "dynamic-link.h"
>
>    if (HP_TIMING_INLINE && HP_SMALL_TIMING_AVAIL)
> diff --git a/sysdeps/hppa/dl-machine.h b/sysdeps/hppa/dl-machine.h
> index e24bd25c63..acfb9fc31f 100644
> --- a/sysdeps/hppa/dl-machine.h
> +++ b/sysdeps/hppa/dl-machine.h
> @@ -62,7 +62,7 @@ __hppa_init_bootstrap_fdesc_table (struct link_map *map)
>  }
>
>  #define ELF_MACHINE_BEFORE_RTLD_RELOC(dynamic_info)		\
> -	__hppa_init_bootstrap_fdesc_table (&bootstrap_map);	\
> +	__hppa_init_bootstrap_fdesc_table (BOOTSTRAP_MAP);	\
>  	_dl_fptr_init();
>
>  /* Return nonzero iff ELF header is compatible with the running host.  */
> diff --git a/sysdeps/ia64/dl-machine.h b/sysdeps/ia64/dl-machine.h
> index 8d0d3c97dd..b56f1c8194 100644
> --- a/sysdeps/ia64/dl-machine.h
> +++ b/sysdeps/ia64/dl-machine.h
> @@ -45,7 +45,7 @@ __ia64_init_bootstrap_fdesc_table (struct link_map *map)
>  }
>
>  #define ELF_MACHINE_BEFORE_RTLD_RELOC(dynamic_info)		\
> -	__ia64_init_bootstrap_fdesc_table (&bootstrap_map);
> +	__ia64_init_bootstrap_fdesc_table (BOOTSTRAP_MAP);
>
>  /* Return nonzero iff ELF header is compatible with the running host.  */
>  static inline int __attribute__ ((unused))
> diff --git a/sysdeps/mips/dl-machine.h b/sysdeps/mips/dl-machine.h
> index 74ead7f524..da9d6332ea 100644
> --- a/sysdeps/mips/dl-machine.h
> +++ b/sysdeps/mips/dl-machine.h
> @@ -190,7 +190,7 @@ elf_machine_load_address (void)
>     fiddles with global data.  */
>  #define ELF_MACHINE_BEFORE_RTLD_RELOC(dynamic_info)			\
>  do {									\
> -  struct link_map *map = &bootstrap_map;				\
> +  struct link_map *map = BOOTSTRAP_MAP;					\
>    ElfW(Sym) *sym;							\
>    ElfW(Addr) *got;							\
>    int i, n;								\
> --
> 2.13.6
>
>

Tested with build-many-glibcs.py.  Will check it in shortly.

-- 
H.J.

      reply	other threads:[~2017-10-02 22:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-29 21:38 H.J. Lu
2017-10-02 22:00 ` H.J. Lu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMe9rOq0m0NtOzj5Gr=6=yA76BAnx3MCqwnUp-TW42uFxabzAg@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).