diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-02-02 09:07:58 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-02-02 21:13:22 +0300 |
commit | 2fb8c6371ba29e8dd457e090edd5274efc8bed5a (patch) | |
tree | 1c55742cd8328a865aa0848575d07fc60cc0e1f8 /dyn_load.c | |
parent | cbef64d771cf2419a677259dd7367ed2d1035a98 (diff) | |
download | bdwgc-2fb8c6371ba29e8dd457e090edd5274efc8bed5a.tar.gz |
Discard sections with pseudo-paths except heap in register_map_entries
If USE_PROC_FOR_LIBRARIES, this commit prevents addition of special
writable sections (from proc maps) like stacks.
* dyn_load.c [(SCO_ELF || DGUX || HURD || NACL || __ELF__ && (LINUX
|| FREEBSD || NETBSD || OPENBSD)) && USE_PROC_FOR_LIBRARIES]
(GC_register_map_entries): Declare path local variable and pass it to
GC_parse_map_entry; discard writable section if its path (mapping name)
starts with '[' but does not match "[heap]".
Diffstat (limited to 'dyn_load.c')
-rw-r--r-- | dyn_load.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -309,7 +309,7 @@ static void sort_heap_sects(struct HeapSect *base, size_t number_of_elements) STATIC void GC_register_map_entries(const char *maps) { - const char *prot; + const char *prot, *path; ptr_t start, end; unsigned int maj_dev; ptr_t least_ha, greatest_ha; @@ -322,7 +322,7 @@ STATIC void GC_register_map_entries(const char *maps) + GC_our_memory[GC_n_memory-1].hs_bytes; for (;;) { - maps = GC_parse_map_entry(maps, &start, &end, &prot, &maj_dev, 0); + maps = GC_parse_map_entry(maps, &start, &end, &prot, &maj_dev, &path); if (NULL == maps) break; if (prot[1] == 'w') { @@ -334,6 +334,9 @@ STATIC void GC_register_map_entries(const char *maps) /* Stack mapping; discard */ continue; } + if (path[0] == '[' && strncmp(path+1, "heap]", 5) != 0) + continue; /* discard if a pseudo-path unless "[heap]" */ + # ifdef THREADS /* This may fail, since a thread may already be */ /* unregistered, but its thread stack may still be there. */ |