[patch] Re: OpenOffice.org-2.0.4rc1 compile problems on -CURRENT

Kostik Belousov kostikbel at gmail.com
Mon Sep 18 02:59:13 PDT 2006


On Fri, Sep 15, 2006 at 02:17:12PM -0400, Jung-uk Kim wrote:
> On Thursday 14 September 2006 10:19 pm, Nicolas Blais wrote:
> --- >8 --- SNIP!!! --- >8 ---
> > =============
> > Building project udkapi
> > =============
> > /usr/ports/editors/openoffice.org-2.0/work/OOD680_m3/udkapi/com/sun
> >/star/uno mkout -- version: 1.7
> > idlc @/tmp/mkmJ4vAL
> > idlc: compile 'Exception.idl' ...
> > idlc: could not load registry dll.
> > idlc: detected 1 errors
> > Sun Microsystems (R) idlc Version 1.1
> >
> > dmake:  Error code 1, while
> > making '../../../../unxfbsdi.pro/misc/urd_cssuno.don'
> > '---* tg_merge.mk *---'
> >
> > ERROR: Error 65280 occurred while
> > making
> > /usr/ports/editors/openoffice.org-2.0/work/OOD680_m3/udkapi/com/sun
> >/star/uno dmake:  Error code 1, while making
> > 'build_instsetoo_native' '---* *---'
> > *** Error code 255
> >
> > Stop in /usr/ports/editors/openoffice.org-2.0.
> >
> > The port tree is up to date and so is -CURRENT. Any suggestions?
> 
> src/libexec/rtld-elf/rtld.c 1.117 has serious regression:
> 
> http://docs.freebsd.org/cgi/mid.cgi?200609081459.k88ExtSR084500
> 
> You can revert to 1.116 and pass this but there is some other 
> issues. :-(
> 
> Jung-uk Kim

Ok, below is the patch that shall fix the issue. It was tested by
Jung-uk Kim' regression test. Also, adopted patch (for STABLE) was
tested with KDE (opening https:// sites) and OpenOffice 2.0.3.
The latter was simply run and several documents of different
types where opended. I have no resources to rebuild the beast
myself. Konqueror issued a lot of warning for undefined symbols
(like kdecore (KLibLoader): WARNING: KLibrary: Undefined symbol
"OPENSSL_add_all_algorithms" ), but it does it with both patched and
non-patched rtld on 6-STABLE. In both cases it worked normally, allowed
to open the sites, and I see no excessive VM usage (I assume 30-40Mb is
normal for it).

Original patch (committed as rev. 1.117) scanned objects from the
obj->dagmembers list for symbol retrieved by dlsym(). This appeared to
be wrong by two reasons:

1. dagmembers are initialized only when dlopen actually load the dso. This
caused the second test from Jung-uk Kim' regression set to fail, because
it dlopen() depended dso and tries to lookup symbol from there.
2. In the case dso A depends on B and C, usage of dagmembers would cause
B to expose symbols from C, that is wrong too.

Attached patch uses obj->needed, that is filled for each dso, and is a real
DAG instead of list. Patch (hopefully) implements SUSv3-required breadth-first
lookup for dependent symbols.

Please, give it a try.

Patch for rtld.c rev. 1.117 (CURRENT)

Index: rtld.c
===================================================================
RCS file: /usr/local/arch/ncvs/src/libexec/rtld-elf/rtld.c,v
retrieving revision 1.117
diff -u -r1.117 rtld.c
--- rtld.c	8 Sep 2006 14:59:54 -0000	1.117
+++ rtld.c	18 Sep 2006 09:54:02 -0000
@@ -125,6 +125,9 @@
   const Obj_Entry *, const Obj_Entry **, const Ver_Entry *, int);
 static const Elf_Sym *symlook_list(const char *, unsigned long, const Objlist *,
   const Obj_Entry **, const Ver_Entry *, int flags, DoneList *);
+static const Elf_Sym *symlook_needed(const char *, unsigned long,
+  const Needed_Entry *, const Obj_Entry **, const Ver_Entry *,
+  int flags, DoneList *dlp);
 static void trace_loaded_objects(Obj_Entry *obj);
 static void unlink_object(Obj_Entry *);
 static void unload_object(Obj_Entry *);
@@ -1852,17 +1855,21 @@
 	}
 
 	DoneList donelist;
-	const Objlist *srch_list;
 	donelist_init(&donelist);
 	if (obj->mainprog) {
 	    /* Search main program and all libraries loaded by it. */
-	    srch_list = &list_main;
+	    def = symlook_list(name, hash, &list_main, &defobj, ve, flags,
+			       &donelist);
 	} else {
+	    Needed_Entry fake;
+
 	    /* Search the whole DAG rooted at the given object. */
-	    srch_list = &(obj->dagmembers);
+	    fake.next = NULL;
+	    fake.obj = (Obj_Entry *)obj;
+	    fake.name = 0;
+	    def = symlook_needed(name, hash, &fake, &defobj, ve, flags,
+				 &donelist);
 	}
-	def = symlook_list(name, hash, srch_list, &defobj, ve, flags,
-			   &donelist);
     }
 
     if (def != NULL) {
@@ -2362,6 +2369,57 @@
 }
 
 /*
+ * Search the symbol table of a shared object and all objects needed
+ * by it for a symbol of the given name.  Search order is
+ * breadth-first.  Returns a pointer to the symbol, or NULL if no
+ * definition was found.
+ */
+static const Elf_Sym *
+symlook_needed(const char *name, unsigned long hash, const Needed_Entry *needed,
+  const Obj_Entry **defobj_out, const Ver_Entry *ventry, int flags,
+  DoneList *dlp)
+{
+    const Elf_Sym *def, *def_w;
+    const Needed_Entry *n;
+    const Obj_Entry *obj, *defobj, *defobj1;
+    
+    def = def_w = NULL;
+    defobj = NULL;
+    for (n = needed; n != NULL; n = n->next) {
+        if ((obj = n->obj) == NULL ||
+            donelist_check(dlp, obj) ||
+            (def = symlook_obj(name, hash, obj, ventry, flags)) == NULL)
+                continue;
+        defobj = obj;
+        if (ELF_ST_BIND(def->st_info) != STB_WEAK) {
+            *defobj_out = defobj;
+            return (def);
+	}
+    }
+    /*
+     * There we come when either symbol definition is not found in
+     * directly needed objects, or found symbol is weak.
+     */
+    for (n = needed; n != NULL; n = n->next) {
+        if ((obj = n->obj) == NULL)
+            continue;
+        def_w = symlook_needed(name, hash, obj->needed, &defobj1,
+			       ventry, flags, dlp);
+        if (def_w == NULL)
+            continue;
+        if (def == NULL) {
+            def = def_w;
+            defobj = defobj1;
+        }
+        if (ELF_ST_BIND(def_w->st_info) != STB_WEAK)
+            break;
+    }
+    if (def != NULL)
+        *defobj_out = defobj;
+    return def;
+}
+
+/*
  * Search the symbol table of a single shared object for a symbol of
  * the given name and version, if requested.  Returns a pointer to the
  * symbol, or NULL if no definition was found.

For rtld.c rev. 1.106.2.3 from 6-STABLE:

Index: rtld.c
===================================================================
RCS file: /usr/local/arch/ncvs/src/libexec/rtld-elf/rtld.c,v
retrieving revision 1.106.2.3
diff -u -r1.106.2.3 rtld.c
--- rtld.c	2 Sep 2006 20:38:13 -0000	1.106.2.3
+++ rtld.c	18 Sep 2006 08:45:49 -0000
@@ -123,7 +123,9 @@
 static const Elf_Sym *symlook_default(const char *, unsigned long hash,
   const Obj_Entry *refobj, const Obj_Entry **defobj_out, bool in_plt);
 static const Elf_Sym *symlook_list(const char *, unsigned long,
-  Objlist *, const Obj_Entry **, bool in_plt, DoneList *);
+  const Objlist *, const Obj_Entry **, bool in_plt, DoneList *);
+static const Elf_Sym *symlook_needed(const char *, unsigned long,
+  const Needed_Entry *, const Obj_Entry **, bool, DoneList *);
 static void trace_loaded_objects(Obj_Entry *obj);
 static void unlink_object(Obj_Entry *);
 static void unload_object(Obj_Entry *);
@@ -1810,20 +1812,22 @@
 	    return NULL;
 	}
 
+	DoneList donelist;
+	donelist_init(&donelist);
 	if (obj->mainprog) {
-	    DoneList donelist;
 
-	    /* Search main program and all libraries loaded by it. */
-	    donelist_init(&donelist);
-	    def = symlook_list(name, hash, &list_main, &defobj, true,
-	      &donelist);
+		/* Search main program and all libraries loaded by it. */
+		def = symlook_list(name, hash, &list_main, &defobj, true,
+			   &donelist);
 	} else {
-	    /*
-	     * XXX - This isn't correct.  The search should include the whole
-	     * DAG rooted at the given object.
-	     */
-	    def = symlook_obj(name, hash, obj, true);
-	    defobj = obj;
+		Needed_Entry fake;
+		
+		/* Search the DAG rooted at the given object */
+		fake.next = NULL;
+		fake.name = 0;
+		fake.obj = (Obj_Entry *)obj;
+		def = symlook_needed(name, hash, &fake, &defobj, true,
+			&donelist);
 	}
     }
 
@@ -2274,7 +2278,7 @@
 }
 
 static const Elf_Sym *
-symlook_list(const char *name, unsigned long hash, Objlist *objlist,
+symlook_list(const char *name, unsigned long hash, const Objlist *objlist,
   const Obj_Entry **defobj_out, bool in_plt, DoneList *dlp)
 {
     const Elf_Sym *symp;
@@ -2302,6 +2306,58 @@
 }
 
 /*
+ * Search the symbol table of a shared object and all objects needed
+ * by it for a symbol of the given name.  Search order is
+ * breadth-first.  Returns a pointer to the symbol, or NULL if no
+ * definition was found.
+ */
+static const Elf_Sym *
+symlook_needed(const char *name, unsigned long hash, const Needed_Entry *needed,
+  const Obj_Entry **defobj_out, bool in_plt, DoneList *dlp)
+{
+    const Elf_Sym *def, *def_w;
+    const Needed_Entry *n;
+    const Obj_Entry *obj, *defobj, *defobj1;
+    
+    def = def_w = NULL;
+    defobj = NULL;
+    for (n = needed; n != NULL; n = n->next) {
+        if ((obj = n->obj) == NULL ||
+            donelist_check(dlp, obj) ||
+            (def = symlook_obj(name, hash, obj, in_plt)) == NULL)
+                continue;
+        defobj = obj;
+        if (ELF_ST_BIND(def->st_info) != STB_WEAK) {
+            *defobj_out = defobj;
+            return (def);
+	}
+    }
+    /*
+     * There we come when either symbol definition is not found in
+     * directly needed objects, or found symbol is weak.
+     */
+    for (n = needed; n != NULL; n = n->next) {
+        if ((obj = n->obj) == NULL)
+            continue;
+        def_w = symlook_needed(name, hash, obj->needed, &defobj1,
+			       in_plt, dlp);
+        if (def_w == NULL)
+            continue;
+        if (ELF_ST_BIND(def_w->st_info) != STB_WEAK) {
+            *defobj_out = defobj1;
+            return (def_w);
+        }
+        if (def == NULL) {
+            def = def_w;
+            defobj = defobj1;
+        }
+    }
+    if (def != NULL)
+        *defobj_out = defobj;
+    return def;
+}
+
+/*
  * Search the symbol table of a single shared object for a symbol of
  * the given name.  Returns a pointer to the symbol, or NULL if no
  * definition was found.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-openoffice/attachments/20060918/9cefb4ce/attachment.pgp


More information about the freebsd-openoffice mailing list