Skip to content

Commit

Permalink
always exclude ELF dynamic linker/loader
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeut committed Apr 18, 2020
1 parent 507619b commit 1a4bf56
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
3 changes: 2 additions & 1 deletion auditwheel/elfutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def elf_find_versioned_symbols(elf: ELFFile) -> Iterator[Tuple[str, str]]:

if section is not None:
for verneed, verneed_iter in section.iter_versions():
if verneed.name.startswith('ld-linux'):
if verneed.name.startswith('ld-linux') or \
verneed.name in ['ld64.so.2', 'ld64.so.1']:
continue
for vernaux in verneed_iter:
yield (verneed.name,
Expand Down
7 changes: 5 additions & 2 deletions auditwheel/policy/external_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ def lddtree_external_references(lddtree: Dict, wheel_path: str):

def filter_libs(libs, whitelist):
for lib in libs:
if 'ld-linux' in lib:
# always exclude ld-linux.so
if 'ld-linux' in lib or lib in ['ld64.so.2', 'ld64.so.1']:
# always exclude ELF dynamic linker/loader
# 'ld64.so.2' on s390x
# 'ld64.so.1' on ppc64le
# 'ld-linux*' on other platforms
continue
if LIBPYTHON_RE.match(lib):
# always exclude libpythonXY
Expand Down
14 changes: 13 additions & 1 deletion tests/integration/testdependencies/testdependencies.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#endif
#include <Python.h>

static __thread int tres = 0;

static PyObject *
run(PyObject *self, PyObject *args)
{
Expand All @@ -24,14 +26,24 @@ run(PyObject *self, PyObject *args)
#else
res = 0;
#endif
return PyLong_FromLong(res);
return PyLong_FromLong(res + tres);
}

static PyObject *
set_tres(PyObject *self, PyObject *args)
{
(void)self;
(void)args;
tres = 1;
return PyLong_FromLong(tres);
}

/* Module initialization */
PyMODINIT_FUNC PyInit_testdependencies(void)
{
static PyMethodDef module_methods[] = {
{"run", (PyCFunction)run, METH_NOARGS, "run."},
{"set_tres", (PyCFunction)set_tres, METH_NOARGS, "set_tres."},
{NULL} /* Sentinel */
};
static struct PyModuleDef moduledef = {
Expand Down
9 changes: 6 additions & 3 deletions tests/unit/test_elfutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,16 @@ def test_find_symbols(self):
# THEN
assert symbols == [("foo-lib", "foo-lib")]

def test_only_ld_linux(self):
@pytest.mark.parametrize('ld_name', ['ld-linux', 'ld64.so.2', 'ld64.so.1'])
def test_only_ld_linux(self, ld_name):
# GIVEN
elf = Mock()
verneed = Mock()
verneed.configure_mock(name="ld-linux")
verneed.configure_mock(name=ld_name)
veraux = Mock()
veraux.configure_mock(name="foo-lib")
elf.get_section_by_name.return_value.iter_versions.return_value = (
(verneed, []),
(verneed, [veraux]),
)

# WHEN
Expand Down

0 comments on commit 1a4bf56

Please sign in to comment.