summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/clippy/__init__.py1
-rw-r--r--python/clippy/elf.py11
-rw-r--r--python/xrelfo.py15
3 files changed, 25 insertions, 2 deletions
diff --git a/python/clippy/__init__.py b/python/clippy/__init__.py
index 60119fbac0..668724ab2a 100644
--- a/python/clippy/__init__.py
+++ b/python/clippy/__init__.py
@@ -20,6 +20,7 @@ from _clippy import (
CMD_ATTR_HIDDEN,
CMD_ATTR_DEPRECATED,
CMD_ATTR_NOSH,
+ elf_notes,
)
diff --git a/python/clippy/elf.py b/python/clippy/elf.py
index cc442eeda9..fd348428f0 100644
--- a/python/clippy/elf.py
+++ b/python/clippy/elf.py
@@ -458,7 +458,16 @@ class ELFSubset(object):
- `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):
"""
diff --git a/python/xrelfo.py b/python/xrelfo.py
index a40b19e5fb..07cd74071f 100644
--- a/python/xrelfo.py
+++ b/python/xrelfo.py
@@ -22,7 +22,7 @@ import argparse
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
@@ -327,6 +327,7 @@ class Xrelfo(dict):
}
)
self._xrefs = []
+ self.note_warn = False
def load_file(self, filename):
orig_filename = filename
@@ -395,6 +396,15 @@ class Xrelfo(dict):
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")
@@ -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))