| https://sourceware.org/bugzilla/show_bug.cgi?id=16381 |
| |
| From 798212a01311491d5e14fcda687460b75f8ca286 Mon Sep 17 00:00:00 2001 |
| From: Paul Pluzhnikov <ppluzhnikov@google.com> |
| Date: Wed, 12 Mar 2014 15:58:39 -0700 |
| Subject: [PATCH] 2014-03-12 Paul Pluzhnikov <ppluzhnikov@google.com> |
| |
| [BZ #16381] |
| |
| * elf/Makefile (tests): Add tst-pie2. |
| (tests-pie): Add tst-pie2. |
| * elf/tst-pie2.c: New file. |
| * elf/dl-load.c (_dl_map_object_from_fd): Assert correct l_type |
| for ET_EXEC. |
| * elf/rtld.c (map_doit): Load executable as lt_executable. |
| (dl_main): Likewise. |
| --- |
| ChangeLog | 12 ++++++++++++ |
| NEWS | 6 +++--- |
| elf/Makefile | 5 +++-- |
| elf/dl-load.c | 4 ++-- |
| elf/rtld.c | 5 +++-- |
| 5 files changed, 23 insertions(+), 9 deletions(-) |
| |
| diff --git a/elf/dl-load.c b/elf/dl-load.c |
| index 6501ff2..8ebc128 100644 |
| --- a/elf/dl-load.c |
| +++ b/elf/dl-load.c |
| @@ -1534,8 +1534,8 @@ cannot enable executable stack as shared object requires"); |
| /* Signal that we closed the file. */ |
| fd = -1; |
| |
| - if (l->l_type == lt_library && type == ET_EXEC) |
| - l->l_type = lt_executable; |
| + /* If this is ET_EXEC, we should have loaded it as lt_executable. */ |
| + assert (type != ET_EXEC || l->l_type == lt_executable); |
| |
| l->l_entry += l->l_addr; |
| |
| diff --git a/elf/rtld.c b/elf/rtld.c |
| index 7f1413a..63e92d3 100644 |
| --- a/elf/rtld.c |
| +++ b/elf/rtld.c |
| @@ -623,7 +623,8 @@ static void |
| map_doit (void *a) |
| { |
| struct map_args *args = (struct map_args *) a; |
| - args->map = _dl_map_object (args->loader, args->str, lt_library, 0, |
| + int type = (args->mode == __RTLD_OPENEXEC) ? lt_executable : lt_library; |
| + args->map = _dl_map_object (args->loader, args->str, type, 0, |
| args->mode, LM_ID_BASE); |
| } |
| |
| @@ -1075,7 +1076,7 @@ of this helper program; chances are you did not intend to run this program.\n\ |
| else |
| { |
| HP_TIMING_NOW (start); |
| - _dl_map_object (NULL, rtld_progname, lt_library, 0, |
| + _dl_map_object (NULL, rtld_progname, lt_executable, 0, |
| __RTLD_OPENEXEC, LM_ID_BASE); |
| HP_TIMING_NOW (stop); |
| |
| -- |
| 2.1.2 |
| |