The segment parsing code for binaries linked with custom linker scripts is now nearly identical to the new system script method so we can consolidate two functions into one code path.
There are two interesting semantics to note: 1) verify_segment_layout() will be called when we are using custom linker scripts as well as the system scripts. Although checking should not be needed for custom scripts, it's harmless and probably a good idea anyway. 2) There are now two ways to specify which segments to remap: the PHDR flag PF_LINUX_HUGETLB and the HUGETLB_ELFMAP environment variable. In the event that both ways are used at one time, the environment variable shall override the ELF flags. Signed-off-by: Adam Litke <[EMAIL PROTECTED]> --- elflink.c | 40 ++++++++-------------------------------- 1 files changed, 8 insertions(+), 32 deletions(-) diff --git a/elflink.c b/elflink.c index 9e3c7ad..727cbe0 100644 --- a/elflink.c +++ b/elflink.c @@ -613,34 +613,6 @@ int save_phdr(int table_idx, int phnum, const ElfW(Phdr) *phdr) return 0; } -/* - * Parse the phdrs of a program linked with the libhugetlbfs linker scripts - */ -static -int parse_elf_relinked(struct dl_phdr_info *info, size_t size, void *data) -{ - int i; - - for (i = 0; i < info->dlpi_phnum; i++) { - if (info->dlpi_phdr[i].p_type != PT_LOAD) - continue; - - if (!(info->dlpi_phdr[i].p_flags & PF_LINUX_HUGETLB)) - continue; - - if (save_phdr(htlb_num_segs, i, &info->dlpi_phdr[i])) - return 1; - - get_extracopy(&htlb_seg_table[htlb_num_segs], - &info->dlpi_phdr[0], info->dlpi_phnum); - - htlb_num_segs++; - } - if (__hugetlbfs_debug) - check_memsz(); - return 1; -} - static int verify_segment_layout(struct seg_layout *segs, int num_segs) { int i; @@ -669,7 +641,7 @@ static int verify_segment_layout(struct seg_layout *segs, int num_segs) } static -int parse_elf_noldscript(struct dl_phdr_info *info, size_t size, void *data) +int parse_elf_normal(struct dl_phdr_info *info, size_t size, void *data) { int i, num_segs; unsigned long page_size, hpage_size, seg_psize, start, end; @@ -693,6 +665,9 @@ int parse_elf_noldscript(struct dl_phdr_info *info, size_t size, void *data) seg_psize = hpage_size; else if (remap_writable && info->dlpi_phdr[i].p_flags & PF_W) seg_psize = hpage_size; + else if (!remap_readonly && !remap_writable && + (info->dlpi_phdr[i].p_flags & PF_LINUX_HUGETLB)) + seg_psize = hpage_size; else seg_psize = page_size; @@ -715,6 +690,9 @@ int parse_elf_noldscript(struct dl_phdr_info *info, size_t size, void *data) if (verify_segment_layout(segments, num_segs)) htlb_num_segs = 0; + if (__hugetlbfs_debug) + check_memsz(); + return 1; } @@ -1180,10 +1158,8 @@ static int parse_elf() { if (force_remap) dl_iterate_phdr(parse_elf_partial, NULL); - else if (remap_readonly || remap_writable) - dl_iterate_phdr(parse_elf_noldscript, NULL); else - dl_iterate_phdr(parse_elf_relinked, NULL); + dl_iterate_phdr(parse_elf_normal, NULL); if (htlb_num_segs == 0) { DEBUG("No segments were appropriate for remapping\n"); ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Libhugetlbfs-devel mailing list Libhugetlbfs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel