Set inode for vdso to 0.
authorSoren Sandmann <sandmann@daimi.au.dk>
Thu, 23 Nov 2006 08:03:02 +0000 (08:03 +0000)
committerSøren Sandmann Pedersen <ssp@src.gnome.org>
Thu, 23 Nov 2006 08:03:02 +0000 (08:03 +0000)
2006-11-23  Soren Sandmann <sandmann@daimi.au.dk>

        * process.c (read_maps): Set inode for vdso to 0.

        * binfile.c (read_inode): Return -1 on error, 0 on vdso
        (bin_file_new): Only read the inode if the file actually exists
        and is an elf file.
        (bin_file_check_inode): Return FALSE if there is no file.

ChangeLog
binfile.c
process.c

index 01db7f7..342f378 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-11-23  Soren Sandmann <sandmann@daimi.au.dk>
+
+       * process.c (read_maps): Set inode for vdso to 0.
+
+       * binfile.c (read_inode): Return -1 on error, 0 on vdso
+       (bin_file_new): Only read the inode if the file actually exists
+       and is an elf file.
+       (bin_file_check_inode): Return FALSE if there is no file.
+
 2006-11-22  Soren Sandmann <sandmann@daimi.au.dk>
 
        * sfile.c (sfile_load): Use GMappedFile instead
index d53ca83..89b4421 100644 (file)
--- a/binfile.c
+++ b/binfile.c
@@ -54,16 +54,17 @@ struct BinFile
     ino_t      inode;
 };
 
-/* FIXME: error handling */
 static ino_t
 read_inode (const char *filename)
 {
     struct stat statbuf;
 
     if (strcmp (filename, "[vdso]") == 0)
+       return (ino_t)0;
+    
+    if (stat (filename, &statbuf) < 0)
        return (ino_t)-1;
-
-    stat (filename, &statbuf);
+    
     return statbuf.st_ino;
 }
 
@@ -242,6 +243,13 @@ bin_file_new (const char *filename)
     {
        bf = g_new0 (BinFile, 1);
 
+       bf->inode_check = FALSE;
+       bf->filename = g_strdup (filename);
+       bf->undefined_name = g_strdup_printf ("In file %s", filename);
+       bf->ref_count = 1;
+       
+       g_hash_table_insert (bin_files, bf->filename, bf);
+       
        if (strcmp (filename, "[vdso]") == 0)
        {
            gsize length;
@@ -295,15 +303,8 @@ bin_file_new (const char *filename)
            else
                g_print ("   opened the original elf file\n");
 #endif
+           bf->inode = read_inode (filename);
        }
-
-       bf->inode_check = FALSE;
-       bf->inode = read_inode (filename);
-       bf->filename = g_strdup (filename);
-       bf->undefined_name = g_strdup_printf ("In file %s", filename);
-       bf->ref_count = 1;
-       
-       g_hash_table_insert (bin_files, bf->filename, bf);
     }
     
     return bf;
@@ -369,6 +370,9 @@ bin_file_check_inode   (BinFile         *bin_file,
     if (bin_file->inode == inode)
        return TRUE;
 
+    if (!bin_file->elf)
+       return FALSE;
+    
     if (!bin_file->inode_check)
     {
        g_print ("warning: %s has inode %lld. It should be %lld\n",
index 972f5f1..63832c9 100644 (file)
--- a/process.c
+++ b/process.c
@@ -106,10 +106,12 @@ read_maps (int pid, int *n_maps)
            {
                /* For the vdso, the kernel reports 'offset' as the
                 * the same as the mapping addres. This doesn't make
-                * any sense to me, so we just zero it here.
+                * any sense to me, so we just zero it here. There
+                * is code in binfile.c (read_inode) that returns 0
+                * for [vdso].
                 */
                map.offset = 0;
-               map.inode = -1;
+               map.inode = 0;
            }
            else
            {