On Tue, 2007-01-23 at 08:20 -0800, Nishanth Aravamudan wrote:
> > Sure.  I am fine with that too.  Want to handle it directly or shall I
> > spin another patch?
> 
> If you could spin one more, I'd appreciate it.

Here ye' here ye'

diff --git a/elflink.c b/elflink.c
index 6b260c9..6316563 100644
--- a/elflink.c
+++ b/elflink.c
@@ -464,6 +464,32 @@ 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)
+ */
+static inline int keep_symbol(Elf_Sym *s, void *start, void *end)
+{
+       if ((void *)s->st_value < start)
+               return 0;
+       if ((void *)s->st_value > end)
+               return 0;
+       if ((ELF_ST_BIND(s->st_info) != STB_GLOBAL) &&
+           (ELF_ST_BIND(s->st_info) != STB_WEAK))
+               return 0;
+       if (ELF_ST_TYPE(s->st_info) != STT_OBJECT)
+               return 0;
+       if (s->st_size == 0)
+               return 0;
+
+       return 1;
+}
+
 /*
  * Subtle:  Since libhugetlbfs depends on glibc, we allow it
  * it to be loaded before us.  As part of its init functions, it
@@ -510,22 +536,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, start_orig, end_orig))
                        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