From ba949b3fdaf4fa8631af0d999a44d71c0964b5ce Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 10 Jan 2007 20:44:29 +0000 Subject: [PATCH] 2007-01-10 Roland McGrath * dwfl-bug-addr-overflow.c: New file. * Makefile.am (TESTS): Add it. (dwfl_bug_addr_overflow_LDADD): New variable. --- libdwfl/ChangeLog | 4 ++ libdwfl/libdwfl.h | 6 ++- tests/ChangeLog | 6 +++ tests/Makefile.am | 9 ++-- tests/dwfl-bug-addr-overflow.c | 81 ++++++++++++++++++++++++++++++++++ 5 files changed, 101 insertions(+), 5 deletions(-) create mode 100644 tests/dwfl-bug-addr-overflow.c diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 0ee9633e1..e14cce9cf 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,7 @@ +2007-01-10 Roland McGrath + + * libdwfl.h (dwfl_begin): Require nonnull argument. + 2006-12-27 Roland McGrath * dwfl_module.c (compare_modules): Fix address comparison to avoid diff --git a/libdwfl/libdwfl.h b/libdwfl/libdwfl.h index a7e8caeef..9fe3dca0e 100644 --- a/libdwfl/libdwfl.h +++ b/libdwfl/libdwfl.h @@ -1,5 +1,5 @@ /* Interfaces for libdwfl. - Copyright (C) 2005, 2006 Red Hat, Inc. + Copyright (C) 2005, 2006, 2007 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -94,7 +94,9 @@ extern "C" { #endif /* Start a new session with the library. */ -extern Dwfl *dwfl_begin (const Dwfl_Callbacks *callbacks); +extern Dwfl *dwfl_begin (const Dwfl_Callbacks *callbacks) + __nonnull_attribute__ (1); + /* End a session. */ extern void dwfl_end (Dwfl *); diff --git a/tests/ChangeLog b/tests/ChangeLog index 372ff7ebb..3a75bd1c7 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2007-01-10 Roland McGrath + + * dwfl-bug-addr-overflow.c: New file. + * Makefile.am (TESTS): Add it. + (dwfl_bug_addr_overflow_LDADD): New variable. + 2006-12-17 Roland McGrath * msg_tst.c (libelf_msgs): Fix ELF_E_INVALID_PHDR msg. diff --git a/tests/Makefile.am b/tests/Makefile.am index bc46c42e5..93a2f8e30 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to create Makefile.in ## -## Copyright (C) 1996-2002, 2003, 2004, 2005, 2006 Red Hat, Inc. +## Copyright (C) 1996-2002, 2003, 2004, 2005, 2006, 2007 Red Hat, Inc. ## This file is part of Red Hat elfutils. ## ## Red Hat elfutils is free software; you can redistribute it and/or modify @@ -58,7 +58,8 @@ noinst_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \ show-die-info get-files get-lines get-pubnames \ get-aranges allfcts line2addr addrscopes funcscopes \ show-abbrev hash newscn ecp dwflmodtest \ - find-prologues funcretval allregs rdwrmmap + find-prologues funcretval allregs rdwrmmap \ + dwfl-bug-addr-overflow # get-ciefde asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \ asm-tst6 asm-tst7 asm-tst8 asm-tst9 @@ -75,7 +76,8 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \ run-ranlib-test2.sh run-ranlib-test3.sh run-ranlib-test4.sh \ run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \ run-find-prologues.sh run-allregs.sh run-readelf-test1.sh \ - run-native-test.sh run-bug1-test.sh + run-native-test.sh run-bug1-test.sh \ + dwfl-bug-addr-overflow # run-show-ciefde.sh if !STANDALONE @@ -198,6 +200,7 @@ asm_tst8_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl asm_tst9_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl dwflmodtest_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl rdwrmmap_LDADD = $(libelf) +dwfl_bug_addr_overflow_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl CLEANFILES = xxx *.gcno *.gcda *gconv diff --git a/tests/dwfl-bug-addr-overflow.c b/tests/dwfl-bug-addr-overflow.c new file mode 100644 index 000000000..0e875dac1 --- /dev/null +++ b/tests/dwfl-bug-addr-overflow.c @@ -0,0 +1,81 @@ +/* Test program for libdwfl basic module tracking, relocation. + Copyright (C) 2007 Red Hat, Inc. + This file is part of Red Hat elfutils. + + Red Hat elfutils 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; version 2 of the License. + + Red Hat 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 Red Hat elfutils; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. + + Red Hat elfutils is an included package of the Open Invention Network. + An included package of the Open Invention Network is a package for which + Open Invention Network licensees cross-license their patents. No patent + license is granted, either expressly or impliedly, by designation as an + included package. Should you wish to participate in the Open Invention + Network licensing program, please visit www.openinventionnetwork.com + . */ + +#include +#include +#include +#include +#include +#include +#include +#include ELFUTILS_HEADER(dwfl) + + +static const Dwfl_Callbacks offline_callbacks = + { + .find_debuginfo = INTUSE(dwfl_standard_find_debuginfo), + .section_address = INTUSE(dwfl_offline_section_address), + }; + + +int +main (void) +{ + /* We use no threads here which can interfere with handling a stream. */ + (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER); + + /* Set locale. */ + (void) setlocale (LC_ALL, ""); + + Dwfl *dwfl = dwfl_begin (&offline_callbacks); + assert (dwfl != NULL); + + Dwfl_Module *high = dwfl_report_module (dwfl, "high", + UINT64_C (0xffffffff00010000), + UINT64_C (0xffffffff00020000)); + assert (high); + Dwfl_Module *low = dwfl_report_module (dwfl, "low", + UINT64_C (0x00010000), + UINT64_C (0x00020000)); + assert (low); + Dwfl_Module *middle = dwfl_report_module (dwfl, "middle", + UINT64_C (0xffff00010000), + UINT64_C (0xffff00020000)); + assert (middle); + + int ret = dwfl_report_end (dwfl, NULL, NULL); + assert (ret == 0); + + Dwfl_Module *mod = dwfl_addrmodule (dwfl, UINT64_C (0xffffffff00010123)); + assert (mod == high); + mod = dwfl_addrmodule (dwfl, UINT64_C (0x00010123)); + assert (mod == low); + mod = dwfl_addrmodule (dwfl, UINT64_C (0xffff00010123)); + assert (mod == middle); + + dwfl_end (dwfl); + + return 0; +} -- 2.47.2