Fix the following compiler warning:
```
lib/elf_py.c: In function _elffile_load_:
lib/elf_py.c:1310:34: warning: _calloc_ sizes specified with _sizeof_ in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
1310 | w->sects = calloc(sizeof(PyObject *), w->ehdr->e_shnum);
| ^~~~~~~~
lib/elf_py.c:1310:34: note: earlier argument should specify number of elements, later size of each element
```
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
While clippy tries really, really hard to work under adverse conditions,
and this catches missing XREF_SETUP() on almost all CPU architectures,
this doesn't quite work on hppa. So, make it a warning on *all*
platforms (or error for --enable-dev-build) in order to catch it before
shipping off to Debian's buildd and blowing up there...
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Mostly to make coverity happy, no compiler/linker should produce broken
ELF files like this (and if it does we can't process it anyway...)
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
David rightly pointed out that having a test for fd > 0 would
technically not be right, but not wrong for this portion of the
code since we know that we would never get a fd = 0 in this section.
In any event let's make coverity happy and move on with our life.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
The error condition handled both failure to open
and a fstat failure. Just double check that the close
is appropriate to call.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
If symvalid is false, looking at symidx is bogus.
This fixes a build-time SEGV on mips64el.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This has already been a requirement for Solaris, it is still a
requirement for some of the autoconf feature checks to work correctly,
and it will be a requirement for `-fms-extensions`.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
elf_getdata_rawchunk() already endian-converts; doing it again is, uh,
counterproductive.
Fixes: #10051
Reported-by: Lucian Cristian <lucian.cristian@gmail.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
... need to ignore TLS sections, their address is effectively
meaningless but can overlap other sections we actually need to access.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This fixes some spurious warnings on *BSD, where `elffile_add_dynreloc`
isn't used since `elf_getdata_rawchunk` is not available.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
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>