Alan Hourihane wrote:

Is there someone looking to integrate the TLS patches for libGL ??

We should certainly take a look soon and comment upon the patches used.

Here is a patch that covers part of what's in the Redhat patch. This convert the static_functions table to a list of offsets instead of a list of pointers. According to 'objdump -R' on the Mesa libGL, it cuts out about 1800 R_386_RELATIVE relocs. However, the size of the library *increases* by about 24k. That doesn't make sense to me.


Is there some other tool that should be used for this type of thing? Does anyone know what Jakub used for the analysis included with his original patch? Is there any good documentation available on this stuff? I haven't worked on this level since the last 40k intro I did on the Amiga.

http://marc.theaimsgroup.com/?l=dri-devel&m=105187260618425&w=2

Index: src/mesa/sources
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/sources,v
retrieving revision 1.11
diff -u -d -r1.11 sources
--- a/src/mesa/sources  27 Apr 2004 13:39:20 -0000      1.11
+++ b/src/mesa/sources  21 May 2004 22:51:16 -0000
@@ -167,8 +167,9 @@
        x86/sse_xform2.S        \
        x86/sse_xform3.S        \
        x86/sse_xform4.S        \
-       x86/sse_normal.S \
-       tnl/t_vtx_x86_gcc.S
+       x86/sse_normal.S        \
+       tnl/t_vtx_x86_gcc.S     \
+       glapi/glprocs_x86.S
 
 SPARC_SOURCES =                        \
        sparc/clip.S            \
Index: src/mesa/glapi/gl_procs.py
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/glapi/gl_procs.py,v
retrieving revision 1.1
diff -u -d -r1.1 gl_procs.py
--- a/src/mesa/glapi/gl_procs.py        18 May 2004 18:33:40 -0000      1.1
+++ b/src/mesa/glapi/gl_procs.py        21 May 2004 22:51:17 -0000
@@ -61,23 +61,70 @@
                        % (f.name, f.name, f.real_name)
 
 
+class PrintGlProcsX86(gl_XML.FilterGLAPISpecBase):
+       name = "gl_procs.py (from Mesa)"
+
+       def __init__(self):
+               gl_XML.FilterGLAPISpecBase.__init__(self)
+               self.license = license.bsd_license_template % ("""(C) Copyright IBM 
Corporation 2004""", "IBM")
+
+       def printRealHeader(self):
+               print ''
+               print '#include "glapioffsets.h"'
+               print ''
+               print '/* This file is only linked with glapi.c and is used for'
+               print ' * the GetProcAddress() function'
+               print ' */'
+               print ''
+               print '\t\t.section .rodata.str1.1'
+               print '\t\t.globl gl_string_table_start'
+               print 'gl_string_table_start:'
+               print '\t\t.section .rodata.gl_static_functions'
+               print '\t\t.globl static_functions_x86'
+               print 'static_functions_x86:'
+               return
+
+       def printRealFooter(self):
+               print '\t\t.section .rodata.gl_static_functions'
+               print '\t\t.long\t-1, 0'
+               return
+
+       def printFunction(self, f):
+               print ''
+               print '\t\t.section .rodata.str1.1'
+               print 'gl%s_string:\t.string "gl%s"' % (f.name, f.name)
+               print '\t\t.section .rodata.gl_static_functions'
+               print '\t\t.long\tgl%s_string - gl_string_table_start, _gloffset_%s' % 
(f.name, f.real_name)
+
+
 def show_usage():
-       print "Usage: %s [-f input_file_name]" % sys.argv[0]
+       print "Usage: %s [-f input_file_name] [-m mode]" % sys.argv[0]
+       print 'mode can be one of:'
+       print '    h   - emit a C header file (default)'
+       print '    x86 - emit an x86 assembly file'
        sys.exit(1)
 
 if __name__ == '__main__':
        file_name = "gl_API.xml"
     
        try:
-               (args, trail) = getopt.getopt(sys.argv[1:], "f:")
+               (args, trail) = getopt.getopt(sys.argv[1:], "f:m:")
        except Exception,e:
                show_usage()
 
+       mode = "h"
        for (arg,val) in args:
                if arg == "-f":
                        file_name = val
+               elif arg == "-m":
+                       mode = val
 
-       dh = PrintGlProcs()
+       if mode == "h":
+               dh = PrintGlProcs()
+       elif mode == "x86":
+               dh = PrintGlProcsX86()
+       else:
+               show_usage()
 
        parser = make_parser()
        parser.setFeature(feature_namespaces, 0)
Index: src/mesa/glapi/gl_x86_asm.py
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/glapi/gl_x86_asm.py,v
retrieving revision 1.1
diff -u -d -r1.1 gl_x86_asm.py
--- a/src/mesa/glapi/gl_x86_asm.py      18 May 2004 18:33:40 -0000      1.1
+++ b/src/mesa/glapi/gl_x86_asm.py      21 May 2004 22:51:17 -0000
@@ -87,6 +87,9 @@
                print 'SEG_TEXT'
                print 'EXTERN GLNAME(_glapi_Dispatch)'
                print ''
+               print '\t\tALIGNTEXT16 ; GLOBL gl_dispatch_functions_start'
+               print 'gl_dispatch_functions_start:'
+               print ''
                return
 
        def printRealFooter(self):
@@ -95,8 +98,6 @@
                return
 
        def printFunction(self, f):
-               if f.fn_offset == -1: return
-
                stack = self.get_stack_size(f)
 
                print '\tGL_STUB(%s, _gloffset_%s, %u)' % (f.name, f.real_name, stack)
Index: src/mesa/glapi/glapi.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/glapi/glapi.c,v
retrieving revision 1.73
diff -u -d -r1.73 glapi.c
--- a/src/mesa/glapi/glapi.c    23 Apr 2004 20:33:07 -0000      1.73
+++ b/src/mesa/glapi/glapi.c    21 May 2004 22:51:17 -0000
@@ -446,6 +446,7 @@
 };
 
 
+#if !defined( USE_X86_ASM )
 /* The code in this file is auto-generated with Python */
 #include "glprocs.h"
 
@@ -484,6 +485,98 @@
    return NULL;
 }
 
+static const char *
+get_static_proc_name(GLuint offset)
+{
+   const GLuint n = sizeof(static_functions) / sizeof(struct name_address_offset);
+   GLuint i;
+
+   /* search built-in functions */
+   for (i = 0; i < n; i++) {
+      if (static_functions[i].Offset == offset)
+         return static_functions[i].Name;
+   }
+   
+   return NULL;
+}
+
+#else
+struct name_address_offset_x86 {
+   int Name_offset;
+   unsigned int Offset;
+};
+
+extern const struct name_address_offset_x86 static_functions_x86[];
+
+extern const char gl_string_table_start[];
+extern const char gl_dispatch_functions_start[]; 
+
+static struct name_address_offset_x86 *
+find_entry( const char * n )
+{
+   unsigned   i;
+
+   for ( i = 0 ; static_functions_x86[i].Name_offset >= 0 ; i++ ) {
+      const char * test_name;
+
+      test_name = gl_string_table_start + static_functions_x86[i].Name_offset;
+      if (strcmp(test_name, n) == 0) {
+        return & static_functions_x86[i];
+      }
+   }
+   return NULL;
+}
+
+/*
+ * Return dispatch table offset of the named static (built-in) function.
+ * Return -1 if function not found.
+ */
+static GLint
+get_static_proc_offset(const char *funcName)
+{
+   const struct name_address_offset_x86 * const f = find_entry( funcName );
+
+   if ( f != NULL ) {
+      return f->Offset;
+   }
+   else {
+      return -1;
+   }
+}
+
+
+/*
+ * Return dispatch function address the named static (built-in) function.
+ * Return NULL if function not found.
+ */
+static const GLvoid *
+get_static_proc_address(const char *funcName)
+{
+   const struct name_address_offset_x86 * const f = find_entry( funcName );
+
+   if ( f != NULL ) {
+      return gl_dispatch_functions_start + (16 * f->Offset);
+   }
+   else {
+      return NULL;
+   }
+}
+
+
+static const char *
+get_static_proc_name( GLuint offset )
+{
+   unsigned   i;
+
+   for ( i = 0 ; static_functions_x86[i].Name_offset >= 0 ; i++ ) {
+      if (static_functions_x86[i].Offset == offset) {
+        return gl_string_table_start + static_functions_x86[i].Name_offset;
+      }
+   }
+   return NULL;
+}
+#endif
+
 
 
 /**********************************************************************
@@ -802,13 +895,13 @@
 const char *
 _glapi_get_proc_name(GLuint offset)
 {
-   const GLuint n = sizeof(static_functions) / sizeof(struct name_address_offset);
    GLuint i;
+   const char * n;
 
    /* search built-in functions */
-   for (i = 0; i < n; i++) {
-      if (static_functions[i].Offset == offset)
-         return static_functions[i].Name;
+   n = get_static_proc_name(offset);
+   if ( n != NULL ) {
+      return n;
    }
 
    /* search added extension functions */

Reply via email to