From fad4301bc02512662853ffd348933367e7720e52 Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Mon, 8 Oct 2018 11:41:47 -0700 Subject: [PATCH] [LibOS] Reduce glibc patch --- LibOS/glibc-2.19.patch | 161 ----------------------------------------- 1 file changed, 161 deletions(-) diff --git a/LibOS/glibc-2.19.patch b/LibOS/glibc-2.19.patch index 09777db3..f0f6d06f 100644 --- a/LibOS/glibc-2.19.patch +++ b/LibOS/glibc-2.19.patch @@ -240,151 +240,6 @@ index 6dcbabc..c87c773 100644 /* Now life is sane; we can call functions and access global data. Set up to use the operating system facilities, and find out from the operating system's program loader where to find the program -@@ -1233,9 +1253,20 @@ of this helper program; chances are you did not intend to run this program.\n\ - main_map->l_map_end = allocend; - if ((ph->p_flags & PF_X) && allocend > main_map->l_text_end) - main_map->l_text_end = allocend; -+ -+#if 0 -+ ElfW(Addr) mapend = (allocend + GLRO(dl_pagesize) - 1) -+ & ~(GLRO(dl_pagesize) - 1); -+ int prot = ((ph->p_flags & PF_R) ? PROT_READ : 0)| -+ ((ph->p_flags & PF_W) ? PROT_WRITE : 0)| -+ ((ph->p_flags & PF_X) ? PROT_EXEC : 0); -+ __mmap ((void *) mapstart, mapend - mapstart, -+ prot, -+ MAP_ANON|MAP_PRIVATE|MAP_FIXED|0x20000000, -+ -1, 0); -+#endif - } - break; -- - case PT_TLS: - if (ph->p_memsz > 0) - { -@@ -1381,13 +1412,31 @@ of this helper program; chances are you did not intend to run this program.\n\ - /* PT_GNU_RELRO is usually the last phdr. */ - size_t cnt = rtld_ehdr->e_phnum; - while (cnt-- > 0) -+ { - if (rtld_phdr[cnt].p_type == PT_GNU_RELRO) - { - GL(dl_rtld_map).l_relro_addr = rtld_phdr[cnt].p_vaddr; - GL(dl_rtld_map).l_relro_size = rtld_phdr[cnt].p_memsz; -- break; - } - -+#if 0 -+ if (rtld_phdr[cnt].p_type == PT_LOAD) -+ { -+ ElfW(Addr) mapstart = rtld_phdr[cnt].p_vaddr & ~(GLRO(dl_pagesize) - 1); -+ ElfW(Addr) mapend = (rtld_phdr[cnt].p_vaddr + rtld_phdr[cnt].p_memsz -+ + GLRO(dl_pagesize) - 1) -+ & ~(GLRO(dl_pagesize) - 1); -+ int prot = ((rtld_phdr[cnt].p_flags & PF_R) ? PROT_READ : 0)| -+ ((rtld_phdr[cnt].p_flags & PF_W) ? PROT_WRITE : 0)| -+ ((rtld_phdr[cnt].p_flags & PF_X) ? PROT_EXEC : 0); -+ __mmap ((void *) mapstart, mapend - mapstart, -+ prot, -+ MAP_ANON|MAP_PRIVATE|MAP_FIXED|0x20000000, -+ -1, 0); -+ } -+#endif -+ } -+ - /* Add the dynamic linker to the TLS list if it also uses TLS. */ - if (GL(dl_rtld_map).l_tls_blocksize != 0) - /* Assign a module ID. Do this before loading any audit modules. */ -@@ -1636,89 +1654,6 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", - } - } - -- /* There usually is no ld.so.preload file, it should only be used -- for emergencies and testing. So the open call etc should usually -- fail. Using access() on a non-existing file is faster than using -- open(). So we do this first. If it succeeds we do almost twice -- the work but this does not matter, since it is not for production -- use. */ -- static const char preload_file[] = "/etc/ld.so.preload"; -- if (__builtin_expect (__access (preload_file, R_OK) == 0, 0)) -- { -- /* Read the contents of the file. */ -- file = _dl_sysdep_read_whole_file (preload_file, &file_size, -- PROT_READ | PROT_WRITE); -- if (__builtin_expect (file != MAP_FAILED, 0)) -- { -- /* Parse the file. It contains names of libraries to be loaded, -- separated by white spaces or `:'. It may also contain -- comments introduced by `#'. */ -- char *problem; -- char *runp; -- size_t rest; -- -- /* Eliminate comments. */ -- runp = file; -- rest = file_size; -- while (rest > 0) -- { -- char *comment = memchr (runp, '#', rest); -- if (comment == NULL) -- break; -- -- rest -= comment - runp; -- do -- *comment = ' '; -- while (--rest > 0 && *++comment != '\n'); -- } -- -- /* We have one problematic case: if we have a name at the end of -- the file without a trailing terminating characters, we cannot -- place the \0. Handle the case separately. */ -- if (file[file_size - 1] != ' ' && file[file_size - 1] != '\t' -- && file[file_size - 1] != '\n' && file[file_size - 1] != ':') -- { -- problem = &file[file_size]; -- while (problem > file && problem[-1] != ' ' -- && problem[-1] != '\t' -- && problem[-1] != '\n' && problem[-1] != ':') -- --problem; -- -- if (problem > file) -- problem[-1] = '\0'; -- } -- else -- { -- problem = NULL; -- file[file_size - 1] = '\0'; -- } -- -- HP_TIMING_NOW (start); -- -- if (file != problem) -- { -- char *p; -- runp = file; -- while ((p = strsep (&runp, ": \t\n")) != NULL) -- if (p[0] != '\0') -- npreloads += do_preload (p, main_map, preload_file); -- } -- -- if (problem != NULL) -- { -- char *p = strndupa (problem, file_size - (problem - file)); -- -- npreloads += do_preload (p, main_map, preload_file); -- } -- -- HP_TIMING_NOW (stop); -- HP_TIMING_DIFF (diff, start, stop); -- HP_TIMING_ACCUM_NT (load_time, diff); -- -- /* We don't need the file anymore. */ -- __munmap (file, file_size); -- } -- } - - if (__builtin_expect (*first_preload != NULL, 0)) - { diff --git a/malloc/arena.c b/malloc/arena.c index 5088a25..33a3879 100644 --- a/malloc/arena.c @@ -480,22 +335,6 @@ index bb11277..354149a 100644 + syscalldb; glibc_option; + } } -diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c -index 9d7f52f..72d50ae 100644 ---- a/nptl/pthread_create.c -+++ b/nptl/pthread_create.c -@@ -405,8 +405,11 @@ start_thread (void *arg) - # error "to do" - #endif - assert (freesize < pd->stackblock_size); -+ /* XXX: may not be necessary */ -+#if 0 - if (freesize > PTHREAD_STACK_MIN) - __madvise (pd->stackblock, freesize - PTHREAD_STACK_MIN, MADV_DONTNEED); -+#endif - - /* If the thread is detached free the TCB. */ - if (IS_DETACHED (pd)) diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S b/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S index 89fda5e..f6963f6 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S