]> sourceware.org Git - glibc.git/commitdiff
* elf/dl-load.c: Don't include dl-osinfo.h here.
authorRoland McGrath <roland@gnu.org>
Wed, 30 Mar 2005 02:07:41 +0000 (02:07 +0000)
committerRoland McGrath <roland@gnu.org>
Wed, 30 Mar 2005 02:07:41 +0000 (02:07 +0000)
ChangeLog
elf/dl-load.c
sysdeps/unix/sysv/linux/dl-osinfo.h

index ac148f03496e683d4e92948e284fbba40dd2dac7..cc508e969c33e749c555fadcc1174446ed6d3512 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@
        (DL_SYSDEP_OSCHECK): ... here.  Use that.
        Do the discovery and set GLRO(dl_osversion) if successful,
        if __LINUX_KERNEL_VERSION <= 0.
+       * elf/dl-load.c: Don't include dl-osinfo.h here.
 
 2005-03-29  Alfred M. Szmidt  <ams@gnu.org>
 
index d9c2da2ac75ae28604d2306218fbb028a971ae50..2ca108ef698356278d130e1cb6fe4ec0a8e9d916 100644 (file)
@@ -33,7 +33,6 @@
 #include <sys/types.h>
 #include "dynamic-link.h"
 #include <abi-tag.h>
-#include <dl-osinfo.h>
 #include <stackinfo.h>
 #include <caller.h>
 #include <sysdep.h>
index dfb4cde72d34f98acf188cbd3dd39bbc2c03c96b..befa804cb1fa1f62214a3060b2d786193b41e2ff 100644 (file)
@@ -43,6 +43,45 @@ dl_fatal (const char *str)
 static inline int __attribute__ ((always_inline))
 _dl_discover_osversion (void)
 {
+#if (defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_DSO) && defined SHARED
+  if (GLRO(dl_sysinfo_map) != NULL)
+    {
+      /* If the kernel-supplied DSO contains a note indicating the kernel's
+        version, we don't need to call uname or parse any strings.  */
+
+      static const struct
+      {
+       ElfW(Word) vendorlen;
+       ElfW(Word) datalen;
+       ElfW(Word) type;
+       char vendor[8];
+      } expected_note = { sizeof "Linux", sizeof (ElfW(Word)), 0, "Linux" };
+      const ElfW(Phdr) *const phdr = GLRO(dl_sysinfo_map)->l_phdr;
+      const ElfW(Word) phnum = GLRO(dl_sysinfo_map)->l_phnum;
+      for (uint_fast16_t i = 0; i < phnum; ++i)
+       if (phdr[i].p_type == PT_NOTE)
+         {
+           const ElfW(Addr) start = (phdr[i].p_vaddr
+                                     + GLRO(dl_sysinfo_map)->l_addr);
+           const struct
+           {
+             ElfW(Word) vendorlen;
+             ElfW(Word) datalen;
+             ElfW(Word) type;
+           } *note = (const void *) start;
+           while ((ElfW(Addr)) (note + 1) - start < phdr[i].p_memsz)
+             {
+               if (!memcmp (note, &expected_note, sizeof expected_note))
+                 return *(const ElfW(Word) *) ((const void *) note
+                                               + sizeof expected_note);
+#define ROUND(len) (((len) + sizeof (ElfW(Word)) - 1) & -sizeof (ElfW(Word)))
+               note = ((const void *) (note + 1)
+                       + ROUND (note->vendorlen) + ROUND (note->datalen));
+             }
+         }
+    }
+#endif
+
   char bufmem[64];
   char *buf = bufmem;
   unsigned int version;
This page took 0.047308 seconds and 5 git commands to generate.