mirror of
https://github.com/FRRouting/frr.git
synced 2025-04-30 13:37:17 +02:00
lib/clippy: add libelf wrapper
This adds _clippy.ELFFile, which provides a fast wrapper around libelf. The API is similar to / a subset of pyelfutils, which unfortunately is painfully slow (to the tune of minutes instead of seconds.) The idea is that xrefs can be read out of ELF files by reading out the "xref_array" section or "FRRouting/XREF" note. Signed-off-by: David Lamparter <equinox@diac24.net>
This commit is contained in:
parent
4fe016fe13
commit
5609b3af49
14
configure.ac
14
configure.ac
|
@ -794,6 +794,20 @@ fi
|
|||
#
|
||||
|
||||
AS_IF([test "$host" = "$build"], [
|
||||
AC_CHECK_HEADER([gelf.h], [], [
|
||||
AC_MSG_ERROR([libelf headers are required for building clippy. (Host only when cross-compiling.)])
|
||||
])
|
||||
AC_CHECK_LIB([elf], [elf_memory], [], [
|
||||
AC_MSG_ERROR([libelf is required for building clippy. (Host only when cross-compiling.)])
|
||||
])
|
||||
|
||||
AC_CHECK_LIB([elf], [elf_getdata_rawchunk], [
|
||||
AC_DEFINE([HAVE_ELF_GETDATA_RAWCHUNK], [1], [Have elf_getdata_rawchunk()])
|
||||
])
|
||||
AC_CHECK_LIB([elf], [gelf_getnote], [
|
||||
AC_DEFINE([HAVE_GELF_GETNOTE], [1], [Have gelf_getnote()])
|
||||
])
|
||||
|
||||
FRR_PYTHON_DEV
|
||||
], [
|
||||
FRR_PYTHON
|
||||
|
|
1
debian/control
vendored
1
debian/control
vendored
|
@ -13,6 +13,7 @@ Build-Depends: bison,
|
|||
install-info,
|
||||
libc-ares-dev,
|
||||
libcap-dev,
|
||||
libelf-dev,
|
||||
libjson-c-dev | libjson0-dev,
|
||||
libpam0g-dev | libpam-dev,
|
||||
libpcre3-dev,
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#ifndef _FRR_CLIPPY_H
|
||||
#define _FRR_CLIPPY_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <Python.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -28,6 +29,7 @@ extern "C" {
|
|||
|
||||
extern PyObject *clippy_parse(PyObject *self, PyObject *args);
|
||||
extern PyMODINIT_FUNC command_py_init(void);
|
||||
extern bool elf_py_init(PyObject *pymod);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -345,5 +345,7 @@ PyMODINIT_FUNC command_py_init(void)
|
|||
PyModule_AddObject(pymod, "GraphNode", (PyObject *)&typeobj_graph_node);
|
||||
Py_INCREF(&typeobj_graph);
|
||||
PyModule_AddObject(pymod, "Graph", (PyObject *)&typeobj_graph);
|
||||
if (!elf_py_init(pymod))
|
||||
initret(NULL);
|
||||
initret(pymod);
|
||||
}
|
||||
|
|
1301
lib/elf_py.c
Normal file
1301
lib/elf_py.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -410,7 +410,7 @@ lib_grammar_sandbox_LDADD = \
|
|||
|
||||
lib_clippy_CPPFLAGS = $(AM_CPPFLAGS) -D_GNU_SOURCE -DBUILDING_CLIPPY
|
||||
lib_clippy_CFLAGS = $(PYTHON_CFLAGS)
|
||||
lib_clippy_LDADD = $(PYTHON_LIBS) $(UST_LIBS)
|
||||
lib_clippy_LDADD = $(PYTHON_LIBS) $(UST_LIBS) -lelf
|
||||
lib_clippy_LDFLAGS = -export-dynamic
|
||||
lib_clippy_SOURCES = \
|
||||
lib/jhash.c \
|
||||
|
@ -420,9 +420,11 @@ lib_clippy_SOURCES = \
|
|||
lib/command_parse.y \
|
||||
lib/command_py.c \
|
||||
lib/defun_lex.l \
|
||||
lib/elf_py.c \
|
||||
lib/graph.c \
|
||||
lib/libfrr_trace.c \
|
||||
lib/memory.c \
|
||||
lib/typesafe.c \
|
||||
lib/vector.c \
|
||||
# end
|
||||
|
||||
|
|
Loading…
Reference in a new issue