The current extracopysize detection algorithm does not include weak
objects in the copy window.  These are symbols marked with 'W' and 'V'
in nm output.  These can in fact be initialized global variables (just
like STB_GLOBAL symbols) and should be included in the extracopy window.

The following patch adds STB_WEAK symbols to the extracopy window.
Since the if statement is getting a bit large and out of hand, move the
logic out of the function and into its own macro "keep_symbol".

This patch resolves an eon (speccpu2000 benchmark) failure.

Signed-off-by: Adam Litke <[EMAIL PROTECTED]>

diff --git a/elflink.c b/elflink.c
index 6b260c9..9556dad 100644
--- a/elflink.c
+++ b/elflink.c
@@ -464,6 +464,23 @@ static int find_numsyms(Elf_Sym *symtab,
        return ((void *)strtab - (void *)symtab) / sizeof(Elf_Sym);
 }
 
+/* 
+ * To reduce the size of the extra copy window, we can eliminate certain
+ * symbols based on information in the dynamic section.  The following
+ * characteristics apply to symbols which may require copying:
+ * - Within the BSS
+ * - Global or Weak binding
+ * - Object type (variable)
+ * - Non-zero size (zero size means the symbol is just a marker with no data)
+ */
+#define keep_symbol(s) \
+       ((((void *)s->st_value >= start_orig) && \
+         ((void *)s->st_value <= end_orig))                    && \
+        ((ELF_ST_BIND(s->st_info) == STB_GLOBAL) || \
+         (ELF_ST_BIND(s->st_info) == STB_WEAK))                && \
+        (ELF_ST_TYPE(sym->st_info) == STT_OBJECT)              && \
+        (s->st_size > 0))
+
 /*
  * Subtle:  Since libhugetlbfs depends on glibc, we allow it
  * it to be loaded before us.  As part of its init functions, it
@@ -510,22 +527,8 @@ static void get_extracopy(struct seg_inf
        start = end_orig;
        end = start_orig;
 
-       /* 
-        * To reduce the size of the extra copy window, we can eliminate certain
-        * symbols based on information in the dynamic section.  The following
-        * characteristics apply to symbols which may require copying:
-        * - Within the BSS
-        * - Global scope
-        * - Object type (variable)
-        * - Non-zero size (zero size means the symbol is just a marker with no
-        *   data)
-        */
        for (sym = symtab; sym < symtab + numsyms; sym++) {
-               if (((void *)sym->st_value < start_orig) || 
-                       ((void *)sym->st_value > end_orig) ||
-                       (ELF_ST_BIND(sym->st_info) != STB_GLOBAL) ||
-                       (ELF_ST_TYPE(sym->st_info) != STT_OBJECT) ||
-                       (sym->st_size == 0))
+               if (!keep_symbol(sym))
                        continue;
                /* TODO - add filtering so that we only look at symbols from 
glibc 
                   (@@GLIBC_*) */

-- 
Adam Litke - (agl at us.ibm.com)
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