]> git.corax.cc Git - corax/commitdiff
Directly map read-only regions instead of copying them, when forking a process
authorMatthias Kruk <m@m10k.eu>
Mon, 18 Nov 2019 09:02:55 +0000 (18:02 +0900)
committerMatthias Kruk <m@m10k.eu>
Mon, 18 Nov 2019 09:02:55 +0000 (18:02 +0900)
kernel/core/process.c

index 118b9771fddbb441473c419f010034330cd9511d..edc7a86aa3a7e550674d0dfbcb8c614efa15ff65 100644 (file)
@@ -172,9 +172,13 @@ int _fork_region(pg_dir_t *parent_dir, region_t *reg, void *data)
 
                switch(reg->reg_type) {
                case REGION_TEXT:
+               case REGION_RODATA:
+                       /* .text and .rodata are read-only, so we might as well just map them */
+                       ret_val = pg_dir_map_region(child_dir, parent_dir, reg);
+                       break;
+
                case REGION_BSS:
                case REGION_DATA:
-               case REGION_RODATA:
                        /* copy the region and its contents */
                        ret_val = pg_dir_clone_region(child_dir, parent_dir, reg);
                        break;