Преглед на файлове

use private maps even for read-only segments of FDPIC libraries

the nommu kernel shares memory when it can anyway for private
read-only maps, but semantically the map should be private. this can
make a difference when debugging breakpoints are to be used, in which
case the kernel may need to ensure that the mapping is not shared.

the new behavior matches how the kernel FDPIC loader maps the main
program and/or program interpreter (dynamic linker) binary.
Rich Felker преди 9 години
родител
ревизия
5fe38516f7
променени са 1 файла, в които са добавени 1 реда и са изтрити 1 реда
  1. 1 1
      src/ldso/dynlink.c

+ 1 - 1
src/ldso/dynlink.c

@@ -602,7 +602,7 @@ static void *map_library(int fd, struct dso *dso)
 				((ph->p_flags&PF_W) ? PROT_WRITE: 0) |
 				((ph->p_flags&PF_X) ? PROT_EXEC : 0));
 			map = mmap(0, ph->p_memsz + (ph->p_vaddr & PAGE_SIZE-1),
-				prot, (prot&PROT_WRITE) ? MAP_PRIVATE : MAP_SHARED,
+				prot, MAP_PRIVATE,
 				fd, ph->p_offset & -PAGE_SIZE);
 			if (map == MAP_FAILED) {
 				unmap_library(dso);