+ nl[0].n_name = ENTRY_SYM;
+ nl[1].n_name = sym;
+ nl[2].n_name = 0;
+
+ /* There is a potential problem here. If application
+ * did not pass a full path name, and changed the
+ * working directory after the load(), then nlist()
+ * will be unable to open the original shared library
+ * file to resolve the symbols. there are 3 ways to working
+ * round this: 1. convert to full pathname in driver
+ * manager. 2. applications always pass driver's full
+ * path name. 3. if driver itself don't support
+ * SQLGetFunctions(), call it with SQL_ALL_FUNCTIONS
+ * as flag immidately after SQLConnect(), SQLDriverConnect()
+ * and SQLBrowseConnect() to force the driver manager
+ * resolving all will be used symbols.
+ */
+ if (nlist (pobj->path, nl) == -1)
+ return 0;
+
+ if (!nl[0].n_type && !nl[0].n_value)
+ {
+ errmsg = "can't locate module entry symbol";
+ return 0;
+ }
+
+ /* Note: On AIX 3.x if the object library is not
+ * built with -g compiling option, .n_type field
+ * is always 0. While on 4.x it will be 32.
+ * On AIX 4.x, if the symbol is a entry point,
+ * n_value will be 0. However, one thing is for sure
+ * that if a symbol is not existance in the file,
+ * both .n_type and .n_value would be 0.
+ */
+
+ if (!nl[1].n_type && !nl[1].n_value)
+ {
+ errmsg = "symbol not existance in this module";
+ return 0;
+ }
+
+ ent = slot_alloc (sym);
+
+ if (!ent)
+ return 0;
+
+ /* catch it with a slot in the hashing table */
+ insert (pobj->htab, ent);
+
+ memcpy (ent->fdesc, pobj->pentry, sizeof (ent->fdesc));
+
+ /* now ent->fdesc[0] is the virtual address of entry point
+ * and ent->fdesc[1] is the TOC of the module
+ */
+
+ /* let's calculate the virtual address of the symbol
+ * by adding a relative offset getting from the module
+ * file symbol table, i.e
+ *
+ * functin virtual address = entry point virtual address +
+ * + ( function offset in file - entry point offset in file )
+ */
+
+ (ent->fdesc)[0] = (ent->fdesc)[0] +
+ (nl[1].n_value - nl[0].n_value);
+
+ /* return the function descriptor */
+ return ent->fdesc;