]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Move nested functions check64 and check32 in link_map.c to file scope.
authorChih-Hung Hsieh <chh@google.com>
Tue, 17 Nov 2015 22:45:15 +0000 (14:45 -0800)
committerMark Wielaard <mjw@redhat.com>
Sun, 3 Jan 2016 21:24:51 +0000 (22:24 +0100)
* In libdwfl/link_map.c, nested functions check64, check32, are moved
  to file scope to compile with clang.

Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
libdwfl/ChangeLog
libdwfl/link_map.c

index 8657da45a8525cab5df9e2c7dcb7a69de3a75db1..f3266af682b9a2c40526aa11db5c22c831c503a4 100644 (file)
@@ -1,3 +1,8 @@
+2015-11-17  Chih-Hung Hsieh <chh@google.com>
+
+       * link_map.c (auxv_format_probe): Move nested functions
+       check64 and check32 to file scope.
+
 2015-12-08  Jose E. Marchesi  <jose.marchesi@oracle.com>
 
        * dwfl_frame.c (state_fetch_pc): Add a backend-defined offset to
index 2bc0400664086a79ec835e2f3da4407b63dd7e94..28d7382fca5eb7de4e9206201f40b87ff83db0ac 100644 (file)
 #define PROBE_VAL64    sizeof (Elf64_Phdr)
 
 
-/* Examine an auxv data block and determine its format.
-   Return true iff we figured it out.  */
-static bool
-auxv_format_probe (const void *auxv, size_t size,
-                  uint_fast8_t *elfclass, uint_fast8_t *elfdata)
+static inline bool
+do_check64 (size_t i, const Elf64_auxv_t (*a64)[], uint_fast8_t *elfdata)
 {
-  const Elf32_auxv_t (*a32)[size / sizeof (Elf32_auxv_t)] = (void *) auxv;
-  const Elf64_auxv_t (*a64)[size / sizeof (Elf64_auxv_t)] = (void *) auxv;
+  /* The AUXV pointer might not even be naturally aligned for 64-bit
+     data, because note payloads in a core file are not aligned.  */
 
-  inline bool check64 (size_t i)
-  {
-    /* The AUXV pointer might not even be naturally aligned for 64-bit
-       data, because note payloads in a core file are not aligned.  */
+  uint64_t type = read_8ubyte_unaligned_noncvt (&(*a64)[i].a_type);
+  uint64_t val = read_8ubyte_unaligned_noncvt (&(*a64)[i].a_un.a_val);
 
-    uint64_t type = read_8ubyte_unaligned_noncvt (&(*a64)[i].a_type);
-    uint64_t val = read_8ubyte_unaligned_noncvt (&(*a64)[i].a_un.a_val);
+  if (type == BE64 (PROBE_TYPE)
+      && val == BE64 (PROBE_VAL64))
+    {
+      *elfdata = ELFDATA2MSB;
+      return true;
+    }
 
-    if (type == BE64 (PROBE_TYPE)
-       && val == BE64 (PROBE_VAL64))
-      {
-       *elfdata = ELFDATA2MSB;
-       return true;
-      }
+  if (type == LE64 (PROBE_TYPE)
+      && val == LE64 (PROBE_VAL64))
+    {
+      *elfdata = ELFDATA2LSB;
+      return true;
+    }
 
-    if (type == LE64 (PROBE_TYPE)
-       && val == LE64 (PROBE_VAL64))
-      {
-       *elfdata = ELFDATA2LSB;
-       return true;
-      }
+  return false;
+}
 
-    return false;
-  }
+#define check64(n) do_check64 (n, a64, elfdata)
 
-  inline bool check32 (size_t i)
-  {
-    /* The AUXV pointer might not even be naturally aligned for 32-bit
-       data, because note payloads in a core file are not aligned.  */
+static inline bool
+do_check32 (size_t i, const Elf32_auxv_t (*a32)[], uint_fast8_t *elfdata)
+{
+  /* The AUXV pointer might not even be naturally aligned for 32-bit
+     data, because note payloads in a core file are not aligned.  */
 
-    uint32_t type = read_4ubyte_unaligned_noncvt (&(*a32)[i].a_type);
-    uint32_t val = read_4ubyte_unaligned_noncvt (&(*a32)[i].a_un.a_val);
+  uint32_t type = read_4ubyte_unaligned_noncvt (&(*a32)[i].a_type);
+  uint32_t val = read_4ubyte_unaligned_noncvt (&(*a32)[i].a_un.a_val);
 
-    if (type == BE32 (PROBE_TYPE)
-       && val == BE32 (PROBE_VAL32))
-      {
-       *elfdata = ELFDATA2MSB;
-       return true;
-      }
+  if (type == BE32 (PROBE_TYPE)
+      && val == BE32 (PROBE_VAL32))
+    {
+      *elfdata = ELFDATA2MSB;
+      return true;
+    }
 
-    if (type == LE32 (PROBE_TYPE)
-       && val == LE32 (PROBE_VAL32))
-      {
-       *elfdata = ELFDATA2LSB;
-       return true;
-      }
+  if (type == LE32 (PROBE_TYPE)
+      && val == LE32 (PROBE_VAL32))
+    {
+      *elfdata = ELFDATA2LSB;
+      return true;
+    }
 
-    return false;
-  }
+  return false;
+}
+
+#define check32(n) do_check32 (n, a32, elfdata)
+
+/* Examine an auxv data block and determine its format.
+   Return true iff we figured it out.  */
+static bool
+auxv_format_probe (const void *auxv, size_t size,
+                  uint_fast8_t *elfclass, uint_fast8_t *elfdata)
+{
+  const Elf32_auxv_t (*a32)[size / sizeof (Elf32_auxv_t)] = (void *) auxv;
+  const Elf64_auxv_t (*a64)[size / sizeof (Elf64_auxv_t)] = (void *) auxv;
 
   for (size_t i = 0; i < size / sizeof (Elf64_auxv_t); ++i)
     {