]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ctf: cater for elfutils 0.156 change in dwfl_report_elf() prototype
authorNick Alcock <nick.alcock@oracle.com>
Thu, 23 Jan 2014 23:20:22 +0000 (23:20 +0000)
committerNick Alcock <nick.alcock@oracle.com>
Tue, 21 Jul 2015 14:29:27 +0000 (15:29 +0100)
This version of elfutils breaks source compatibility, adding a new parameter to
dwfl_report_elf().  Compensate for this in a manner that does not break
compilation with older elfutils.

Orabug: 18117421
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Reviewed-by: Jerry Snitselaar <jerry.snitselaar@oracle.com>
scripts/Makefile
scripts/dwarf2ctf/Makefile
scripts/dwarf2ctf/dwarf2ctf.c
scripts/dwarf2ctf/eu_simple.c [new file with mode: 0644]
scripts/eu_simple.c [new file with mode: 0644]
scripts/eu_simple.h [new file with mode: 0644]
scripts/kallsyms.c

index 4cdb5168e91b5fd77764e542e66b3e6db2e2ce17..e7e81b87841d08917ddcd98d490dd742f5a3a473 100644 (file)
@@ -22,8 +22,11 @@ HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include
 
 always         := $(hostprogs-y) $(hostprogs-m)
 
-HOSTCFLAGS_kallsyms.o := $(shell pkg-config --cflags glib-2.0) -g
-HOSTLOADLIBES_kallsyms := $(shell pkg-config --libs glib-2.0) -ldw -g
+kallsyms-objs   := kallsyms.o eu_simple.o
+
+HOSTCFLAGS_eu_simple.o := -I$(srctree)/scripts
+HOSTCFLAGS_kallsyms.o := $(shell pkg-config --cflags glib-2.0) -I$(srctree)/scripts
+HOSTLOADLIBES_kallsyms := $(shell pkg-config --libs glib-2.0) -ldw
 
 # The following hostprogs-y programs are only build on demand
 hostprogs-y += unifdef docproc
index ad89de7679ad04afbc4285d07fe9b12da9acb8d4..73a0016fce92051da9c4ddad3663f62d72862c7d 100644 (file)
@@ -3,7 +3,11 @@ ifndef CONFIG_DT_DISABLE_CTF
 hostprogs-y    := dwarf2ctf
 always         := $(hostprogs-y)
 
-HOSTCFLAGS_dwarf2ctf.o := $(shell pkg-config --cflags glib-2.0)
+dwarf2ctf-objs  := dwarf2ctf.o eu_simple.o
+
+HOSTCFLAGS_eu_simple.o := -I$(srctree)/scripts
+HOSTCFLAGS_dwarf2ctf.o := $(shell pkg-config --cflags glib-2.0) -I$(srctree)/scripts
+
 HOSTLOADLIBES_dwarf2ctf := -ldtrace-ctf -lelf -ldw $(shell pkg-config --libs glib-2.0) -lz
 endif
 endif
index 7e75d24ae20992d8fb4e035a539de288274f64c6..3f1d41ef0dfdbb89b042d133708d042fb8bb6d65 100644 (file)
@@ -2,7 +2,7 @@
  * dwarf2ctf.c: Read in DWARF[23] debugging information from some set of ELF
  * files, and generate CTF in correspondingly-named files.
  *
- * (C) 2011, 2012 Oracle, Inc.  All rights reserved.
+ * (C) 2011, 2012, 2013, 2014 Oracle, Inc.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 #include <dwarf.h>
 #include <elfutils/libdwfl.h>
 #include <elfutils/libdw.h>
+#include <elfutils/version.h>
 #include <sys/ctf_api.h>
 #include <glib.h>
 
+#include <eu_simple.h>
+
 #ifndef PATH_MAX
 #define PATH_MAX 1024
 #endif
@@ -592,16 +595,6 @@ static long count_ctf_members(ctf_file_t *fp, ctf_id_t souid);
 static int count_ctf_members_internal(const char *name, ctf_id_t member,
                                      ulong_t offset, void *count);
 
-/*
- * Wrap up dwfl_new() complexities.
- */
-static Dwfl *private_dwfl_new(const char *file_name);
-
-/*
- * The converse of private_dwfl_new().
- */
-static void private_dwfl_free(Dwfl *dwfl);
-
 /*
  * Given a DIE that may contain a type attribute, look up the target of that
  * attribute and return it, or NULL if none.
@@ -644,18 +637,6 @@ static char *fn_to_module(const char *file_name);
  */
 static const char *abs_file_name(const char *file_name);
 
-/*
- * Stub libdwfl callback, use only the ELF handle passed in.
- */
-static int no_debuginfo(Dwfl_Module *mod __unused__,
-                       void **userdata __unused__,
-                       const char *modname __unused__,
-                       Dwarf_Addr base __unused__,
-                       const char *file_name __unused__,
-                       const char *debuglink_file __unused__,
-                       GElf_Word debuglink_crc __unused__,
-                       char **debuginfo_file_name __unused__);
-
 /*
  * Trivial wrapper, avoid an incompatible pointer type warning.
  */
@@ -1247,7 +1228,7 @@ static void init_tu_to_modules(void)
                 * construct mappings from each TU to "vmlinux".
                 */
 
-               Dwfl *dwfl = private_dwfl_new(builtin_objects[i]);
+               Dwfl *dwfl = simple_dwfl_new(builtin_objects[i]);
                Dwarf_Die *tu = NULL;
                Dwarf_Addr junk;
 
@@ -1260,7 +1241,7 @@ static void init_tu_to_modules(void)
                                                     xstrdup(tu_name),
                                                     xstrdup("vmlinux"));
                }
-               private_dwfl_free(dwfl);
+               simple_dwfl_free(dwfl);
        }
 
        /*
@@ -1275,7 +1256,7 @@ static void init_tu_to_modules(void)
                 * mappings from each TU to the module name.
                 */
 
-               Dwfl *dwfl = private_dwfl_new(builtin_modules[i]);
+               Dwfl *dwfl = simple_dwfl_new(builtin_modules[i]);
                Dwarf_Die *tu = NULL;
                Dwarf_Addr junk;
 
@@ -1288,7 +1269,7 @@ static void init_tu_to_modules(void)
                                                     xstrdup(tu_name),
                                                     xstrdup(module_name));
                }
-               private_dwfl_free(dwfl);
+               simple_dwfl_free(dwfl);
                free(module_name);
        }
 }
@@ -1526,7 +1507,7 @@ static void process_file(const char *file_name,
        char *fn_module_name = fn_to_module(file_name);
        const char *module_name = fn_module_name;
 
-       Dwfl *dwfl = private_dwfl_new(file_name);
+       Dwfl *dwfl = simple_dwfl_new(file_name);
        GHashTable *seen_before = g_hash_table_new_full(g_str_hash, g_str_equal,
                                                        free, free);
        Dwarf_Die *tu_die = NULL;
@@ -1603,7 +1584,7 @@ static void process_file(const char *file_name,
        }
 
        free(fn_module_name);
-       private_dwfl_free(dwfl);
+       simple_dwfl_free(dwfl);
        g_hash_table_destroy(seen_before);
 
        return;
@@ -3435,47 +3416,6 @@ static void write_types(char *output_dir)
 
 /* Utilities.  */
 
-/*
- * Wrap up dwfl_new() complexities.
- */
-static Dwfl *private_dwfl_new(const char *file_name)
-{
-       const char *err;
-       static Dwfl_Callbacks cb = { .find_debuginfo = no_debuginfo,
-                                    .section_address = dwfl_offline_section_address };
-       Dwfl *dwfl = dwfl_begin(&cb);
-
-       if (dwfl == NULL) {
-               err = "initialize libdwfl";
-               goto fail;
-       }
-
-       if (dwfl_report_elf(dwfl, "", file_name, -1, 0) == NULL) {
-               err = "open object file with libdwfl";
-               goto fail;
-       }
-
-       if (dwfl_report_end(dwfl, NULL, NULL) != 0) {
-               err = "finish opening object file with libdwfl";
-               goto fail;
-       }
-
-       return dwfl;
- fail:
-       fprintf(stderr, "Cannot %s for %s: %s\n", err, file_name,
-               dwfl_errmsg(dwfl_errno()));
-       exit(1);
-}
-
-/*
- * The converse of private_dwfl_new().
- */
-static void private_dwfl_free(Dwfl *dwfl)
-{
-       dwfl_report_end(dwfl, NULL, NULL);
-       dwfl_end(dwfl);
-}
-
 /*
  * Given a DIE that may contain a type attribute, look up the target of that
  * attribute and return it, or NULL if none.
@@ -3757,21 +3697,6 @@ static int count_ctf_members_internal(const char *name, ctf_id_t member,
        return 0;
 }
 
-/*
- * Stub libdwfl callback, use only the ELF handle passed in.
- */
-static int no_debuginfo(Dwfl_Module *mod __unused__,
-                       void **userdata __unused__,
-                       const char *modname __unused__,
-                       Dwarf_Addr base __unused__,
-                       const char *file_name __unused__,
-                       const char *debuglink_file __unused__,
-                       GElf_Word debuglink_crc __unused__,
-                       char **debuginfo_file_name __unused__)
-{
-       return -1;
-}
-
 /*
  * Trivial wrapper, avoid an incompatible pointer type warning.
  */
diff --git a/scripts/dwarf2ctf/eu_simple.c b/scripts/dwarf2ctf/eu_simple.c
new file mode 100644 (file)
index 0000000..66d821e
--- /dev/null
@@ -0,0 +1 @@
+#include "../eu_simple.c"
diff --git a/scripts/eu_simple.c b/scripts/eu_simple.c
new file mode 100644 (file)
index 0000000..9c7f8ac
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Convenience wrappers for functions in elfutils.
+ *
+ * (C) 2014 Oracle, Inc.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <stdlib.h>
+#include <elfutils/libdwfl.h>
+#include <elfutils/version.h>
+
+#include <eu_simple.h>
+
+#ifndef __GNUC__
+#define __attribute__((foo))
+#endif
+
+#define __unused__ __attribute__((__unused__))
+
+/*
+ * A version of dwfl_report_elf() that compensates for parameter changes in
+ * newer elfutils.
+ */
+static Dwfl_Module *private_dwfl_report_elf(Dwfl *dwfl, const char *name,
+                                           const char *file_name, int fd,
+                                           GElf_Addr base)
+{
+#if _ELFUTILS_PREREQ(0,156)
+       return dwfl_report_elf(dwfl, name, file_name, fd, base, 0);
+#else
+       return dwfl_report_elf(dwfl, name, file_name, fd, base);
+#endif
+}
+
+/*
+ * Stub libdwfl callback, use only the ELF handle passed in.
+ */
+static int no_debuginfo(Dwfl_Module *mod __unused__,
+                       void **userdata __unused__,
+                       const char *modname __unused__,
+                       Dwarf_Addr base __unused__,
+                       const char *file_name __unused__,
+                       const char *debuglink_file __unused__,
+                       GElf_Word debuglink_crc __unused__,
+                       char **debuginfo_file_name __unused__)
+{
+       return -1;
+}
+
+/*
+ * Wrap up dwfl_new() complexities.
+ */
+Dwfl *simple_dwfl_new(const char *file_name)
+{
+       const char *err;
+       static Dwfl_Callbacks cb = { .find_debuginfo = no_debuginfo,
+                                    .section_address = dwfl_offline_section_address };
+       Dwfl *dwfl = dwfl_begin(&cb);
+
+       if (dwfl == NULL) {
+               err = "initialize libdwfl";
+               goto fail;
+       }
+
+       if (private_dwfl_report_elf(dwfl, "", file_name, -1, 0) == NULL) {
+               err = "open object file with libdwfl";
+               goto fail;
+       }
+
+       if (dwfl_report_end(dwfl, NULL, NULL) != 0) {
+               err = "finish opening object file with libdwfl";
+               goto fail;
+       }
+
+       return dwfl;
+ fail:
+       fprintf(stderr, "Cannot %s for %s: %s\n", err, file_name,
+               dwfl_errmsg(dwfl_errno()));
+       exit(1);
+}
+
+/*
+ * The converse of simple_dwfl_new().
+ */
+void simple_dwfl_free(Dwfl *dwfl)
+{
+       dwfl_report_end(dwfl, NULL, NULL);
+       dwfl_end(dwfl);
+}
diff --git a/scripts/eu_simple.h b/scripts/eu_simple.h
new file mode 100644 (file)
index 0000000..90491b5
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Simplifying wrappers for functions in elfutils.
+ *
+ * (C) 2014 Oracle, Inc.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef _LINUX_EU_SIMPLE_H
+#define _LINUX_EU_SIMPLE_H
+
+/*
+ * Wrap up dwfl_new() complexities.
+ */
+Dwfl *simple_dwfl_new(const char *file_name);
+
+/*
+ * The converse of simple_dwfl_new().
+ */
+void simple_dwfl_free(Dwfl *dwfl);
+
+#endif
index b96f2328b4704c081e0155d8b5298a6ded4d05bf..861d760f3389c00726243c9c27d2086d5c61059b 100644 (file)
@@ -34,6 +34,8 @@
 #include <elfutils/libdw.h>
 #include <glib.h>
 
+#include <eu_simple.h>
+
 #ifndef ARRAY_SIZE
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
 #endif
@@ -739,61 +741,6 @@ static void make_percpus_absolute(void)
 
 /* Built-in module list computation. */
 
-/*
- * Stub libdwfl callback, use only the ELF handle passed in.
- */
-static int no_debuginfo(Dwfl_Module *mod,
-                       void **userdata,
-                       const char *modname,
-                       Dwarf_Addr base,
-                       const char *file_name,
-                       const char *debuglink_file,
-                       GElf_Word debuglink_crc,
-                       char **debuginfo_file_name)
-{
-       return -1;
-}
-
-/*
- * Wrap up dwfl_new() complexities.
- */
-static Dwfl *private_dwfl_new(const char *file_name)
-{
-       const char *err;
-       static Dwfl_Callbacks cb = { .find_debuginfo = no_debuginfo,
-                                    .section_address = dwfl_offline_section_address };
-       Dwfl *dwfl = dwfl_begin(&cb);
-
-       if (dwfl == NULL) {
-               err = "initialize libdwfl";
-               goto fail;
-       }
-
-       if (dwfl_report_elf(dwfl, "", file_name, -1, 0) == NULL) {
-               err = "open object file with libdwfl";
-               goto fail;
-       }
-
-       if (dwfl_report_end(dwfl, NULL, NULL) != 0) {
-               err = "finish opening object file with libdwfl";
-               goto fail;
-       }
-
-       return dwfl;
- fail:
-       fprintf(stderr, "Cannot %s for %s: %s\n", err, file_name,
-               dwfl_errmsg(dwfl_errno()));
-       exit(1);
-}
-
-/*
- * The converse of private_dwfl_new().
- */
-static void private_dwfl_free(Dwfl *dwfl)
-{
-       dwfl_report_end(dwfl, NULL, NULL);
-}
-
 /*
  * Populate the symbol_to_module mapping for one built-in module.
  */
@@ -801,7 +748,7 @@ static void read_module_symbols(unsigned int module_name,
                                const char *module_path,
                                GHashTable *module_symbol_seen)
 {
-       Dwfl *dwfl = private_dwfl_new(module_path);
+       Dwfl *dwfl = simple_dwfl_new(module_path);
        Dwarf_Die *tu = NULL;
        Dwarf_Addr junk;
        unsigned int *module_idx = NULL;
@@ -886,7 +833,7 @@ static void read_module_symbols(unsigned int module_name,
                                module_path, dwarf_errmsg(dwarf_errno()));
                }
        }
-       private_dwfl_free(dwfl);
+       simple_dwfl_free(dwfl);
 
        /*
         * Work over all the symbols seen in this module and note that in future