Skip to content

Commit

Permalink
Merge pull request #15902 from opensourcerouting/build-xref-setup-hppa
Browse files Browse the repository at this point in the history
build: fix missing `XREF_SETUP` (and HP PA-RISC build failure)
  • Loading branch information
donaldsharp committed May 6, 2024
2 parents 9de2f13 + 2e84c37 commit 216bac2
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 2 deletions.
5 changes: 5 additions & 0 deletions fpm/fpm_pb.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@
/*
* Main file for the fpm_pb library.
*/

#include "config.h"
#include "xref.h"

XREF_SETUP();
9 changes: 9 additions & 0 deletions lib/elf_py.c
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,15 @@ bool elf_py_init(PyObject *pymod)
(void)methods_elfpy;
#endif

#if defined(HAVE_GELF_GETNOTE) && defined(HAVE_ELF_GETDATA_RAWCHUNK)
PyObject *elf_notes = Py_True;
#else
PyObject *elf_notes = Py_False;
#endif
Py_INCREF(elf_notes);
if (PyModule_AddObject(pymod, "elf_notes", elf_notes))
Py_DECREF(elf_notes);

ELFFormatError = PyErr_NewException("_clippy.ELFFormatError",
PyExc_ValueError, NULL);
PyModule_AddObject(pymod, "ELFFormatError", ELFFormatError);
Expand Down
6 changes: 6 additions & 0 deletions mgmtd/mgmt_be_nb.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later

#include "config.h"
#include "xref.h"

XREF_SETUP();
1 change: 1 addition & 0 deletions mgmtd/subdir.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ clippy_scan += \

lib_LTLIBRARIES += mgmtd/libmgmt_be_nb.la
mgmtd_libmgmt_be_nb_la_SOURCES = \
mgmtd/mgmt_be_nb.c \
zebra/zebra_cli.c \
# end
nodist_mgmtd_libmgmt_be_nb_la_SOURCES = \
Expand Down
1 change: 1 addition & 0 deletions python/clippy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
CMD_ATTR_HIDDEN,
CMD_ATTR_DEPRECATED,
CMD_ATTR_NOSH,
elf_notes,
)


Expand Down
11 changes: 10 additions & 1 deletion python/clippy/elf.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,16 @@ def __getitem__(self, k):
- `this[123:str]` - extract until null byte. The slice stop value is
the `str` type (or, technically, `unicode`.)
"""
return self._obj[k]
if k.start < getattr(self._obj, "len", float("+Inf")):
return self._obj[k]

real_sect = self._elffile.get_section_addr(self._obj.sh_addr + k.start)
offs = self._obj.sh_addr - real_sect.sh_addr
if k.stop is str:
new_k = slice(k.start + offs, str)
else:
new_k = slice(k.start + offs, k.stop + offs)
return real_sect[new_k]

def getreloc(self, offset):
"""
Expand Down
15 changes: 14 additions & 1 deletion python/xrelfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from clippy.uidhash import uidhash
from clippy.elf import *
from clippy import frr_top_src, CmdAttr
from clippy import frr_top_src, CmdAttr, elf_notes
from tiabwarfo import FieldApplicator
from xref2vtysh import CommandEntry

Expand Down Expand Up @@ -327,6 +327,7 @@ def __init__(self):
}
)
self._xrefs = []
self.note_warn = False

def load_file(self, filename):
orig_filename = filename
Expand Down Expand Up @@ -395,6 +396,15 @@ def load_elf(self, filename, orig_filename):
ptrs = edf.iter_data(XrefPtr, slice(start, end))

else:
if elf_notes:
self.note_warn = True
sys.stderr.write(
"""%s: warning: binary has no FRRouting.XREF note
%s- one of FRR_MODULE_SETUP, FRR_DAEMON_INFO or XREF_SETUP must be used
"""
% (orig_filename, orig_filename)
)

xrefarray = edf.get_section("xref_array")
if xrefarray is None:
raise ValueError("file has neither xref note nor xref_array section")
Expand Down Expand Up @@ -471,6 +481,9 @@ def _main(args):
sys.stderr.write("while processing %s:\n" % (fn))
traceback.print_exc()

if xrelfo.note_warn and args.Werror:
errors += 1

for option in dir(args):
if option.startswith("W") and option != "Werror":
checks = sorted(xrelfo.check(args))
Expand Down
5 changes: 5 additions & 0 deletions qpb/qpb.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@
/*
* Main file for the qpb library.
*/

#include "config.h"
#include "xref.h"

XREF_SETUP();
2 changes: 2 additions & 0 deletions zebra/fpm_listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include "fpm/fpm.h"
#include "lib/libfrr.h"

XREF_SETUP();

struct glob {
int server_sock;
int sock;
Expand Down

0 comments on commit 216bac2

Please sign in to comment.