diff options
author | CoprDistGit <infra@openeuler.org> | 2024-08-03 06:28:41 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2024-08-03 06:28:41 +0000 |
commit | d20db0561a6a36f914fde030512503b114ef9a0c (patch) | |
tree | d4e5e3494d95c269a1cee6195f11bf3201bcadbf /0003-elf-ld.so-remove-_mmap_hole-when-ld.so-mmap-PT_LOAD-.patch | |
parent | 016343d99b1b269d7246ef1e143d4b54914433d4 (diff) |
automatic import of glibcopeneuler22.03_LTS_SP4openeuler22.03_LTS_SP3openeuler20.03
Diffstat (limited to '0003-elf-ld.so-remove-_mmap_hole-when-ld.so-mmap-PT_LOAD-.patch')
-rw-r--r-- | 0003-elf-ld.so-remove-_mmap_hole-when-ld.so-mmap-PT_LOAD-.patch | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/0003-elf-ld.so-remove-_mmap_hole-when-ld.so-mmap-PT_LOAD-.patch b/0003-elf-ld.so-remove-_mmap_hole-when-ld.so-mmap-PT_LOAD-.patch new file mode 100644 index 0000000..a12f0fb --- /dev/null +++ b/0003-elf-ld.so-remove-_mmap_hole-when-ld.so-mmap-PT_LOAD-.patch @@ -0,0 +1,84 @@ +From 117a913e7b1c380bb99796588b266547de959de9 Mon Sep 17 00:00:00 2001 +From: Lv Ying <lvying6@huawei.com> +Date: Thu, 23 Feb 2023 22:15:06 +0800 +Subject: [PATCH 3/3] elf/ld.so: remove _mmap_hole when ld.so mmap PT_LOAD + segment try to use hugepage + +When ld.so mmap PT_LOAD segment try to use hugepage, it's unnecessary to +remap hole area, becasue __mmap_reserved_area already mmap reserved area +as PROT_NONE. Besides _mmap_hole may mmap hole area from 4KB page +misaligned addresses which will cause mmap faiure(invalid argument). + +Signed-off-by: Lv Ying <lvying6@huawei.com> +--- + elf/dl-load.h | 2 -- + elf/dl-map-segments-hugepage.h | 26 -------------------------- + 2 files changed, 28 deletions(-) + +diff --git a/elf/dl-load.h b/elf/dl-load.h +index fcf91a47..f2428165 100644 +--- a/elf/dl-load.h ++++ b/elf/dl-load.h +@@ -136,8 +136,6 @@ static const char *_dl_map_segments (struct link_map *l, int fd, + N_("cannot map Non shared object file in hugepage") + #define DL_MAP_SEGMENTS_ERROR_ARRANGE \ + N_("shared object's PT_LOAD segment in wrong arrange") +-#define DL_MAP_SEGMENTS_ERROR_MAP_HOLE_FILL \ +- N_("failed to mmap shared object's hole part of PT_LOAD") + #define DL_MAP_RESERVED_HUGEPAGE_AREA_ERROR \ + N_("failed to map reserved 2MB contiguous hugepage va space") + #define DL_FIND_EXEC_SEGMENT_ERROR \ +diff --git a/elf/dl-map-segments-hugepage.h b/elf/dl-map-segments-hugepage.h +index e7202131..a352c903 100644 +--- a/elf/dl-map-segments-hugepage.h ++++ b/elf/dl-map-segments-hugepage.h +@@ -486,19 +486,6 @@ _mmap_segment(struct link_map *l, const struct loadcmd loadcmds[], size_t nloadc + return NULL; + } + +-static __always_inline void * +-_mmap_hole(const struct loadcmd *current, const struct loadcmd *next, +- ElfW(Addr) mapstart, size_t mapseglen, int fd) +-{ +- if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES)) +- _dl_debug_printf("\tmmap hole area:[%lx-%lx)\n", mapstart + mapseglen, +- mapstart + (next->mapstart - current->mapstart)); +- return __mmap((void *)(mapstart + mapseglen), +- next->mapstart - (current->mapstart + mapseglen), +- PROT_NONE, MAP_FILE|MAP_PRIVATE|MAP_FIXED, +- fd, current->mapoff + mapseglen); +-} +- + static __always_inline const char * + _dl_map_segments_largein (struct link_map *l, int fd, + const ElfW(Ehdr) *header, int type, +@@ -541,13 +528,6 @@ _dl_map_segments_largein (struct link_map *l, int fd, + goto unmap_reserved_area; + } + +- if (prev->mapstart + mapseglen < c->mapstart && +- _mmap_hole(prev, c, map_addr, mapseglen, fd) == MAP_FAILED) +- { +- errstring = DL_MAP_SEGMENTS_ERROR_MAP_HOLE_FILL; +- goto unmap_reserved_area; +- } +- + map_addr += c->mapstart - prev->mapstart; + errstring = _mmap_segment(l, loadcmds, nloadcmds, c, map_addr, fd, + &mapseglen, hp_bitmap); +@@ -582,12 +562,6 @@ _dl_map_segments_largein (struct link_map *l, int fd, + goto unmap_reserved_area; + } + +- if (c->mapstart + mapseglen < prev->mapstart && +- _mmap_hole(c, prev, map_addr, mapseglen, fd) == MAP_FAILED) +- { +- errstring = DL_MAP_SEGMENTS_ERROR_MAP_HOLE_FILL; +- goto unmap_reserved_area; +- } + prev = c; + --c; + } +-- +2.38.1 + |