From: Mark Wielaard Date: Tue, 15 Oct 2013 21:53:32 +0000 (+0200) Subject: libdwfl: Don't report and abort on non-file mappings in maps. X-Git-Tag: elfutils-0.158~87 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d182974079c7205973ae7885b95216a5b83b6f82;p=thirdparty%2Felfutils.git libdwfl: Don't report and abort on non-file mappings in maps. proc_maps_report, used for -p or -M, could report modules with names that were not absolute file names (and not the special vdso marker). dwfl_linux_proc_find_elf would abort on such names. This isn't a very nice thing to do in a library. Make sure only real (absolute) file mappings are reported and don't abort when unexpected file names are found, just report failure. Test case with some examples as found in Linux /proc/PID/maps added. Signed-off-by: Mark Wielaard --- diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 4d119fd92..b6729c77d 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,9 @@ +2013-10-15 Mark Wielaard + + * linux-proc-maps.c (proc_maps_report): Ignore non-absolute file + mappings. + (dwfl_linux_proc_find_elf): Don't abort, just return failure. + 2013-09-12 Mark Wielaard * cu.c (intern_cu): If dwarf_offdie fails free cu. diff --git a/libdwfl/linux-proc-maps.c b/libdwfl/linux-proc-maps.c index 10946b9c3..4eaccdba8 100644 --- a/libdwfl/linux-proc-maps.c +++ b/libdwfl/linux-proc-maps.c @@ -232,7 +232,7 @@ proc_maps_report (Dwfl *dwfl, FILE *f, GElf_Addr sysinfo_ehdr, pid_t pid) } char *file = line + nread + strspn (line + nread, " \t"); - if (file[0] == '\0' || (ino == 0 && dmajor == 0 && dminor == 0)) + if (file[0] != '/' || (ino == 0 && dmajor == 0 && dminor == 0)) /* This line doesn't indicate a file mapping. */ continue; @@ -373,7 +373,6 @@ dwfl_linux_proc_find_elf (Dwfl_Module *mod __attribute__ ((unused)), return -1; } - abort (); return -1; } INTDEF (dwfl_linux_proc_find_elf) diff --git a/tests/ChangeLog b/tests/ChangeLog index db248dc0c..f6b794b20 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2013-10-15 Mark Wielaard + + * run-unstrip-M.sh: New test. + * Makefile.am (TESTS): Add run-unstrip-M.sh. + (EXTRA_DIST): Likewise. + 2013-10-06 Mark Wielaard * run-addrcfi.sh: Remove nop from expected ppc and ppc64 @@ -7,7 +13,7 @@ * typeiter2.c: New file, reversing typeiter.c. * run-typeiter.sh: Also run typeiter2. - * Makefile.am (ckeck_PROGRAMS): Add typeiter2. + * Makefile.am (check_PROGRAMS): Add typeiter2. (typeiter2_LDADD): New variable. 2013-09-26 Petr Machata diff --git a/tests/Makefile.am b/tests/Makefile.am index de98e456c..f3c56bffb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -65,7 +65,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \ run-strip-test3.sh run-strip-test4.sh run-strip-test5.sh \ run-strip-test6.sh run-strip-test7.sh run-strip-test8.sh \ run-strip-groups.sh run-strip-reloc.sh \ - run-unstrip-test.sh run-unstrip-test2.sh \ + run-unstrip-test.sh run-unstrip-test2.sh run-unstrip-M.sh \ run-ecp-test.sh run-ecp-test2.sh run-alldts.sh \ run-elflint-test.sh run-elflint-self.sh run-ranlib-test.sh \ run-ranlib-test2.sh run-ranlib-test3.sh run-ranlib-test4.sh \ @@ -125,7 +125,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ run-strip-test7.sh run-strip-test8.sh run-strip-groups.sh \ run-strip-reloc.sh hello_i386.ko.bz2 hello_x86_64.ko.bz2 \ hello_ppc64.ko.bz2 hello_s390.ko.bz2 \ - run-unstrip-test.sh run-unstrip-test2.sh \ + run-unstrip-test.sh run-unstrip-test2.sh run-unstrip-M.sh\ run-elflint-self.sh run-ranlib-test.sh run-ranlib-test2.sh \ run-ranlib-test3.sh run-ranlib-test4.sh \ run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \ diff --git a/tests/run-unstrip-M.sh b/tests/run-unstrip-M.sh new file mode 100755 index 000000000..614a8aa52 --- /dev/null +++ b/tests/run-unstrip-M.sh @@ -0,0 +1,51 @@ +#! /bin/sh +# Copyright (C) 2013 Red Hat, Inc. +# This file is part of elfutils. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# elfutils is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. $srcdir/test-subr.sh + +# Linux /proc/PID/maps file with some non-file entries (and fake exe/lib names). +tempfiles testmaps +cat > testmaps <