elflink: fix-up DEBUG with plt rework

If the libhuge_filesz symbol is used to find the end of the extracopy
area, and HUGETLB_DEBUG is set in the environment, we don't do anything,
because the found label skips the call to check_bss(). Also,
__libhuge_filez should only be used if its address is greater than that
found by the criss-cross extracopy algorithm. Fix both issues by moving
the check for libhuge_filesz below the algorithm and removing the found
label.

Signed-off-by: Nishanth Aravamudan <[EMAIL PROTECTED]>

--
Adam, if you want to review and provide your Ack for this patch, too,
I'll combine it with the original one before requesting a pull.

diff --git a/elflink.c b/elflink.c
index 00b403a..92a8a96 100644
--- a/elflink.c
+++ b/elflink.c
@@ -423,13 +423,6 @@ static void get_extracopy(struct seg_info *seg, Elf_Phdr 
*phdr, int phnum)
        if (!minimal_copy)
                goto bail2;
 
-       if (&__libhuge_filesz) {
-               found_sym = 1;
-               start = start_orig;
-               end = &__libhuge_filesz;
-               goto found;
-       }
-
        /* Find dynamic program header */
        ret = find_dynamic(&dyntab, phdr, phnum);
        if (ret < 0)
@@ -467,10 +460,18 @@ static void get_extracopy(struct seg_info *seg, Elf_Phdr 
*phdr, int phnum)
                        end = sym_end;
        }
 
+       if (&__libhuge_filesz > end) {
+               /* be careful if the algorithm didn't find any symbols
+                * to copy */
+               if (start == end_orig)
+                       start = start_orig;
+               end = &__libhuge_filesz;
+               DEBUG("Found __libhuge_filesz at %p\n", &__libhuge_filesz);
+       }
+
        if (__debug)
                check_bss(end, end_orig);
 
-found:
        if (found_sym) {
                /* Return the copy window */
                seg->extra_vaddr = start;

-- 
Nishanth Aravamudan <[EMAIL PROTECTED]>
IBM Linux Technology Center

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Libhugetlbfs-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to