[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [hivexml] Relinking warning and shared library error (was: Re: [Hivex] [PATCH v3] Report last-modified time of hive root and nodes)



Hi Richard, all,

The modifications make sense.  I'm happier with the nested if tests instead of the gotos.  Thank you.

I noticed while I was producing the patch that I had to have the filetime_to_8601 in xml/hivexml.c due to a linking error.  I would've liked to have the function in lib/hivex.c, but I hit a strange linking error when I had the function and its prototype placed as in the patch below.  It's strange because the extern doesn't appear to be in a strange place, and there is no static restriction on the function definition, so the function seems to me like it should behave like any of the other API functions.  Could it be a linking eror against an old library?  The last few lines of `make V=1` in a Fedora 15 VM are:

Making all in xml
make[2]: Entering directory `/home/alex/local/src/hivex/xml'
/bin/sh ../libtool  --tag=CC   --mode=link gcc -std=gnu99 -DLOCALEBASEDIR=\""/usr/local/share/locale"\" -I../gnulib/lib -I../lib -I/usr/include/libxml2   -g -O2   -o hivexml hivexml-hivexml.o ../lib/libhivex.la -lxml2 -lz -lm 
libtool: link: gcc -std=gnu99 -DLOCALEBASEDIR=\"/usr/local/share/locale\" -I../gnulib/lib -I../lib -I/usr/include/libxml2 -g -O2 -o .libs/hivexml hivexml-hivexml.o  ../lib/.libs/libhivex.so -lxml2 -lz -lm -Wl,-rpath -Wl,/usr/local/lib
hivexml-hivexml.o: In function `node_start':
/home/alex/local/src/hivex/xml/hivexml.c:167: undefined reference to `filetime_to_8601'
hivexml-hivexml.o: In function `main':
/home/alex/local/src/hivex/xml/hivexml.c:129: undefined reference to `filetime_to_8601'
collect2: ld returned 1 exit status
make[2]: *** [hivexml] Error 1
make[2]: Leaving directory `/home/alex/local/src/hivex/xml'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/alex/local/src/hivex'
make: *** [all] Error 2


I think I've found a related issue while trying to get hivexml running from the GIt source on a fresh Ubuntu 11.04 VM.  I asked about the linking error because Ubuntu warns about relinking, though it did compile (without the below patch moving filetime_to_8601 around).

Environment:  Completely new virtual machine, with this command ran for dependencies:
sudo apt-get install git libtool autopoint ocaml autoconf libxml2-dev python-dev

To build, I cd'd into the git-clone'd directory and ran:
./autogen.sh && make V=1 && sudo make install

At the 'sudo make install' phase, this warning appeared:
libtool: install: warning: relinking 'libhivexmod.la'
The relinking warning remained after running 'sudo make uninstall' and 'make clean' in succession, and even removing the cloned folder and starting over again.

Also, running hivexml raised this error:
hivexml: error while loading shared libraries: libhivex.so.0: cannot open shared object file: No such file or directory
I needed this line in my ~/.bashrc to get the shared library working:
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
If that's a complaint about Ubuntu in general, though, than I guess it's not a problem for a Redhat mailing list.

--Alex


---
 generator/generator.ml |    6 ++++++
 lib/hivex.c            |   34 ++++++++++++++++++++++++++++++++++
 xml/hivexml.c          |   42 ------------------------------------------
 3 files changed, 40 insertions(+), 42 deletions(-)

diff --git a/generator/generator.ml b/generator/generator.ml
index 943039c..47ddc31 100755
--- a/generator/generator.ml
+++ b/generator/generator.ml
@@ -710,6 +710,12 @@ let rec generate_c_header () =
 extern \"C\" {
 #endif
 
+#include <time.h>
+#define WINDOWS_TICK 10000000LL
+#define SEC_TO_UNIX_EPOCH 11644473600LL
+#define TIMESTAMP_BUF_LEN 32
+extern char *filetime_to_8601 (int64_t windows_ticks);
+
 /* NOTE: This API is documented in the man page hivex(3). */
 
 /* Hive handle. */
diff --git a/lib/hivex.c b/lib/hivex.c
index dceea73..e1a2c87 100644
--- a/lib/hivex.c
+++ b/lib/hivex.c
@@ -266,6 +266,40 @@ header_checksum (const hive_h *h)
   return sum;
 }
 
+/* Convert Windows filetime to ISO 8601 format.
+ * http://stackoverflow.com/questions/6161776/convert-windows-filetime-to-second-in-unix-linux/6161842#6161842
+ *
+ * Source for time_t->char* conversion: Fiwalk version 0.6.14's
+ * fiwalk.cpp.
+ *
+ * The caller should free the returned buffer.
+ */
+char *
+filetime_to_8601 (int64_t windows_ticks)
+{
+  char *ret;
+  time_t t;
+  struct tm *tm;
+
+  t = windows_ticks / WINDOWS_TICK - SEC_TO_UNIX_EPOCH;
+  tm = gmtime (&t);
+  if (tm == NULL)
+    return NULL;
+
+  ret = malloc (TIMESTAMP_BUF_LEN);
+  if (ret == NULL) {
+    perror ("malloc");
+    exit (EXIT_FAILURE);
+  }
+
+  if (strftime (ret, TIMESTAMP_BUF_LEN, "%FT%TZ", tm) == 0) {
+    perror ("strftime");
+    exit (EXIT_FAILURE);
+  }
+
+  return ret;
+}
+
 #define HIVEX_OPEN_MSGLVL_MASK (HIVEX_OPEN_VERBOSE|HIVEX_OPEN_DEBUG)
 
 hive_h *
diff --git a/xml/hivexml.c b/xml/hivexml.c
index 2967ac9..a846799 100644
--- a/xml/hivexml.c
+++ b/xml/hivexml.c
@@ -25,7 +25,6 @@
 #include <inttypes.h>
 #include <unistd.h>
 #include <errno.h>
-#include <time.h>
 
 #include <libxml/xmlwriter.h>
 
@@ -40,8 +39,6 @@
 //#define N_(str) str
 #endif
 
-static char *filetime_to_8601 (int64_t windows_ticks);
-
 /* Callback functions. */
 static int node_start (hive_h *, void *, hive_node_h, const char *name);
 static int node_end (hive_h *, void *, hive_node_h, const char *name);
@@ -155,45 +152,6 @@ main (int argc, char *argv[])
   exit (EXIT_SUCCESS);
 }
 
-/* Convert Windows filetime to ISO 8601 format.
- * http://stackoverflow.com/questions/6161776/convert-windows-filetime-to-second-in-unix-linux/6161842#6161842
- *
- * Source for time_t->char* conversion: Fiwalk version 0.6.14's
- * fiwalk.cpp.
- *
- * The caller should free the returned buffer.
- */
-
-#define WINDOWS_TICK 10000000LL
-#define SEC_TO_UNIX_EPOCH 11644473600LL
-#define TIMESTAMP_BUF_LEN 32
-
-static char *
-filetime_to_8601 (int64_t windows_ticks)
-{
-  char *ret;
-  time_t t;
-  struct tm *tm;
-
-  t = windows_ticks / WINDOWS_TICK - SEC_TO_UNIX_EPOCH;
-  tm = gmtime (&t);
-  if (tm == NULL)
-    return NULL;
-
-  ret = malloc (TIMESTAMP_BUF_LEN);
-  if (ret == NULL) {
-    perror ("malloc");
-    exit (EXIT_FAILURE);
-  }
-
-  if (strftime (ret, TIMESTAMP_BUF_LEN, "%FT%TZ", tm) == 0) {
-    perror ("strftime");
-    exit (EXIT_FAILURE);
-  }
-
-  return ret;
-}
-
 static int
 node_start (hive_h *h, void *writer_v, hive_node_h node, const char *name)
 {
-- 
1.7.6



On Aug 13, 2011, at 01:46 , Richard W.M. Jones wrote:

> 
> I have modified the code quite a lot before committing it.  Please
> take a look:
> 
> http://git.annexia.org/?p=hivex.git;a=commitdiff;h=e0b21193257f9784b28e931525f2a382a74775c6
> 
> Thanks for your contribution,
> 
> Rich.
> 
> -- 
> Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
> libguestfs lets you edit virtual machines.  Supports shell scripting,
> bindings from many languages.  http://libguestfs.org



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]