From 41e96dc8f0a700a440c7bb87fbbd1cc70271ff15 Mon Sep 17 00:00:00 2001 From: Caroline Tice Date: Sun, 8 Sep 2013 16:35:14 -0700 Subject: Update libvtv testsuite so that most of the tests now run under the dejagnu test harness. From-SVN: r202373 --- libvtv/ChangeLog | 81 ++++ libvtv/testsuite/Makefile.am | 57 +-- libvtv/testsuite/Makefile.in | 105 +++-- libvtv/testsuite/config/default.exp | 17 + libvtv/testsuite/const_vtable.cc | 82 ---- libvtv/testsuite/dataentry.cc | 37 -- libvtv/testsuite/dlopen.cc | 38 -- libvtv/testsuite/dlopen_mt.cc | 112 ----- libvtv/testsuite/dup_name.cc | 60 --- libvtv/testsuite/environment-fail-32.s | 514 --------------------- libvtv/testsuite/environment-fail-64.s | 425 ----------------- libvtv/testsuite/environment.cc | 37 -- libvtv/testsuite/event-definitions.cc | 10 - libvtv/testsuite/event-main.cc | 13 - libvtv/testsuite/event-private.cc | 10 - libvtv/testsuite/event-private.h | 7 - libvtv/testsuite/event.h | 29 -- libvtv/testsuite/event.list | 1 - libvtv/testsuite/field-test.cc | 94 ---- libvtv/testsuite/lib/libvtv-dg.exp | 21 + libvtv/testsuite/lib/libvtv.exp | 220 +++++++++ libvtv/testsuite/libvtv.cc/bb_tests.cc | 53 +++ libvtv/testsuite/libvtv.cc/const_vtable.cc | 83 ++++ libvtv/testsuite/libvtv.cc/dataentry.cc | 39 ++ libvtv/testsuite/libvtv.cc/derived-lib.cpp | 18 + libvtv/testsuite/libvtv.cc/derived-main.cpp | 18 + libvtv/testsuite/libvtv.cc/derived.list | 1 + libvtv/testsuite/libvtv.cc/dup_name.cc | 62 +++ libvtv/testsuite/libvtv.cc/environment.cc | 38 ++ libvtv/testsuite/libvtv.cc/event-defintions.cpp | 10 + libvtv/testsuite/libvtv.cc/event-main.cpp | 15 + libvtv/testsuite/libvtv.cc/event-private.cpp | 10 + libvtv/testsuite/libvtv.cc/event-private.h | 7 + libvtv/testsuite/libvtv.cc/event.h | 29 ++ libvtv/testsuite/libvtv.cc/event.list | 1 + libvtv/testsuite/libvtv.cc/mul_inh.cc | 27 ++ libvtv/testsuite/libvtv.cc/nested_vcall_test.cc | 77 +++ .../libvtv.cc/parts-test-extra-parts-views.cpp | 16 + .../libvtv.cc/parts-test-extra-parts-views.h | 14 + .../testsuite/libvtv.cc/parts-test-extra-parts.cpp | 15 + .../testsuite/libvtv.cc/parts-test-extra-parts.h | 13 + libvtv/testsuite/libvtv.cc/parts-test-main.cpp | 39 ++ libvtv/testsuite/libvtv.cc/parts-test-main.h | 15 + libvtv/testsuite/libvtv.cc/parts-test.list | 1 + libvtv/testsuite/libvtv.cc/povray-derived.cc | 74 +++ libvtv/testsuite/libvtv.cc/register_set_pair.cc | 101 ++++ .../libvtv.cc/register_set_pair_inserts.cc | 106 +++++ .../testsuite/libvtv.cc/template-list-iostream.cc | 120 +++++ libvtv/testsuite/libvtv.cc/template-list.cc | 94 ++++ libvtv/testsuite/libvtv.cc/template-list2.cc | 46 ++ libvtv/testsuite/libvtv.cc/test1.cc | 74 +++ libvtv/testsuite/libvtv.cc/thunk.cc | 37 ++ .../testsuite/libvtv.cc/thunk_vtable_map_attack.cc | 113 +++++ libvtv/testsuite/libvtv.cc/v8-test-2.cc | 97 ++++ libvtv/testsuite/libvtv.cc/virtfunc-test.cc | 222 +++++++++ libvtv/testsuite/libvtv.cc/virtual_inheritance.cc | 48 ++ libvtv/testsuite/libvtv.cc/vtv.exp | 83 ++++ libvtv/testsuite/libvtv.cc/xlan-test.cc | 185 ++++++++ libvtv/testsuite/libvtv.mempool.cc/mempool.exp | 68 +++ .../libvtv.mempool.cc/mempool_negative.cc | 193 ++++++++ .../libvtv.mempool.cc/mempool_positive.cc | 199 ++++++++ libvtv/testsuite/libvtv.mt.cc/mt.exp | 68 +++ .../libvtv.mt.cc/register_set_pair_inserts_mt.cc | 156 +++++++ .../testsuite/libvtv.mt.cc/register_set_pair_mt.cc | 158 +++++++ libvtv/testsuite/mempool_negative.c | 196 -------- libvtv/testsuite/mempool_positive.c | 196 -------- libvtv/testsuite/nested_vcall_test.cc | 76 --- libvtv/testsuite/other-tests/Makefile.am | 52 +++ libvtv/testsuite/other-tests/Makefile.in | 379 +++++++++++++++ libvtv/testsuite/other-tests/README | 8 + libvtv/testsuite/other-tests/dlopen.cc | 38 ++ libvtv/testsuite/other-tests/dlopen_mt.cc | 112 +++++ libvtv/testsuite/other-tests/environment-fail-32.s | 514 +++++++++++++++++++++ libvtv/testsuite/other-tests/environment-fail-64.s | 425 +++++++++++++++++ libvtv/testsuite/other-tests/field-test.cc | 94 ++++ libvtv/testsuite/other-tests/replace-fail.cc | 11 + libvtv/testsuite/other-tests/so.cc | 93 ++++ libvtv/testsuite/other-tests/temp_deriv.cc | 67 +++ libvtv/testsuite/other-tests/temp_deriv2.cc | 69 +++ libvtv/testsuite/other-tests/temp_deriv3.cc | 79 ++++ libvtv/testsuite/parts-test-extra-parts-views.cc | 16 - libvtv/testsuite/parts-test-extra-parts-views.h | 14 - libvtv/testsuite/parts-test-extra-parts.cc | 15 - libvtv/testsuite/parts-test-extra-parts.h | 13 - libvtv/testsuite/parts-test-main.cc | 37 -- libvtv/testsuite/parts-test-main.h | 15 - libvtv/testsuite/parts-test.list | 1 - libvtv/testsuite/povray-derived.cc | 72 --- libvtv/testsuite/register_pair.cc | 39 -- libvtv/testsuite/register_pair_inserts.cc | 46 -- libvtv/testsuite/register_pair_inserts_mt.cc | 100 ---- libvtv/testsuite/register_pair_mt.cc | 102 ---- libvtv/testsuite/replace-fail.cc | 11 - libvtv/testsuite/so.cc | 93 ---- libvtv/testsuite/temp_deriv.cc | 67 --- libvtv/testsuite/temp_deriv2.cc | 69 --- libvtv/testsuite/temp_deriv3.cc | 79 ---- libvtv/testsuite/template-list-iostream.cc | 118 ----- libvtv/testsuite/template-list.cc | 92 ---- libvtv/testsuite/template-list2.cc | 44 -- libvtv/testsuite/thunk.cc | 35 -- libvtv/testsuite/thunk_vtable_map_attack.cc | 111 ----- libvtv/testsuite/virtual_inheritance.cc | 46 -- 103 files changed, 5194 insertions(+), 3263 deletions(-) create mode 100644 libvtv/testsuite/config/default.exp delete mode 100644 libvtv/testsuite/const_vtable.cc delete mode 100644 libvtv/testsuite/dataentry.cc delete mode 100644 libvtv/testsuite/dlopen.cc delete mode 100644 libvtv/testsuite/dlopen_mt.cc delete mode 100644 libvtv/testsuite/dup_name.cc delete mode 100644 libvtv/testsuite/environment-fail-32.s delete mode 100644 libvtv/testsuite/environment-fail-64.s delete mode 100644 libvtv/testsuite/environment.cc delete mode 100644 libvtv/testsuite/event-definitions.cc delete mode 100644 libvtv/testsuite/event-main.cc delete mode 100644 libvtv/testsuite/event-private.cc delete mode 100644 libvtv/testsuite/event-private.h delete mode 100644 libvtv/testsuite/event.h delete mode 100644 libvtv/testsuite/event.list delete mode 100644 libvtv/testsuite/field-test.cc create mode 100644 libvtv/testsuite/lib/libvtv-dg.exp create mode 100644 libvtv/testsuite/lib/libvtv.exp create mode 100644 libvtv/testsuite/libvtv.cc/bb_tests.cc create mode 100644 libvtv/testsuite/libvtv.cc/const_vtable.cc create mode 100644 libvtv/testsuite/libvtv.cc/dataentry.cc create mode 100644 libvtv/testsuite/libvtv.cc/derived-lib.cpp create mode 100644 libvtv/testsuite/libvtv.cc/derived-main.cpp create mode 100644 libvtv/testsuite/libvtv.cc/derived.list create mode 100644 libvtv/testsuite/libvtv.cc/dup_name.cc create mode 100644 libvtv/testsuite/libvtv.cc/environment.cc create mode 100644 libvtv/testsuite/libvtv.cc/event-defintions.cpp create mode 100644 libvtv/testsuite/libvtv.cc/event-main.cpp create mode 100644 libvtv/testsuite/libvtv.cc/event-private.cpp create mode 100644 libvtv/testsuite/libvtv.cc/event-private.h create mode 100644 libvtv/testsuite/libvtv.cc/event.h create mode 100644 libvtv/testsuite/libvtv.cc/event.list create mode 100644 libvtv/testsuite/libvtv.cc/mul_inh.cc create mode 100644 libvtv/testsuite/libvtv.cc/nested_vcall_test.cc create mode 100644 libvtv/testsuite/libvtv.cc/parts-test-extra-parts-views.cpp create mode 100644 libvtv/testsuite/libvtv.cc/parts-test-extra-parts-views.h create mode 100644 libvtv/testsuite/libvtv.cc/parts-test-extra-parts.cpp create mode 100644 libvtv/testsuite/libvtv.cc/parts-test-extra-parts.h create mode 100644 libvtv/testsuite/libvtv.cc/parts-test-main.cpp create mode 100644 libvtv/testsuite/libvtv.cc/parts-test-main.h create mode 100644 libvtv/testsuite/libvtv.cc/parts-test.list create mode 100644 libvtv/testsuite/libvtv.cc/povray-derived.cc create mode 100644 libvtv/testsuite/libvtv.cc/register_set_pair.cc create mode 100644 libvtv/testsuite/libvtv.cc/register_set_pair_inserts.cc create mode 100644 libvtv/testsuite/libvtv.cc/template-list-iostream.cc create mode 100644 libvtv/testsuite/libvtv.cc/template-list.cc create mode 100644 libvtv/testsuite/libvtv.cc/template-list2.cc create mode 100644 libvtv/testsuite/libvtv.cc/test1.cc create mode 100644 libvtv/testsuite/libvtv.cc/thunk.cc create mode 100644 libvtv/testsuite/libvtv.cc/thunk_vtable_map_attack.cc create mode 100644 libvtv/testsuite/libvtv.cc/v8-test-2.cc create mode 100644 libvtv/testsuite/libvtv.cc/virtfunc-test.cc create mode 100644 libvtv/testsuite/libvtv.cc/virtual_inheritance.cc create mode 100644 libvtv/testsuite/libvtv.cc/vtv.exp create mode 100644 libvtv/testsuite/libvtv.cc/xlan-test.cc create mode 100644 libvtv/testsuite/libvtv.mempool.cc/mempool.exp create mode 100644 libvtv/testsuite/libvtv.mempool.cc/mempool_negative.cc create mode 100644 libvtv/testsuite/libvtv.mempool.cc/mempool_positive.cc create mode 100644 libvtv/testsuite/libvtv.mt.cc/mt.exp create mode 100644 libvtv/testsuite/libvtv.mt.cc/register_set_pair_inserts_mt.cc create mode 100644 libvtv/testsuite/libvtv.mt.cc/register_set_pair_mt.cc delete mode 100644 libvtv/testsuite/mempool_negative.c delete mode 100644 libvtv/testsuite/mempool_positive.c delete mode 100644 libvtv/testsuite/nested_vcall_test.cc create mode 100644 libvtv/testsuite/other-tests/Makefile.am create mode 100644 libvtv/testsuite/other-tests/Makefile.in create mode 100644 libvtv/testsuite/other-tests/README create mode 100644 libvtv/testsuite/other-tests/dlopen.cc create mode 100644 libvtv/testsuite/other-tests/dlopen_mt.cc create mode 100644 libvtv/testsuite/other-tests/environment-fail-32.s create mode 100644 libvtv/testsuite/other-tests/environment-fail-64.s create mode 100644 libvtv/testsuite/other-tests/field-test.cc create mode 100644 libvtv/testsuite/other-tests/replace-fail.cc create mode 100644 libvtv/testsuite/other-tests/so.cc create mode 100644 libvtv/testsuite/other-tests/temp_deriv.cc create mode 100644 libvtv/testsuite/other-tests/temp_deriv2.cc create mode 100644 libvtv/testsuite/other-tests/temp_deriv3.cc delete mode 100644 libvtv/testsuite/parts-test-extra-parts-views.cc delete mode 100644 libvtv/testsuite/parts-test-extra-parts-views.h delete mode 100644 libvtv/testsuite/parts-test-extra-parts.cc delete mode 100644 libvtv/testsuite/parts-test-extra-parts.h delete mode 100644 libvtv/testsuite/parts-test-main.cc delete mode 100644 libvtv/testsuite/parts-test-main.h delete mode 100644 libvtv/testsuite/parts-test.list delete mode 100644 libvtv/testsuite/povray-derived.cc delete mode 100644 libvtv/testsuite/register_pair.cc delete mode 100644 libvtv/testsuite/register_pair_inserts.cc delete mode 100644 libvtv/testsuite/register_pair_inserts_mt.cc delete mode 100644 libvtv/testsuite/register_pair_mt.cc delete mode 100644 libvtv/testsuite/replace-fail.cc delete mode 100644 libvtv/testsuite/so.cc delete mode 100644 libvtv/testsuite/temp_deriv.cc delete mode 100644 libvtv/testsuite/temp_deriv2.cc delete mode 100644 libvtv/testsuite/temp_deriv3.cc delete mode 100644 libvtv/testsuite/template-list-iostream.cc delete mode 100644 libvtv/testsuite/template-list.cc delete mode 100644 libvtv/testsuite/template-list2.cc delete mode 100644 libvtv/testsuite/thunk.cc delete mode 100644 libvtv/testsuite/thunk_vtable_map_attack.cc delete mode 100644 libvtv/testsuite/virtual_inheritance.cc (limited to 'libvtv') diff --git a/libvtv/ChangeLog b/libvtv/ChangeLog index 265a861e8f9..20092f4d0a3 100644 --- a/libvtv/ChangeLog +++ b/libvtv/ChangeLog @@ -1,3 +1,84 @@ +2013-09-08 Caroline Tice + + * testsuite/event-main.cc: Move to libvtv.cc subdirectory. + * testsuite/environment.cc: Ditto. + * testsuite/template-list2.cc: Ditto. + * testsuite/event.h: Ditto. + * testsuite/dataentry.cc: Ditto. + * testsuite/event-private.h: Ditto. + * testsuite/virtual_inheritance.cc: Ditto. + * testsuite/povray-derived.cc: Ditto. + * testsuite/nested_vcall_test.cc: Ditto. + * testsuite/template-list-iostream.cc: Ditto. + * testsuite/parts-test-extra-parts-views.h: Ditto. + * testsuite/virtfunc-test.cc: Ditto. + * testsuite/parts-test-extra-parts.h: Ditto. + * testsuite/const_vtable.cc: Ditto. + * testsuite/template-list.cc: Ditto. + * testsuite/dup_name.cc: Ditto. + * testsuite/thunk.cc: Ditto. + * testsuite/parts-test-main.h: Ditto. + * testsuite/mul_inh.cc: Ditto. + * testsuite/test1.cc: Ditto. + * testsuite/bb_tests.cc: Ditto. + * testsuite/v8-test-2.cc: Ditto. + * testsuite/thunk_vtable_map_attack.cc: Ditto. + * testsuite/xlan-test.cc: Ditto. + * testsuite/parts-test-main.cpp: Move to libvtv.cc subdirectory and + change file extension from .cc to .cpp. + * testsuite/event-definitions.cpp: Ditto. + * testsuite/event-main.cpp: Ditto. + * testsuite/derived-main.cpp: Ditto. + * testsuite/derived-lib.cpp: Ditto. + * testsuite/event-private.cpp: Ditto. + * testsuite/parts-test-extra-parts-views.cpp: Ditto. + * testsuite/parts-test-extra-parts.cpp: Ditto. + * testsuite/parts-test.list: Move to libvtv.cc subdirectory. Change + file extensions inside file from .cc to .cpp. + * testsuite/event.list: Ditto. + * testsuite/derived.list: Ditto. + * testsuite/register_pair.cc: Move to libvtv.cc; rename file to + register_set_pair.cc; include stdlib.h, stdio.h stdint.h string.h + (KEY_TYPE_FIXED_SIZE): New define. + (key_buffer, name_string, fake_names): New global variables. + (generate_names): New function. + (vtv_string_hans): New function. + (main): Add call to generate_names. Update middle for-loop to + initialize new parameters for __VLTRegisterPair... calls; move calls + to __VLTRegisterPair... to middle for-loop. Add calls to + __VLTRegisterSet... + * testsuite/register_pair_mt.cc: Ditto; renamed to + register_set_pair_mt.cc + * testsuite/libvtv.cc/vtv.exp: New file. + * testsuite/libvtv.mempool.cc/mempool.exp: New file. + * testsuite/libvtv.mt.cc/mt.exp: New file. + * testsuite/lib/libvtv.exp: New file. + * testsuite/lib/libvtv-dg.exp: New file. + * testsuite/config/default.exp: New file. + * testsuite/Makefile.am: New file. (Old file was moved to other-tests + subdirectory.) + * testsuite/Makefile.in: New file (generated). + * testsuite/mempool_negative.c: Change to C++ file; move to + libvtv.mempool.cc; include vtv-change-permission.h. + (main): Add call to __VLTChangePermission. + * testsuite/mempool_positive.c: Change to C++ file; move to + libvtv.mempool.cc; include vtv-change-permission.h. + (main): Add call to __VLTChangePermission. + * testsuite/temp_deriv3.cc: Move to other-tests subdirectory. + * testsuite/environment-fail-64.s: Ditto. + * testsutite/dlopen.cc: Ditto. + * testsuite/so.cc: Ditto. + * testsuite/temp_deriv2.cc: Ditto. + * testsuite/field-test.cc: Ditto. + * testsuite/dlopen_mt.cc: Ditto. + * testsuite/environment-fail-32.s: Ditto. + * testsuite/temp_deriv.cc: Ditto. + * testsuite/replace-fail.cc: Ditto. + * testsuite/other-tests/Makefile.am: New file. Copied from the + Makefile.am that used to be in testsuite directory. + * testsuite/other-tests/Makefile.in: Generated. (New file). + * testsuite/other-tests/README: New file. + 2013-09-07 Paolo Carlini * testsuite/Makefile.am: Remove #if ENABLE_VTABLE_VERIFY check around diff --git a/libvtv/testsuite/Makefile.am b/libvtv/testsuite/Makefile.am index 56f76a79f5b..a2c1e9f4ea3 100644 --- a/libvtv/testsuite/Makefile.am +++ b/libvtv/testsuite/Makefile.am @@ -1,52 +1,11 @@ -## Makefile for the testsuite subdirectory of the VTV library. -## -## Copyright (C) 2013 Free Software Foundation, Inc. -## -## Process this file with automake to produce Makefile.in. -## -## This file is part of the Vtable Verification (VTV) Library. This -## library 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, or (at your option) -## any later version. +## Process this with automake to create Makefile.in -## This library 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. +AUTOMAKE_OPTIONS = foreign dejagnu -## You should have received a copy of the GNU General Public License -## along with this library; see the file COPYING3. If not see -## . +EXPECT = `if [ -f ../../expect/expect ] ; then \ + echo ../../expect/expect ; \ + else echo expect ; fi` -AUTOMAKE_OPTIONS = nostdinc - -# Runs the testsuite via a script. - -# Create subdirectories. -stamp-subdir: - if test ! -d lib64; then \ - mkdir -p lib64; \ - fi; \ - if test ! -d lib32; then \ - mkdir -p lib32; \ - fi; \ - echo `date` > stamp-subdir; - - -testing_script=${libvtv_srcdir}/scripts/run-testsuite.sh -check-script: ${testing_script} stamp-subdir - -@(chmod +x ${testing_script}; \ - ${testing_script} ${libvtv_srcdir} ${libvtv_builddir}) - -check-am: - $(MAKE) $(AM_MAKEFLAGS) check-script - -.PHONY: check-script - -# By adding these files here, automake will remove them for 'make clean' -CLEANFILES = *.out environment-fail-* stamp-* replace-fail-* - -# To remove directories. -clean-local: - rm -rf lib* +RUNTEST = `if [ -f ${srcdir}/../../dejagnu/runtest ] ; then \ + echo ${srcdir}/../../dejagnu/runtest ; \ + else echo runtest ; fi` diff --git a/libvtv/testsuite/Makefile.in b/libvtv/testsuite/Makefile.in index 66a75e16ea6..ba28e744f95 100644 --- a/libvtv/testsuite/Makefile.in +++ b/libvtv/testsuite/Makefile.in @@ -53,6 +53,8 @@ mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = +DEJATOOL = $(PACKAGE) +RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ @@ -190,11 +192,15 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ toplevel_builddir = @toplevel_builddir@ toplevel_srcdir = @toplevel_srcdir@ -AUTOMAKE_OPTIONS = nostdinc -testing_script = ${libvtv_srcdir}/scripts/run-testsuite.sh +AUTOMAKE_OPTIONS = foreign dejagnu +EXPECT = `if [ -f ../../expect/expect ] ; then \ + echo ../../expect/expect ; \ + else echo expect ; fi` + +RUNTEST = `if [ -f ${srcdir}/../../dejagnu/runtest ] ; then \ + echo ${srcdir}/../../dejagnu/runtest ; \ + else echo runtest ; fi` -# By adding these files here, automake will remove them for 'make clean' -CLEANFILES = *.out environment-fail-* stamp-* replace-fail-* all: all-am .SUFFIXES: @@ -240,7 +246,46 @@ TAGS: ctags: CTAGS CTAGS: + +check-DEJAGNU: site.exp + srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \ + EXPECT=$(EXPECT); export EXPECT; \ + runtest=$(RUNTEST); \ + if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ + exit_status=0; l='$(DEJATOOL)'; for tool in $$l; do \ + if $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) $(RUNTESTFLAGS); \ + then :; else exit_status=1; fi; \ + done; \ + else echo "WARNING: could not find \`runtest'" 1>&2; :;\ + fi; \ + exit $$exit_status +site.exp: Makefile + @echo 'Making a new site.exp file...' + @echo '## these variables are automatically generated by make ##' >site.tmp + @echo '# Do not edit here. If you wish to override these values' >>site.tmp + @echo '# edit the last section' >>site.tmp + @echo 'set srcdir $(srcdir)' >>site.tmp + @echo "set objdir `pwd`" >>site.tmp + @echo 'set build_alias "$(build_alias)"' >>site.tmp + @echo 'set build_triplet $(build_triplet)' >>site.tmp + @echo 'set host_alias "$(host_alias)"' >>site.tmp + @echo 'set host_triplet $(host_triplet)' >>site.tmp + @echo 'set target_alias "$(target_alias)"' >>site.tmp + @echo 'set target_triplet $(target_triplet)' >>site.tmp + @echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp + @test ! -f site.exp || \ + sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp + @-rm -f site.bak + @test ! -f site.exp || mv site.exp site.bak + @mv site.tmp site.exp + +distclean-DEJAGNU: + -rm -f site.exp site.bak + -l='$(DEJATOOL)'; for tool in $$l; do \ + rm -f $$tool.sum $$tool.log; \ + done check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU check: check-am all-am: Makefile installdirs: @@ -261,7 +306,6 @@ install-strip: mostlyclean-generic: clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) @@ -272,11 +316,11 @@ maintainer-clean-generic: @echo "it deletes files that may require special tools to rebuild." clean: clean-am -clean-am: clean-generic clean-libtool clean-local mostlyclean-am +clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile -distclean-am: clean-am distclean-generic +distclean-am: clean-am distclean-DEJAGNU distclean-generic dvi: dvi-am @@ -336,43 +380,20 @@ ps-am: uninstall-am: -.MAKE: install-am install-strip - -.PHONY: all all-am check check-am clean clean-generic clean-libtool \ - clean-local distclean distclean-generic distclean-libtool dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am - - -# Runs the testsuite via a script. - -# Create subdirectories. -stamp-subdir: - if test ! -d lib64; then \ - mkdir -p lib64; \ - fi; \ - if test ! -d lib32; then \ - mkdir -p lib32; \ - fi; \ - echo `date` > stamp-subdir; -check-script: ${testing_script} stamp-subdir - -@(chmod +x ${testing_script}; \ - ${testing_script} ${libvtv_srcdir} ${libvtv_builddir}) - -check-am: - $(MAKE) $(AM_MAKEFLAGS) check-script +.MAKE: check-am install-am install-strip -.PHONY: check-script +.PHONY: all all-am check check-DEJAGNU check-am clean clean-generic \ + clean-libtool distclean distclean-DEJAGNU distclean-generic \ + distclean-libtool dvi dvi-am html html-am info info-am install \ + install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + uninstall uninstall-am -# To remove directories. -clean-local: - rm -rf lib* # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/libvtv/testsuite/config/default.exp b/libvtv/testsuite/config/default.exp new file mode 100644 index 00000000000..6d5eba84f10 --- /dev/null +++ b/libvtv/testsuite/config/default.exp @@ -0,0 +1,17 @@ +# Copyright (C) 2013 Free Software Foundation, Inc. + +# This program 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. +# +# This program 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 GCC; see the file COPYING3. If not see +# . + +load_lib "standard.exp" diff --git a/libvtv/testsuite/const_vtable.cc b/libvtv/testsuite/const_vtable.cc deleted file mode 100644 index a0946abf4fe..00000000000 --- a/libvtv/testsuite/const_vtable.cc +++ /dev/null @@ -1,82 +0,0 @@ -extern "C" int printf(const char *,...); -struct V1 { - int v; - virtual int foo(); - V1(); - ~V1(); -}; -struct V2 : virtual V1 { - int v2; - virtual int foo(); - V2(); - ~V2(); -}; -struct C : virtual V1, virtual V2 { - int c; - virtual int foo(); - C(); - ~C(); -}; - -struct B { - int b; }; -struct D : B, C { - int d; - virtual int bar(); - D(); - ~D(); -}; -extern "C" int printf(const char *,...); -main() -{ - try { - D *d = new D; - delete d; - } catch (int) { - printf("Int caught\n"); - } -} - -int V1::foo() { - printf("V1::foo called\n"); return 1; } -V1::V1() : v(5) { - printf("V1 called\n"); } -V1::~V1() { - printf("~V1 called\n"); } - -int V2::foo() { - printf("V2::foo called\n"); return 1; } -V2::V2() : v2(6) { - printf("V2 called\n"); } -V2::~V2() { - printf("~V2 called\n"); } - -int C::foo() { - printf("C::foo called %d\n", c); return 1; } -C::C() : c(7) { - printf("C called\n"); - V1 *vv = this; vv->foo(); - C *cp = dynamic_cast(vv); - if (this == cp) { - printf("PASSED this == cp\n"); - } else { - printf("FAILED this != cp\n"); - } -} -C::~C() { - printf("~C called\n"); - V1 *vv = this; vv->foo(); - C *cp = dynamic_cast(vv); - if (this == cp) { - printf("PASSED this == cp\n"); - } else { - printf("FAILED this != cp\n"); - } -} - -int D::bar() { - printf("D::bar called\n"); return 1; } -D::D() : d(8) { - printf("D called\n"); throw 5; } -D::~D() { - printf("~D called\n"); } diff --git a/libvtv/testsuite/dataentry.cc b/libvtv/testsuite/dataentry.cc deleted file mode 100644 index fa027d5bc71..00000000000 --- a/libvtv/testsuite/dataentry.cc +++ /dev/null @@ -1,37 +0,0 @@ -template -class DataOutInterface -{ - public: - virtual ~DataOutInterface() {} -}; - -template -class DataOut_DoFData : public DataOutInterface -{ - public: - virtual ~DataOut_DoFData() {} - -class DataEntryBase { - public: - virtual ~DataEntryBase () {} -}; - -template -class DataEntry : public DataEntryBase -{ - public: - virtual ~DataEntry() {} -}; -}; - -template void Destroy(T * p) __attribute__((noinline)); -template void Destroy(T * p) -{ - delete p; -} - -int main() -{ - DataOut_DoFData<3,3>::DataEntryBase * p = new DataOut_DoFData<3,3>::DataEntry(); - Destroy(p); -} diff --git a/libvtv/testsuite/dlopen.cc b/libvtv/testsuite/dlopen.cc deleted file mode 100644 index 4ffbe83acf7..00000000000 --- a/libvtv/testsuite/dlopen.cc +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include -#include - - - -typedef void (*voidfn)(void); - -int failures = 0; - -void -__vtv_verify_fail (void **data_set_ptr, const void *vtbl_pointer) -{ - failures++; - return; -} - - -int main() -{ - char so_name[] = "so0.so"; - void * dlhandle = dlopen(so_name, RTLD_NOW); - if (!dlhandle) - { - fprintf(stderr, "dlopen %s error: %s\n", so_name, dlerror()); - exit(1); - } - voidfn so_entry = (voidfn)dlsym(dlhandle, "so_entry_0"); - if (!so_entry) - { - fprintf(stderr, "dlopen %s dlsym error: %s\n", so_name, dlerror()); - exit(2); - } - - so_entry(); - - dlclose(dlhandle); -} diff --git a/libvtv/testsuite/dlopen_mt.cc b/libvtv/testsuite/dlopen_mt.cc deleted file mode 100644 index 772e8a733ed..00000000000 --- a/libvtv/testsuite/dlopen_mt.cc +++ /dev/null @@ -1,112 +0,0 @@ -#include -#include -#include - -#include "vtv_utils.h" -#include "vtv_rts.h" -#include "pthread.h" - -#define NUM_REPEATS 10 -#define NUM_THREADS 10 -#define NUM_SOS 100 -#define NUM_SOS_PER_THREAD (NUM_SOS/NUM_THREADS) - -typedef void (*voidfn)(void); - -int failures = 0; - -void -__vtv_verify_fail (void **data_set_ptr, const void *vtbl_pointer) -{ - failures++; - return; -} - - -void do_dlopen(int so_num) -{ - char so_name [sizeof("soxxx.so")]; - sprintf(so_name, "so%d.so", so_num); - // printf("dl-opening %s\n", so_name); - void * dlhandle = dlopen(so_name, RTLD_NOW); - if (!dlhandle) - { - fprintf(stderr, "dlopen so:%s error: %s\n", so_name, dlerror()); - exit(1); - } - char so_entry [sizeof("so_entry_xxx")]; - sprintf(so_entry, "so_entry_%d", so_num); - voidfn so_entry_fn = (voidfn)dlsym(dlhandle, so_entry); - if (!so_entry_fn) - { - fprintf(stderr, "so:%s dlsym error: %s\n", so_name, dlerror()); - exit(2); - } - - so_entry_fn(); - - dlclose(dlhandle); -} - -volatile int threads_completed_it = 0; -volatile int current_wave = -1; - -void * do_dlopens(void * ptid) -{ - for (int k = 0; k < NUM_REPEATS; k++) - { - - for (int i = 0; i < NUM_SOS_PER_THREAD; i++) - { - while (current_wave < (k*NUM_SOS_PER_THREAD + i)) /* from 0 to 99 */ - ; - - do_dlopen((NUM_SOS_PER_THREAD * *(int *)ptid) + i); - - int old_value; - do { - old_value = threads_completed_it; - } while (!__sync_bool_compare_and_swap(&threads_completed_it, old_value, old_value + 1)); - - if (old_value == (NUM_THREADS - 1)) // Only one thread will do this. - { - threads_completed_it = 0; - printf("%c%d", 13, current_wave + 1); - fflush(stdout); - current_wave++; - } - } - } - - return NULL; -} - - -int main() -{ - pthread_t thread_ids[NUM_THREADS]; - int thread_nids[NUM_THREADS]; - - for (int t = 0; t < NUM_THREADS; t++ ) - { - thread_nids[t] = t; - if (pthread_create(&thread_ids[t], NULL, do_dlopens, &thread_nids[t]) != 0) - { - printf("failed pthread_create\n"); - exit(1); - } - } - - current_wave = 0; // start the work on the other threads - - for (int t = 0; t < NUM_THREADS; t++) - if (pthread_join(thread_ids[t], NULL) != 0) - { - printf("failed pthread_join\n"); - exit(2); - } - - printf("\n"); - - return 0; -} diff --git a/libvtv/testsuite/dup_name.cc b/libvtv/testsuite/dup_name.cc deleted file mode 100644 index f0f1c2a8136..00000000000 --- a/libvtv/testsuite/dup_name.cc +++ /dev/null @@ -1,60 +0,0 @@ -#include - -extern "C" int printf(const char *, ...); - -class Subscriptor -{ - public: - - Subscriptor() - { counter = 1;} - - virtual ~Subscriptor() - { - counter--; - assert(counter == 0); - } - - private: - static int counter; -}; - -int Subscriptor::counter; - -template -class Polynomial : public Subscriptor -{ -}; - -class LagrangeEquidistant: public Polynomial -{ -}; - -template -class A -{ - public: - class Nested: public LagrangeEquidistant - { - }; - A() { n = new Nested; } - ~A() { delete n; } - Subscriptor * n; -}; - -template -inline void -_MyDestroy(_Tp* __pointer) - { __pointer->~_Tp(); } - -int main() -{ - Subscriptor * s1 = new LagrangeEquidistant; - _MyDestroy(s1); - A<1> * a1 = new A<1>; - _MyDestroy(a1); - A<2> * a2 = new A<2>; - _MyDestroy(a2); - - return 0; -} diff --git a/libvtv/testsuite/environment-fail-32.s b/libvtv/testsuite/environment-fail-32.s deleted file mode 100644 index cac501652a7..00000000000 --- a/libvtv/testsuite/environment-fail-32.s +++ /dev/null @@ -1,514 +0,0 @@ - .file "environment.cc" - .section .text._ZN15EnvironmentImpl6GetVarEPKcPc,"axG",@progbits,_ZN15EnvironmentImpl6GetVarEPKcPc,comdat - .align 2 - .weak _ZN15EnvironmentImpl6GetVarEPKcPc - .type _ZN15EnvironmentImpl6GetVarEPKcPc, @function -_ZN15EnvironmentImpl6GetVarEPKcPc: -.LFB0: - .cfi_startproc - pushl %ebp - .cfi_def_cfa_offset 8 - .cfi_offset 5, -8 - movl %esp, %ebp - .cfi_def_cfa_register 5 - movl $1, %eax - popl %ebp - .cfi_restore 5 - .cfi_def_cfa 4, 4 - ret - .cfi_endproc -.LFE0: - .size _ZN15EnvironmentImpl6GetVarEPKcPc, .-_ZN15EnvironmentImpl6GetVarEPKcPc - .text - .align 2 - .globl _ZN11EnvironmentD2Ev - .type _ZN11EnvironmentD2Ev, @function -_ZN11EnvironmentD2Ev: -.LFB2: - .cfi_startproc - pushl %ebp - .cfi_def_cfa_offset 8 - .cfi_offset 5, -8 - movl %esp, %ebp - .cfi_def_cfa_register 5 - pushl %ebx - subl $20, %esp - .cfi_offset 3, -12 - call __x86.get_pc_thunk.bx - addl $_GLOBAL_OFFSET_TABLE_, %ebx - movl 8(%ebp), %eax - movl _ZTV11Environment@GOT(%ebx), %edx - leal 8(%edx), %edx - movl %edx, (%eax) - movl $0, %eax - testl %eax, %eax - je .L3 - movl 8(%ebp), %eax - movl %eax, (%esp) - call _ZdlPv@PLT -.L3: - addl $20, %esp - popl %ebx - .cfi_restore 3 - popl %ebp - .cfi_restore 5 - .cfi_def_cfa 4, 4 - ret - .cfi_endproc -.LFE2: - .size _ZN11EnvironmentD2Ev, .-_ZN11EnvironmentD2Ev - .globl _ZN11EnvironmentD1Ev - .set _ZN11EnvironmentD1Ev,_ZN11EnvironmentD2Ev - .align 2 - .globl _ZN11EnvironmentD0Ev - .type _ZN11EnvironmentD0Ev, @function -_ZN11EnvironmentD0Ev: -.LFB4: - .cfi_startproc - pushl %ebp - .cfi_def_cfa_offset 8 - .cfi_offset 5, -8 - movl %esp, %ebp - .cfi_def_cfa_register 5 - pushl %ebx - subl $20, %esp - .cfi_offset 3, -12 - call __x86.get_pc_thunk.bx - addl $_GLOBAL_OFFSET_TABLE_, %ebx - movl 8(%ebp), %eax - movl %eax, (%esp) - call _ZN11EnvironmentD1Ev@PLT - movl 8(%ebp), %eax - movl %eax, (%esp) - call _ZdlPv@PLT - addl $20, %esp - popl %ebx - .cfi_restore 3 - popl %ebp - .cfi_restore 5 - .cfi_def_cfa 4, 4 - ret - .cfi_endproc -.LFE4: - .size _ZN11EnvironmentD0Ev, .-_ZN11EnvironmentD0Ev - .section .text._ZN11EnvironmentC2Ev,"axG",@progbits,_ZN11EnvironmentC5Ev,comdat - .align 2 - .weak _ZN11EnvironmentC2Ev - .type _ZN11EnvironmentC2Ev, @function -_ZN11EnvironmentC2Ev: -.LFB8: - .cfi_startproc - pushl %ebp - .cfi_def_cfa_offset 8 - .cfi_offset 5, -8 - movl %esp, %ebp - .cfi_def_cfa_register 5 - call __x86.get_pc_thunk.cx - addl $_GLOBAL_OFFSET_TABLE_, %ecx - movl 8(%ebp), %eax - movl _ZTV11Environment@GOT(%ecx), %edx - leal 8(%edx), %edx - movl %edx, (%eax) - popl %ebp - .cfi_restore 5 - .cfi_def_cfa 4, 4 - ret - .cfi_endproc -.LFE8: - .size _ZN11EnvironmentC2Ev, .-_ZN11EnvironmentC2Ev - .weak _ZN11EnvironmentC1Ev - .set _ZN11EnvironmentC1Ev,_ZN11EnvironmentC2Ev - .section .text._ZN15EnvironmentImplC2Ev,"axG",@progbits,_ZN15EnvironmentImplC5Ev,comdat - .align 2 - .weak _ZN15EnvironmentImplC2Ev - .type _ZN15EnvironmentImplC2Ev, @function -_ZN15EnvironmentImplC2Ev: -.LFB10: - .cfi_startproc - pushl %ebp - .cfi_def_cfa_offset 8 - .cfi_offset 5, -8 - movl %esp, %ebp - .cfi_def_cfa_register 5 - pushl %ebx - subl $20, %esp - .cfi_offset 3, -12 - call __x86.get_pc_thunk.bx - addl $_GLOBAL_OFFSET_TABLE_, %ebx - movl 8(%ebp), %eax - movl %eax, (%esp) - call _ZN11EnvironmentC2Ev@PLT - movl 8(%ebp), %eax - movl _ZTV15EnvironmentImpl@GOT(%ebx), %edx - leal 8(%edx), %edx - movl %edx, (%eax) - addl $20, %esp - popl %ebx - .cfi_restore 3 - popl %ebp - .cfi_restore 5 - .cfi_def_cfa 4, 4 - ret - .cfi_endproc -.LFE10: - .size _ZN15EnvironmentImplC2Ev, .-_ZN15EnvironmentImplC2Ev - .weak _ZN15EnvironmentImplC1Ev - .set _ZN15EnvironmentImplC1Ev,_ZN15EnvironmentImplC2Ev - .text - .align 2 - .globl _ZN11Environment6CreateEv - .type _ZN11Environment6CreateEv, @function -_ZN11Environment6CreateEv: -.LFB5: - .cfi_startproc - pushl %ebp - .cfi_def_cfa_offset 8 - .cfi_offset 5, -8 - movl %esp, %ebp - .cfi_def_cfa_register 5 - pushl %esi - pushl %ebx - subl $16, %esp - .cfi_offset 6, -12 - .cfi_offset 3, -16 - call __x86.get_pc_thunk.bx - addl $_GLOBAL_OFFSET_TABLE_, %ebx - movl $4, (%esp) - call _Znwj@PLT - movl %eax, %esi - movl $0, (%esi) - movl %esi, (%esp) - call _ZN15EnvironmentImplC1Ev@PLT - movl %esi, %eax - addl $16, %esp - popl %ebx - .cfi_restore 3 - popl %esi - .cfi_restore 6 - popl %ebp - .cfi_restore 5 - .cfi_def_cfa 4, 4 - ret - .cfi_endproc -.LFE5: - .size _ZN11Environment6CreateEv, .-_ZN11Environment6CreateEv - .section .rodata -.LC0: - .string "%p\n" - .text - .globl main - .type main, @function -main: -.LFB12: - .cfi_startproc - pushl %ebp - .cfi_def_cfa_offset 8 - .cfi_offset 5, -8 - movl %esp, %ebp - .cfi_def_cfa_register 5 - pushl %ebx - andl $-16, %esp - subl $32, %esp - .cfi_offset 3, -12 - call __x86.get_pc_thunk.bx - addl $_GLOBAL_OFFSET_TABLE_, %ebx - movl $0, 28(%esp) - call _ZN11Environment6CreateEv@PLT - movl %eax, 24(%esp) - movl 24(%esp), %eax - movl (%eax), %eax - movl %eax, 4(%esp) - leal _ZN4_VTVI11EnvironmentE12__vtable_mapE@GOTOFF(%ebx), %eax - movl %eax, (%esp) - call _Z24__VLTVerifyVtablePointerPPvPKv@PLT - addl $8, %eax - movl (%eax), %eax - movl 28(%esp), %edx - movl %edx, 8(%esp) - movl $0, 4(%esp) - movl 24(%esp), %edx - movl %edx, (%esp) - call *%eax - movl 24(%esp), %eax - movl %eax, 4(%esp) - leal .LC0@GOTOFF(%ebx), %eax - movl %eax, (%esp) - call printf@PLT - movl $0, %eax - movl -4(%ebp), %ebx - leave - .cfi_restore 5 - .cfi_restore 3 - .cfi_def_cfa 4, 4 - ret - .cfi_endproc -.LFE12: - .size main, .-main - .weak _ZTV11Environment - .section .data.rel.ro._ZTV11Environment,"awG",@progbits,_ZTV11Environment,comdat - .align 8 - .type _ZTV11Environment, @object - .size _ZTV11Environment, 20 -_ZTV11Environment: - .long 0 - .long _ZTI11Environment - .long _ZN11EnvironmentD1Ev - .long _ZN11EnvironmentD0Ev - .long __cxa_pure_virtual - .weak _ZTV15EnvironmentImpl - .section .data.rel.ro._ZTV15EnvironmentImpl,"awG",@progbits,_ZTV15EnvironmentImpl,comdat - .align 8 - .type _ZTV15EnvironmentImpl, @object - .size _ZTV15EnvironmentImpl, 20 -_ZTV15EnvironmentImpl: - .long 0 - .long _ZTI15EnvironmentImpl - .long _ZN15EnvironmentImplD1Ev - .long _ZN15EnvironmentImplD0Ev - .long _ZN15EnvironmentImpl6GetVarEPKcPc - .section .text._ZN15EnvironmentImplD2Ev,"axG",@progbits,_ZN15EnvironmentImplD5Ev,comdat - .align 2 - .weak _ZN15EnvironmentImplD2Ev - .type _ZN15EnvironmentImplD2Ev, @function -_ZN15EnvironmentImplD2Ev: -.LFB14: - .cfi_startproc - .cfi_personality 0x9b,DW.ref.__gxx_personality_v0 - .cfi_lsda 0x1b,.LLSDA14 - pushl %ebp - .cfi_def_cfa_offset 8 - .cfi_offset 5, -8 - movl %esp, %ebp - .cfi_def_cfa_register 5 - pushl %ebx - subl $20, %esp - .cfi_offset 3, -12 - call __x86.get_pc_thunk.bx - addl $_GLOBAL_OFFSET_TABLE_, %ebx - movl 8(%ebp), %eax - movl _ZTV15EnvironmentImpl@GOT(%ebx), %edx - leal 8(%edx), %edx - movl %edx, (%eax) - movl 8(%ebp), %eax - movl %eax, (%esp) -.LEHB0: - call _ZN11EnvironmentD2Ev@PLT -.LEHE0: - movl $0, %eax - testl %eax, %eax - je .L19 - movl 8(%ebp), %eax - movl %eax, (%esp) - call _ZdlPv@PLT - jmp .L19 -.L18: - movl %eax, (%esp) -.LEHB1: - call _Unwind_Resume@PLT -.LEHE1: -.L19: - addl $20, %esp - popl %ebx - .cfi_restore 3 - popl %ebp - .cfi_restore 5 - .cfi_def_cfa 4, 4 - ret - .cfi_endproc -.LFE14: - .globl __gxx_personality_v0 - .section .gcc_except_table._ZN15EnvironmentImplD2Ev,"aG",@progbits,_ZN15EnvironmentImplD5Ev,comdat -.LLSDA14: - .byte 0xff - .byte 0xff - .byte 0x1 - .uleb128 .LLSDACSE14-.LLSDACSB14 -.LLSDACSB14: - .uleb128 .LEHB0-.LFB14 - .uleb128 .LEHE0-.LEHB0 - .uleb128 .L18-.LFB14 - .uleb128 0 - .uleb128 .LEHB1-.LFB14 - .uleb128 .LEHE1-.LEHB1 - .uleb128 0 - .uleb128 0 -.LLSDACSE14: - .section .text._ZN15EnvironmentImplD2Ev,"axG",@progbits,_ZN15EnvironmentImplD5Ev,comdat - .size _ZN15EnvironmentImplD2Ev, .-_ZN15EnvironmentImplD2Ev - .weak _ZN15EnvironmentImplD1Ev - .set _ZN15EnvironmentImplD1Ev,_ZN15EnvironmentImplD2Ev - .section .text._ZN15EnvironmentImplD0Ev,"axG",@progbits,_ZN15EnvironmentImplD0Ev,comdat - .align 2 - .weak _ZN15EnvironmentImplD0Ev - .type _ZN15EnvironmentImplD0Ev, @function -_ZN15EnvironmentImplD0Ev: -.LFB16: - .cfi_startproc - pushl %ebp - .cfi_def_cfa_offset 8 - .cfi_offset 5, -8 - movl %esp, %ebp - .cfi_def_cfa_register 5 - pushl %ebx - subl $20, %esp - .cfi_offset 3, -12 - call __x86.get_pc_thunk.bx - addl $_GLOBAL_OFFSET_TABLE_, %ebx - movl 8(%ebp), %eax - movl %eax, (%esp) - call _ZN15EnvironmentImplD1Ev@PLT - movl 8(%ebp), %eax - movl %eax, (%esp) - call _ZdlPv@PLT - addl $20, %esp - popl %ebx - .cfi_restore 3 - popl %ebp - .cfi_restore 5 - .cfi_def_cfa 4, 4 - ret - .cfi_endproc -.LFE16: - .size _ZN15EnvironmentImplD0Ev, .-_ZN15EnvironmentImplD0Ev - .weak _ZTS15EnvironmentImpl - .section .rodata._ZTS15EnvironmentImpl,"aG",@progbits,_ZTS15EnvironmentImpl,comdat - .type _ZTS15EnvironmentImpl, @object - .size _ZTS15EnvironmentImpl, 18 -_ZTS15EnvironmentImpl: - .string "15EnvironmentImpl" - .weak _ZTI15EnvironmentImpl - .section .data.rel.ro._ZTI15EnvironmentImpl,"awG",@progbits,_ZTI15EnvironmentImpl,comdat - .align 4 - .type _ZTI15EnvironmentImpl, @object - .size _ZTI15EnvironmentImpl, 12 -_ZTI15EnvironmentImpl: - .long _ZTVN10__cxxabiv120__si_class_type_infoE+8 - .long _ZTS15EnvironmentImpl - .long _ZTI11Environment - .weak _ZTI11Environment - .section .data.rel.ro._ZTI11Environment,"awG",@progbits,_ZTI11Environment,comdat - .align 4 - .type _ZTI11Environment, @object - .size _ZTI11Environment, 8 -_ZTI11Environment: - .long _ZTVN10__cxxabiv117__class_type_infoE+8 - .long _ZTS11Environment - .weak _ZTS11Environment - .section .rodata._ZTS11Environment,"aG",@progbits,_ZTS11Environment,comdat - .type _ZTS11Environment, @object - .size _ZTS11Environment, 14 -_ZTS11Environment: - .string "11Environment" - .hidden _ZN4_VTVI11EnvironmentE12__vtable_mapE - .weak _ZN4_VTVI11EnvironmentE12__vtable_mapE - .section .vtable_map_vars,"awG",@progbits,_ZN4_VTVI11EnvironmentE12__vtable_mapE,comdat - .align 4 - .type _ZN4_VTVI11EnvironmentE12__vtable_mapE, @gnu_unique_object - .size _ZN4_VTVI11EnvironmentE12__vtable_mapE, 4 -_ZN4_VTVI11EnvironmentE12__vtable_mapE: - .zero 4 - .hidden _ZN4_VTVI15EnvironmentImplE12__vtable_mapE - .weak _ZN4_VTVI15EnvironmentImplE12__vtable_mapE - .section .vtable_map_vars,"awG",@progbits,_ZN4_VTVI15EnvironmentImplE12__vtable_mapE,comdat - .align 4 - .type _ZN4_VTVI15EnvironmentImplE12__vtable_mapE, @gnu_unique_object - .size _ZN4_VTVI15EnvironmentImplE12__vtable_mapE, 4 -_ZN4_VTVI15EnvironmentImplE12__vtable_mapE: - .zero 4 - .section .data.rel.ro,"aw",@progbits - .align 4 - .type __vptr_array_11Environment, @object - .size __vptr_array_11Environment, 8 -__vptr_array_11Environment: - .long _ZTV11Environment+8 - .long _ZTV15EnvironmentImpl+8 - .section .rodata - .align 4 -.LC1: - .string "&" - .string "" - .string "" - .ascii "\224\tl\022_ZN4_VTVI11EnvironmentE12__vtable_mapE" - .align 4 -.LC2: - .string "*" - .string "" - .string "" - .ascii "N\225\r\334_ZN4_VTVI15EnvironmentImplE12__vtable_mapE" - .text - .type _GLOBAL__sub_I.00099_environment.cc, @function -_GLOBAL__sub_I.00099_environment.cc: -.LFB17: - .cfi_startproc - pushl %ebp - .cfi_def_cfa_offset 8 - .cfi_offset 5, -8 - movl %esp, %ebp - .cfi_def_cfa_register 5 - pushl %ebx - subl $36, %esp - .cfi_offset 3, -12 - call __x86.get_pc_thunk.bx - addl $_GLOBAL_OFFSET_TABLE_, %ebx - leal __vptr_array_11Environment@GOTOFF(%ebx), %eax - movl %eax, 16(%esp) - movl $2, 12(%esp) - movl $2, 8(%esp) - leal .LC1@GOTOFF(%ebx), %eax - movl %eax, 4(%esp) - leal _ZN4_VTVI11EnvironmentE12__vtable_mapE@GOTOFF(%ebx), %eax - movl %eax, (%esp) - movl _ZTV15EnvironmentImpl@GOT(%ebx), %eax - leal 8(%eax), %eax - movl %eax, 12(%esp) - movl $1, 8(%esp) - leal .LC2@GOTOFF(%ebx), %eax - movl %eax, 4(%esp) - leal _ZN4_VTVI15EnvironmentImplE12__vtable_mapE@GOTOFF(%ebx), %eax - movl %eax, (%esp) - call _Z17__VLTRegisterPairPPvPKvjS2_@PLT - addl $36, %esp - popl %ebx - .cfi_restore 3 - popl %ebp - .cfi_restore 5 - .cfi_def_cfa 4, 4 - ret - .cfi_endproc -.LFE17: - .size _GLOBAL__sub_I.00099_environment.cc, .-_GLOBAL__sub_I.00099_environment.cc - .section .init_array.00099,"aw" - .align 4 - .long _GLOBAL__sub_I.00099_environment.cc - .section .text.__x86.get_pc_thunk.cx,"axG",@progbits,__x86.get_pc_thunk.cx,comdat - .globl __x86.get_pc_thunk.cx - .hidden __x86.get_pc_thunk.cx - .type __x86.get_pc_thunk.cx, @function -__x86.get_pc_thunk.cx: -.LFB18: - .cfi_startproc - movl (%esp), %ecx - ret - .cfi_endproc -.LFE18: - .section .text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat - .globl __x86.get_pc_thunk.bx - .hidden __x86.get_pc_thunk.bx - .type __x86.get_pc_thunk.bx, @function -__x86.get_pc_thunk.bx: -.LFB19: - .cfi_startproc - movl (%esp), %ebx - ret - .cfi_endproc -.LFE19: - .hidden DW.ref.__gxx_personality_v0 - .weak DW.ref.__gxx_personality_v0 - .section .data.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat - .align 4 - .type DW.ref.__gxx_personality_v0, @object - .size DW.ref.__gxx_personality_v0, 4 -DW.ref.__gxx_personality_v0: - .long __gxx_personality_v0 - .ident "GCC: (GNU) 4.9.0 20130616 (experimental)" - .section .note.GNU-stack,"",@progbits diff --git a/libvtv/testsuite/environment-fail-64.s b/libvtv/testsuite/environment-fail-64.s deleted file mode 100644 index d75db248b07..00000000000 --- a/libvtv/testsuite/environment-fail-64.s +++ /dev/null @@ -1,425 +0,0 @@ - .file "environment.cc" - .section .text._ZN15EnvironmentImpl6GetVarEPKcPc,"axG",@progbits,_ZN15EnvironmentImpl6GetVarEPKcPc,comdat - .align 2 - .weak _ZN15EnvironmentImpl6GetVarEPKcPc - .type _ZN15EnvironmentImpl6GetVarEPKcPc, @function -_ZN15EnvironmentImpl6GetVarEPKcPc: -.LFB0: - .cfi_startproc - pushq %rbp - .cfi_def_cfa_offset 16 - .cfi_offset 6, -16 - movq %rsp, %rbp - .cfi_def_cfa_register 6 - movq %rdi, -8(%rbp) - movq %rsi, -16(%rbp) - movq %rdx, -24(%rbp) - movl $1, %eax - popq %rbp - .cfi_def_cfa 7, 8 - ret - .cfi_endproc -.LFE0: - .size _ZN15EnvironmentImpl6GetVarEPKcPc, .-_ZN15EnvironmentImpl6GetVarEPKcPc - .text - .align 2 - .globl _ZN11EnvironmentD2Ev - .type _ZN11EnvironmentD2Ev, @function -_ZN11EnvironmentD2Ev: -.LFB2: - .cfi_startproc - pushq %rbp - .cfi_def_cfa_offset 16 - .cfi_offset 6, -16 - movq %rsp, %rbp - .cfi_def_cfa_register 6 - subq $16, %rsp - movq %rdi, -8(%rbp) - movq -8(%rbp), %rax - movq _ZTV11Environment@GOTPCREL(%rip), %rdx - leaq 16(%rdx), %rdx - movq %rdx, (%rax) - movl $0, %eax - testl %eax, %eax - je .L3 - movq -8(%rbp), %rax - movq %rax, %rdi - call _ZdlPv@PLT -.L3: - leave - .cfi_def_cfa 7, 8 - ret - .cfi_endproc -.LFE2: - .size _ZN11EnvironmentD2Ev, .-_ZN11EnvironmentD2Ev - .globl _ZN11EnvironmentD1Ev - .set _ZN11EnvironmentD1Ev,_ZN11EnvironmentD2Ev - .align 2 - .globl _ZN11EnvironmentD0Ev - .type _ZN11EnvironmentD0Ev, @function -_ZN11EnvironmentD0Ev: -.LFB4: - .cfi_startproc - pushq %rbp - .cfi_def_cfa_offset 16 - .cfi_offset 6, -16 - movq %rsp, %rbp - .cfi_def_cfa_register 6 - subq $16, %rsp - movq %rdi, -8(%rbp) - movq -8(%rbp), %rax - movq %rax, %rdi - call _ZN11EnvironmentD1Ev@PLT - movq -8(%rbp), %rax - movq %rax, %rdi - call _ZdlPv@PLT - leave - .cfi_def_cfa 7, 8 - ret - .cfi_endproc -.LFE4: - .size _ZN11EnvironmentD0Ev, .-_ZN11EnvironmentD0Ev - .section .text._ZN11EnvironmentC2Ev,"axG",@progbits,_ZN11EnvironmentC5Ev,comdat - .align 2 - .weak _ZN11EnvironmentC2Ev - .type _ZN11EnvironmentC2Ev, @function -_ZN11EnvironmentC2Ev: -.LFB8: - .cfi_startproc - pushq %rbp - .cfi_def_cfa_offset 16 - .cfi_offset 6, -16 - movq %rsp, %rbp - .cfi_def_cfa_register 6 - movq %rdi, -8(%rbp) - movq -8(%rbp), %rax - movq _ZTV11Environment@GOTPCREL(%rip), %rdx - leaq 16(%rdx), %rdx - movq %rdx, (%rax) - popq %rbp - .cfi_def_cfa 7, 8 - ret - .cfi_endproc -.LFE8: - .size _ZN11EnvironmentC2Ev, .-_ZN11EnvironmentC2Ev - .weak _ZN11EnvironmentC1Ev - .set _ZN11EnvironmentC1Ev,_ZN11EnvironmentC2Ev - .section .text._ZN15EnvironmentImplC2Ev,"axG",@progbits,_ZN15EnvironmentImplC5Ev,comdat - .align 2 - .weak _ZN15EnvironmentImplC2Ev - .type _ZN15EnvironmentImplC2Ev, @function -_ZN15EnvironmentImplC2Ev: -.LFB10: - .cfi_startproc - pushq %rbp - .cfi_def_cfa_offset 16 - .cfi_offset 6, -16 - movq %rsp, %rbp - .cfi_def_cfa_register 6 - subq $16, %rsp - movq %rdi, -8(%rbp) - movq -8(%rbp), %rax - movq %rax, %rdi - call _ZN11EnvironmentC2Ev@PLT - movq -8(%rbp), %rax - movq _ZTV15EnvironmentImpl@GOTPCREL(%rip), %rdx - leaq 16(%rdx), %rdx - movq %rdx, (%rax) - leave - .cfi_def_cfa 7, 8 - ret - .cfi_endproc -.LFE10: - .size _ZN15EnvironmentImplC2Ev, .-_ZN15EnvironmentImplC2Ev - .weak _ZN15EnvironmentImplC1Ev - .set _ZN15EnvironmentImplC1Ev,_ZN15EnvironmentImplC2Ev - .text - .align 2 - .globl _ZN11Environment6CreateEv - .type _ZN11Environment6CreateEv, @function -_ZN11Environment6CreateEv: -.LFB5: - .cfi_startproc - pushq %rbp - .cfi_def_cfa_offset 16 - .cfi_offset 6, -16 - movq %rsp, %rbp - .cfi_def_cfa_register 6 - pushq %rbx - subq $8, %rsp - .cfi_offset 3, -24 - movl $8, %edi - call _Znwm@PLT - movq %rax, %rbx - movq $0, (%rbx) - movq %rbx, %rdi - call _ZN15EnvironmentImplC1Ev@PLT - movq %rbx, %rax - addq $8, %rsp - popq %rbx - popq %rbp - .cfi_def_cfa 7, 8 - ret - .cfi_endproc -.LFE5: - .size _ZN11Environment6CreateEv, .-_ZN11Environment6CreateEv - .section .rodata -.LC0: - .string "%p\n" - .text - .globl main - .type main, @function -main: -.LFB12: - .cfi_startproc - pushq %rbp - .cfi_def_cfa_offset 16 - .cfi_offset 6, -16 - movq %rsp, %rbp - .cfi_def_cfa_register 6 - subq $16, %rsp - movq $0, -8(%rbp) - call _ZN11Environment6CreateEv@PLT - movq %rax, -16(%rbp) - movq -16(%rbp), %rax - movq (%rax), %rax - movq %rax, %rsi - leaq _ZN4_VTVI11EnvironmentE12__vtable_mapE(%rip), %rdi - call _Z24__VLTVerifyVtablePointerPPvPKv@PLT - addq $16, %rax - movq (%rax), %rax - movq -8(%rbp), %rdx - movq -16(%rbp), %rcx - movl $0, %esi - movq %rcx, %rdi - call *%rax - movq -16(%rbp), %rax - movq %rax, %rsi - leaq .LC0(%rip), %rdi - movl $0, %eax - call printf@PLT - movl $0, %eax - leave - .cfi_def_cfa 7, 8 - ret - .cfi_endproc -.LFE12: - .size main, .-main - .weak _ZTV11Environment - .section .data.rel.ro._ZTV11Environment,"awG",@progbits,_ZTV11Environment,comdat - .align 32 - .type _ZTV11Environment, @object - .size _ZTV11Environment, 40 -_ZTV11Environment: - .quad 0 - .quad _ZTI11Environment - .quad _ZN11EnvironmentD1Ev - .quad _ZN11EnvironmentD0Ev - .quad __cxa_pure_virtual - .weak _ZTV15EnvironmentImpl - .section .data.rel.ro._ZTV15EnvironmentImpl,"awG",@progbits,_ZTV15EnvironmentImpl,comdat - .align 32 - .type _ZTV15EnvironmentImpl, @object - .size _ZTV15EnvironmentImpl, 40 -_ZTV15EnvironmentImpl: - .quad 0 - .quad _ZTI15EnvironmentImpl - .quad _ZN15EnvironmentImplD1Ev - .quad _ZN15EnvironmentImplD0Ev - .quad _ZN15EnvironmentImpl6GetVarEPKcPc - .section .text._ZN15EnvironmentImplD2Ev,"axG",@progbits,_ZN15EnvironmentImplD5Ev,comdat - .align 2 - .weak _ZN15EnvironmentImplD2Ev - .type _ZN15EnvironmentImplD2Ev, @function -_ZN15EnvironmentImplD2Ev: -.LFB14: - .cfi_startproc - .cfi_personality 0x9b,DW.ref.__gxx_personality_v0 - .cfi_lsda 0x1b,.LLSDA14 - pushq %rbp - .cfi_def_cfa_offset 16 - .cfi_offset 6, -16 - movq %rsp, %rbp - .cfi_def_cfa_register 6 - subq $16, %rsp - movq %rdi, -8(%rbp) - movq -8(%rbp), %rax - movq _ZTV15EnvironmentImpl@GOTPCREL(%rip), %rdx - leaq 16(%rdx), %rdx - movq %rdx, (%rax) - movq -8(%rbp), %rax - movq %rax, %rdi -.LEHB0: - call _ZN11EnvironmentD2Ev@PLT -.LEHE0: - movl $0, %eax - testl %eax, %eax - je .L19 - movq -8(%rbp), %rax - movq %rax, %rdi - call _ZdlPv@PLT - jmp .L19 -.L18: - movq %rax, %rdi -.LEHB1: - call _Unwind_Resume@PLT -.LEHE1: -.L19: - leave - .cfi_def_cfa 7, 8 - ret - .cfi_endproc -.LFE14: - .globl __gxx_personality_v0 - .section .gcc_except_table._ZN15EnvironmentImplD2Ev,"aG",@progbits,_ZN15EnvironmentImplD5Ev,comdat -.LLSDA14: - .byte 0xff - .byte 0xff - .byte 0x1 - .uleb128 .LLSDACSE14-.LLSDACSB14 -.LLSDACSB14: - .uleb128 .LEHB0-.LFB14 - .uleb128 .LEHE0-.LEHB0 - .uleb128 .L18-.LFB14 - .uleb128 0 - .uleb128 .LEHB1-.LFB14 - .uleb128 .LEHE1-.LEHB1 - .uleb128 0 - .uleb128 0 -.LLSDACSE14: - .section .text._ZN15EnvironmentImplD2Ev,"axG",@progbits,_ZN15EnvironmentImplD5Ev,comdat - .size _ZN15EnvironmentImplD2Ev, .-_ZN15EnvironmentImplD2Ev - .weak _ZN15EnvironmentImplD1Ev - .set _ZN15EnvironmentImplD1Ev,_ZN15EnvironmentImplD2Ev - .section .text._ZN15EnvironmentImplD0Ev,"axG",@progbits,_ZN15EnvironmentImplD0Ev,comdat - .align 2 - .weak _ZN15EnvironmentImplD0Ev - .type _ZN15EnvironmentImplD0Ev, @function -_ZN15EnvironmentImplD0Ev: -.LFB16: - .cfi_startproc - pushq %rbp - .cfi_def_cfa_offset 16 - .cfi_offset 6, -16 - movq %rsp, %rbp - .cfi_def_cfa_register 6 - subq $16, %rsp - movq %rdi, -8(%rbp) - movq -8(%rbp), %rax - movq %rax, %rdi - call _ZN15EnvironmentImplD1Ev@PLT - movq -8(%rbp), %rax - movq %rax, %rdi - call _ZdlPv@PLT - leave - .cfi_def_cfa 7, 8 - ret - .cfi_endproc -.LFE16: - .size _ZN15EnvironmentImplD0Ev, .-_ZN15EnvironmentImplD0Ev - .weak _ZTS15EnvironmentImpl - .section .rodata._ZTS15EnvironmentImpl,"aG",@progbits,_ZTS15EnvironmentImpl,comdat - .align 16 - .type _ZTS15EnvironmentImpl, @object - .size _ZTS15EnvironmentImpl, 18 -_ZTS15EnvironmentImpl: - .string "15EnvironmentImpl" - .weak _ZTI15EnvironmentImpl - .section .data.rel.ro._ZTI15EnvironmentImpl,"awG",@progbits,_ZTI15EnvironmentImpl,comdat - .align 16 - .type _ZTI15EnvironmentImpl, @object - .size _ZTI15EnvironmentImpl, 24 -_ZTI15EnvironmentImpl: - .quad _ZTVN10__cxxabiv120__si_class_type_infoE+16 - .quad _ZTS15EnvironmentImpl - .quad _ZTI11Environment - .weak _ZTI11Environment - .section .data.rel.ro._ZTI11Environment,"awG",@progbits,_ZTI11Environment,comdat - .align 16 - .type _ZTI11Environment, @object - .size _ZTI11Environment, 16 -_ZTI11Environment: - .quad _ZTVN10__cxxabiv117__class_type_infoE+16 - .quad _ZTS11Environment - .weak _ZTS11Environment - .section .rodata._ZTS11Environment,"aG",@progbits,_ZTS11Environment,comdat - .type _ZTS11Environment, @object - .size _ZTS11Environment, 14 -_ZTS11Environment: - .string "11Environment" - .hidden _ZN4_VTVI11EnvironmentE12__vtable_mapE - .weak _ZN4_VTVI11EnvironmentE12__vtable_mapE - .section .vtable_map_vars,"awG",@progbits,_ZN4_VTVI11EnvironmentE12__vtable_mapE,comdat - .align 8 - .type _ZN4_VTVI11EnvironmentE12__vtable_mapE, @gnu_unique_object - .size _ZN4_VTVI11EnvironmentE12__vtable_mapE, 8 -_ZN4_VTVI11EnvironmentE12__vtable_mapE: - .zero 8 - .hidden _ZN4_VTVI15EnvironmentImplE12__vtable_mapE - .weak _ZN4_VTVI15EnvironmentImplE12__vtable_mapE - .section .vtable_map_vars,"awG",@progbits,_ZN4_VTVI15EnvironmentImplE12__vtable_mapE,comdat - .align 8 - .type _ZN4_VTVI15EnvironmentImplE12__vtable_mapE, @gnu_unique_object - .size _ZN4_VTVI15EnvironmentImplE12__vtable_mapE, 8 -_ZN4_VTVI15EnvironmentImplE12__vtable_mapE: - .zero 8 - .section .data.rel.ro,"aw",@progbits - .align 16 - .type __vptr_array_11Environment, @object - .size __vptr_array_11Environment, 16 -__vptr_array_11Environment: - .quad _ZTV11Environment+16 - .quad _ZTV15EnvironmentImpl+16 - .section .rodata - .align 8 -.LC1: - .string "&" - .string "" - .string "" - .ascii "\224\tl\022_ZN4_VTVI11EnvironmentE12__vtable_mapE" - .align 8 -.LC2: - .string "*" - .string "" - .string "" - .ascii "N\225\r\334_ZN4_VTVI15EnvironmentImplE12__vtable_mapE" - .text - .type _GLOBAL__sub_I.00099_environment.cc, @function -_GLOBAL__sub_I.00099_environment.cc: -.LFB17: - .cfi_startproc - pushq %rbp - .cfi_def_cfa_offset 16 - .cfi_offset 6, -16 - movq %rsp, %rbp - .cfi_def_cfa_register 6 - leaq __vptr_array_11Environment(%rip), %r8 - movl $2, %ecx - movl $2, %edx - leaq .LC1(%rip), %rsi - leaq _ZN4_VTVI11EnvironmentE12__vtable_mapE(%rip), %rdi - movq _ZTV15EnvironmentImpl@GOTPCREL(%rip), %rax - leaq 16(%rax), %rcx - movl $1, %edx - leaq .LC2(%rip), %rsi - leaq _ZN4_VTVI15EnvironmentImplE12__vtable_mapE(%rip), %rdi - call _Z17__VLTRegisterPairPPvPKvmS2_@PLT - popq %rbp - .cfi_def_cfa 7, 8 - ret - .cfi_endproc -.LFE17: - .size _GLOBAL__sub_I.00099_environment.cc, .-_GLOBAL__sub_I.00099_environment.cc - .section .init_array.00099,"aw" - .align 8 - .quad _GLOBAL__sub_I.00099_environment.cc - .hidden DW.ref.__gxx_personality_v0 - .weak DW.ref.__gxx_personality_v0 - .section .data.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat - .align 8 - .type DW.ref.__gxx_personality_v0, @object - .size DW.ref.__gxx_personality_v0, 8 -DW.ref.__gxx_personality_v0: - .quad __gxx_personality_v0 - .ident "GCC: (GNU) 4.9.0 20130616 (experimental)" - .section .note.GNU-stack,"",@progbits diff --git a/libvtv/testsuite/environment.cc b/libvtv/testsuite/environment.cc deleted file mode 100644 index 83adf53b601..00000000000 --- a/libvtv/testsuite/environment.cc +++ /dev/null @@ -1,37 +0,0 @@ - -extern "C" int printf(const char *, ...); - -class Environment { - public: - virtual ~Environment(); - - // Static factory method that returns the implementation that provide the - // appropriate platform-specific instance. - static Environment* Create(); - - // Gets an environment variable's value and stores it in |result|. - // Returns false if the key is unset. - virtual bool GetVar(const char* variable_name, char* result) = 0; -}; - -class EnvironmentImpl : public Environment { - public: - virtual bool GetVar(const char* variable_name, char* result) { - return true; - } -}; - -Environment::~Environment() {} - -// static -Environment* Environment::Create() { - return new EnvironmentImpl(); -} - -int main() -{ - char * null = 0; - Environment * env = Environment::Create(); - env->GetVar(0, null); - printf("%p\n", env); -} diff --git a/libvtv/testsuite/event-definitions.cc b/libvtv/testsuite/event-definitions.cc deleted file mode 100644 index ba9efe11a4d..00000000000 --- a/libvtv/testsuite/event-definitions.cc +++ /dev/null @@ -1,10 +0,0 @@ -#include "event.h" - -Event::Event() -{ -} - -Event::~Event() -{ - -} diff --git a/libvtv/testsuite/event-main.cc b/libvtv/testsuite/event-main.cc deleted file mode 100644 index b0312848934..00000000000 --- a/libvtv/testsuite/event-main.cc +++ /dev/null @@ -1,13 +0,0 @@ -#include "event-private.h" - -template void derefIfNotNull(T* ptr) -{ - if (ptr != 0) - ptr->deref(); -} - -int main() -{ - Event * ev = new Event; - derefIfNotNull(ev); -} diff --git a/libvtv/testsuite/event-private.cc b/libvtv/testsuite/event-private.cc deleted file mode 100644 index a27f4697a25..00000000000 --- a/libvtv/testsuite/event-private.cc +++ /dev/null @@ -1,10 +0,0 @@ -#include "event-private.h" - -PrivateEvent::PrivateEvent() -{ -} - -PrivateEvent::~PrivateEvent() -{ - -} diff --git a/libvtv/testsuite/event-private.h b/libvtv/testsuite/event-private.h deleted file mode 100644 index 678ab5f68af..00000000000 --- a/libvtv/testsuite/event-private.h +++ /dev/null @@ -1,7 +0,0 @@ -#include "event.h" - -class PrivateEvent: public Event { - public: - PrivateEvent(); - ~PrivateEvent (); -}; diff --git a/libvtv/testsuite/event.h b/libvtv/testsuite/event.h deleted file mode 100644 index 61e1d7c9172..00000000000 --- a/libvtv/testsuite/event.h +++ /dev/null @@ -1,29 +0,0 @@ -class RefCountedBase { -protected: - bool derefBase() - { - return true; - } -}; - -template class RefCounted : public RefCountedBase { -public: - void deref() - { - if (derefBase()) - delete static_cast(this); - } - -protected: - // RefCounted() { } - ~RefCounted() - { - } -}; - - -class Event : public RefCounted { - public: - Event(); - virtual ~Event(); -}; diff --git a/libvtv/testsuite/event.list b/libvtv/testsuite/event.list deleted file mode 100644 index 83226fdd03f..00000000000 --- a/libvtv/testsuite/event.list +++ /dev/null @@ -1 +0,0 @@ -event-main.cc event-definitions.cc event-private.cc \ No newline at end of file diff --git a/libvtv/testsuite/field-test.cc b/libvtv/testsuite/field-test.cc deleted file mode 100644 index b6f34bca02c..00000000000 --- a/libvtv/testsuite/field-test.cc +++ /dev/null @@ -1,94 +0,0 @@ -// Compile with /home/llozano/local2/proj/vtable/gcc-root/usr/local/bin/g++ -m32 -fvtable-verify=std -fpic -rdynamic -Wl,-R,/home/llozano/local2/proj/vtable/gcc-root/usr/local/lib32:./lib32 -I/home/llozano/local2/proj/vtable/vt2/gcc-4_6-mobile-vtable-security//libstdc++-v3/libsupc++ temp_deriv.cc -O0 -ldl -lpthread -Wl,--whole-archive,-lvtv_init,--no-whole-archive,-z,relro -DTPID=0 -g -// Look at assembly with: objdump -drl a.out - -#include -#include -#include - -extern "C" int printf(const char *, ...); - -static int counter = 0; - -int i = TPID; -struct base -{ - virtual void inc() { counter += i; } -}; - -struct derived: public base -{ - virtual void inc() { counter += (10*i); } -}; - -// We don't use this class. It is just here so that the -// compiler does not devirtualize calls to derived::inc() -struct derived2: public derived -{ - virtual void inc() { counter += (20*i); } -}; - -/* -static base * bp = new base(); -static derived * dp = new derived(); -static base * dbp = new derived(); -*/ - -struct my_struct { - base *bp; - derived *dp; - base *dbp; -}; - -typedef void * vtptr; - -vtptr get_vtptr(void * object_ptr) -{ - vtptr * object_vtptr_ptr = (vtptr *)object_ptr; - return *object_vtptr_ptr; -} - -void set_vptr(void * object_ptr, vtptr vtp) -{ - vtptr * object_vtptr_ptr = (vtptr *)object_ptr; - *object_vtptr_ptr = vtp; -} - -// Given 2 pointers to C++ objects (non PODs), exchange the pointers to vtable -void exchange_vtptr(void * object1_ptr, void * object2_ptr) -{ - vtptr object1_vtptr = get_vtptr(object1_ptr); - vtptr object2_vtptr = get_vtptr(object2_ptr); - set_vptr(object1_ptr, object2_vtptr); - set_vptr(object2_ptr, object1_vtptr); -} - -main() -{ - int prev_counter; - - struct my_struct *my_obj = (struct my_struct *) malloc (sizeof (struct my_struct)); - - my_obj->bp = new base(); - my_obj->dp = new derived (); - my_obj->dbp = new derived (); - - - counter = 0; - my_obj->bp->inc(); - my_obj->dp->inc(); - my_obj->dbp->inc(); - assert(counter == (TPID + 10*TPID + 10*TPID)); - - prev_counter = counter; - printf("before ex bp vptr=%x dp vptr=%x\n", get_vtptr(my_obj->bp), get_vtptr(my_obj->dp)); - exchange_vtptr(my_obj->bp, my_obj->dp); - printf("after ex bp vptr=%x dp vptr=%x\n", get_vtptr(my_obj->bp), get_vtptr(my_obj->dp)); - my_obj->bp->inc(); // This one should not abort but it is calling the wrong member - assert(counter == (prev_counter + 10*TPID)); - printf("Pass first attack! Expected!\n"); - printf("TPDI=%d counter %d\n", TPID, counter); - my_obj->dp->inc(); - printf("Pass second attack! SHOULD NOT BE HERE!\n"); - printf("TPDI=%d counter %d\n", TPID, counter); - exit(1); -} diff --git a/libvtv/testsuite/lib/libvtv-dg.exp b/libvtv/testsuite/lib/libvtv-dg.exp new file mode 100644 index 00000000000..b140c194cdc --- /dev/null +++ b/libvtv/testsuite/lib/libvtv-dg.exp @@ -0,0 +1,21 @@ +# This program 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 2 of the License, or +# (at your option) any later version. +# +# This program 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +proc libvtv-dg-test { prog do_what extra_tool_flags } { + return [gcc-dg-test-1 libvtv_target_compile $prog $do_what $extra_tool_flags] +} + +proc libvtv-dg-prune { system text } { + return [gcc-dg-prune $system $text] +} diff --git a/libvtv/testsuite/lib/libvtv.exp b/libvtv/testsuite/lib/libvtv.exp new file mode 100644 index 00000000000..83674be29a2 --- /dev/null +++ b/libvtv/testsuite/lib/libvtv.exp @@ -0,0 +1,220 @@ +# This program 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 2 of the License, or +# (at your option) any later version. +# +# This program 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# Damn dejagnu for not having proper library search paths for load_lib. +# We have to explicitly load everything that gcc-dg.exp wants to load. + +proc load_gcc_lib { filename } { + global srcdir loaded_libs + + load_file $srcdir/../../gcc/testsuite/lib/$filename + set loaded_libs($filename) "" +} + +load_lib dg.exp +load_gcc_lib file-format.exp +load_gcc_lib target-supports.exp +load_gcc_lib target-supports-dg.exp +load_gcc_lib scanasm.exp +load_gcc_lib scandump.exp +load_gcc_lib scanrtl.exp +load_gcc_lib scantree.exp +load_gcc_lib scanipa.exp +load_gcc_lib prune.exp +load_gcc_lib target-libpath.exp +load_gcc_lib wrapper.exp +load_gcc_lib gcc-defs.exp +load_gcc_lib torture-options.exp +load_gcc_lib timeout.exp +load_gcc_lib timeout-dg.exp +load_gcc_lib fortran-modules.exp +load_gcc_lib gcc-dg.exp + +set dg-do-what-default run + +# +# GCC_UNDER_TEST is the compiler under test. +# + +set libvtv_compile_options "" + +# +# libvtv_init +# + +if [info exists TOOL_OPTIONS] { + set multilibs [get_multilibs $TOOL_OPTIONS] +} else { + set multilibs [get_multilibs] +} + +proc libvtv_init { args } { + global srcdir blddir objdir tool_root_dir + global libvtv_initialized + global tmpdir + global blddir + global gluefile wrap_flags + global ALWAYS_CFLAGS + global CFLAGS + global TOOL_EXECUTABLE TOOL_OPTIONS + global GCC_UNDER_TEST + global TESTING_IN_BUILD_TREE + global target_triplet + global always_ld_library_path + + set blddir [lookfor_file [get_multilibs] libvtv] + + # We set LC_ALL and LANG to C so that we get the same error + # messages as expected. + setenv LC_ALL C + setenv LANG C + + if ![info exists GCC_UNDER_TEST] then { + if [info exists TOOL_EXECUTABLE] { + set GCC_UNDER_TEST $TOOL_EXECUTABLE + } else { + set GCC_UNDER_TEST "[find_gcc]" + } + } + + if ![info exists tmpdir] { + set tmpdir "/tmp" + } + + if [info exists gluefile] { + unset gluefile + } + + if {![info exists CFLAGS]} { + set CFLAGS "" + } + + # Locate libgcc.a so we don't need to account for different values of + # SHLIB_EXT on different platforms + set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a] + if {$gccdir != ""} { + set gccdir [file dirname $gccdir] + } + + # Compute what needs to be put into LD_LIBRARY_PATH + set always_ld_library_path ".:${blddir}/.libs" + + # Compute what needs to be added to the existing LD_LIBRARY_PATH. + if {$gccdir != ""} { + # Add AIX pthread directory first. + if { [llength [glob -nocomplain ${gccdir}/pthread/libgcc_s*.a]] >= 1 } { + append always_ld_library_path ":${gccdir}/pthread" + } + append always_ld_library_path ":${gccdir}" + set compiler [lindex $GCC_UNDER_TEST 0] + + if { [is_remote host] == 0 && [which $compiler] != 0 } { + foreach i "[exec $compiler --print-multi-lib]" { + set mldir "" + regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir + set mldir [string trimright $mldir "\;@"] + if { "$mldir" == "." } { + continue + } + if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } { + append always_ld_library_path ":${gccdir}/${mldir}" + } + } + } + } + + set ALWAYS_CFLAGS "" + if { $blddir != "" } { + lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/" + lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}" + lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs" + } + lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.." + + if [istarget *-*-darwin*] { + lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc" + } + + if [info exists TOOL_OPTIONS] { + lappend ALWAYS_CFLAGS "additional_flags=$TOOL_OPTIONS" + } + + # Make sure that lines are not wrapped. That can confuse the + # error-message parsing machinery. + lappend ALWAYS_CFLAGS "additional_flags=-fmessage-length=0" + + # Turn on vtable verification + lappend ALWAYS_CFLAGS "-fvtable-verify=std" + # lappend ALWAYS_CFLAGS "ldflags=-lvtv" +} + +# +# libvtv_target_compile -- compile a source file +# + +proc libvtv_target_compile { source dest type options } { + global blddir + global libvtv_compile_options + global gluefile wrap_flags + global ALWAYS_CFLAGS + global GCC_UNDER_TEST + global lang_test_file + global lang_library_path + global lang_link_flags + + if { [info exists lang_test_file] } { + if { $blddir != "" } { + lappend options "ldflags=-L${blddir}/${lang_library_path}" + } + lappend options "ldflags=${lang_link_flags}" + } + + if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } { + lappend options "libs=${gluefile}" + lappend options "ldflags=${wrap_flags}" + } + + lappend options "additional_flags=[libio_include_flags]" + lappend options "timeout=[timeout_value]" + lappend options "compiler=$GCC_UNDER_TEST" + + set options [concat $libvtv_compile_options $options] + + if [info exists ALWAYS_CFLAGS] { + set options [concat "$ALWAYS_CFLAGS" $options] + } + + set options [dg-additional-files-options $options $source] + + set result [target_compile $source $dest $type $options] + + return $result +} + +proc libvtv_option_help { } { + send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n" +} + +proc libvtv_option_proc { option } { + if [regexp "^--additional_options," $option] { + global libvtv_compile_options + regsub "--additional_options," $option "" option + foreach x [split $option ","] { + lappend libvtv_compile_options "additional_flags=$x" + } + return 1 + } else { + return 0 + } +} diff --git a/libvtv/testsuite/libvtv.cc/bb_tests.cc b/libvtv/testsuite/libvtv.cc/bb_tests.cc new file mode 100644 index 00000000000..2a2447d02c8 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/bb_tests.cc @@ -0,0 +1,53 @@ +// { dg-do run } +struct base +{ + int total; + virtual void add (int i) { total += i; } + virtual void sub (int i) { total -= i; } + virtual void init (void) { total = 73; } +}; + +struct derived : public base +{ + int total; + virtual void add (int i) { total += 10 * i; } + virtual void sub (int i) { total -= 2 * i; } + virtual void init (void) { total = 0; } +}; + +bool +get_cond_value (int x) +{ + if ((x % 3) > 0) + return true; + else + return false; + + return false; +} + +int +main (int argc, char **argv) +{ + base *a; + bool cond_value = get_cond_value (10); + int x; + + if (cond_value) + a = new base (); + else + a = new derived (); + + cond_value = get_cond_value (47); + x = 0; + if (!cond_value) + x = 17; + + a->init (); + + for ( ; x < 10; ++x) + { + a->add(50); + a->sub(25); + } +} diff --git a/libvtv/testsuite/libvtv.cc/const_vtable.cc b/libvtv/testsuite/libvtv.cc/const_vtable.cc new file mode 100644 index 00000000000..3229f008308 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/const_vtable.cc @@ -0,0 +1,83 @@ +// { dg-do run } +extern "C" int printf(const char *,...); +struct V1 { + int v; + virtual int foo(); + V1(); + ~V1(); +}; +struct V2 : virtual V1 { + int v2; + virtual int foo(); + V2(); + ~V2(); +}; +struct C : virtual V1, virtual V2 { + int c; + virtual int foo(); + C(); + ~C(); +}; + +struct B { + int b; }; +struct D : B, C { + int d; + virtual int bar(); + D(); + ~D(); +}; +extern "C" int printf(const char *,...); +main() +{ + try { + D *d = new D; + delete d; + } catch (int) { + printf("Int caught\n"); + } +} + +int V1::foo() { + printf("V1::foo called\n"); return 1; } +V1::V1() : v(5) { + printf("V1 called\n"); } +V1::~V1() { + printf("~V1 called\n"); } + +int V2::foo() { + printf("V2::foo called\n"); return 1; } +V2::V2() : v2(6) { + printf("V2 called\n"); } +V2::~V2() { + printf("~V2 called\n"); } + +int C::foo() { + printf("C::foo called %d\n", c); return 1; } +C::C() : c(7) { + printf("C called\n"); + V1 *vv = this; vv->foo(); + C *cp = dynamic_cast(vv); + if (this == cp) { + printf("PASSED this == cp\n"); + } else { + printf("FAILED this != cp\n"); + } +} +C::~C() { + printf("~C called\n"); + V1 *vv = this; vv->foo(); + C *cp = dynamic_cast(vv); + if (this == cp) { + printf("PASSED this == cp\n"); + } else { + printf("FAILED this != cp\n"); + } +} + +int D::bar() { + printf("D::bar called\n"); return 1; } +D::D() : d(8) { + printf("D called\n"); throw 5; } +D::~D() { + printf("~D called\n"); } diff --git a/libvtv/testsuite/libvtv.cc/dataentry.cc b/libvtv/testsuite/libvtv.cc/dataentry.cc new file mode 100644 index 00000000000..6246136e521 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/dataentry.cc @@ -0,0 +1,39 @@ +// { dg-do run } + +template +class DataOutInterface +{ + public: + virtual ~DataOutInterface() {} +}; + +template +class DataOut_DoFData : public DataOutInterface +{ + public: + virtual ~DataOut_DoFData() {} + +class DataEntryBase { + public: + virtual ~DataEntryBase () {} +}; + +template +class DataEntry : public DataEntryBase +{ + public: + virtual ~DataEntry() {} +}; +}; + +template void Destroy(T * p) __attribute__((noinline)); +template void Destroy(T * p) +{ + delete p; +} + +int main() +{ + DataOut_DoFData<3,3>::DataEntryBase * p = new DataOut_DoFData<3,3>::DataEntry(); + Destroy(p); +} diff --git a/libvtv/testsuite/libvtv.cc/derived-lib.cpp b/libvtv/testsuite/libvtv.cc/derived-lib.cpp new file mode 100644 index 00000000000..375dbe41bde --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/derived-lib.cpp @@ -0,0 +1,18 @@ +#include "lib.h" + +struct Derived_Private : public Base +{ + virtual ~Derived_Private() + { printf("in Derived_Private destructor\n"); } +}; + +Base * GetPrivate() +{ + return new Derived_Private(); +} + +void Destroy(Base * pb) +{ + delete pb; // Virtual call #1 +} + diff --git a/libvtv/testsuite/libvtv.cc/derived-main.cpp b/libvtv/testsuite/libvtv.cc/derived-main.cpp new file mode 100644 index 00000000000..0933ff69621 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/derived-main.cpp @@ -0,0 +1,18 @@ +// { dg-do run } + +#include "lib.h" + +struct Derived: public Base +{ + virtual ~Derived() + { printf("In Derived destructor\n"); } +}; + +int main() +{ + Derived * d = new Derived; + Destroy(d); + Base * pp = GetPrivate(); + delete pp; // Virtual call #2 +} + diff --git a/libvtv/testsuite/libvtv.cc/derived.list b/libvtv/testsuite/libvtv.cc/derived.list new file mode 100644 index 00000000000..6ea3b9cf603 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/derived.list @@ -0,0 +1 @@ +derived-main.cpp derived-lib.cpp diff --git a/libvtv/testsuite/libvtv.cc/dup_name.cc b/libvtv/testsuite/libvtv.cc/dup_name.cc new file mode 100644 index 00000000000..d9d02512630 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/dup_name.cc @@ -0,0 +1,62 @@ +// { dg-do run } + +#include + +extern "C" int printf(const char *, ...); + +class Subscriptor +{ + public: + + Subscriptor() + { counter = 1;} + + virtual ~Subscriptor() + { + counter--; + assert(counter == 0); + } + + private: + static int counter; +}; + +int Subscriptor::counter; + +template +class Polynomial : public Subscriptor +{ +}; + +class LagrangeEquidistant: public Polynomial +{ +}; + +template +class A +{ + public: + class Nested: public LagrangeEquidistant + { + }; + A() { n = new Nested; } + ~A() { delete n; } + Subscriptor * n; +}; + +template +inline void +_MyDestroy(_Tp* __pointer) + { __pointer->~_Tp(); } + +int main() +{ + Subscriptor * s1 = new LagrangeEquidistant; + _MyDestroy(s1); + A<1> * a1 = new A<1>; + _MyDestroy(a1); + A<2> * a2 = new A<2>; + _MyDestroy(a2); + + return 0; +} diff --git a/libvtv/testsuite/libvtv.cc/environment.cc b/libvtv/testsuite/libvtv.cc/environment.cc new file mode 100644 index 00000000000..af1a8775298 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/environment.cc @@ -0,0 +1,38 @@ +// { dg-do run } + +extern "C" int printf(const char *, ...); + +class Environment { + public: + virtual ~Environment(); + + // Static factory method that returns the implementation that provide the + // appropriate platform-specific instance. + static Environment* Create(); + + // Gets an environment variable's value and stores it in |result|. + // Returns false if the key is unset. + virtual bool GetVar(const char* variable_name, char* result) = 0; +}; + +class EnvironmentImpl : public Environment { + public: + virtual bool GetVar(const char* variable_name, char* result) { + return true; + } +}; + +Environment::~Environment() {} + +// static +Environment* Environment::Create() { + return new EnvironmentImpl(); +} + +int main() +{ + char * null = 0; + Environment * env = Environment::Create(); + env->GetVar(0, null); + printf("%p\n", env); +} diff --git a/libvtv/testsuite/libvtv.cc/event-defintions.cpp b/libvtv/testsuite/libvtv.cc/event-defintions.cpp new file mode 100644 index 00000000000..ba9efe11a4d --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/event-defintions.cpp @@ -0,0 +1,10 @@ +#include "event.h" + +Event::Event() +{ +} + +Event::~Event() +{ + +} diff --git a/libvtv/testsuite/libvtv.cc/event-main.cpp b/libvtv/testsuite/libvtv.cc/event-main.cpp new file mode 100644 index 00000000000..95c4640313a --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/event-main.cpp @@ -0,0 +1,15 @@ +// { dg-do run } + +#include "event-private.h" + +template void derefIfNotNull(T* ptr) +{ + if (ptr != 0) + ptr->deref(); +} + +int main() +{ + Event * ev = new Event; + derefIfNotNull(ev); +} diff --git a/libvtv/testsuite/libvtv.cc/event-private.cpp b/libvtv/testsuite/libvtv.cc/event-private.cpp new file mode 100644 index 00000000000..a27f4697a25 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/event-private.cpp @@ -0,0 +1,10 @@ +#include "event-private.h" + +PrivateEvent::PrivateEvent() +{ +} + +PrivateEvent::~PrivateEvent() +{ + +} diff --git a/libvtv/testsuite/libvtv.cc/event-private.h b/libvtv/testsuite/libvtv.cc/event-private.h new file mode 100644 index 00000000000..678ab5f68af --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/event-private.h @@ -0,0 +1,7 @@ +#include "event.h" + +class PrivateEvent: public Event { + public: + PrivateEvent(); + ~PrivateEvent (); +}; diff --git a/libvtv/testsuite/libvtv.cc/event.h b/libvtv/testsuite/libvtv.cc/event.h new file mode 100644 index 00000000000..61e1d7c9172 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/event.h @@ -0,0 +1,29 @@ +class RefCountedBase { +protected: + bool derefBase() + { + return true; + } +}; + +template class RefCounted : public RefCountedBase { +public: + void deref() + { + if (derefBase()) + delete static_cast(this); + } + +protected: + // RefCounted() { } + ~RefCounted() + { + } +}; + + +class Event : public RefCounted { + public: + Event(); + virtual ~Event(); +}; diff --git a/libvtv/testsuite/libvtv.cc/event.list b/libvtv/testsuite/libvtv.cc/event.list new file mode 100644 index 00000000000..77606f8c122 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/event.list @@ -0,0 +1 @@ +event-main.cpp event-definitions.cpp event-private.cpp \ No newline at end of file diff --git a/libvtv/testsuite/libvtv.cc/mul_inh.cc b/libvtv/testsuite/libvtv.cc/mul_inh.cc new file mode 100644 index 00000000000..b32b710c835 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/mul_inh.cc @@ -0,0 +1,27 @@ +// { dg-do run } + +extern "C" int printf(const char *, ...); + +struct A { + virtual ~A() {} +}; + +struct B { + virtual ~B() {} +}; + +struct C: public A { + virtual ~C() {} +}; + +struct D: public C, B { + virtual ~D() {} +}; + +D d; + +int main() +{ + printf ("%p\n", &d); + return 0; +} diff --git a/libvtv/testsuite/libvtv.cc/nested_vcall_test.cc b/libvtv/testsuite/libvtv.cc/nested_vcall_test.cc new file mode 100644 index 00000000000..9d1a9c692da --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/nested_vcall_test.cc @@ -0,0 +1,77 @@ +// { dg-do run } + +class EtherCtrl { + protected: + int ssap; + + public: + EtherCtrl(void); + ~EtherCtrl(); + virtual int getSsap(void) const; + virtual void setSsap(int); +}; + +class EtherFrameWithLLC { + protected: + int ssap; + + public: + EtherFrameWithLLC(const char *, int); + ~EtherFrameWithLLC(); + virtual int getSsap(void) const; + virtual void setSsap(int); +}; + + +EtherCtrl::EtherCtrl() +{ + this->ssap = 0; +} + +EtherCtrl::~EtherCtrl() +{ +} + +int EtherCtrl::getSsap() const +{ + return ssap; +} + +void EtherCtrl::setSsap(int ssap) +{ + this->ssap = ssap; +} + +EtherFrameWithLLC::EtherFrameWithLLC(const char *name, int kind) +{ + this->ssap = 0; +} + +EtherFrameWithLLC::~EtherFrameWithLLC() +{ +} + +int EtherFrameWithLLC::getSsap() const +{ + return ssap; +} + +void EtherFrameWithLLC::setSsap(int ssap) +{ + this->ssap = ssap; +} + + +int +main (int argc, char **argv) +{ + EtherCtrl *etherctrl = new EtherCtrl (); + EtherFrameWithLLC *frame = new EtherFrameWithLLC ("test", 10); + int my_value; + + etherctrl->setSsap(43); + frame->setSsap(etherctrl->getSsap()); + my_value = frame->getSsap(); + + return 0; +} diff --git a/libvtv/testsuite/libvtv.cc/parts-test-extra-parts-views.cpp b/libvtv/testsuite/libvtv.cc/parts-test-extra-parts-views.cpp new file mode 100644 index 00000000000..13d7fdc6e4f --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/parts-test-extra-parts-views.cpp @@ -0,0 +1,16 @@ +#include "parts-test-extra-parts-views.h" + +ExtraPartsViews::ExtraPartsViews () + : ExtraParts () { +} + +ExtraPartsViews::~ExtraPartsViews () {} + +void +ExtraPartsViews::ToolkitInitialized () +{ + /* Do something */ + int sum = 0; + for (int i = 0; i < 10; ++i) + sum += i; +} diff --git a/libvtv/testsuite/libvtv.cc/parts-test-extra-parts-views.h b/libvtv/testsuite/libvtv.cc/parts-test-extra-parts-views.h new file mode 100644 index 00000000000..0784c0ecdaa --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/parts-test-extra-parts-views.h @@ -0,0 +1,14 @@ +#ifndef _EXTRA_PARTS_VIEWS_H_ +#define _EXTRA_PARTS_VIEWS_H_ + +#include "parts-test-extra-parts.h" + +class ExtraPartsViews : public ExtraParts { + public: + ExtraPartsViews (); + virtual ~ExtraPartsViews (); + + virtual void ToolkitInitialized (); +}; + +#endif /* _EXTRA_PARTS_VIEWS_H_ */ diff --git a/libvtv/testsuite/libvtv.cc/parts-test-extra-parts.cpp b/libvtv/testsuite/libvtv.cc/parts-test-extra-parts.cpp new file mode 100644 index 00000000000..dbd3dbfd8f5 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/parts-test-extra-parts.cpp @@ -0,0 +1,15 @@ +#include "parts-test-extra-parts.h" + +ExtraParts::ExtraParts () {} + +ExtraParts::~ExtraParts () {} + +void +ExtraParts::ToolkitInitialized () +{ +} + +void +ExtraParts::PreEarlyInitialization () +{ +} diff --git a/libvtv/testsuite/libvtv.cc/parts-test-extra-parts.h b/libvtv/testsuite/libvtv.cc/parts-test-extra-parts.h new file mode 100644 index 00000000000..4ed2a4ce1a0 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/parts-test-extra-parts.h @@ -0,0 +1,13 @@ +#ifndef _EXTRA_PARTS_H_ +#define _EXTRA_PARTS_H_ + +class ExtraParts { + public: + ExtraParts (); + virtual ~ExtraParts (); + + virtual void PreEarlyInitialization (); + virtual void ToolkitInitialized (); +}; + +#endif /* _EXTRA_PARTS_H_ */ diff --git a/libvtv/testsuite/libvtv.cc/parts-test-main.cpp b/libvtv/testsuite/libvtv.cc/parts-test-main.cpp new file mode 100644 index 00000000000..a0cc721abf5 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/parts-test-main.cpp @@ -0,0 +1,39 @@ +// { dg-do run } + +#include "parts-test-main.h" +#include "parts-test-extra-parts-views.h" + +MainParts::MainParts () {} + +MainParts::~MainParts () +{ + for (int i = static_cast(main_extra_parts_.size()) - 1; i >= 0; --i) + delete main_extra_parts_[i]; + main_extra_parts_.clear(); +} + +void +MainParts::AddParts (ExtraParts *parts) +{ + main_extra_parts_.push_back (parts); +} + + +void +MainParts::PreEarlyInitialization (void) +{ + for (int i = 0; i < main_extra_parts_.size(); ++i) + main_extra_parts_[i]->PreEarlyInitialization (); +} + + +int +main (int argc, char **argv) +{ + MainParts *main_parts = new MainParts (); + + main_parts->AddParts (new ExtraPartsViews ()); + main_parts->PreEarlyInitialization (); + + return 0; +} diff --git a/libvtv/testsuite/libvtv.cc/parts-test-main.h b/libvtv/testsuite/libvtv.cc/parts-test-main.h new file mode 100644 index 00000000000..fb631dec340 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/parts-test-main.h @@ -0,0 +1,15 @@ +#include + +class ExtraParts; + +class MainParts { + public: + MainParts (); + virtual ~MainParts (); + virtual void AddParts (ExtraParts *parts); + + virtual void PreEarlyInitialization (); + + protected: + std::vector main_extra_parts_; +}; diff --git a/libvtv/testsuite/libvtv.cc/parts-test.list b/libvtv/testsuite/libvtv.cc/parts-test.list new file mode 100644 index 00000000000..11a959a62d1 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/parts-test.list @@ -0,0 +1 @@ +parts-test-main.cpp parts-test-extra-parts.cpp parts-test-extra-parts-views.cpp diff --git a/libvtv/testsuite/libvtv.cc/povray-derived.cc b/libvtv/testsuite/libvtv.cc/povray-derived.cc new file mode 100644 index 00000000000..9005826dff4 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/povray-derived.cc @@ -0,0 +1,74 @@ +// { dg-do run } + +// Small test case from povray, see if it reproduces. + +#include + +class POVMS_MessageReceiver +{ + +private: + int x; + class Handler + { + public: + virtual void print() = 0; + }; +protected: + template class MemberHandler : public Handler + { + public: + MemberHandler(T *xx) + { + x = xx; + } + + ~MemberHandler() {} + + void print() + { + printf("In print\n"); + } + private: + T *x; + }; + +private: + struct HandlerNode + { + Handler *handler; + }; + + HandlerNode *receiver; +public: + POVMS_MessageReceiver(int xx) : x(xx) {} + ~POVMS_MessageReceiver() {} + + void foo(int *xx); + void try_call(); +}; + +void POVMS_MessageReceiver::foo(int *xx) +{ + receiver = new HandlerNode; + + receiver->handler = new MemberHandler(xx); +} + +void POVMS_MessageReceiver::try_call() +{ + receiver->handler->print(); +} + + +int main() +{ + int loc = 34; + POVMS_MessageReceiver a_test(100); + + a_test.foo(&loc); + a_test.try_call(); +} + + + diff --git a/libvtv/testsuite/libvtv.cc/register_set_pair.cc b/libvtv/testsuite/libvtv.cc/register_set_pair.cc new file mode 100644 index 00000000000..b7f08331d68 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/register_set_pair.cc @@ -0,0 +1,101 @@ +#include +#include +#include +#include + +#include "vtv_utils.h" +#include "vtv_rts.h" + +/* This configuration will test mostly inserting of elements that are already inserted since + the number of repeats is 200 */ + +#define NUM_MAPS 4000 +#define ELEMENTS_PER_MAP 100 +#define NUM_REPEATS 200 + +#define KEY_TYPE_FIXED_SIZE 8 +void *key_buffer = malloc (17); +typedef char * name_string; +name_string fake_names[NUM_MAPS]; + +/* This variable has to be put in rel.ro */ +void * maps[NUM_MAPS] VTV_PROTECTED_VAR; + +struct fake_vt { + void * fake_vfp [4]; +}; +void * fake_vts [NUM_MAPS * ELEMENTS_PER_MAP]; + +void +generate_names (void) +{ + int i; + + for (i = 0; i < NUM_MAPS; ++i) + { + fake_names[i] = (char *) malloc (9 * sizeof (char)); + snprintf (fake_names[i], 9, "name%d", i); + } +} + +static uint32_t +vtv_string_hash(const char *in) +{ + const char *s = in; + uint32_t h = 0; + + for ( ; *s; ++s) + h = 5 * h + *s; + return h; +} + +int main() +{ + __VLTChangePermission(__VLTP_READ_WRITE); + + generate_names (); + + for (int k = 0; k < NUM_REPEATS; k++) + { + int curr_fake_vt = 0; + for (int i = 0; i < NUM_MAPS; i++) + { + uint32_t *value_ptr = (uint32_t *) key_buffer; + uint32_t len1 = strlen (fake_names[i]); + uint32_t hash_value = vtv_string_hash (fake_names[i]); + void *temp_array[ELEMENTS_PER_MAP]; + + *value_ptr = len1; + value_ptr++; + *value_ptr = hash_value; + + memcpy ((char *) key_buffer + KEY_TYPE_FIXED_SIZE, fake_names[i], + len1); + + +#ifdef VTV_DEBUG + __VLTRegisterPairDebug (&maps[i], (char *) key_buffer, 128, + &fake_vts[curr_fake_vt], "", ""); +#else + __VLTRegisterPair (&maps[i], (char *) key_buffer, 128, + &fake_vts[curr_fake_vt]); +#endif + for (int j = 0; j < ELEMENTS_PER_MAP; j++) + { + temp_array[j] = &fake_vts[curr_fake_vt]; + curr_fake_vt++; + } +#ifdef VTV_DEBUG + __VLTRegisterSetDebug (&maps[i], (char *) key_buffer, 128, 100, + (void **) &temp_array); +#else + __VLTRegisterSet (&maps[i], (char *) key_buffer, 128, 100, + (void **) &temp_array); +#endif + } + } + + __VLTChangePermission(__VLTP_READ_ONLY); + + return 0; +} diff --git a/libvtv/testsuite/libvtv.cc/register_set_pair_inserts.cc b/libvtv/testsuite/libvtv.cc/register_set_pair_inserts.cc new file mode 100644 index 00000000000..297e8756797 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/register_set_pair_inserts.cc @@ -0,0 +1,106 @@ +#include +#include +#include +#include + +#include "vtv_utils.h" +#include "vtv_rts.h" + +/* This configuration will test mostly inserting of new elements since + the number of repeats is 1. It should also do a lot of rehashing */ + +/* This test case may fail depending on the system configuration. + Check the value of /proc/sys/vm/max_map_count and fix by doing + Ex: sudo sh -c "echo 131060 > /proc/sys/vm/max_map_count" */ + +#define NUM_MAPS 40000 +#define ELEMENTS_PER_MAP 100 +#define NUM_REPEATS 1 + +#define KEY_TYPE_FIXED_SIZE 8 +void *key_buffer = malloc (17); +typedef char * name_string; +name_string fake_names[NUM_MAPS]; + +/* This variable has to be put in rel.ro */ +void * maps[NUM_MAPS] VTV_PROTECTED_VAR; + +struct fake_vt { + void * fake_vfp [4]; +}; +void * fake_vts [NUM_MAPS * ELEMENTS_PER_MAP]; + + +void +generate_names (void) +{ + int i; + + for (i = 0; i < NUM_MAPS; ++i) + { + fake_names[i] = (char *) malloc (9 * sizeof (char)); + snprintf (fake_names[i], 9, "name%d", i); + } +} + +static uint32_t +vtv_string_hash(const char *in) +{ + const char *s = in; + uint32_t h = 0; + + for ( ; *s; ++s) + h = 5 * h + *s; + return h; +} + +int main() +{ + __VLTChangePermission(__VLTP_READ_WRITE); + + generate_names(); + + for (int k = 0; k < NUM_REPEATS; k++) + { + int curr_fake_vt = 0; + for (int i = 0; i < NUM_MAPS; i++) + { + uint32_t *value_ptr = (uint32_t *) key_buffer; + uint32_t len1 = strlen (fake_names[i]); + uint32_t hash_value = vtv_string_hash (fake_names[i]); + void *temp_array[ELEMENTS_PER_MAP]; + + *value_ptr = len1; + value_ptr++; + *value_ptr = hash_value; + + memcpy ((char *) key_buffer + KEY_TYPE_FIXED_SIZE, fake_names[i], + len1); + + +#ifdef VTV_DEBUG + __VLTRegisterPairDebug (&maps[i], (char *) key_buffer, 128, + &fake_vts[curr_fake_vt], "", ""); +#else + __VLTRegisterPair (&maps[i], (char *) key_buffer, 128, + &fake_vts[curr_fake_vt]); +#endif + for (int j = 0; j < ELEMENTS_PER_MAP; j++) + { + temp_array[j] = &fake_vts[curr_fake_vt]; + curr_fake_vt++; + } +#ifdef VTV_DEBUG + __VLTRegisterSetDebug (&maps[i], (char *) key_buffer, 128, 100, + (void **) &temp_array); +#else + __VLTRegisterSet (&maps[i], (char *) key_buffer, 128, 100, + (void **) &temp_array); +#endif + } + } + + __VLTChangePermission(__VLTP_READ_ONLY); + + return 0; +} diff --git a/libvtv/testsuite/libvtv.cc/template-list-iostream.cc b/libvtv/testsuite/libvtv.cc/template-list-iostream.cc new file mode 100644 index 00000000000..06ec3b01e10 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/template-list-iostream.cc @@ -0,0 +1,120 @@ +// { dg-do run } + +#include +#include +#include + +using std::ofstream; +using std::ifstream; +using std::ios; + +extern "C" int printf(const char *, ...); + +class Subscriptor +{ + public: + + Subscriptor() : counter(1) {} + + virtual ~Subscriptor() + { + counter--; + assert(counter == 0); + } + + private: + mutable int counter; +}; + +template struct Function +{ + Function(int i): value(dim + i) {} + int value; +}; + +template struct Triangulation +{ + +}; + +template struct Exercise_2_3 +{ + enum { DIM = dim }; +}; + + template + struct SetUpBase : public Subscriptor + { + virtual + const Function get_boundary_values () const = 0; + + virtual + const Function get_right_hand_side () const = 0; + + // virtual + // void create_coarse_grid (Triangulation &coarse_grid) const = 0; + }; + + template + struct SetUp : public SetUpBase + { + SetUp () {}; + + virtual + const Function get_boundary_values () const + { return Function(Traits::DIM); } + + virtual + const Function get_right_hand_side () const + { return Function(Traits::DIM); } + + // virtual + // void create_coarse_grid (Triangulation &coarse_grid) const; + + // static const typename Traits::BoundaryValues boundary_values; + // static const typename Traits::RightHandSide right_hand_side; + }; + + +void myread(std::istream * in) +{ + char input_str[50] = "\0"; + if (in->good()) + (*in) >> input_str; + std::cout << input_str << std::endl; + delete in; +} + + + +int main() +{ + /* + + SetUp, 2> s1a; + SetUp, 1> s2; + SetUp, 2> s2a; + return s1->get_boundary_values().value + s1a.get_boundary_values().value + + s2.get_boundary_values().value + s2a.get_boundary_values().value + + s1->get_right_hand_side().value + s1a.get_right_hand_side().value + + s2.get_right_hand_side().value + s2a.get_right_hand_side().value; + */ + + SetUp, 1> * s1 = new SetUp, 1>(); + + printf("%d\n", s1->get_boundary_values().value); + + ifstream * infile = new ifstream("./template-list-iostream.cc"); + + myread(infile); + + ofstream * outfile = new ofstream("/tmp/xxx.txt"); + + if (outfile->good()) + (*outfile) << "hello there" << std::endl; + std::cerr << "Reached End" << std::endl; + + delete outfile; + + return 0; +} diff --git a/libvtv/testsuite/libvtv.cc/template-list.cc b/libvtv/testsuite/libvtv.cc/template-list.cc new file mode 100644 index 00000000000..aeb2db9e526 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/template-list.cc @@ -0,0 +1,94 @@ +// { dg-do run } + +#include + +extern "C" int printf(const char *, ...); + +class Subscriptor +{ + public: + + Subscriptor() : counter(1) {} + + virtual ~Subscriptor() + { + counter--; + assert(counter == 0); + } + + private: + mutable int counter; +}; + +template struct Function +{ + Function(int i): value(dim + i) {} + int value; +}; + +template struct Triangulation +{ + +}; + +template struct Exercise_2_3 +{ + enum { DIM = dim }; +}; + + template + struct SetUpBase : public Subscriptor + { + virtual + const Function get_boundary_values () const = 0; + + virtual + const Function get_right_hand_side () const = 0; + + // virtual + // void create_coarse_grid (Triangulation &coarse_grid) const = 0; + }; + + template + struct SetUp : public SetUpBase + { + SetUp () {}; + + virtual + const Function get_boundary_values () const + { return Function(Traits::DIM); } + + virtual + const Function get_right_hand_side () const + { return Function(Traits::DIM); } + + // virtual + // void create_coarse_grid (Triangulation &coarse_grid) const; + + // static const typename Traits::BoundaryValues boundary_values; + // static const typename Traits::RightHandSide right_hand_side; + }; + + +int main() +{ + /* + + SetUp, 2> s1a; + SetUp, 1> s2; + SetUp, 2> s2a; + return s1->get_boundary_values().value + s1a.get_boundary_values().value + + s2.get_boundary_values().value + s2a.get_boundary_values().value + + s1->get_right_hand_side().value + s1a.get_right_hand_side().value + + s2.get_right_hand_side().value + s2a.get_right_hand_side().value; + */ +#ifndef NFAIL + SetUp, 1> * s1 = new SetUp, 1>(); + printf("%d\n", s1->get_boundary_values().value); + return 0; +#else + SetUp, 1> s1; + printf("%d\n", s1.get_boundary_values().value); + return 0; +#endif +} diff --git a/libvtv/testsuite/libvtv.cc/template-list2.cc b/libvtv/testsuite/libvtv.cc/template-list2.cc new file mode 100644 index 00000000000..3df8d372418 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/template-list2.cc @@ -0,0 +1,46 @@ +// { dg-do run } + +#include + +extern "C" int printf(const char *, ...); + +class Subscriptor +{ + public: + + Subscriptor() + { counter = 1;} + + virtual ~Subscriptor() + { + counter--; + assert(counter == 0); + } + + private: + static int counter; +}; + +int Subscriptor::counter; + +template +class Polynomial : public Subscriptor +{ +}; + +class LagrangeEquidistant: public Polynomial +{ +}; + +template +inline void +_MyDestroy(_Tp* __pointer) + { __pointer->~_Tp(); } + +int main() +{ + LagrangeEquidistant * s1 = new LagrangeEquidistant; + _MyDestroy(s1); + + return 0; +} diff --git a/libvtv/testsuite/libvtv.cc/test1.cc b/libvtv/testsuite/libvtv.cc/test1.cc new file mode 100644 index 00000000000..9005826dff4 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/test1.cc @@ -0,0 +1,74 @@ +// { dg-do run } + +// Small test case from povray, see if it reproduces. + +#include + +class POVMS_MessageReceiver +{ + +private: + int x; + class Handler + { + public: + virtual void print() = 0; + }; +protected: + template class MemberHandler : public Handler + { + public: + MemberHandler(T *xx) + { + x = xx; + } + + ~MemberHandler() {} + + void print() + { + printf("In print\n"); + } + private: + T *x; + }; + +private: + struct HandlerNode + { + Handler *handler; + }; + + HandlerNode *receiver; +public: + POVMS_MessageReceiver(int xx) : x(xx) {} + ~POVMS_MessageReceiver() {} + + void foo(int *xx); + void try_call(); +}; + +void POVMS_MessageReceiver::foo(int *xx) +{ + receiver = new HandlerNode; + + receiver->handler = new MemberHandler(xx); +} + +void POVMS_MessageReceiver::try_call() +{ + receiver->handler->print(); +} + + +int main() +{ + int loc = 34; + POVMS_MessageReceiver a_test(100); + + a_test.foo(&loc); + a_test.try_call(); +} + + + diff --git a/libvtv/testsuite/libvtv.cc/thunk.cc b/libvtv/testsuite/libvtv.cc/thunk.cc new file mode 100644 index 00000000000..bec1057f564 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/thunk.cc @@ -0,0 +1,37 @@ +// { dg-do run } + +#include +struct A { + A():value(123) {} + int value; + virtual int access() { return this->value; } +}; +struct B { + B():value(456) {} + int value; + virtual int access() { return this->value; } +}; +struct C : public A, public B { + C():better_value(789) {} + int better_value; + virtual int access() { return this->better_value; } +}; +struct D: public C { + D():other_value(987) {} + int other_value; + virtual int access() { return this->other_value; } +}; + +int use(B *b) +{ + return b->access(); +} + +int main() +{ + C c; + assert(use(&c) == 789); + D d; + assert(use(&d) == 987); + return 0; +} diff --git a/libvtv/testsuite/libvtv.cc/thunk_vtable_map_attack.cc b/libvtv/testsuite/libvtv.cc/thunk_vtable_map_attack.cc new file mode 100644 index 00000000000..51f974ee4e7 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/thunk_vtable_map_attack.cc @@ -0,0 +1,113 @@ +// { dg-do run } + +#include +#include +#include +#include + +#include +#include + +using std::ofstream; +using std::ifstream; +using std::ios; + +struct A { + A():value(123) {} + int value; + virtual int access() { return this->value; } +}; +struct B { + B():value(456) {} + int value; + virtual int access() { return this->value; } +}; +struct C : public A, public B { + C():better_value(789) {} + int better_value; + virtual int access() { return this->better_value; } +}; +struct D: public C { + D():other_value(987) {} + int other_value; + virtual int access() { return this->other_value; } +}; + +volatile static int signal_count = 0; + +sigjmp_buf before_segv; + +static void +handler(int sig, siginfo_t *si, void *unused) +{ + /* + printf("Got SIGSEGV at address: 0x%lx\n", + (long) si->si_addr); + */ + + signal_count++; + /* You are not supposed to longjmp out of a signal handler but it seems + to work for this test case and it simplifies it */ + siglongjmp(before_segv, 1); + /* exit(1); */ +} + +/* Access one of the vtable_map variables generated by this .o */ +extern void * _ZN4_VTVI1BE12__vtable_mapE; + +/* Access one of the vtable_map variables generated by libstdc++ */ +extern void * _ZN4_VTVISt8ios_baseE12__vtable_mapE; + +int use(B *b) +{ + int ret; + + ret = sigsetjmp(before_segv, 1); + if (ret == 0) + { + /* This should generate a segmentation violation. ie: at this point it should + be protected */ + _ZN4_VTVI1BE12__vtable_mapE = 0; + } + assert(ret == 1 && signal_count == 1); + + ret = sigsetjmp(before_segv, 1); + if (ret == 0) + { + /* Try to modify one of the vtable_map variables in the stdc++ library. + This should generate a segmentation violation. ie: at this point it + should be protected */ + _ZN4_VTVISt8ios_baseE12__vtable_mapE = 0; + } + assert(ret == 1 && signal_count == 2); + + return b->access(); +} + +void myread(std::istream * in) +{ + char input_str[50] = "\0"; + if (in->good()) + (*in) >> input_str; + std::cout << input_str << std::endl; + delete in; +} + +int main() +{ + ifstream * infile = new ifstream("./thunk_vtable_map_attack.cpp"); + myread(infile); + + /* Set up handler for SIGSEGV. */ + struct sigaction sa; + sa.sa_flags = SA_SIGINFO; + sigemptyset(&sa.sa_mask); + sa.sa_sigaction = handler; + if (sigaction(SIGSEGV, &sa, NULL) == -1) + assert(0); + + C c; + assert(use(&c) == 789); + + return 0; +} diff --git a/libvtv/testsuite/libvtv.cc/v8-test-2.cc b/libvtv/testsuite/libvtv.cc/v8-test-2.cc new file mode 100644 index 00000000000..6bfda56e8c6 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/v8-test-2.cc @@ -0,0 +1,97 @@ +// { dg-do run } + +#include +#include + +class Literal; +class CallRuntime; + +class AstNode { +public: + + enum Type { + kLiteral, kCallRuntime, + kInvalid = -1 + }; + + AstNode() { } + + virtual ~AstNode() { } + + virtual Type node_type() const = 0; + + bool + IsLiteral() { return node_type() == AstNode::kLiteral; } + + Literal * + AsLiteral() { return IsLiteral() ? reinterpret_cast(this) + : NULL; } + + bool + IsCallRuntime() { return node_type() == AstNode::kCallRuntime; } + + CallRuntime * + AsCallRuntime() { return IsCallRuntime() ? reinterpret_cast(this) + : NULL; } + +}; + +class Expression: public AstNode { +public: +private: + int id_; +}; + +class Literal: public Expression { +public: + + virtual AstNode::Type node_type() const { return AstNode::kLiteral; } + + private: + std::string ToString(); + +}; + +class CallRuntime: public Expression { +public: + + virtual AstNode::Type node_type() const { return AstNode::kCallRuntime; } + + private: + std::string name_; +}; + +Expression * +ExpressionCheck (bool *ok) +{ + if (*ok == true) + return new CallRuntime(); + else + return new Literal (); + + return NULL; +} + +Expression * +GetExpression (bool *ok) +{ + Expression *expression = ExpressionCheck (ok); + Expression *return_expr = NULL; + + if (expression != NULL && expression->AsLiteral() != NULL) + return_expr = new Literal(); + else if (expression != NULL && expression->AsCallRuntime() != NULL) + return_expr = expression; + + return return_expr; +} + +int +main (int argc, char **argv) +{ + bool a_bool = true; + + AstNode *node = GetExpression (&a_bool); + + return 0; +} diff --git a/libvtv/testsuite/libvtv.cc/virtfunc-test.cc b/libvtv/testsuite/libvtv.cc/virtfunc-test.cc new file mode 100644 index 00000000000..3ad12b896c1 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/virtfunc-test.cc @@ -0,0 +1,222 @@ +// { dg-do run } + +/* This test script is part of GDB, the GNU debugger. + + Copyright 1993, 1994, 1997, 1998, 1999, 2003, 2004, + Free Software Foundation, Inc. + + This program 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. + + This program 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 . + */ + +// Pls try the following program on virtual functions and try to do print on +// most of the code in main(). Almost none of them works ! + +// +// The inheritance structure is: +// +// V : VA VB +// A : (V) +// B : A +// D : AD (V) +// C : (V) +// E : B (V) D C +// + +class VA +{ +public: + int va; +}; + +class VB +{ +public: + int vb; + int fvb(); + virtual int vvb(); +}; + +class V : public VA, public VB +{ +public: + int f(); + virtual int vv(); + int w; +}; + +class A : virtual public V +{ +public: + virtual int f(); +private: + int a; +}; + +class B : public A +{ +public: + int f(); +private: + int b; +}; + +class C : public virtual V +{ +public: + int c; +}; + +class AD +{ +public: + virtual int vg() = 0; +}; + +class D : public AD, virtual public V +{ +public: + static void s(); + virtual int vg(); + virtual int vd(); + int fd(); + int d; +}; + +class E : public B, virtual public V, public D, public C +{ +public: + int f(); + int vg(); + int vv(); + int e; +}; + +D dd; +D* ppd = ⅆ +AD* pAd = ⅆ + +A a; +B b; +C c; +D d; +E e; +V v; +VB vb; + + +A* pAa = &a; +A* pAe = &e; + +B* pBe = &e; + +D* pDd = &d; +D* pDe = &e; + +V* pVa = &a; +V* pVv = &v; +V* pVe = &e; +V* pVd = &d; + +AD* pADe = &e; + +E* pEe = &e; + +VB* pVB = &vb; + +void init() +{ + a.vb = 1; + b.vb = 2; + c.vb = 3; + d.vb = 4; + e.vb = 5; + v.vb = 6; + vb.vb = 7; + + d.d = 1; + e.d = 2; +} + +extern "C" int printf(const char *, ...); + +int all_count = 0; +int failed_count = 0; + +#define TEST(EXPR, EXPECTED) \ + ret = EXPR; \ + if (ret != EXPECTED) {\ + printf("Failed %s is %d, should be %d!\n", #EXPR, ret, EXPECTED); \ + failed_count++; } \ + all_count++; + +int ret; + +void test_calls() +{ + TEST(pAe->f(), 20); + TEST(pAa->f(), 1); + + TEST(pDe->vg(), 202); + TEST(pADe->vg(), 202); + TEST(pDd->vg(), 101); + + TEST(pEe->vvb(), 411); + + TEST(pVB->vvb(), 407); + + TEST(pBe->vvb(), 411); + TEST(pDe->vvb(), 411); + + TEST(pEe->vd(), 282); + TEST(pEe->fvb(), 311); + + TEST(pEe->D::vg(), 102); + printf("Did %d tests, of which %d failed.\n", all_count, failed_count); +} +#ifdef usestubs +extern "C" { + void set_debug_traps(); + void breakpoint(); +}; +#endif + +int main() +{ +#ifdef usestubs + set_debug_traps(); + breakpoint(); +#endif + init(); + + e.w = 7; + e.vb = 11; + + test_calls(); + return 0; + +} + +int A::f() {return 1;} +int B::f() {return 2;} +void D::s() {} +int E::f() {return 20;} +int D::vg() {return 100+d;} +int E::vg() {return 200+d;} +int V::f() {return 600+w;} +int V::vv() {return 400+w;} +int E::vv() {return 450+w;} +int D::fd() {return 250+d;} +int D::vd() {return 280+d;} +int VB::fvb() {return 300+vb;} +int VB::vvb() {return 400+vb;} diff --git a/libvtv/testsuite/libvtv.cc/virtual_inheritance.cc b/libvtv/testsuite/libvtv.cc/virtual_inheritance.cc new file mode 100644 index 00000000000..1c49c966453 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/virtual_inheritance.cc @@ -0,0 +1,48 @@ +// { dg-do run } + +#include +struct V { + V(): virtual_value(-123) {} + int virtual_value; + virtual int access_vv() { return virtual_value; } +}; + +struct A: virtual public V { + A():value(123) {} + int value; + virtual int access() { return value; } +}; +struct B: virtual public V { + B():value(456) {} + int value; + virtual int access() { return value; } +}; +struct C : public A, public B { + C():better_value(789) {} + int better_value; + virtual int access() { return better_value; } +}; +struct D: public A, public B { + D():better_virtual_value(-345) {} + int better_virtual_value; + virtual int access_vv() { return better_virtual_value; } +}; + +int use(B *b) +{ + return b->access(); +} + +int v_use(V * v) +{ + return v->access_vv(); +} + +int main() +{ + C c; + assert(v_use(&c) == -123); + D d; + assert(v_use(&d) == -345); + return 0; +} diff --git a/libvtv/testsuite/libvtv.cc/vtv.exp b/libvtv/testsuite/libvtv.cc/vtv.exp new file mode 100644 index 00000000000..12ed77431a8 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/vtv.exp @@ -0,0 +1,83 @@ +load_lib libvtv-dg.exp +load_gcc_lib gcc-dg.exp + +global VTV_FLAGS +set VTV_FLAGS [list {-O0} {-O2}] + +libvtv_init c++ + +set shlib_ext [get_shlib_extension] +set lang_link_flags "-shared-libgcc -lstdc++" +set lang_test_file_found 0 +set lang_library_path "../libstdc++-v3/src/.libs" + +dg-init + +set blddir [lookfor_file [get_multilibs] libvtv] + +# Find the correct libstdc++ library to use. + +if { $blddir != "" } { + # Look for a static libstdc++ first. + if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] { + set lang_test_file "${lang_library_path}/libstdc++.a" + set lang_test_file_found 1 + # We may have a shared only build, so look for a shared libstdc++. + } elseif [file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] { + set lang_test_file "${lang_library_path}/libstdc++.${shlib_ext}" + set lang_test_file_found 1 + } else { + puts "looking for ${blddir}/${lang_library_path}/libstdc++.${shlib_ext}" + puts "No libstdc++ library found, will not execute c++ tests" + } +} elseif { [info exists GXX_UNDER_TEST] } { + set lang_test_file_found 1 + # Needs to exist for libvtv.exp. + set lang_test_file "" +} else { + puts "GXX_UNDER_TEST not defined, will not execute c++ tests" +} + + +global srcdir + +if { $lang_test_file_found } { + # Set the path for finding libstdc++. + if { $blddir != "" } { + set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}" + } else { + set ld_library_path "$always_ld_library_path" + } + append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST] + set_ld_library_path_env_vars + + # Make sure we can find the libstdc++ header files. + set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags" + if { [file exists $flags_file] } { + set libstdcxx_includes [exec sh $flags_file --build-includes] + } else { + set libstdcxx_includes "" + } + + # Run the tests with -fvtable-verify=std + foreach flags $VTV_FLAGS { + foreach srcfile [lsort [glob -nocomplain ${srcdir}/libvtv.cc/*.cc]] { + dg-runtest $srcfile "$flags -fvtable-verify=std" $libstdcxx_includes + } + + foreach srcfile [lsort [glob -nocomplain ${srcdir}/libvtv.cc/@*.list]] { + dg-runtest $srcfile "$flags -fvtable-verify=std" $libstdcxx_includes + } + } + + # Run the tests with -fvtable-verify=preinit + foreach flags $VTV_FLAGS { + foreach srcfile [lsort [glob -nocomplain ${srcdir}/libvtv.cc/*.cc]] { + dg-runtest $srcfile "$flags -fvtable-verify=preinit" $libstdcxx_includes + } + + foreach srcfile [lsort [glob -nocomplain ${srcdir}/libvtv.cc/@*.list]] { + dg-runtest $srcfile "$flags -fvtable-verify=preinit" $libstdcxx_includes + } + } +} diff --git a/libvtv/testsuite/libvtv.cc/xlan-test.cc b/libvtv/testsuite/libvtv.cc/xlan-test.cc new file mode 100644 index 00000000000..213ed613fbb --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/xlan-test.cc @@ -0,0 +1,185 @@ +// { dg-do run } + +#include +#include + +class XMemory +{ +public: + void * operator new (size_t size); + void operator delete (void *p); + +protected: + XMemory () {} + + virtual ~XMemory() {} +}; + +class XSerializable +{ +public: + virtual ~XSerializable () {}; + + virtual bool isSerializable() const = 0; + virtual void serialize () = 0; + +protected: + XSerializable() {}; + +}; + +class Grammar: public XSerializable, public XMemory +{ +public: + enum GrammarType { + DTDGrammarType, + SchemaGrammarType, + OtherGrammarType, + Unknown + }; + + virtual ~Grammar() {} + + virtual GrammarType getGrammarType() const = 0; + virtual bool getValidated() const = 0; + + virtual bool isSerializable() const; + virtual void serialize (); + +protected: + Grammar() {}; + +}; + +class SchemaGrammar : public Grammar +{ +public: + + SchemaGrammar () : Grammar(), elemID(10) { fValidated = true; } + + virtual ~SchemaGrammar() {} + + virtual Grammar::GrammarType getGrammarType() const; + virtual bool getValidated() const; + + virtual bool isSerializable () const; + virtual void serialize (); + +private: + const unsigned int elemID; + bool fValidated; + +}; + +class OtherGrammar : public Grammar +{ +public: + + OtherGrammar () : Grammar(), elemID(10) { fValidated = true; } + + virtual ~OtherGrammar() {} + + virtual Grammar::GrammarType getGrammarType() const; + virtual bool getValidated() const; + + virtual bool isSerializable () const; + virtual void serialize (); + +private: + const unsigned int elemID; + bool fValidated; + +}; + +void +Grammar::serialize () +{ + printf ("in Grammar::serialize\n"); +} + +bool +Grammar::isSerializable () const +{ + return true; +} + +bool +SchemaGrammar::isSerializable () const +{ + return true; +} + +void +SchemaGrammar::serialize () +{ + printf ("in SchemaGrammar::serialize\n"); +} + +Grammar::GrammarType +SchemaGrammar::getGrammarType() const { + return Grammar::SchemaGrammarType; +} + +bool +SchemaGrammar::getValidated () const +{ + return fValidated; +} + +void * +XMemory::operator new (size_t size) +{ + return malloc (size); +} + +void +XMemory::operator delete (void *p) +{ +} + +bool +OtherGrammar::isSerializable () const +{ + return false; +} + +void +OtherGrammar::serialize () +{ + printf ("in OtherGrammar::serialize\n"); +} + +Grammar::GrammarType +OtherGrammar::getGrammarType() const { + return Grammar::OtherGrammarType; +} + +bool +OtherGrammar::getValidated () const +{ + return fValidated; +} + +int +main (int argc, char **argv) +{ + SchemaGrammar sPtr; + OtherGrammar oPtr; + Grammar &sGrammar = sPtr; + + for (int i = 0; i < 2; ++i) + { + if (i == 0) + sGrammar = oPtr; + else + sGrammar = sPtr; + + if (sGrammar.getGrammarType() != Grammar::SchemaGrammarType || + sGrammar.getValidated ()) + printf ("if condition was true.\n"); + else + printf ("if condition was false.\n"); + } + + return 0; +} diff --git a/libvtv/testsuite/libvtv.mempool.cc/mempool.exp b/libvtv/testsuite/libvtv.mempool.cc/mempool.exp new file mode 100644 index 00000000000..9565eae711a --- /dev/null +++ b/libvtv/testsuite/libvtv.mempool.cc/mempool.exp @@ -0,0 +1,68 @@ +load_lib libvtv-dg.exp +load_gcc_lib gcc-dg.exp + +global VTV_FLAGS +set VTV_FLAGS [list {-O0} {-O2}] + +libvtv_init c++ + +set shlib_ext [get_shlib_extension] +set lang_link_flags "-shared-libgcc -lstdc++" +set lang_test_file_found 0 +set lang_library_path "../libstdc++-v3/src/.libs" + +dg-init + +set blddir [lookfor_file [get_multilibs] libvtv] + +# Find the correct libstdc++ library to use. + +if { $blddir != "" } { + # Look for a static libstdc++ first. + if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] { + set lang_test_file "${lang_library_path}/libstdc++.a" + set lang_test_file_found 1 + # We may have a shared only build, so look for a shared libstdc++. + } elseif [file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] { + set lang_test_file "${lang_library_path}/libstdc++.${shlib_ext}" + set lang_test_file_found 1 + } else { + puts "looking for ${blddir}/${lang_library_path}/libstdc++.${shlib_ext}" + puts "No libstdc++ library found, will not execute c++ tests" + } +} elseif { [info exists GXX_UNDER_TEST] } { + set lang_test_file_found 1 + # Needs to exist for libvtv.exp. + set lang_test_file "" +} else { + puts "GXX_UNDER_TEST not defined, will not execute c++ tests" +} + + +global srcdir + +if { $lang_test_file_found } { + # Set the path for finding libstdc++. + if { $blddir != "" } { + set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}" + } else { + set ld_library_path "$always_ld_library_path" + } + append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST] + set_ld_library_path_env_vars + + # Make sure we can find the libstdc++ header files. + set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags" + if { [file exists $flags_file] } { + set libstdcxx_includes [exec sh $flags_file --build-includes] + } else { + set libstdcxx_includes "" + } + + # Run the tests with -fvtable-verify=std + foreach flags $VTV_FLAGS { + foreach srcfile [lsort [glob -nocomplain ${srcdir}/libvtv.mempool.cc/*.cc]] { + dg-runtest $srcfile "$flags -fvtable-verify=std" $libstdcxx_includes + } + } +} diff --git a/libvtv/testsuite/libvtv.mempool.cc/mempool_negative.cc b/libvtv/testsuite/libvtv.mempool.cc/mempool_negative.cc new file mode 100644 index 00000000000..2d5e1d0b531 --- /dev/null +++ b/libvtv/testsuite/libvtv.mempool.cc/mempool_negative.cc @@ -0,0 +1,193 @@ +#include +#include +#include +#include +#include + +#include "vtv_malloc.h" +#include "../../../include/vtv-change-permission.h" + +volatile static int signal_count = 0; + +sigjmp_buf before_segv; + +unsigned int vtv_debug = 0; + +static void +handler(int sig, siginfo_t *si, void *unused) +{ + signal_count++; + /* You are not supposed to longjmp out of a signal handler but it seems + to work for this test case and it simplifies it */ + siglongjmp(before_segv, 1); +} + +/* Try to modify the memory pointed by "s" but dont actually change the values. + Assumes and verifies the memory to be modified is mprotected */ +void mempoke(void * s, size_t n) +{ + volatile char * p = (char *)s; + int ret; + + signal_count = 0; + ret = sigsetjmp(before_segv, 1); + if (ret == 0) + p[0] = p[0]; + + assert(ret == 1 && signal_count == 1); + + ret = sigsetjmp(before_segv, 1); + if (ret == 0) + p[n - 1] = p[n - 1]; + + assert(ret == 1 && signal_count == 2); +} + +int main() +{ + char * ptr; + int size; + + /* Set up handler for SIGSEGV. */ + struct sigaction sa; + sa.sa_flags = SA_SIGINFO; + sigemptyset(&sa.sa_mask); + sa.sa_sigaction = handler; + if (sigaction(SIGSEGV, &sa, NULL) == -1) + assert(0); + + /* Make the 'bookkeeping' vars read-write. */ + __VLTChangePermission (__VLTP_READ_WRITE); + __vtv_malloc_init(); + + size = 10; + + /* Verify not writable after unprotect */ + __vtv_malloc_unprotect(); + ptr = (char *)__vtv_malloc(size); + memset(ptr, 'a', size); + __vtv_malloc_protect(); + mempoke(ptr, size); + __vtv_free(ptr); + + /* verify not-writable after protect, unprotect */ + __vtv_malloc_unprotect(); + ptr = (char *)__vtv_malloc(size); + memset(ptr, 'a', size); + __vtv_malloc_protect(); + __vtv_malloc_unprotect(); + memset(ptr, 'a', size); + assert(ptr[size - 1] == 'a'); + __vtv_malloc_protect(); + assert(ptr[size - 1] == 'a'); + mempoke(ptr,size); + __vtv_free(ptr); + + /* Allocate a bunch of small objects. + Make sure the alignment is correct. + Verify data has not been corrupted. + Make sure the data cannot modified */ + { + int s; + for (s = 3; s < 28; s += 3) + { + size = s; + { + int i; + #define ITERS 1000 + char * ptrs[ITERS]; + + __vtv_malloc_unprotect(); + for (i = 0; i < ITERS; i++) + { + ptr = (char *)__vtv_malloc(size); + assert(((long)ptr & VTV_ALIGNMENT_MASK) == 0); + memset(ptr, (i & 127), size); + assert(ptr[size - 1] == (i & 127)); + ptrs[i] = ptr; + } + __vtv_malloc_protect(); + + for (i = 0; i < ITERS; i++) + mempoke(ptrs[i], size); + + __vtv_malloc_unprotect(); + for (i = 0; i < ITERS; i++) + __vtv_free(ptrs[i]); + __vtv_malloc_protect(); + } + } + } + + /* Allocate a bunch of medium size objects. + Make sure the alignment is correct. + Verify data has not been corrupted. + Try to modify the data to verify everything gets unprotected */ + { + int s; + for (s = 501; s < 2500; s += 91) + { + size = s; + { + int i; + #define ITERS2 100 + char * ptrs[ITERS2]; + + __vtv_malloc_unprotect(); + for (i = 0; i < ITERS2; i++) + { + + ptr = (char *)__vtv_malloc(size); + assert(((long)ptr & VTV_ALIGNMENT_MASK) == 0); + memset(ptr, i & 127, size); + assert(ptr[size - 1] == i & 127); + ptrs[i] = ptr; + } + __vtv_malloc_protect(); + + for (i = 0; i < ITERS2; i++) + mempoke(ptrs[i], size); + + __vtv_malloc_unprotect(); + for (i = 0; i < ITERS2; i++) + __vtv_free(ptrs[i]); + __vtv_malloc_protect(); + } + } + } + + /* Allocate a bunch of medium size objects. Make sure the alignment is correct */ + { + int s; + for (s = 3001; s < 15000; s += 307) + { + size = s; + { + int i; + #define ITERS3 50 + char * ptrs[ITERS3]; + + __vtv_malloc_unprotect(); + for (i = 0; i < ITERS3; i++) + { + ptr = (char *)__vtv_malloc(size); + assert(((long)ptr & VTV_ALIGNMENT_MASK) == 0); + memset(ptr, i & 127, size); + assert(ptr[size - 1] == i & 127); + ptrs[i] = ptr; + } + __vtv_malloc_protect(); + + for (i = 0; i < ITERS3; i++) + mempoke(ptrs[i], size); + + __vtv_malloc_unprotect(); + for (i = 0; i < ITERS3; i++) + __vtv_free(ptrs[i]); + __vtv_malloc_protect(); + } + } + } + + return 0; +} diff --git a/libvtv/testsuite/libvtv.mempool.cc/mempool_positive.cc b/libvtv/testsuite/libvtv.mempool.cc/mempool_positive.cc new file mode 100644 index 00000000000..5e60df9b686 --- /dev/null +++ b/libvtv/testsuite/libvtv.mempool.cc/mempool_positive.cc @@ -0,0 +1,199 @@ +#include +#include +#include +#include + +#include "vtv_malloc.h" +#include "../../../include/vtv-change-permission.h" + +unsigned int vtv_debug = 0; + +static void +handler(int sig, siginfo_t *si, void *unused) +{ + printf("Got SIGSEGV at address: 0x%lx\n", + (long) si->si_addr); + exit(1); +} + +int memchk(const void * s, int c, size_t n) +{ + const char * p = (const char *)s; + for (; p < ((char *)s + n); p++) + if (*p != c) + return 1; + return 0; +} + +int main() +{ + char * ptr; + int size; + + /* Set up handler for SIGSEGV. In this test case, we should never hit any SIGSEGV */ + struct sigaction sa; + sa.sa_flags = SA_SIGINFO; + sigemptyset(&sa.sa_mask); + sa.sa_sigaction = handler; + if (sigaction(SIGSEGV, &sa, NULL) == -1) + assert(0); + + /* Make the 'bookkeeping' vars read-write. */ + __VLTChangePermission (__VLTP_READ_WRITE); + __vtv_malloc_init(); + + size = 10; + + /* Verify simple allocation and deallocation */ + __vtv_malloc_unprotect(); + ptr = (char *)__vtv_malloc(size); + __vtv_malloc_protect(); + __vtv_free(ptr); + + /* Verify writable after unprotect */ + __vtv_malloc_unprotect(); + ptr = (char *)__vtv_malloc(size); + memset(ptr, 'a', size); + __vtv_malloc_protect(); + __vtv_free(ptr); + + /* verify readable after protect */ + __vtv_malloc_unprotect(); + ptr = (char *)__vtv_malloc(size); + memset(ptr, 'a', size); + __vtv_malloc_protect(); + assert(ptr[size - 1] == 'a'); + __vtv_free(ptr); + + /* verify writable after protect, unprotect */ + __vtv_malloc_unprotect(); + ptr = (char *)__vtv_malloc(size); + memset(ptr, 'a', size); + __vtv_malloc_protect(); + __vtv_malloc_unprotect(); + memset(ptr, 'a', size); + assert(ptr[size - 1] == 'a'); + __vtv_malloc_protect(); + assert(ptr[size - 1] == 'a'); + __vtv_free(ptr); + + /* Allocate a bunch of small objects. + Make sure the alignment is correct. + Verify data has not been corrupted. + Try to modify the data to verify everything gets unprotected */ + { + int s; + for (s = 3; s < 28; s += 3) + { + size = s; + { + int i; + #define ITERS 1000 + char * ptrs[ITERS]; + + __vtv_malloc_unprotect(); + for (i = 0; i < ITERS; i++) + { + ptr = (char *)__vtv_malloc(size); + assert(((long)ptr & VTV_ALIGNMENT_MASK) == 0); + memset(ptr, (i & 127), size); + assert(ptr[size - 1] == (i & 127)); + ptrs[i] = ptr; + } + __vtv_malloc_protect(); + + __vtv_malloc_unprotect(); + for (i = 0; i < ITERS; i++) + { + if (memchk(ptrs[i], i & 127, size) != 0) + assert(0); + memset(ptrs[i], (i + 1) & 127, size); + if (memchk(ptrs[i], (i + 1) & 127, size) != 0) + assert(0); + __vtv_free(ptrs[i]); + } + __vtv_malloc_protect(); + } + } + } + + /* Allocate a bunch of medium size objects. + Make sure the alignment is correct. + Verify data has not been corrupted. + Try to modify the data to verify everything gets unprotected */ + { + int s; + for (s = 501; s < 2500; s += 91) + { + size = s; + { + int i; + #define ITERS2 100 + char * ptrs[ITERS2]; + + __vtv_malloc_unprotect(); + for (i = 0; i < ITERS2; i++) + { + + ptr = (char *)__vtv_malloc(size); + assert(((long)ptr & VTV_ALIGNMENT_MASK) == 0); + memset(ptr, i & 127, size); + assert(ptr[size - 1] == i & 127); + ptrs[i] = ptr; + } + __vtv_malloc_protect(); + + __vtv_malloc_unprotect(); + for (i = 0; i < ITERS2; i++) + { + if (memchk(ptrs[i], i & 127, size) != 0) + assert(0); + memset(ptrs[i], (i + 1) & 127, size); + if (memchk(ptrs[i], (i + 1) & 127, size) != 0) + assert(0); + __vtv_free(ptrs[i]); + } + __vtv_malloc_protect(); + } + } + } + + /* Allocate a bunch of medium size objects. Make sure the alignment is correct */ + { + int s; + for (s = 3001; s < 15000; s += 307) + { + size = s; + { + int i; + #define ITERS3 50 + char * ptrs[ITERS3]; + + __vtv_malloc_unprotect(); + for (i = 0; i < ITERS3; i++) + { + ptr = (char *)__vtv_malloc(size); + assert(((long)ptr & VTV_ALIGNMENT_MASK) == 0); + memset(ptr, i & 127, size); + assert(ptr[size - 1] == i & 127); + ptrs[i] = ptr; + } + __vtv_malloc_protect(); + + __vtv_malloc_unprotect(); + for (i = 0; i < ITERS3; i++) + { + if (memchk(ptrs[i], i & 127, size) != 0) + assert(0); + memset(ptrs[i], (i + 1) & 127, size); + if (memchk(ptrs[i], (i + 1) & 127, size) != 0) + assert(0); + __vtv_free(ptrs[i]); + } + __vtv_malloc_protect(); + } + } + } + + return 0; +} diff --git a/libvtv/testsuite/libvtv.mt.cc/mt.exp b/libvtv/testsuite/libvtv.mt.cc/mt.exp new file mode 100644 index 00000000000..e2ee43577a3 --- /dev/null +++ b/libvtv/testsuite/libvtv.mt.cc/mt.exp @@ -0,0 +1,68 @@ +load_lib libvtv-dg.exp +load_gcc_lib gcc-dg.exp + +global VTV_FLAGS +set VTV_FLAGS [list {-O0} {-O2}] + +libvtv_init c++ + +set shlib_ext [get_shlib_extension] +set lang_link_flags "-shared-libgcc -lstdc++" +set lang_test_file_found 0 +set lang_library_path "../libstdc++-v3/src/.libs" + +dg-init + +set blddir [lookfor_file [get_multilibs] libvtv] + +# Find the correct libstdc++ library to use. + +if { $blddir != "" } { + # Look for a static libstdc++ first. + if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] { + set lang_test_file "${lang_library_path}/libstdc++.a" + set lang_test_file_found 1 + # We may have a shared only build, so look for a shared libstdc++. + } elseif [file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] { + set lang_test_file "${lang_library_path}/libstdc++.${shlib_ext}" + set lang_test_file_found 1 + } else { + puts "looking for ${blddir}/${lang_library_path}/libstdc++.${shlib_ext}" + puts "No libstdc++ library found, will not execute c++ tests" + } +} elseif { [info exists GXX_UNDER_TEST] } { + set lang_test_file_found 1 + # Needs to exist for libvtv.exp. + set lang_test_file "" +} else { + puts "GXX_UNDER_TEST not defined, will not execute c++ tests" +} + + +global srcdir + +if { $lang_test_file_found } { + # Set the path for finding libstdc++. + if { $blddir != "" } { + set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}" + } else { + set ld_library_path "$always_ld_library_path" + } + append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST] + set_ld_library_path_env_vars + + # Make sure we can find the libstdc++ header files. + set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags" + if { [file exists $flags_file] } { + set libstdcxx_includes [exec sh $flags_file --build-includes] + } else { + set libstdcxx_includes "" + } + + # Run the tests with -fvtable-verify=std + foreach flags $VTV_FLAGS { + foreach srcfile [lsort [glob -nocomplain ${srcdir}/libvtv.mt.cc/*.cc]] { + dg-runtest $srcfile "$flags -fvtable-verify=std -lpthread" $libstdcxx_includes + } + } +} diff --git a/libvtv/testsuite/libvtv.mt.cc/register_set_pair_inserts_mt.cc b/libvtv/testsuite/libvtv.mt.cc/register_set_pair_inserts_mt.cc new file mode 100644 index 00000000000..6df197343f7 --- /dev/null +++ b/libvtv/testsuite/libvtv.mt.cc/register_set_pair_inserts_mt.cc @@ -0,0 +1,156 @@ +#include +#include +#include +#include + +#include "vtv_utils.h" +#include "vtv_rts.h" +#include "pthread.h" + + +/* Multi-threaded test for calls to RegisterPair */ + +/* This configuration will test mostly inserting of new elements since + the number of repeats is 1. It should also do a lot of rehashing */ + +/* This test case may fail depending on the system configuration. + Check the value of /proc/sys/vm/max_map_count and fix by doing + Ex: sudo sh -c "echo 131060 > /proc/sys/vm/max_map_count" */ + +#define NUM_MAPS 2000 +#define ELEMENTS_PER_MAP 100 +#define NUM_REPEATS 1 + +#define NUM_THREADS 9 + +#define KEY_TYPE_FIXED_SIZE 8 +void *key_buffer = malloc (17); +typedef char * name_string; +name_string fake_names[NUM_MAPS]; + +/* This variable has to be put in rel.ro */ +void * volatile maps[NUM_MAPS] VTV_PROTECTED_VAR; + +struct fake_vt { + void * fake_vfp [4]; +}; +void * fake_vts [NUM_MAPS * ELEMENTS_PER_MAP]; + +volatile int current_map = -1; +volatile int threads_completed_it = 0; + +void +generate_names (void) +{ + int i; + + for (i = 0; i < NUM_MAPS; ++i) + { + fake_names[i] = (char *) malloc (9 * sizeof (char)); + snprintf (fake_names[i], 9, "name%d", i); + } +} + +static uint32_t +vtv_string_hash(const char *in) +{ + const char *s = in; + uint32_t h = 0; + + for ( ; *s; ++s) + h = 5 * h + *s; + return h; +} + +void * do_register_pairs(void *) +{ + for (int k = 0; k < NUM_REPEATS; k++) + { + int curr_fake_vt = 0; + for (int i = 0; i < NUM_MAPS; i++) + { + uint32_t *value_ptr = (uint32_t *) key_buffer; + uint32_t len1 = strlen (fake_names[i]); + uint32_t hash_value = vtv_string_hash (fake_names[i]); + void *temp_array[ELEMENTS_PER_MAP]; + + while (current_map < (k*NUM_MAPS + i)) + ; + + __VLTChangePermission(__VLTP_READ_WRITE); + + *value_ptr = len1; + value_ptr++; + *value_ptr = hash_value; + + memcpy ((char *) key_buffer + KEY_TYPE_FIXED_SIZE, fake_names[i], + len1); + + +#ifdef VTV_DEBUG + __VLTRegisterPairDebug ((void **) &maps[i], (char *) key_buffer, 128, + &fake_vts[curr_fake_vt], "", ""); +#else + __VLTRegisterPair ((void **) &maps[i], (char *) key_buffer, 128, + &fake_vts[curr_fake_vt]); +#endif + for (int j = 0; j < ELEMENTS_PER_MAP; j++) + { + temp_array[j] = &fake_vts[curr_fake_vt]; + curr_fake_vt++; + } + +#ifdef VTV_DEBUG + __VLTRegisterSetDebug ((void **) &maps[i], (char *) key_buffer, 128, 100, + (void **) &temp_array); +#else + __VLTRegisterSet ((void **) &maps[i], (char *) key_buffer, 128, 100, + (void **) &temp_array); +#endif + __VLTChangePermission(__VLTP_READ_ONLY); + + int old_value; + do { + old_value = threads_completed_it; + } while (!__sync_bool_compare_and_swap(&threads_completed_it, old_value, old_value + 1)); + + if (old_value == (NUM_THREADS - 1)) // Only one thread will do this. + { + threads_completed_it = 0; + printf("%c%d", 13, current_map + 1); + fflush(stdout); + current_map++; + } + } + } + + return NULL; +} + + +int main() +{ + pthread_t thread_ids[NUM_THREADS]; + + generate_names(); + + for (int t = 0; t < NUM_THREADS; t++ ) + if (pthread_create(&thread_ids[t], NULL, do_register_pairs, NULL) != 0) + { + printf("failed pthread_create\n"); + exit(1); + } + + current_map = 0; // start the work on the other threads + + for (int t = 0; t < NUM_THREADS; t++) + if (pthread_join(thread_ids[t], NULL) != 0) + { + printf("failed pthread_join\n"); + exit(2); + } + + printf("\n"); + + return 0; +} diff --git a/libvtv/testsuite/libvtv.mt.cc/register_set_pair_mt.cc b/libvtv/testsuite/libvtv.mt.cc/register_set_pair_mt.cc new file mode 100644 index 00000000000..1d480a1e3b8 --- /dev/null +++ b/libvtv/testsuite/libvtv.mt.cc/register_set_pair_mt.cc @@ -0,0 +1,158 @@ +#include +#include +#include +#include + +#include "vtv_utils.h" +#include "vtv_rts.h" +#include "pthread.h" + + +/* Multi-threaded test for calls to RegisterPair */ + +/* This configuration will test mostly inserting of elements that are already inserted since + the number of repeats is 10 */ + +/* This test case may fail depending on the system configuration. + Check the value of /proc/sys/vm/max_map_count and fix by doing + Ex: sudo sh -c "echo 131060 > /proc/sys/vm/max_map_count" */ + +#define NUM_MAPS 200 +#define ELEMENTS_PER_MAP 100 +#define NUM_REPEATS 10 + +#define NUM_THREADS 9 + +#define KEY_TYPE_FIXED_SIZE 8 +void *key_buffer = malloc (17); +typedef char * name_string; +name_string fake_names[NUM_MAPS]; + +/* This variable has to be put in rel.ro */ +void * volatile maps[NUM_MAPS] VTV_PROTECTED_VAR; + +struct fake_vt { + void * fake_vfp [4]; +}; +void * fake_vts [NUM_MAPS * ELEMENTS_PER_MAP]; + +volatile int current_map = -1; +volatile int threads_completed_it = 0; + +void +generate_names (void) +{ + int i; + + for (i = 0; i < NUM_MAPS; ++i) + { + fake_names[i] = (char *) malloc (9 * sizeof (char)); + snprintf (fake_names[i], 9, "name%d", i); + } +} + +static uint32_t +vtv_string_hash(const char *in) +{ + const char *s = in; + uint32_t h = 0; + + for ( ; *s; ++s) + h = 5 * h + *s; + return h; +} + +void * do_register_pairs(void *) +{ + for (int k = 0; k < NUM_REPEATS; k++) + { + int curr_fake_vt = 0; + for (int i = 0; i < NUM_MAPS; i++) + { + uint32_t *value_ptr = (uint32_t *) key_buffer; + uint32_t len1 = strlen (fake_names[i]); + uint32_t hash_value = vtv_string_hash (fake_names[i]); + void *temp_array[ELEMENTS_PER_MAP]; + + while (current_map < (k*NUM_MAPS + i)) + ; + + __VLTChangePermission(__VLTP_READ_WRITE); + + *value_ptr = len1; + value_ptr++; + *value_ptr = hash_value; + + memcpy ((char *) key_buffer + KEY_TYPE_FIXED_SIZE, fake_names[i], + len1); + + +#ifdef VTV_DEBUG + __VLTRegisterPairDebug ((void **) &maps[i], (char *) key_buffer, 128, + &fake_vts[curr_fake_vt], "", ""); +#else + __VLTRegisterPair ((void **) &maps[i], (char *) key_buffer, 128, + &fake_vts[curr_fake_vt]); +#endif + for (int j = 0; j < ELEMENTS_PER_MAP; j++) + { + temp_array[j] = &fake_vts[curr_fake_vt]; + curr_fake_vt++; + } + +#ifdef VTV_DEBUG + __VLTRegisterSetDebug ((void **) &maps[i], (char *) key_buffer, 128, 100, + (void **) &temp_array); +#else + __VLTRegisterSet ((void **) &maps[i], (char *) key_buffer, 128, 100, + (void **) &temp_array); +#endif + __VLTChangePermission(__VLTP_READ_ONLY); + + int old_value; + do { + old_value = threads_completed_it; + } while (!__sync_bool_compare_and_swap(&threads_completed_it, old_value, old_value + 1)); + + if (old_value == (NUM_THREADS - 1)) // Only one thread will do this. + { + threads_completed_it = 0; + printf("%c%d", 13, current_map + 1); + fflush(stdout); + current_map++; + } + } + } + + return NULL; +} + + +int main() +{ + pthread_t thread_ids[NUM_THREADS]; + + generate_names (); + + for (int t = 0; t < NUM_THREADS; t++ ) + if (pthread_create(&thread_ids[t], NULL, do_register_pairs, NULL) != 0) + { + printf("failed pthread_create\n"); + exit(1); + } + + current_map = 0; // start the work on the other threads + + for (int t = 0; t < NUM_THREADS; t++) + if (pthread_join(thread_ids[t], NULL) != 0) + { + printf("failed pthread_join\n"); + exit(2); + } + + printf("\n"); + + + + return 0; +} diff --git a/libvtv/testsuite/mempool_negative.c b/libvtv/testsuite/mempool_negative.c deleted file mode 100644 index 50ed53109bd..00000000000 --- a/libvtv/testsuite/mempool_negative.c +++ /dev/null @@ -1,196 +0,0 @@ -#include -#include -#include -#include -#include - -#include "vtv_malloc.h" - -volatile static int signal_count = 0; - -sigjmp_buf before_segv; - -bool vtv_debug = false; - -static void -handler(int sig, siginfo_t *si, void *unused) -{ - /* - printf("Got SIGSEGV at address: 0x%lx\n", - (long) si->si_addr); - */ - - signal_count++; - /* You are not supposed to longjmp out of a signal handler but it seems - to work for this test case and it simplifies it */ - siglongjmp(before_segv, 1); - /* exit(1); */ -} - -/* Try to modify the memory pointed by "s" but dont actually change the values. - Assumes and verifies the memory to be modified is mprotected */ -void mempoke(void * s, size_t n) -{ - volatile char * p = (char *)s; - int ret; - - signal_count = 0; - ret = sigsetjmp(before_segv, 1); - if (ret == 0) - p[0] = p[0]; - /* printf("after first setjmp ret=%d\n", ret); */ - assert(ret == 1 && signal_count == 1); - - ret = sigsetjmp(before_segv, 1); - if (ret == 0) - p[n - 1] = p[n - 1]; - /* printf("after second setjmp ret=%d\n", ret); */ - assert(ret == 1 && signal_count == 2); -} - -int main() -{ - char * ptr; - int size; - - /* Set up handler for SIGSEGV. */ - struct sigaction sa; - sa.sa_flags = SA_SIGINFO; - sigemptyset(&sa.sa_mask); - sa.sa_sigaction = handler; - if (sigaction(SIGSEGV, &sa, NULL) == -1) - assert(0); - - __vtv_malloc_init(); - - size = 10; - - /* Verify not writable after unprotect */ - __vtv_malloc_unprotect(); - ptr = (char *)__vtv_malloc(size); - memset(ptr, 'a', size); - __vtv_malloc_protect(); - mempoke(ptr, size); - __vtv_free(ptr); - - /* verify not-writable after protect, unprotect */ - __vtv_malloc_unprotect(); - ptr = (char *)__vtv_malloc(size); - memset(ptr, 'a', size); - __vtv_malloc_protect(); - __vtv_malloc_unprotect(); - memset(ptr, 'a', size); - assert(ptr[size - 1] == 'a'); - __vtv_malloc_protect(); - assert(ptr[size - 1] == 'a'); - mempoke(ptr,size); - __vtv_free(ptr); - - /* Allocate a bunch of small objects. - Make sure the alignment is correct. - Verify data has not been corrupted. - Make sure the data cannot modified */ - { - int s; - for (s = 3; s < 28; s += 3) - { - size = s; - { - int i; - #define ITERS 1000 - char * ptrs[ITERS]; - - __vtv_malloc_unprotect(); - for (i = 0; i < ITERS; i++) - { - ptr = (char *)__vtv_malloc(size); - assert(((long)ptr & VTV_ALIGNMENT_MASK) == 0); - memset(ptr, (i & 127), size); - assert(ptr[size - 1] == (i & 127)); - ptrs[i] = ptr; - } - __vtv_malloc_protect(); - - for (i = 0; i < ITERS; i++) - mempoke(ptrs[i], size); - - __vtv_malloc_unprotect(); - for (i = 0; i < ITERS; i++) - __vtv_free(ptrs[i]); - __vtv_malloc_protect(); - } - } - } - - /* Allocate a bunch of medium size objects. - Make sure the alignment is correct. - Verify data has not been corrupted. - Try to modify the data to verify everything gets unprotected */ - { - int s; - for (s = 501; s < 2500; s += 91) - { - size = s; - { - int i; - #define ITERS2 100 - char * ptrs[ITERS2]; - - __vtv_malloc_unprotect(); - for (i = 0; i < ITERS2; i++) - { - - ptr = (char *)__vtv_malloc(size); - assert(((long)ptr & VTV_ALIGNMENT_MASK) == 0); - memset(ptr, i & 127, size); - assert(ptr[size - 1] == i & 127); - ptrs[i] = ptr; - } - __vtv_malloc_protect(); - - for (i = 0; i < ITERS2; i++) - mempoke(ptrs[i], size); - - __vtv_malloc_unprotect(); - for (i = 0; i < ITERS2; i++) - __vtv_free(ptrs[i]); - __vtv_malloc_protect(); - } - } - } - - /* Allocate a bunch of medium size objects. Make sure the alignment is correct */ - { - int s; - for (s = 3001; s < 15000; s += 307) - { - size = s; - { - int i; - #define ITERS3 50 - char * ptrs[ITERS3]; - - __vtv_malloc_unprotect(); - for (i = 0; i < ITERS3; i++) - { - ptr = (char *)__vtv_malloc(size); - assert(((long)ptr & VTV_ALIGNMENT_MASK) == 0); - memset(ptr, i & 127, size); - assert(ptr[size - 1] == i & 127); - ptrs[i] = ptr; - } - __vtv_malloc_protect(); - - for (i = 0; i < ITERS3; i++) - mempoke(ptrs[i], size); - - __vtv_malloc_unprotect(); - for (i = 0; i < ITERS3; i++) - __vtv_free(ptrs[i]); - __vtv_malloc_protect(); - } - } - } - - return 0; -} diff --git a/libvtv/testsuite/mempool_positive.c b/libvtv/testsuite/mempool_positive.c deleted file mode 100644 index 511f50a1040..00000000000 --- a/libvtv/testsuite/mempool_positive.c +++ /dev/null @@ -1,196 +0,0 @@ -#include -#include -#include -#include - -#include "vtv_malloc.h" - -bool vtv_debug = false; - -static void -handler(int sig, siginfo_t *si, void *unused) -{ - printf("Got SIGSEGV at address: 0x%lx\n", - (long) si->si_addr); - exit(1); -} - -int memchk(const void * s, int c, size_t n) -{ - const char * p = (const char *)s; - for (; p < ((char *)s + n); p++) - if (*p != c) - return 1; - return 0; -} - -int main() -{ - char * ptr; - int size; - - /* Set up handler for SIGSEGV. In this test case, we should never hit any SIGSEGV */ - struct sigaction sa; - sa.sa_flags = SA_SIGINFO; - sigemptyset(&sa.sa_mask); - sa.sa_sigaction = handler; - if (sigaction(SIGSEGV, &sa, NULL) == -1) - assert(0); - - __vtv_malloc_init(); - - size = 10; - - /* Verify simple allocation and deallocation */ - __vtv_malloc_unprotect(); - ptr = (char *)__vtv_malloc(size); - __vtv_malloc_protect(); - __vtv_free(ptr); - - /* Verify writable after unprotect */ - __vtv_malloc_unprotect(); - ptr = (char *)__vtv_malloc(size); - memset(ptr, 'a', size); - __vtv_malloc_protect(); - __vtv_free(ptr); - - /* verify readable after protect */ - __vtv_malloc_unprotect(); - ptr = (char *)__vtv_malloc(size); - memset(ptr, 'a', size); - __vtv_malloc_protect(); - assert(ptr[size - 1] == 'a'); - __vtv_free(ptr); - - /* verify writable after protect, unprotect */ - __vtv_malloc_unprotect(); - ptr = (char *)__vtv_malloc(size); - memset(ptr, 'a', size); - __vtv_malloc_protect(); - __vtv_malloc_unprotect(); - memset(ptr, 'a', size); - assert(ptr[size - 1] == 'a'); - __vtv_malloc_protect(); - assert(ptr[size - 1] == 'a'); - __vtv_free(ptr); - - /* Allocate a bunch of small objects. - Make sure the alignment is correct. - Verify data has not been corrupted. - Try to modify the data to verify everything gets unprotected */ - { - int s; - for (s = 3; s < 28; s += 3) - { - size = s; - { - int i; - #define ITERS 1000 - char * ptrs[ITERS]; - - __vtv_malloc_unprotect(); - for (i = 0; i < ITERS; i++) - { - ptr = (char *)__vtv_malloc(size); - assert(((long)ptr & VTV_ALIGNMENT_MASK) == 0); - memset(ptr, (i & 127), size); - assert(ptr[size - 1] == (i & 127)); - ptrs[i] = ptr; - } - __vtv_malloc_protect(); - - __vtv_malloc_unprotect(); - for (i = 0; i < ITERS; i++) - { - if (memchk(ptrs[i], i & 127, size) != 0) - assert(0); - memset(ptrs[i], (i + 1) & 127, size); - if (memchk(ptrs[i], (i + 1) & 127, size) != 0) - assert(0); - __vtv_free(ptrs[i]); - } - __vtv_malloc_protect(); - } - } - } - - /* Allocate a bunch of medium size objects. - Make sure the alignment is correct. - Verify data has not been corrupted. - Try to modify the data to verify everything gets unprotected */ - { - int s; - for (s = 501; s < 2500; s += 91) - { - size = s; - { - int i; - #define ITERS2 100 - char * ptrs[ITERS2]; - - __vtv_malloc_unprotect(); - for (i = 0; i < ITERS2; i++) - { - - ptr = (char *)__vtv_malloc(size); - assert(((long)ptr & VTV_ALIGNMENT_MASK) == 0); - memset(ptr, i & 127, size); - assert(ptr[size - 1] == i & 127); - ptrs[i] = ptr; - } - __vtv_malloc_protect(); - - __vtv_malloc_unprotect(); - for (i = 0; i < ITERS2; i++) - { - if (memchk(ptrs[i], i & 127, size) != 0) - assert(0); - memset(ptrs[i], (i + 1) & 127, size); - if (memchk(ptrs[i], (i + 1) & 127, size) != 0) - assert(0); - __vtv_free(ptrs[i]); - } - __vtv_malloc_protect(); - } - } - } - - /* Allocate a bunch of medium size objects. Make sure the alignment is correct */ - { - int s; - for (s = 3001; s < 15000; s += 307) - { - size = s; - { - int i; - #define ITERS3 50 - char * ptrs[ITERS3]; - - __vtv_malloc_unprotect(); - for (i = 0; i < ITERS3; i++) - { - ptr = (char *)__vtv_malloc(size); - assert(((long)ptr & VTV_ALIGNMENT_MASK) == 0); - memset(ptr, i & 127, size); - assert(ptr[size - 1] == i & 127); - ptrs[i] = ptr; - } - __vtv_malloc_protect(); - - __vtv_malloc_unprotect(); - for (i = 0; i < ITERS3; i++) - { - if (memchk(ptrs[i], i & 127, size) != 0) - assert(0); - memset(ptrs[i], (i + 1) & 127, size); - if (memchk(ptrs[i], (i + 1) & 127, size) != 0) - assert(0); - __vtv_free(ptrs[i]); - } - __vtv_malloc_protect(); - } - } - } - - return 0; -} diff --git a/libvtv/testsuite/nested_vcall_test.cc b/libvtv/testsuite/nested_vcall_test.cc deleted file mode 100644 index 13d7143edf8..00000000000 --- a/libvtv/testsuite/nested_vcall_test.cc +++ /dev/null @@ -1,76 +0,0 @@ - -class EtherCtrl { - protected: - int ssap; - - public: - EtherCtrl(void); - ~EtherCtrl(); - virtual int getSsap(void) const; - virtual void setSsap(int); -}; - -class EtherFrameWithLLC { - protected: - int ssap; - - public: - EtherFrameWithLLC(const char *, int); - ~EtherFrameWithLLC(); - virtual int getSsap(void) const; - virtual void setSsap(int); -}; - - -EtherCtrl::EtherCtrl() -{ - this->ssap = 0; -} - -EtherCtrl::~EtherCtrl() -{ -} - -int EtherCtrl::getSsap() const -{ - return ssap; -} - -void EtherCtrl::setSsap(int ssap) -{ - this->ssap = ssap; -} - -EtherFrameWithLLC::EtherFrameWithLLC(const char *name, int kind) -{ - this->ssap = 0; -} - -EtherFrameWithLLC::~EtherFrameWithLLC() -{ -} - -int EtherFrameWithLLC::getSsap() const -{ - return ssap; -} - -void EtherFrameWithLLC::setSsap(int ssap) -{ - this->ssap = ssap; -} - - -int -main (int argc, char **argv) -{ - EtherCtrl *etherctrl = new EtherCtrl (); - EtherFrameWithLLC *frame = new EtherFrameWithLLC ("test", 10); - int my_value; - - etherctrl->setSsap(43); - frame->setSsap(etherctrl->getSsap()); - my_value = frame->getSsap(); - - return 0; -} diff --git a/libvtv/testsuite/other-tests/Makefile.am b/libvtv/testsuite/other-tests/Makefile.am new file mode 100644 index 00000000000..56f76a79f5b --- /dev/null +++ b/libvtv/testsuite/other-tests/Makefile.am @@ -0,0 +1,52 @@ +## Makefile for the testsuite subdirectory of the VTV library. +## +## Copyright (C) 2013 Free Software Foundation, Inc. +## +## Process this file with automake to produce Makefile.in. +## +## This file is part of the Vtable Verification (VTV) Library. This +## library 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, or (at your option) +## any later version. + +## This library 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 library; see the file COPYING3. If not see +## . + +AUTOMAKE_OPTIONS = nostdinc + +# Runs the testsuite via a script. + +# Create subdirectories. +stamp-subdir: + if test ! -d lib64; then \ + mkdir -p lib64; \ + fi; \ + if test ! -d lib32; then \ + mkdir -p lib32; \ + fi; \ + echo `date` > stamp-subdir; + + +testing_script=${libvtv_srcdir}/scripts/run-testsuite.sh +check-script: ${testing_script} stamp-subdir + -@(chmod +x ${testing_script}; \ + ${testing_script} ${libvtv_srcdir} ${libvtv_builddir}) + +check-am: + $(MAKE) $(AM_MAKEFLAGS) check-script + +.PHONY: check-script + +# By adding these files here, automake will remove them for 'make clean' +CLEANFILES = *.out environment-fail-* stamp-* replace-fail-* + +# To remove directories. +clean-local: + rm -rf lib* diff --git a/libvtv/testsuite/other-tests/Makefile.in b/libvtv/testsuite/other-tests/Makefile.in new file mode 100644 index 00000000000..66a75e16ea6 --- /dev/null +++ b/libvtv/testsuite/other-tests/Makefile.in @@ -0,0 +1,379 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = testsuite +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ + $(top_srcdir)/../config/depstand.m4 \ + $(top_srcdir)/../config/lead-dot.m4 \ + $(top_srcdir)/../config/libstdc++-raw-cxx.m4 \ + $(top_srcdir)/../config/multi.m4 \ + $(top_srcdir)/../config/override.m4 \ + $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ + $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ + $(top_srcdir)/acinclude.m4 $(top_srcdir)/../libtool.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +SOURCES = +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBSTDCXX_RAW_CXX_CXXFLAGS = @LIBSTDCXX_RAW_CXX_CXXFLAGS@ +LIBSTDCXX_RAW_CXX_LDFLAGS = @LIBSTDCXX_RAW_CXX_LDFLAGS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XCFLAGS = @XCFLAGS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +enable_shared = @enable_shared@ +enable_static = @enable_static@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +libtool_VERSION = @libtool_VERSION@ +libvtv_builddir = @libvtv_builddir@ +libvtv_srcdir = @libvtv_srcdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +multi_basedir = @multi_basedir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_noncanonical = @target_noncanonical@ +target_os = @target_os@ +target_vendor = @target_vendor@ +toolexecdir = @toolexecdir@ +toolexeclibdir = @toolexeclibdir@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +toplevel_builddir = @toplevel_builddir@ +toplevel_srcdir = @toplevel_srcdir@ +AUTOMAKE_OPTIONS = nostdinc +testing_script = ${libvtv_srcdir}/scripts/run-testsuite.sh + +# By adding these files here, automake will remove them for 'make clean' +CLEANFILES = *.out environment-fail-* stamp-* replace-fail-* +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign testsuite/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign testsuite/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-local mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + clean-local distclean distclean-generic distclean-libtool dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am + + +# Runs the testsuite via a script. + +# Create subdirectories. +stamp-subdir: + if test ! -d lib64; then \ + mkdir -p lib64; \ + fi; \ + if test ! -d lib32; then \ + mkdir -p lib32; \ + fi; \ + echo `date` > stamp-subdir; +check-script: ${testing_script} stamp-subdir + -@(chmod +x ${testing_script}; \ + ${testing_script} ${libvtv_srcdir} ${libvtv_builddir}) + +check-am: + $(MAKE) $(AM_MAKEFLAGS) check-script + +.PHONY: check-script + +# To remove directories. +clean-local: + rm -rf lib* + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libvtv/testsuite/other-tests/README b/libvtv/testsuite/other-tests/README new file mode 100644 index 00000000000..a64047460a6 --- /dev/null +++ b/libvtv/testsuite/other-tests/README @@ -0,0 +1,8 @@ +This directory contains tests that have not yet been converted to +proper dejagnu tests. If you look at the run_testsuite script in +libvtv/scripts, you should get a fair idea as to how to run these +tests. The plan is to convert these tests into proper dejangnu tests +sometime in the near future. + + +Aug. 30, 2013 \ No newline at end of file diff --git a/libvtv/testsuite/other-tests/dlopen.cc b/libvtv/testsuite/other-tests/dlopen.cc new file mode 100644 index 00000000000..4ffbe83acf7 --- /dev/null +++ b/libvtv/testsuite/other-tests/dlopen.cc @@ -0,0 +1,38 @@ +#include +#include +#include + + + +typedef void (*voidfn)(void); + +int failures = 0; + +void +__vtv_verify_fail (void **data_set_ptr, const void *vtbl_pointer) +{ + failures++; + return; +} + + +int main() +{ + char so_name[] = "so0.so"; + void * dlhandle = dlopen(so_name, RTLD_NOW); + if (!dlhandle) + { + fprintf(stderr, "dlopen %s error: %s\n", so_name, dlerror()); + exit(1); + } + voidfn so_entry = (voidfn)dlsym(dlhandle, "so_entry_0"); + if (!so_entry) + { + fprintf(stderr, "dlopen %s dlsym error: %s\n", so_name, dlerror()); + exit(2); + } + + so_entry(); + + dlclose(dlhandle); +} diff --git a/libvtv/testsuite/other-tests/dlopen_mt.cc b/libvtv/testsuite/other-tests/dlopen_mt.cc new file mode 100644 index 00000000000..772e8a733ed --- /dev/null +++ b/libvtv/testsuite/other-tests/dlopen_mt.cc @@ -0,0 +1,112 @@ +#include +#include +#include + +#include "vtv_utils.h" +#include "vtv_rts.h" +#include "pthread.h" + +#define NUM_REPEATS 10 +#define NUM_THREADS 10 +#define NUM_SOS 100 +#define NUM_SOS_PER_THREAD (NUM_SOS/NUM_THREADS) + +typedef void (*voidfn)(void); + +int failures = 0; + +void +__vtv_verify_fail (void **data_set_ptr, const void *vtbl_pointer) +{ + failures++; + return; +} + + +void do_dlopen(int so_num) +{ + char so_name [sizeof("soxxx.so")]; + sprintf(so_name, "so%d.so", so_num); + // printf("dl-opening %s\n", so_name); + void * dlhandle = dlopen(so_name, RTLD_NOW); + if (!dlhandle) + { + fprintf(stderr, "dlopen so:%s error: %s\n", so_name, dlerror()); + exit(1); + } + char so_entry [sizeof("so_entry_xxx")]; + sprintf(so_entry, "so_entry_%d", so_num); + voidfn so_entry_fn = (voidfn)dlsym(dlhandle, so_entry); + if (!so_entry_fn) + { + fprintf(stderr, "so:%s dlsym error: %s\n", so_name, dlerror()); + exit(2); + } + + so_entry_fn(); + + dlclose(dlhandle); +} + +volatile int threads_completed_it = 0; +volatile int current_wave = -1; + +void * do_dlopens(void * ptid) +{ + for (int k = 0; k < NUM_REPEATS; k++) + { + + for (int i = 0; i < NUM_SOS_PER_THREAD; i++) + { + while (current_wave < (k*NUM_SOS_PER_THREAD + i)) /* from 0 to 99 */ + ; + + do_dlopen((NUM_SOS_PER_THREAD * *(int *)ptid) + i); + + int old_value; + do { + old_value = threads_completed_it; + } while (!__sync_bool_compare_and_swap(&threads_completed_it, old_value, old_value + 1)); + + if (old_value == (NUM_THREADS - 1)) // Only one thread will do this. + { + threads_completed_it = 0; + printf("%c%d", 13, current_wave + 1); + fflush(stdout); + current_wave++; + } + } + } + + return NULL; +} + + +int main() +{ + pthread_t thread_ids[NUM_THREADS]; + int thread_nids[NUM_THREADS]; + + for (int t = 0; t < NUM_THREADS; t++ ) + { + thread_nids[t] = t; + if (pthread_create(&thread_ids[t], NULL, do_dlopens, &thread_nids[t]) != 0) + { + printf("failed pthread_create\n"); + exit(1); + } + } + + current_wave = 0; // start the work on the other threads + + for (int t = 0; t < NUM_THREADS; t++) + if (pthread_join(thread_ids[t], NULL) != 0) + { + printf("failed pthread_join\n"); + exit(2); + } + + printf("\n"); + + return 0; +} diff --git a/libvtv/testsuite/other-tests/environment-fail-32.s b/libvtv/testsuite/other-tests/environment-fail-32.s new file mode 100644 index 00000000000..cac501652a7 --- /dev/null +++ b/libvtv/testsuite/other-tests/environment-fail-32.s @@ -0,0 +1,514 @@ + .file "environment.cc" + .section .text._ZN15EnvironmentImpl6GetVarEPKcPc,"axG",@progbits,_ZN15EnvironmentImpl6GetVarEPKcPc,comdat + .align 2 + .weak _ZN15EnvironmentImpl6GetVarEPKcPc + .type _ZN15EnvironmentImpl6GetVarEPKcPc, @function +_ZN15EnvironmentImpl6GetVarEPKcPc: +.LFB0: + .cfi_startproc + pushl %ebp + .cfi_def_cfa_offset 8 + .cfi_offset 5, -8 + movl %esp, %ebp + .cfi_def_cfa_register 5 + movl $1, %eax + popl %ebp + .cfi_restore 5 + .cfi_def_cfa 4, 4 + ret + .cfi_endproc +.LFE0: + .size _ZN15EnvironmentImpl6GetVarEPKcPc, .-_ZN15EnvironmentImpl6GetVarEPKcPc + .text + .align 2 + .globl _ZN11EnvironmentD2Ev + .type _ZN11EnvironmentD2Ev, @function +_ZN11EnvironmentD2Ev: +.LFB2: + .cfi_startproc + pushl %ebp + .cfi_def_cfa_offset 8 + .cfi_offset 5, -8 + movl %esp, %ebp + .cfi_def_cfa_register 5 + pushl %ebx + subl $20, %esp + .cfi_offset 3, -12 + call __x86.get_pc_thunk.bx + addl $_GLOBAL_OFFSET_TABLE_, %ebx + movl 8(%ebp), %eax + movl _ZTV11Environment@GOT(%ebx), %edx + leal 8(%edx), %edx + movl %edx, (%eax) + movl $0, %eax + testl %eax, %eax + je .L3 + movl 8(%ebp), %eax + movl %eax, (%esp) + call _ZdlPv@PLT +.L3: + addl $20, %esp + popl %ebx + .cfi_restore 3 + popl %ebp + .cfi_restore 5 + .cfi_def_cfa 4, 4 + ret + .cfi_endproc +.LFE2: + .size _ZN11EnvironmentD2Ev, .-_ZN11EnvironmentD2Ev + .globl _ZN11EnvironmentD1Ev + .set _ZN11EnvironmentD1Ev,_ZN11EnvironmentD2Ev + .align 2 + .globl _ZN11EnvironmentD0Ev + .type _ZN11EnvironmentD0Ev, @function +_ZN11EnvironmentD0Ev: +.LFB4: + .cfi_startproc + pushl %ebp + .cfi_def_cfa_offset 8 + .cfi_offset 5, -8 + movl %esp, %ebp + .cfi_def_cfa_register 5 + pushl %ebx + subl $20, %esp + .cfi_offset 3, -12 + call __x86.get_pc_thunk.bx + addl $_GLOBAL_OFFSET_TABLE_, %ebx + movl 8(%ebp), %eax + movl %eax, (%esp) + call _ZN11EnvironmentD1Ev@PLT + movl 8(%ebp), %eax + movl %eax, (%esp) + call _ZdlPv@PLT + addl $20, %esp + popl %ebx + .cfi_restore 3 + popl %ebp + .cfi_restore 5 + .cfi_def_cfa 4, 4 + ret + .cfi_endproc +.LFE4: + .size _ZN11EnvironmentD0Ev, .-_ZN11EnvironmentD0Ev + .section .text._ZN11EnvironmentC2Ev,"axG",@progbits,_ZN11EnvironmentC5Ev,comdat + .align 2 + .weak _ZN11EnvironmentC2Ev + .type _ZN11EnvironmentC2Ev, @function +_ZN11EnvironmentC2Ev: +.LFB8: + .cfi_startproc + pushl %ebp + .cfi_def_cfa_offset 8 + .cfi_offset 5, -8 + movl %esp, %ebp + .cfi_def_cfa_register 5 + call __x86.get_pc_thunk.cx + addl $_GLOBAL_OFFSET_TABLE_, %ecx + movl 8(%ebp), %eax + movl _ZTV11Environment@GOT(%ecx), %edx + leal 8(%edx), %edx + movl %edx, (%eax) + popl %ebp + .cfi_restore 5 + .cfi_def_cfa 4, 4 + ret + .cfi_endproc +.LFE8: + .size _ZN11EnvironmentC2Ev, .-_ZN11EnvironmentC2Ev + .weak _ZN11EnvironmentC1Ev + .set _ZN11EnvironmentC1Ev,_ZN11EnvironmentC2Ev + .section .text._ZN15EnvironmentImplC2Ev,"axG",@progbits,_ZN15EnvironmentImplC5Ev,comdat + .align 2 + .weak _ZN15EnvironmentImplC2Ev + .type _ZN15EnvironmentImplC2Ev, @function +_ZN15EnvironmentImplC2Ev: +.LFB10: + .cfi_startproc + pushl %ebp + .cfi_def_cfa_offset 8 + .cfi_offset 5, -8 + movl %esp, %ebp + .cfi_def_cfa_register 5 + pushl %ebx + subl $20, %esp + .cfi_offset 3, -12 + call __x86.get_pc_thunk.bx + addl $_GLOBAL_OFFSET_TABLE_, %ebx + movl 8(%ebp), %eax + movl %eax, (%esp) + call _ZN11EnvironmentC2Ev@PLT + movl 8(%ebp), %eax + movl _ZTV15EnvironmentImpl@GOT(%ebx), %edx + leal 8(%edx), %edx + movl %edx, (%eax) + addl $20, %esp + popl %ebx + .cfi_restore 3 + popl %ebp + .cfi_restore 5 + .cfi_def_cfa 4, 4 + ret + .cfi_endproc +.LFE10: + .size _ZN15EnvironmentImplC2Ev, .-_ZN15EnvironmentImplC2Ev + .weak _ZN15EnvironmentImplC1Ev + .set _ZN15EnvironmentImplC1Ev,_ZN15EnvironmentImplC2Ev + .text + .align 2 + .globl _ZN11Environment6CreateEv + .type _ZN11Environment6CreateEv, @function +_ZN11Environment6CreateEv: +.LFB5: + .cfi_startproc + pushl %ebp + .cfi_def_cfa_offset 8 + .cfi_offset 5, -8 + movl %esp, %ebp + .cfi_def_cfa_register 5 + pushl %esi + pushl %ebx + subl $16, %esp + .cfi_offset 6, -12 + .cfi_offset 3, -16 + call __x86.get_pc_thunk.bx + addl $_GLOBAL_OFFSET_TABLE_, %ebx + movl $4, (%esp) + call _Znwj@PLT + movl %eax, %esi + movl $0, (%esi) + movl %esi, (%esp) + call _ZN15EnvironmentImplC1Ev@PLT + movl %esi, %eax + addl $16, %esp + popl %ebx + .cfi_restore 3 + popl %esi + .cfi_restore 6 + popl %ebp + .cfi_restore 5 + .cfi_def_cfa 4, 4 + ret + .cfi_endproc +.LFE5: + .size _ZN11Environment6CreateEv, .-_ZN11Environment6CreateEv + .section .rodata +.LC0: + .string "%p\n" + .text + .globl main + .type main, @function +main: +.LFB12: + .cfi_startproc + pushl %ebp + .cfi_def_cfa_offset 8 + .cfi_offset 5, -8 + movl %esp, %ebp + .cfi_def_cfa_register 5 + pushl %ebx + andl $-16, %esp + subl $32, %esp + .cfi_offset 3, -12 + call __x86.get_pc_thunk.bx + addl $_GLOBAL_OFFSET_TABLE_, %ebx + movl $0, 28(%esp) + call _ZN11Environment6CreateEv@PLT + movl %eax, 24(%esp) + movl 24(%esp), %eax + movl (%eax), %eax + movl %eax, 4(%esp) + leal _ZN4_VTVI11EnvironmentE12__vtable_mapE@GOTOFF(%ebx), %eax + movl %eax, (%esp) + call _Z24__VLTVerifyVtablePointerPPvPKv@PLT + addl $8, %eax + movl (%eax), %eax + movl 28(%esp), %edx + movl %edx, 8(%esp) + movl $0, 4(%esp) + movl 24(%esp), %edx + movl %edx, (%esp) + call *%eax + movl 24(%esp), %eax + movl %eax, 4(%esp) + leal .LC0@GOTOFF(%ebx), %eax + movl %eax, (%esp) + call printf@PLT + movl $0, %eax + movl -4(%ebp), %ebx + leave + .cfi_restore 5 + .cfi_restore 3 + .cfi_def_cfa 4, 4 + ret + .cfi_endproc +.LFE12: + .size main, .-main + .weak _ZTV11Environment + .section .data.rel.ro._ZTV11Environment,"awG",@progbits,_ZTV11Environment,comdat + .align 8 + .type _ZTV11Environment, @object + .size _ZTV11Environment, 20 +_ZTV11Environment: + .long 0 + .long _ZTI11Environment + .long _ZN11EnvironmentD1Ev + .long _ZN11EnvironmentD0Ev + .long __cxa_pure_virtual + .weak _ZTV15EnvironmentImpl + .section .data.rel.ro._ZTV15EnvironmentImpl,"awG",@progbits,_ZTV15EnvironmentImpl,comdat + .align 8 + .type _ZTV15EnvironmentImpl, @object + .size _ZTV15EnvironmentImpl, 20 +_ZTV15EnvironmentImpl: + .long 0 + .long _ZTI15EnvironmentImpl + .long _ZN15EnvironmentImplD1Ev + .long _ZN15EnvironmentImplD0Ev + .long _ZN15EnvironmentImpl6GetVarEPKcPc + .section .text._ZN15EnvironmentImplD2Ev,"axG",@progbits,_ZN15EnvironmentImplD5Ev,comdat + .align 2 + .weak _ZN15EnvironmentImplD2Ev + .type _ZN15EnvironmentImplD2Ev, @function +_ZN15EnvironmentImplD2Ev: +.LFB14: + .cfi_startproc + .cfi_personality 0x9b,DW.ref.__gxx_personality_v0 + .cfi_lsda 0x1b,.LLSDA14 + pushl %ebp + .cfi_def_cfa_offset 8 + .cfi_offset 5, -8 + movl %esp, %ebp + .cfi_def_cfa_register 5 + pushl %ebx + subl $20, %esp + .cfi_offset 3, -12 + call __x86.get_pc_thunk.bx + addl $_GLOBAL_OFFSET_TABLE_, %ebx + movl 8(%ebp), %eax + movl _ZTV15EnvironmentImpl@GOT(%ebx), %edx + leal 8(%edx), %edx + movl %edx, (%eax) + movl 8(%ebp), %eax + movl %eax, (%esp) +.LEHB0: + call _ZN11EnvironmentD2Ev@PLT +.LEHE0: + movl $0, %eax + testl %eax, %eax + je .L19 + movl 8(%ebp), %eax + movl %eax, (%esp) + call _ZdlPv@PLT + jmp .L19 +.L18: + movl %eax, (%esp) +.LEHB1: + call _Unwind_Resume@PLT +.LEHE1: +.L19: + addl $20, %esp + popl %ebx + .cfi_restore 3 + popl %ebp + .cfi_restore 5 + .cfi_def_cfa 4, 4 + ret + .cfi_endproc +.LFE14: + .globl __gxx_personality_v0 + .section .gcc_except_table._ZN15EnvironmentImplD2Ev,"aG",@progbits,_ZN15EnvironmentImplD5Ev,comdat +.LLSDA14: + .byte 0xff + .byte 0xff + .byte 0x1 + .uleb128 .LLSDACSE14-.LLSDACSB14 +.LLSDACSB14: + .uleb128 .LEHB0-.LFB14 + .uleb128 .LEHE0-.LEHB0 + .uleb128 .L18-.LFB14 + .uleb128 0 + .uleb128 .LEHB1-.LFB14 + .uleb128 .LEHE1-.LEHB1 + .uleb128 0 + .uleb128 0 +.LLSDACSE14: + .section .text._ZN15EnvironmentImplD2Ev,"axG",@progbits,_ZN15EnvironmentImplD5Ev,comdat + .size _ZN15EnvironmentImplD2Ev, .-_ZN15EnvironmentImplD2Ev + .weak _ZN15EnvironmentImplD1Ev + .set _ZN15EnvironmentImplD1Ev,_ZN15EnvironmentImplD2Ev + .section .text._ZN15EnvironmentImplD0Ev,"axG",@progbits,_ZN15EnvironmentImplD0Ev,comdat + .align 2 + .weak _ZN15EnvironmentImplD0Ev + .type _ZN15EnvironmentImplD0Ev, @function +_ZN15EnvironmentImplD0Ev: +.LFB16: + .cfi_startproc + pushl %ebp + .cfi_def_cfa_offset 8 + .cfi_offset 5, -8 + movl %esp, %ebp + .cfi_def_cfa_register 5 + pushl %ebx + subl $20, %esp + .cfi_offset 3, -12 + call __x86.get_pc_thunk.bx + addl $_GLOBAL_OFFSET_TABLE_, %ebx + movl 8(%ebp), %eax + movl %eax, (%esp) + call _ZN15EnvironmentImplD1Ev@PLT + movl 8(%ebp), %eax + movl %eax, (%esp) + call _ZdlPv@PLT + addl $20, %esp + popl %ebx + .cfi_restore 3 + popl %ebp + .cfi_restore 5 + .cfi_def_cfa 4, 4 + ret + .cfi_endproc +.LFE16: + .size _ZN15EnvironmentImplD0Ev, .-_ZN15EnvironmentImplD0Ev + .weak _ZTS15EnvironmentImpl + .section .rodata._ZTS15EnvironmentImpl,"aG",@progbits,_ZTS15EnvironmentImpl,comdat + .type _ZTS15EnvironmentImpl, @object + .size _ZTS15EnvironmentImpl, 18 +_ZTS15EnvironmentImpl: + .string "15EnvironmentImpl" + .weak _ZTI15EnvironmentImpl + .section .data.rel.ro._ZTI15EnvironmentImpl,"awG",@progbits,_ZTI15EnvironmentImpl,comdat + .align 4 + .type _ZTI15EnvironmentImpl, @object + .size _ZTI15EnvironmentImpl, 12 +_ZTI15EnvironmentImpl: + .long _ZTVN10__cxxabiv120__si_class_type_infoE+8 + .long _ZTS15EnvironmentImpl + .long _ZTI11Environment + .weak _ZTI11Environment + .section .data.rel.ro._ZTI11Environment,"awG",@progbits,_ZTI11Environment,comdat + .align 4 + .type _ZTI11Environment, @object + .size _ZTI11Environment, 8 +_ZTI11Environment: + .long _ZTVN10__cxxabiv117__class_type_infoE+8 + .long _ZTS11Environment + .weak _ZTS11Environment + .section .rodata._ZTS11Environment,"aG",@progbits,_ZTS11Environment,comdat + .type _ZTS11Environment, @object + .size _ZTS11Environment, 14 +_ZTS11Environment: + .string "11Environment" + .hidden _ZN4_VTVI11EnvironmentE12__vtable_mapE + .weak _ZN4_VTVI11EnvironmentE12__vtable_mapE + .section .vtable_map_vars,"awG",@progbits,_ZN4_VTVI11EnvironmentE12__vtable_mapE,comdat + .align 4 + .type _ZN4_VTVI11EnvironmentE12__vtable_mapE, @gnu_unique_object + .size _ZN4_VTVI11EnvironmentE12__vtable_mapE, 4 +_ZN4_VTVI11EnvironmentE12__vtable_mapE: + .zero 4 + .hidden _ZN4_VTVI15EnvironmentImplE12__vtable_mapE + .weak _ZN4_VTVI15EnvironmentImplE12__vtable_mapE + .section .vtable_map_vars,"awG",@progbits,_ZN4_VTVI15EnvironmentImplE12__vtable_mapE,comdat + .align 4 + .type _ZN4_VTVI15EnvironmentImplE12__vtable_mapE, @gnu_unique_object + .size _ZN4_VTVI15EnvironmentImplE12__vtable_mapE, 4 +_ZN4_VTVI15EnvironmentImplE12__vtable_mapE: + .zero 4 + .section .data.rel.ro,"aw",@progbits + .align 4 + .type __vptr_array_11Environment, @object + .size __vptr_array_11Environment, 8 +__vptr_array_11Environment: + .long _ZTV11Environment+8 + .long _ZTV15EnvironmentImpl+8 + .section .rodata + .align 4 +.LC1: + .string "&" + .string "" + .string "" + .ascii "\224\tl\022_ZN4_VTVI11EnvironmentE12__vtable_mapE" + .align 4 +.LC2: + .string "*" + .string "" + .string "" + .ascii "N\225\r\334_ZN4_VTVI15EnvironmentImplE12__vtable_mapE" + .text + .type _GLOBAL__sub_I.00099_environment.cc, @function +_GLOBAL__sub_I.00099_environment.cc: +.LFB17: + .cfi_startproc + pushl %ebp + .cfi_def_cfa_offset 8 + .cfi_offset 5, -8 + movl %esp, %ebp + .cfi_def_cfa_register 5 + pushl %ebx + subl $36, %esp + .cfi_offset 3, -12 + call __x86.get_pc_thunk.bx + addl $_GLOBAL_OFFSET_TABLE_, %ebx + leal __vptr_array_11Environment@GOTOFF(%ebx), %eax + movl %eax, 16(%esp) + movl $2, 12(%esp) + movl $2, 8(%esp) + leal .LC1@GOTOFF(%ebx), %eax + movl %eax, 4(%esp) + leal _ZN4_VTVI11EnvironmentE12__vtable_mapE@GOTOFF(%ebx), %eax + movl %eax, (%esp) + movl _ZTV15EnvironmentImpl@GOT(%ebx), %eax + leal 8(%eax), %eax + movl %eax, 12(%esp) + movl $1, 8(%esp) + leal .LC2@GOTOFF(%ebx), %eax + movl %eax, 4(%esp) + leal _ZN4_VTVI15EnvironmentImplE12__vtable_mapE@GOTOFF(%ebx), %eax + movl %eax, (%esp) + call _Z17__VLTRegisterPairPPvPKvjS2_@PLT + addl $36, %esp + popl %ebx + .cfi_restore 3 + popl %ebp + .cfi_restore 5 + .cfi_def_cfa 4, 4 + ret + .cfi_endproc +.LFE17: + .size _GLOBAL__sub_I.00099_environment.cc, .-_GLOBAL__sub_I.00099_environment.cc + .section .init_array.00099,"aw" + .align 4 + .long _GLOBAL__sub_I.00099_environment.cc + .section .text.__x86.get_pc_thunk.cx,"axG",@progbits,__x86.get_pc_thunk.cx,comdat + .globl __x86.get_pc_thunk.cx + .hidden __x86.get_pc_thunk.cx + .type __x86.get_pc_thunk.cx, @function +__x86.get_pc_thunk.cx: +.LFB18: + .cfi_startproc + movl (%esp), %ecx + ret + .cfi_endproc +.LFE18: + .section .text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat + .globl __x86.get_pc_thunk.bx + .hidden __x86.get_pc_thunk.bx + .type __x86.get_pc_thunk.bx, @function +__x86.get_pc_thunk.bx: +.LFB19: + .cfi_startproc + movl (%esp), %ebx + ret + .cfi_endproc +.LFE19: + .hidden DW.ref.__gxx_personality_v0 + .weak DW.ref.__gxx_personality_v0 + .section .data.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat + .align 4 + .type DW.ref.__gxx_personality_v0, @object + .size DW.ref.__gxx_personality_v0, 4 +DW.ref.__gxx_personality_v0: + .long __gxx_personality_v0 + .ident "GCC: (GNU) 4.9.0 20130616 (experimental)" + .section .note.GNU-stack,"",@progbits diff --git a/libvtv/testsuite/other-tests/environment-fail-64.s b/libvtv/testsuite/other-tests/environment-fail-64.s new file mode 100644 index 00000000000..d75db248b07 --- /dev/null +++ b/libvtv/testsuite/other-tests/environment-fail-64.s @@ -0,0 +1,425 @@ + .file "environment.cc" + .section .text._ZN15EnvironmentImpl6GetVarEPKcPc,"axG",@progbits,_ZN15EnvironmentImpl6GetVarEPKcPc,comdat + .align 2 + .weak _ZN15EnvironmentImpl6GetVarEPKcPc + .type _ZN15EnvironmentImpl6GetVarEPKcPc, @function +_ZN15EnvironmentImpl6GetVarEPKcPc: +.LFB0: + .cfi_startproc + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + movq %rdi, -8(%rbp) + movq %rsi, -16(%rbp) + movq %rdx, -24(%rbp) + movl $1, %eax + popq %rbp + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE0: + .size _ZN15EnvironmentImpl6GetVarEPKcPc, .-_ZN15EnvironmentImpl6GetVarEPKcPc + .text + .align 2 + .globl _ZN11EnvironmentD2Ev + .type _ZN11EnvironmentD2Ev, @function +_ZN11EnvironmentD2Ev: +.LFB2: + .cfi_startproc + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + subq $16, %rsp + movq %rdi, -8(%rbp) + movq -8(%rbp), %rax + movq _ZTV11Environment@GOTPCREL(%rip), %rdx + leaq 16(%rdx), %rdx + movq %rdx, (%rax) + movl $0, %eax + testl %eax, %eax + je .L3 + movq -8(%rbp), %rax + movq %rax, %rdi + call _ZdlPv@PLT +.L3: + leave + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE2: + .size _ZN11EnvironmentD2Ev, .-_ZN11EnvironmentD2Ev + .globl _ZN11EnvironmentD1Ev + .set _ZN11EnvironmentD1Ev,_ZN11EnvironmentD2Ev + .align 2 + .globl _ZN11EnvironmentD0Ev + .type _ZN11EnvironmentD0Ev, @function +_ZN11EnvironmentD0Ev: +.LFB4: + .cfi_startproc + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + subq $16, %rsp + movq %rdi, -8(%rbp) + movq -8(%rbp), %rax + movq %rax, %rdi + call _ZN11EnvironmentD1Ev@PLT + movq -8(%rbp), %rax + movq %rax, %rdi + call _ZdlPv@PLT + leave + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE4: + .size _ZN11EnvironmentD0Ev, .-_ZN11EnvironmentD0Ev + .section .text._ZN11EnvironmentC2Ev,"axG",@progbits,_ZN11EnvironmentC5Ev,comdat + .align 2 + .weak _ZN11EnvironmentC2Ev + .type _ZN11EnvironmentC2Ev, @function +_ZN11EnvironmentC2Ev: +.LFB8: + .cfi_startproc + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + movq %rdi, -8(%rbp) + movq -8(%rbp), %rax + movq _ZTV11Environment@GOTPCREL(%rip), %rdx + leaq 16(%rdx), %rdx + movq %rdx, (%rax) + popq %rbp + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE8: + .size _ZN11EnvironmentC2Ev, .-_ZN11EnvironmentC2Ev + .weak _ZN11EnvironmentC1Ev + .set _ZN11EnvironmentC1Ev,_ZN11EnvironmentC2Ev + .section .text._ZN15EnvironmentImplC2Ev,"axG",@progbits,_ZN15EnvironmentImplC5Ev,comdat + .align 2 + .weak _ZN15EnvironmentImplC2Ev + .type _ZN15EnvironmentImplC2Ev, @function +_ZN15EnvironmentImplC2Ev: +.LFB10: + .cfi_startproc + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + subq $16, %rsp + movq %rdi, -8(%rbp) + movq -8(%rbp), %rax + movq %rax, %rdi + call _ZN11EnvironmentC2Ev@PLT + movq -8(%rbp), %rax + movq _ZTV15EnvironmentImpl@GOTPCREL(%rip), %rdx + leaq 16(%rdx), %rdx + movq %rdx, (%rax) + leave + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE10: + .size _ZN15EnvironmentImplC2Ev, .-_ZN15EnvironmentImplC2Ev + .weak _ZN15EnvironmentImplC1Ev + .set _ZN15EnvironmentImplC1Ev,_ZN15EnvironmentImplC2Ev + .text + .align 2 + .globl _ZN11Environment6CreateEv + .type _ZN11Environment6CreateEv, @function +_ZN11Environment6CreateEv: +.LFB5: + .cfi_startproc + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + pushq %rbx + subq $8, %rsp + .cfi_offset 3, -24 + movl $8, %edi + call _Znwm@PLT + movq %rax, %rbx + movq $0, (%rbx) + movq %rbx, %rdi + call _ZN15EnvironmentImplC1Ev@PLT + movq %rbx, %rax + addq $8, %rsp + popq %rbx + popq %rbp + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE5: + .size _ZN11Environment6CreateEv, .-_ZN11Environment6CreateEv + .section .rodata +.LC0: + .string "%p\n" + .text + .globl main + .type main, @function +main: +.LFB12: + .cfi_startproc + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + subq $16, %rsp + movq $0, -8(%rbp) + call _ZN11Environment6CreateEv@PLT + movq %rax, -16(%rbp) + movq -16(%rbp), %rax + movq (%rax), %rax + movq %rax, %rsi + leaq _ZN4_VTVI11EnvironmentE12__vtable_mapE(%rip), %rdi + call _Z24__VLTVerifyVtablePointerPPvPKv@PLT + addq $16, %rax + movq (%rax), %rax + movq -8(%rbp), %rdx + movq -16(%rbp), %rcx + movl $0, %esi + movq %rcx, %rdi + call *%rax + movq -16(%rbp), %rax + movq %rax, %rsi + leaq .LC0(%rip), %rdi + movl $0, %eax + call printf@PLT + movl $0, %eax + leave + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE12: + .size main, .-main + .weak _ZTV11Environment + .section .data.rel.ro._ZTV11Environment,"awG",@progbits,_ZTV11Environment,comdat + .align 32 + .type _ZTV11Environment, @object + .size _ZTV11Environment, 40 +_ZTV11Environment: + .quad 0 + .quad _ZTI11Environment + .quad _ZN11EnvironmentD1Ev + .quad _ZN11EnvironmentD0Ev + .quad __cxa_pure_virtual + .weak _ZTV15EnvironmentImpl + .section .data.rel.ro._ZTV15EnvironmentImpl,"awG",@progbits,_ZTV15EnvironmentImpl,comdat + .align 32 + .type _ZTV15EnvironmentImpl, @object + .size _ZTV15EnvironmentImpl, 40 +_ZTV15EnvironmentImpl: + .quad 0 + .quad _ZTI15EnvironmentImpl + .quad _ZN15EnvironmentImplD1Ev + .quad _ZN15EnvironmentImplD0Ev + .quad _ZN15EnvironmentImpl6GetVarEPKcPc + .section .text._ZN15EnvironmentImplD2Ev,"axG",@progbits,_ZN15EnvironmentImplD5Ev,comdat + .align 2 + .weak _ZN15EnvironmentImplD2Ev + .type _ZN15EnvironmentImplD2Ev, @function +_ZN15EnvironmentImplD2Ev: +.LFB14: + .cfi_startproc + .cfi_personality 0x9b,DW.ref.__gxx_personality_v0 + .cfi_lsda 0x1b,.LLSDA14 + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + subq $16, %rsp + movq %rdi, -8(%rbp) + movq -8(%rbp), %rax + movq _ZTV15EnvironmentImpl@GOTPCREL(%rip), %rdx + leaq 16(%rdx), %rdx + movq %rdx, (%rax) + movq -8(%rbp), %rax + movq %rax, %rdi +.LEHB0: + call _ZN11EnvironmentD2Ev@PLT +.LEHE0: + movl $0, %eax + testl %eax, %eax + je .L19 + movq -8(%rbp), %rax + movq %rax, %rdi + call _ZdlPv@PLT + jmp .L19 +.L18: + movq %rax, %rdi +.LEHB1: + call _Unwind_Resume@PLT +.LEHE1: +.L19: + leave + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE14: + .globl __gxx_personality_v0 + .section .gcc_except_table._ZN15EnvironmentImplD2Ev,"aG",@progbits,_ZN15EnvironmentImplD5Ev,comdat +.LLSDA14: + .byte 0xff + .byte 0xff + .byte 0x1 + .uleb128 .LLSDACSE14-.LLSDACSB14 +.LLSDACSB14: + .uleb128 .LEHB0-.LFB14 + .uleb128 .LEHE0-.LEHB0 + .uleb128 .L18-.LFB14 + .uleb128 0 + .uleb128 .LEHB1-.LFB14 + .uleb128 .LEHE1-.LEHB1 + .uleb128 0 + .uleb128 0 +.LLSDACSE14: + .section .text._ZN15EnvironmentImplD2Ev,"axG",@progbits,_ZN15EnvironmentImplD5Ev,comdat + .size _ZN15EnvironmentImplD2Ev, .-_ZN15EnvironmentImplD2Ev + .weak _ZN15EnvironmentImplD1Ev + .set _ZN15EnvironmentImplD1Ev,_ZN15EnvironmentImplD2Ev + .section .text._ZN15EnvironmentImplD0Ev,"axG",@progbits,_ZN15EnvironmentImplD0Ev,comdat + .align 2 + .weak _ZN15EnvironmentImplD0Ev + .type _ZN15EnvironmentImplD0Ev, @function +_ZN15EnvironmentImplD0Ev: +.LFB16: + .cfi_startproc + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + subq $16, %rsp + movq %rdi, -8(%rbp) + movq -8(%rbp), %rax + movq %rax, %rdi + call _ZN15EnvironmentImplD1Ev@PLT + movq -8(%rbp), %rax + movq %rax, %rdi + call _ZdlPv@PLT + leave + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE16: + .size _ZN15EnvironmentImplD0Ev, .-_ZN15EnvironmentImplD0Ev + .weak _ZTS15EnvironmentImpl + .section .rodata._ZTS15EnvironmentImpl,"aG",@progbits,_ZTS15EnvironmentImpl,comdat + .align 16 + .type _ZTS15EnvironmentImpl, @object + .size _ZTS15EnvironmentImpl, 18 +_ZTS15EnvironmentImpl: + .string "15EnvironmentImpl" + .weak _ZTI15EnvironmentImpl + .section .data.rel.ro._ZTI15EnvironmentImpl,"awG",@progbits,_ZTI15EnvironmentImpl,comdat + .align 16 + .type _ZTI15EnvironmentImpl, @object + .size _ZTI15EnvironmentImpl, 24 +_ZTI15EnvironmentImpl: + .quad _ZTVN10__cxxabiv120__si_class_type_infoE+16 + .quad _ZTS15EnvironmentImpl + .quad _ZTI11Environment + .weak _ZTI11Environment + .section .data.rel.ro._ZTI11Environment,"awG",@progbits,_ZTI11Environment,comdat + .align 16 + .type _ZTI11Environment, @object + .size _ZTI11Environment, 16 +_ZTI11Environment: + .quad _ZTVN10__cxxabiv117__class_type_infoE+16 + .quad _ZTS11Environment + .weak _ZTS11Environment + .section .rodata._ZTS11Environment,"aG",@progbits,_ZTS11Environment,comdat + .type _ZTS11Environment, @object + .size _ZTS11Environment, 14 +_ZTS11Environment: + .string "11Environment" + .hidden _ZN4_VTVI11EnvironmentE12__vtable_mapE + .weak _ZN4_VTVI11EnvironmentE12__vtable_mapE + .section .vtable_map_vars,"awG",@progbits,_ZN4_VTVI11EnvironmentE12__vtable_mapE,comdat + .align 8 + .type _ZN4_VTVI11EnvironmentE12__vtable_mapE, @gnu_unique_object + .size _ZN4_VTVI11EnvironmentE12__vtable_mapE, 8 +_ZN4_VTVI11EnvironmentE12__vtable_mapE: + .zero 8 + .hidden _ZN4_VTVI15EnvironmentImplE12__vtable_mapE + .weak _ZN4_VTVI15EnvironmentImplE12__vtable_mapE + .section .vtable_map_vars,"awG",@progbits,_ZN4_VTVI15EnvironmentImplE12__vtable_mapE,comdat + .align 8 + .type _ZN4_VTVI15EnvironmentImplE12__vtable_mapE, @gnu_unique_object + .size _ZN4_VTVI15EnvironmentImplE12__vtable_mapE, 8 +_ZN4_VTVI15EnvironmentImplE12__vtable_mapE: + .zero 8 + .section .data.rel.ro,"aw",@progbits + .align 16 + .type __vptr_array_11Environment, @object + .size __vptr_array_11Environment, 16 +__vptr_array_11Environment: + .quad _ZTV11Environment+16 + .quad _ZTV15EnvironmentImpl+16 + .section .rodata + .align 8 +.LC1: + .string "&" + .string "" + .string "" + .ascii "\224\tl\022_ZN4_VTVI11EnvironmentE12__vtable_mapE" + .align 8 +.LC2: + .string "*" + .string "" + .string "" + .ascii "N\225\r\334_ZN4_VTVI15EnvironmentImplE12__vtable_mapE" + .text + .type _GLOBAL__sub_I.00099_environment.cc, @function +_GLOBAL__sub_I.00099_environment.cc: +.LFB17: + .cfi_startproc + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + leaq __vptr_array_11Environment(%rip), %r8 + movl $2, %ecx + movl $2, %edx + leaq .LC1(%rip), %rsi + leaq _ZN4_VTVI11EnvironmentE12__vtable_mapE(%rip), %rdi + movq _ZTV15EnvironmentImpl@GOTPCREL(%rip), %rax + leaq 16(%rax), %rcx + movl $1, %edx + leaq .LC2(%rip), %rsi + leaq _ZN4_VTVI15EnvironmentImplE12__vtable_mapE(%rip), %rdi + call _Z17__VLTRegisterPairPPvPKvmS2_@PLT + popq %rbp + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE17: + .size _GLOBAL__sub_I.00099_environment.cc, .-_GLOBAL__sub_I.00099_environment.cc + .section .init_array.00099,"aw" + .align 8 + .quad _GLOBAL__sub_I.00099_environment.cc + .hidden DW.ref.__gxx_personality_v0 + .weak DW.ref.__gxx_personality_v0 + .section .data.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat + .align 8 + .type DW.ref.__gxx_personality_v0, @object + .size DW.ref.__gxx_personality_v0, 8 +DW.ref.__gxx_personality_v0: + .quad __gxx_personality_v0 + .ident "GCC: (GNU) 4.9.0 20130616 (experimental)" + .section .note.GNU-stack,"",@progbits diff --git a/libvtv/testsuite/other-tests/field-test.cc b/libvtv/testsuite/other-tests/field-test.cc new file mode 100644 index 00000000000..b6f34bca02c --- /dev/null +++ b/libvtv/testsuite/other-tests/field-test.cc @@ -0,0 +1,94 @@ +// Compile with /home/llozano/local2/proj/vtable/gcc-root/usr/local/bin/g++ -m32 -fvtable-verify=std -fpic -rdynamic -Wl,-R,/home/llozano/local2/proj/vtable/gcc-root/usr/local/lib32:./lib32 -I/home/llozano/local2/proj/vtable/vt2/gcc-4_6-mobile-vtable-security//libstdc++-v3/libsupc++ temp_deriv.cc -O0 -ldl -lpthread -Wl,--whole-archive,-lvtv_init,--no-whole-archive,-z,relro -DTPID=0 -g +// Look at assembly with: objdump -drl a.out + +#include +#include +#include + +extern "C" int printf(const char *, ...); + +static int counter = 0; + +int i = TPID; +struct base +{ + virtual void inc() { counter += i; } +}; + +struct derived: public base +{ + virtual void inc() { counter += (10*i); } +}; + +// We don't use this class. It is just here so that the +// compiler does not devirtualize calls to derived::inc() +struct derived2: public derived +{ + virtual void inc() { counter += (20*i); } +}; + +/* +static base * bp = new base(); +static derived * dp = new derived(); +static base * dbp = new derived(); +*/ + +struct my_struct { + base *bp; + derived *dp; + base *dbp; +}; + +typedef void * vtptr; + +vtptr get_vtptr(void * object_ptr) +{ + vtptr * object_vtptr_ptr = (vtptr *)object_ptr; + return *object_vtptr_ptr; +} + +void set_vptr(void * object_ptr, vtptr vtp) +{ + vtptr * object_vtptr_ptr = (vtptr *)object_ptr; + *object_vtptr_ptr = vtp; +} + +// Given 2 pointers to C++ objects (non PODs), exchange the pointers to vtable +void exchange_vtptr(void * object1_ptr, void * object2_ptr) +{ + vtptr object1_vtptr = get_vtptr(object1_ptr); + vtptr object2_vtptr = get_vtptr(object2_ptr); + set_vptr(object1_ptr, object2_vtptr); + set_vptr(object2_ptr, object1_vtptr); +} + +main() +{ + int prev_counter; + + struct my_struct *my_obj = (struct my_struct *) malloc (sizeof (struct my_struct)); + + my_obj->bp = new base(); + my_obj->dp = new derived (); + my_obj->dbp = new derived (); + + + counter = 0; + my_obj->bp->inc(); + my_obj->dp->inc(); + my_obj->dbp->inc(); + assert(counter == (TPID + 10*TPID + 10*TPID)); + + prev_counter = counter; + printf("before ex bp vptr=%x dp vptr=%x\n", get_vtptr(my_obj->bp), get_vtptr(my_obj->dp)); + exchange_vtptr(my_obj->bp, my_obj->dp); + printf("after ex bp vptr=%x dp vptr=%x\n", get_vtptr(my_obj->bp), get_vtptr(my_obj->dp)); + my_obj->bp->inc(); // This one should not abort but it is calling the wrong member + assert(counter == (prev_counter + 10*TPID)); + printf("Pass first attack! Expected!\n"); + printf("TPDI=%d counter %d\n", TPID, counter); + my_obj->dp->inc(); + printf("Pass second attack! SHOULD NOT BE HERE!\n"); + printf("TPDI=%d counter %d\n", TPID, counter); + exit(1); +} diff --git a/libvtv/testsuite/other-tests/replace-fail.cc b/libvtv/testsuite/other-tests/replace-fail.cc new file mode 100644 index 00000000000..2b4070eec77 --- /dev/null +++ b/libvtv/testsuite/other-tests/replace-fail.cc @@ -0,0 +1,11 @@ +#include +#include + + +void __vtv_verify_fail (void **, void*) __attribute__((visibility ("default"))); + +void +__vtv_verify_fail (void **hash_table, const void *vtbl_ptr) +{ + fprintf (stdout, "Executing alternative failure routine.\n"); +} diff --git a/libvtv/testsuite/other-tests/so.cc b/libvtv/testsuite/other-tests/so.cc new file mode 100644 index 00000000000..3f0a346f1e8 --- /dev/null +++ b/libvtv/testsuite/other-tests/so.cc @@ -0,0 +1,93 @@ +#include +#include +#include +#include + +extern "C" int printf(const char *, ...); +extern "C" int sprintf(char *, const char*, ...); + +static int counter = 0; +extern int failures; + +template struct base +{ + virtual char * whoami() { + static char sl[100]; + sprintf(sl, "I am base %d", i); + return sl; + } + virtual void inc() { counter += i; } +}; + +template struct derived: base +{ + virtual char * whoami() { + static char sl[100]; + sprintf(sl, "I am derived %d", i); + return sl; + } + virtual void inc() { counter += (10*i); } +}; + +// We don't use this class. It is just here so that the +// compiler does not devirtualize calls to derived::inc() +template struct derived2: derived +{ + virtual void inc() { counter += (20*i); } +}; + +static base * bp = new base(); +static derived * dp = new derived(); +static base * dbp = new derived(); + + +// Given 2 pointers to C++ objects (non PODs), exchange the pointers to vtable +static void exchange_vtptr(void * object1_ptr, void * object2_ptr) +{ + void ** object1_vtptr_ptr = (void **)object1_ptr; + void ** object2_vtptr_ptr = (void **)object2_ptr; + void * object1_vtptr = *object1_vtptr_ptr; + void * object2_vtptr = *object2_vtptr_ptr; + *object1_vtptr_ptr = object2_vtptr; + *object2_vtptr_ptr = object1_vtptr; +} + +#define BUILD_NAME(NAME,ID) NAME##ID +#define EXPAND(NAME,X) BUILD_NAME(NAME,X) +extern "C" void EXPAND(so_entry_,TPID)(void) +{ + int prev_counter; + int prev_failures; + + counter = 0; + bp->inc(); + dp->inc(); + dbp->inc(); + assert(counter == (TPID + 10*TPID + 10*TPID)); + + prev_counter = counter; + exchange_vtptr(bp, dp); + bp->inc(); // This one should succeed but it is calling the wrong member + if (counter != (prev_counter + 10*TPID)) + { + printf("TPID=%d whoami=%s wrong counter value prev_counter=%d counter=%d\n", TPID, bp->whoami(), prev_counter, counter); + sleep(2); + } + assert(counter == (prev_counter + 10*TPID)); + // printf("Pass first attack!\n"); + + // This one should fail verification!. So it should jump to __vtv_verify_fail above. + prev_failures = failures; + dp->inc(); + // this code may be executed by multiple threads at the same time. So, just verify the number of failures has + // increased as opposed to check for increase by 1. + assert(failures > prev_failures); + assert(counter == (prev_counter + 10*TPID + TPID)); + // printf("TPDI=%d counter %d\n", TPID, counter); + // printf("Pass second attack!\n"); + + // restore the vtable pointers to the original state. + // This is very important. For some reason the dlclose is not "really" closing the library so when we reopen it we are + // getting the old memory state. + exchange_vtptr(bp, dp); +} diff --git a/libvtv/testsuite/other-tests/temp_deriv.cc b/libvtv/testsuite/other-tests/temp_deriv.cc new file mode 100644 index 00000000000..ca360c0bc91 --- /dev/null +++ b/libvtv/testsuite/other-tests/temp_deriv.cc @@ -0,0 +1,67 @@ +// Compile with /home/llozano/local2/proj/vtable/gcc-root/usr/local/bin/g++ -m32 -fvtable-verify=std -fpic -rdynamic -Wl,-R,/home/llozano/local2/proj/vtable/gcc-root/usr/local/lib32:./lib32 -I/home/llozano/local2/proj/vtable/vt2/gcc-4_6-mobile-vtable-security//libstdc++-v3/libsupc++ temp_deriv.cc -O0 -ldl -lpthread -Wl,--whole-archive,-lvtv_init,--no-whole-archive,-z,relro -DTPID=0 -g +// Look at assembly with: objdump -drl a.out + +#include +#include + +extern "C" int printf(const char *, ...); + +static int counter = 0; + +template struct base +{ + virtual void inc() { counter += i; } +}; + +template struct derived: base +{ + virtual void inc() { counter += (10*i); } +}; + +// We don't use this class. It is just here so that the +// compiler does not devirtualize calls to derived::inc() +template struct derived2: derived +{ + virtual void inc() { counter += (20*i); } +}; + +static base * bp = new base(); +static derived * dp = new derived(); +static base * dbp = new derived(); + +// Given 2 pointers to C++ objects (non PODs), exchange the pointers to vtable +void exchange_vtptr(void * object1_ptr, void * object2_ptr) +{ + void ** object1_vtptr_ptr = (void **)object1_ptr; + void ** object2_vtptr_ptr = (void **)object2_ptr; + void * object1_vtptr = *object1_vtptr_ptr; + void * object2_vtptr = *object2_vtptr_ptr; + *object1_vtptr_ptr = object2_vtptr; + *object2_vtptr_ptr = object1_vtptr; +} + +main() +{ + int prev_counter; + + exchange_vtptr(bp, dp); + exchange_vtptr(bp, dp); + exchange_vtptr(bp, dbp); + exchange_vtptr(bp, dbp); + + counter = 0; + bp->inc(); + dp->inc(); + dbp->inc(); + assert(counter == (TPID + 10*TPID + 10*TPID)); + + prev_counter = counter; + exchange_vtptr(bp, dp); + bp->inc(); // This one should succeed but it is calling the wrong member + assert(counter == (prev_counter + 10*TPID)); + printf("Pass first attack!\n"); + dp->inc(); + printf("TPDI=%d counter %d\n", TPID, counter); + printf("Pass second attack!\n"); + +} diff --git a/libvtv/testsuite/other-tests/temp_deriv2.cc b/libvtv/testsuite/other-tests/temp_deriv2.cc new file mode 100644 index 00000000000..78b43f8b08b --- /dev/null +++ b/libvtv/testsuite/other-tests/temp_deriv2.cc @@ -0,0 +1,69 @@ +// Compile with /home/llozano/local2/proj/vtable/gcc-root/usr/local/bin/g++ -m32 -fvtable-verify=std -fpic -rdynamic -Wl,-R,/home/llozano/local2/proj/vtable/gcc-root/usr/local/lib32:./lib32 -I/home/llozano/local2/proj/vtable/vt2/gcc-4_6-mobile-vtable-security//libstdc++-v3/libsupc++ temp_deriv.cc -O0 -ldl -lpthread -Wl,--whole-archive,-lvtv_init,--no-whole-archive,-z,relro -DTPID=0 -g +// Look at assembly with: objdump -drl a.out + +#include +#include + +extern "C" int printf(const char *, ...); + +static int counter = 0; + +int i = TPID; +struct base +{ + virtual void inc() { counter += i; } +}; + +struct derived: public base +{ + virtual void inc() { counter += (10*i); } +}; + +// We don't use this class. It is just here so that the +// compiler does not devirtualize calls to derived::inc() +struct derived2: public derived +{ + virtual void inc() { counter += (20*i); } +}; + +static base * bp = new base(); +static derived * dp = new derived(); +static base * dbp = new derived(); + +// Given 2 pointers to C++ objects (non PODs), exchange the pointers to vtable +void exchange_vtptr(void * object1_ptr, void * object2_ptr) +{ + typedef void * vtptr; + vtptr * object1_vtptr_ptr = (vtptr *)object1_ptr; + vtptr * object2_vtptr_ptr = (vtptr *)object2_ptr; + vtptr object1_vtptr = *object1_vtptr_ptr; + vtptr object2_vtptr = *object2_vtptr_ptr; + *object1_vtptr_ptr = object2_vtptr; + *object2_vtptr_ptr = object1_vtptr; +} + +main() +{ + int prev_counter; + + exchange_vtptr(bp, dp); + exchange_vtptr(bp, dp); + exchange_vtptr(bp, dbp); + exchange_vtptr(bp, dbp); + + counter = 0; + bp->inc(); + dp->inc(); + dbp->inc(); + assert(counter == (TPID + 10*TPID + 10*TPID)); + + prev_counter = counter; + exchange_vtptr(bp, dp); + bp->inc(); // This one should succeed but it is calling the wrong member + assert(counter == (prev_counter + 10*TPID)); + printf("Pass first attack!\n"); + dp->inc(); + printf("TPDI=%d counter %d\n", TPID, counter); + printf("Pass second attack!\n"); + +} diff --git a/libvtv/testsuite/other-tests/temp_deriv3.cc b/libvtv/testsuite/other-tests/temp_deriv3.cc new file mode 100644 index 00000000000..924c47e9628 --- /dev/null +++ b/libvtv/testsuite/other-tests/temp_deriv3.cc @@ -0,0 +1,79 @@ +// Compile with /home/llozano/local2/proj/vtable/gcc-root/usr/local/bin/g++ -m32 -fvtable-verify=std -fpic -rdynamic -Wl,-R,/home/llozano/local2/proj/vtable/gcc-root/usr/local/lib32:./lib32 -I/home/llozano/local2/proj/vtable/vt2/gcc-4_6-mobile-vtable-security//libstdc++-v3/libsupc++ temp_deriv.cc -O0 -ldl -lpthread -Wl,--whole-archive,-lvtv_init,--no-whole-archive,-z,relro -DTPID=0 -g +// Look at assembly with: objdump -drl a.out + +#include +#include +#include + +extern "C" int printf(const char *, ...); + +static int counter = 0; + +int i = TPID; +struct base +{ + virtual void inc() { counter += i; } +}; + +struct derived: public base +{ + virtual void inc() { counter += (10*i); } +}; + +// We don't use this class. It is just here so that the +// compiler does not devirtualize calls to derived::inc() +struct derived2: public derived +{ + virtual void inc() { counter += (20*i); } +}; + +static base * bp = new base(); +static derived * dp = new derived(); +static base * dbp = new derived(); + +typedef void * vtptr; + +vtptr get_vtptr(void * object_ptr) +{ + vtptr * object_vtptr_ptr = (vtptr *)object_ptr; + return *object_vtptr_ptr; +} + +void set_vptr(void * object_ptr, vtptr vtp) +{ + vtptr * object_vtptr_ptr = (vtptr *)object_ptr; + *object_vtptr_ptr = vtp; +} + +// Given 2 pointers to C++ objects (non PODs), exchange the pointers to vtable +void exchange_vtptr(void * object1_ptr, void * object2_ptr) +{ + vtptr object1_vtptr = get_vtptr(object1_ptr); + vtptr object2_vtptr = get_vtptr(object2_ptr); + set_vptr(object1_ptr, object2_vtptr); + set_vptr(object2_ptr, object1_vtptr); +} + +main() +{ + int prev_counter; + + counter = 0; + bp->inc(); + dp->inc(); + dbp->inc(); + assert(counter == (TPID + 10*TPID + 10*TPID)); + + prev_counter = counter; + printf("before ex bp vptr=%x dp vptr=%x\n", get_vtptr(bp), get_vtptr(dp)); + exchange_vtptr(bp, dp); + printf("after ex bp vptr=%x dp vptr=%x\n", get_vtptr(bp), get_vtptr(dp)); + bp->inc(); // This one should not abort but it is calling the wrong member + assert(counter == (prev_counter + 10*TPID)); + printf("Pass first attack! Expected!\n"); + printf("TPDI=%d counter %d\n", TPID, counter); + dp->inc(); + printf("Pass second attack! SHOULD NOT BE HERE!\n"); + printf("TPDI=%d counter %d\n", TPID, counter); + exit(1); +} diff --git a/libvtv/testsuite/parts-test-extra-parts-views.cc b/libvtv/testsuite/parts-test-extra-parts-views.cc deleted file mode 100644 index 13d7fdc6e4f..00000000000 --- a/libvtv/testsuite/parts-test-extra-parts-views.cc +++ /dev/null @@ -1,16 +0,0 @@ -#include "parts-test-extra-parts-views.h" - -ExtraPartsViews::ExtraPartsViews () - : ExtraParts () { -} - -ExtraPartsViews::~ExtraPartsViews () {} - -void -ExtraPartsViews::ToolkitInitialized () -{ - /* Do something */ - int sum = 0; - for (int i = 0; i < 10; ++i) - sum += i; -} diff --git a/libvtv/testsuite/parts-test-extra-parts-views.h b/libvtv/testsuite/parts-test-extra-parts-views.h deleted file mode 100644 index 0784c0ecdaa..00000000000 --- a/libvtv/testsuite/parts-test-extra-parts-views.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _EXTRA_PARTS_VIEWS_H_ -#define _EXTRA_PARTS_VIEWS_H_ - -#include "parts-test-extra-parts.h" - -class ExtraPartsViews : public ExtraParts { - public: - ExtraPartsViews (); - virtual ~ExtraPartsViews (); - - virtual void ToolkitInitialized (); -}; - -#endif /* _EXTRA_PARTS_VIEWS_H_ */ diff --git a/libvtv/testsuite/parts-test-extra-parts.cc b/libvtv/testsuite/parts-test-extra-parts.cc deleted file mode 100644 index dbd3dbfd8f5..00000000000 --- a/libvtv/testsuite/parts-test-extra-parts.cc +++ /dev/null @@ -1,15 +0,0 @@ -#include "parts-test-extra-parts.h" - -ExtraParts::ExtraParts () {} - -ExtraParts::~ExtraParts () {} - -void -ExtraParts::ToolkitInitialized () -{ -} - -void -ExtraParts::PreEarlyInitialization () -{ -} diff --git a/libvtv/testsuite/parts-test-extra-parts.h b/libvtv/testsuite/parts-test-extra-parts.h deleted file mode 100644 index 4ed2a4ce1a0..00000000000 --- a/libvtv/testsuite/parts-test-extra-parts.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef _EXTRA_PARTS_H_ -#define _EXTRA_PARTS_H_ - -class ExtraParts { - public: - ExtraParts (); - virtual ~ExtraParts (); - - virtual void PreEarlyInitialization (); - virtual void ToolkitInitialized (); -}; - -#endif /* _EXTRA_PARTS_H_ */ diff --git a/libvtv/testsuite/parts-test-main.cc b/libvtv/testsuite/parts-test-main.cc deleted file mode 100644 index c90901e7919..00000000000 --- a/libvtv/testsuite/parts-test-main.cc +++ /dev/null @@ -1,37 +0,0 @@ -#include "parts-test-main.h" -#include "parts-test-extra-parts-views.h" - -MainParts::MainParts () {} - -MainParts::~MainParts () -{ - for (int i = static_cast(main_extra_parts_.size()) - 1; i >= 0; --i) - delete main_extra_parts_[i]; - main_extra_parts_.clear(); -} - -void -MainParts::AddParts (ExtraParts *parts) -{ - main_extra_parts_.push_back (parts); -} - - -void -MainParts::PreEarlyInitialization (void) -{ - for (int i = 0; i < main_extra_parts_.size(); ++i) - main_extra_parts_[i]->PreEarlyInitialization (); -} - - -int -main (int argc, char **argv) -{ - MainParts *main_parts = new MainParts (); - - main_parts->AddParts (new ExtraPartsViews ()); - main_parts->PreEarlyInitialization (); - - return 0; -} diff --git a/libvtv/testsuite/parts-test-main.h b/libvtv/testsuite/parts-test-main.h deleted file mode 100644 index fb631dec340..00000000000 --- a/libvtv/testsuite/parts-test-main.h +++ /dev/null @@ -1,15 +0,0 @@ -#include - -class ExtraParts; - -class MainParts { - public: - MainParts (); - virtual ~MainParts (); - virtual void AddParts (ExtraParts *parts); - - virtual void PreEarlyInitialization (); - - protected: - std::vector main_extra_parts_; -}; diff --git a/libvtv/testsuite/parts-test.list b/libvtv/testsuite/parts-test.list deleted file mode 100644 index fdf95a8876c..00000000000 --- a/libvtv/testsuite/parts-test.list +++ /dev/null @@ -1 +0,0 @@ -parts-test-main.cc parts-test-extra-parts.cc parts-test-extra-parts-views.cc diff --git a/libvtv/testsuite/povray-derived.cc b/libvtv/testsuite/povray-derived.cc deleted file mode 100644 index 4f56a3d730f..00000000000 --- a/libvtv/testsuite/povray-derived.cc +++ /dev/null @@ -1,72 +0,0 @@ -// Small test case from povray, see if it reproduces. - -#include - -class POVMS_MessageReceiver -{ - -private: - int x; - class Handler - { - public: - virtual void print() = 0; - }; -protected: - template class MemberHandler : public Handler - { - public: - MemberHandler(T *xx) - { - x = xx; - } - - ~MemberHandler() {} - - void print() - { - printf("In print\n"); - } - private: - T *x; - }; - -private: - struct HandlerNode - { - Handler *handler; - }; - - HandlerNode *receiver; -public: - POVMS_MessageReceiver(int xx) : x(xx) {} - ~POVMS_MessageReceiver() {} - - void foo(int *xx); - void try_call(); -}; - -void POVMS_MessageReceiver::foo(int *xx) -{ - receiver = new HandlerNode; - - receiver->handler = new MemberHandler(xx); -} - -void POVMS_MessageReceiver::try_call() -{ - receiver->handler->print(); -} - - -int main() -{ - int loc = 34; - POVMS_MessageReceiver a_test(100); - - a_test.foo(&loc); - a_test.try_call(); -} - - - diff --git a/libvtv/testsuite/register_pair.cc b/libvtv/testsuite/register_pair.cc deleted file mode 100644 index 0759c472df1..00000000000 --- a/libvtv/testsuite/register_pair.cc +++ /dev/null @@ -1,39 +0,0 @@ -#include "vtv_utils.h" -#include "vtv_rts.h" - -/* This configuration will test mostly inserting of elements that are already inserted since - the number of repeats is 200 */ - -#define NUM_MAPS 4000 -#define ELEMENTS_PER_MAP 100 -#define NUM_REPEATS 200 - -/* This variable has to be put in rel.ro */ -void * maps[NUM_MAPS] VTV_PROTECTED_VAR; - -struct fake_vt { - void * fake_vfp [4]; -}; -void * fake_vts [NUM_MAPS * ELEMENTS_PER_MAP]; - -int main() -{ - __VLTChangePermission(__VLTP_READ_WRITE); - - for (int k = 0; k < NUM_REPEATS; k++) - { - int curr_fake_vt = 0; - for (int i = 0; i < NUM_MAPS; i++) - for (int j = 0; j < ELEMENTS_PER_MAP; j++) - { -#ifdef VTV_DEBUG - __VLTRegisterPairDebug(&maps[i], &fake_vts[curr_fake_vt]); -#endif - curr_fake_vt++; - } - } - - __VLTChangePermission(__VLTP_READ_ONLY); - - return 0; -} diff --git a/libvtv/testsuite/register_pair_inserts.cc b/libvtv/testsuite/register_pair_inserts.cc deleted file mode 100644 index 72d6d968465..00000000000 --- a/libvtv/testsuite/register_pair_inserts.cc +++ /dev/null @@ -1,46 +0,0 @@ -#include "vtv_utils.h" -#include "vtv_rts.h" - -/* This configuration will test mostly inserting of new elements since - the number of repeats is 1. It should also do a lot of rehashing */ - -/* This test case may fail depending on the system configuration. - Check the value of /proc/sys/vm/max_map_count and fix by doing - Ex: sudo sh -c "echo 131060 > /proc/sys/vm/max_map_count" */ - -#define NUM_MAPS 40000 -#define ELEMENTS_PER_MAP 100 -#define NUM_REPEATS 1 - -/* This variable has to be put in rel.ro */ -void * maps[NUM_MAPS] VTV_PROTECTED_VAR; - -struct fake_vt { - void * fake_vfp [4]; -}; -void * fake_vts [NUM_MAPS * ELEMENTS_PER_MAP]; - - -int main() -{ - __VLTChangePermission(__VLTP_READ_WRITE); - - for (int k = 0; k < NUM_REPEATS; k++) - { - int curr_fake_vt = 0; - for (int i = 0; i < NUM_MAPS; i++) - for (int j = 0; j < ELEMENTS_PER_MAP; j++) - { -#ifdef VTV_DEBUG - __VLTRegisterPairDebug(&maps[i], &fake_vts[curr_fake_vt], 0, 0, 0, 0); -#else - __VLTRegisterPair(&maps[i], &fake_vts[curr_fake_vt]); -#endif - curr_fake_vt++; - } - } - - __VLTChangePermission(__VLTP_READ_ONLY); - - return 0; -} diff --git a/libvtv/testsuite/register_pair_inserts_mt.cc b/libvtv/testsuite/register_pair_inserts_mt.cc deleted file mode 100644 index a79dc1f9196..00000000000 --- a/libvtv/testsuite/register_pair_inserts_mt.cc +++ /dev/null @@ -1,100 +0,0 @@ -#include "vtv_utils.h" -#include "vtv_rts.h" -#include "pthread.h" -#include - - -/* Multi-threaded test for calls to RegisterPair */ - -/* This configuration will test mostly inserting of new elements since - the number of repeats is 1. It should also do a lot of rehashing */ - -/* This test case may fail depending on the system configuration. - Check the value of /proc/sys/vm/max_map_count and fix by doing - Ex: sudo sh -c "echo 131060 > /proc/sys/vm/max_map_count" */ - -#define NUM_MAPS 2000 -#define ELEMENTS_PER_MAP 100 -#define NUM_REPEATS 1 - -#define NUM_THREADS 9 - -/* This variable has to be put in rel.ro */ -void * volatile maps[NUM_MAPS] VTV_PROTECTED_VAR; - -struct fake_vt { - void * fake_vfp [4]; -}; -void * fake_vts [NUM_MAPS * ELEMENTS_PER_MAP]; - -volatile int current_map = -1; -volatile int threads_completed_it = 0; - -void * do_register_pairs(void *) -{ - for (int k = 0; k < NUM_REPEATS; k++) - { - int curr_fake_vt = 0; - for (int i = 0; i < NUM_MAPS; i++) - { - while (current_map < (k*NUM_MAPS + i)) - ; - - __VLTChangePermission(__VLTP_READ_WRITE); - - for (int j = 0; j < ELEMENTS_PER_MAP; j++) - { -#ifdef VTV_DEBUG - __VLTRegisterPairDebug((void **) &maps[i], &fake_vts[curr_fake_vt], 0, 0, 0, 0); -#else - __VLTRegisterPair((void **) &maps[i], &fake_vts[curr_fake_vt]); -#endif - __VLTVerifyVtablePointer((void **) &maps[i], &fake_vts[curr_fake_vt]); - curr_fake_vt++; - } - - __VLTChangePermission(__VLTP_READ_ONLY); - - int old_value; - do { - old_value = threads_completed_it; - } while (!__sync_bool_compare_and_swap(&threads_completed_it, old_value, old_value + 1)); - - if (old_value == (NUM_THREADS - 1)) // Only one thread will do this. - { - threads_completed_it = 0; - printf("%c%d", 13, current_map + 1); - fflush(stdout); - current_map++; - } - } - } - - return NULL; -} - - -int main() -{ - pthread_t thread_ids[NUM_THREADS]; - - for (int t = 0; t < NUM_THREADS; t++ ) - if (pthread_create(&thread_ids[t], NULL, do_register_pairs, NULL) != 0) - { - printf("failed pthread_create\n"); - exit(1); - } - - current_map = 0; // start the work on the other threads - - for (int t = 0; t < NUM_THREADS; t++) - if (pthread_join(thread_ids[t], NULL) != 0) - { - printf("failed pthread_join\n"); - exit(2); - } - - printf("\n"); - - return 0; -} diff --git a/libvtv/testsuite/register_pair_mt.cc b/libvtv/testsuite/register_pair_mt.cc deleted file mode 100644 index e421c4f0d2b..00000000000 --- a/libvtv/testsuite/register_pair_mt.cc +++ /dev/null @@ -1,102 +0,0 @@ -#include "vtv_utils.h" -#include "vtv_rts.h" -#include "pthread.h" -#include - - -/* Multi-threaded test for calls to RegisterPair */ - -/* This configuration will test mostly inserting of elements that are already inserted since - the number of repeats is 10 */ - -/* This test case may fail depending on the system configuration. - Check the value of /proc/sys/vm/max_map_count and fix by doing - Ex: sudo sh -c "echo 131060 > /proc/sys/vm/max_map_count" */ - -#define NUM_MAPS 200 -#define ELEMENTS_PER_MAP 100 -#define NUM_REPEATS 10 - -#define NUM_THREADS 9 - -/* This variable has to be put in rel.ro */ -void * volatile maps[NUM_MAPS] VTV_PROTECTED_VAR; - -struct fake_vt { - void * fake_vfp [4]; -}; -void * fake_vts [NUM_MAPS * ELEMENTS_PER_MAP]; - -volatile int current_map = -1; -volatile int threads_completed_it = 0; - -void * do_register_pairs(void *) -{ - for (int k = 0; k < NUM_REPEATS; k++) - { - int curr_fake_vt = 0; - for (int i = 0; i < NUM_MAPS; i++) - { - while (current_map < (k*NUM_MAPS + i)) - ; - - __VLTChangePermission(__VLTP_READ_WRITE); - - for (int j = 0; j < ELEMENTS_PER_MAP; j++) - { -#ifdef VTV_DEBUG - __VLTRegisterPair((void **) &maps[i], &fake_vts[curr_fake_vt], 0, 0, 0, 0); -#else - __VLTRegisterPair((void **) &maps[i], &fake_vts[curr_fake_vt]); -#endif - __VLTVerifyVtablePointer((void **) &maps[i], &fake_vts[curr_fake_vt]); - curr_fake_vt++; - } - - __VLTChangePermission(__VLTP_READ_ONLY); - - int old_value; - do { - old_value = threads_completed_it; - } while (!__sync_bool_compare_and_swap(&threads_completed_it, old_value, old_value + 1)); - - if (old_value == (NUM_THREADS - 1)) // Only one thread will do this. - { - threads_completed_it = 0; - printf("%c%d", 13, current_map + 1); - fflush(stdout); - current_map++; - } - } - } - - return NULL; -} - - -int main() -{ - pthread_t thread_ids[NUM_THREADS]; - - for (int t = 0; t < NUM_THREADS; t++ ) - if (pthread_create(&thread_ids[t], NULL, do_register_pairs, NULL) != 0) - { - printf("failed pthread_create\n"); - exit(1); - } - - current_map = 0; // start the work on the other threads - - for (int t = 0; t < NUM_THREADS; t++) - if (pthread_join(thread_ids[t], NULL) != 0) - { - printf("failed pthread_join\n"); - exit(2); - } - - printf("\n"); - - - - return 0; -} diff --git a/libvtv/testsuite/replace-fail.cc b/libvtv/testsuite/replace-fail.cc deleted file mode 100644 index 2b4070eec77..00000000000 --- a/libvtv/testsuite/replace-fail.cc +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - - -void __vtv_verify_fail (void **, void*) __attribute__((visibility ("default"))); - -void -__vtv_verify_fail (void **hash_table, const void *vtbl_ptr) -{ - fprintf (stdout, "Executing alternative failure routine.\n"); -} diff --git a/libvtv/testsuite/so.cc b/libvtv/testsuite/so.cc deleted file mode 100644 index 3f0a346f1e8..00000000000 --- a/libvtv/testsuite/so.cc +++ /dev/null @@ -1,93 +0,0 @@ -#include -#include -#include -#include - -extern "C" int printf(const char *, ...); -extern "C" int sprintf(char *, const char*, ...); - -static int counter = 0; -extern int failures; - -template struct base -{ - virtual char * whoami() { - static char sl[100]; - sprintf(sl, "I am base %d", i); - return sl; - } - virtual void inc() { counter += i; } -}; - -template struct derived: base -{ - virtual char * whoami() { - static char sl[100]; - sprintf(sl, "I am derived %d", i); - return sl; - } - virtual void inc() { counter += (10*i); } -}; - -// We don't use this class. It is just here so that the -// compiler does not devirtualize calls to derived::inc() -template struct derived2: derived -{ - virtual void inc() { counter += (20*i); } -}; - -static base * bp = new base(); -static derived * dp = new derived(); -static base * dbp = new derived(); - - -// Given 2 pointers to C++ objects (non PODs), exchange the pointers to vtable -static void exchange_vtptr(void * object1_ptr, void * object2_ptr) -{ - void ** object1_vtptr_ptr = (void **)object1_ptr; - void ** object2_vtptr_ptr = (void **)object2_ptr; - void * object1_vtptr = *object1_vtptr_ptr; - void * object2_vtptr = *object2_vtptr_ptr; - *object1_vtptr_ptr = object2_vtptr; - *object2_vtptr_ptr = object1_vtptr; -} - -#define BUILD_NAME(NAME,ID) NAME##ID -#define EXPAND(NAME,X) BUILD_NAME(NAME,X) -extern "C" void EXPAND(so_entry_,TPID)(void) -{ - int prev_counter; - int prev_failures; - - counter = 0; - bp->inc(); - dp->inc(); - dbp->inc(); - assert(counter == (TPID + 10*TPID + 10*TPID)); - - prev_counter = counter; - exchange_vtptr(bp, dp); - bp->inc(); // This one should succeed but it is calling the wrong member - if (counter != (prev_counter + 10*TPID)) - { - printf("TPID=%d whoami=%s wrong counter value prev_counter=%d counter=%d\n", TPID, bp->whoami(), prev_counter, counter); - sleep(2); - } - assert(counter == (prev_counter + 10*TPID)); - // printf("Pass first attack!\n"); - - // This one should fail verification!. So it should jump to __vtv_verify_fail above. - prev_failures = failures; - dp->inc(); - // this code may be executed by multiple threads at the same time. So, just verify the number of failures has - // increased as opposed to check for increase by 1. - assert(failures > prev_failures); - assert(counter == (prev_counter + 10*TPID + TPID)); - // printf("TPDI=%d counter %d\n", TPID, counter); - // printf("Pass second attack!\n"); - - // restore the vtable pointers to the original state. - // This is very important. For some reason the dlclose is not "really" closing the library so when we reopen it we are - // getting the old memory state. - exchange_vtptr(bp, dp); -} diff --git a/libvtv/testsuite/temp_deriv.cc b/libvtv/testsuite/temp_deriv.cc deleted file mode 100644 index ca360c0bc91..00000000000 --- a/libvtv/testsuite/temp_deriv.cc +++ /dev/null @@ -1,67 +0,0 @@ -// Compile with /home/llozano/local2/proj/vtable/gcc-root/usr/local/bin/g++ -m32 -fvtable-verify=std -fpic -rdynamic -Wl,-R,/home/llozano/local2/proj/vtable/gcc-root/usr/local/lib32:./lib32 -I/home/llozano/local2/proj/vtable/vt2/gcc-4_6-mobile-vtable-security//libstdc++-v3/libsupc++ temp_deriv.cc -O0 -ldl -lpthread -Wl,--whole-archive,-lvtv_init,--no-whole-archive,-z,relro -DTPID=0 -g -// Look at assembly with: objdump -drl a.out - -#include -#include - -extern "C" int printf(const char *, ...); - -static int counter = 0; - -template struct base -{ - virtual void inc() { counter += i; } -}; - -template struct derived: base -{ - virtual void inc() { counter += (10*i); } -}; - -// We don't use this class. It is just here so that the -// compiler does not devirtualize calls to derived::inc() -template struct derived2: derived -{ - virtual void inc() { counter += (20*i); } -}; - -static base * bp = new base(); -static derived * dp = new derived(); -static base * dbp = new derived(); - -// Given 2 pointers to C++ objects (non PODs), exchange the pointers to vtable -void exchange_vtptr(void * object1_ptr, void * object2_ptr) -{ - void ** object1_vtptr_ptr = (void **)object1_ptr; - void ** object2_vtptr_ptr = (void **)object2_ptr; - void * object1_vtptr = *object1_vtptr_ptr; - void * object2_vtptr = *object2_vtptr_ptr; - *object1_vtptr_ptr = object2_vtptr; - *object2_vtptr_ptr = object1_vtptr; -} - -main() -{ - int prev_counter; - - exchange_vtptr(bp, dp); - exchange_vtptr(bp, dp); - exchange_vtptr(bp, dbp); - exchange_vtptr(bp, dbp); - - counter = 0; - bp->inc(); - dp->inc(); - dbp->inc(); - assert(counter == (TPID + 10*TPID + 10*TPID)); - - prev_counter = counter; - exchange_vtptr(bp, dp); - bp->inc(); // This one should succeed but it is calling the wrong member - assert(counter == (prev_counter + 10*TPID)); - printf("Pass first attack!\n"); - dp->inc(); - printf("TPDI=%d counter %d\n", TPID, counter); - printf("Pass second attack!\n"); - -} diff --git a/libvtv/testsuite/temp_deriv2.cc b/libvtv/testsuite/temp_deriv2.cc deleted file mode 100644 index 78b43f8b08b..00000000000 --- a/libvtv/testsuite/temp_deriv2.cc +++ /dev/null @@ -1,69 +0,0 @@ -// Compile with /home/llozano/local2/proj/vtable/gcc-root/usr/local/bin/g++ -m32 -fvtable-verify=std -fpic -rdynamic -Wl,-R,/home/llozano/local2/proj/vtable/gcc-root/usr/local/lib32:./lib32 -I/home/llozano/local2/proj/vtable/vt2/gcc-4_6-mobile-vtable-security//libstdc++-v3/libsupc++ temp_deriv.cc -O0 -ldl -lpthread -Wl,--whole-archive,-lvtv_init,--no-whole-archive,-z,relro -DTPID=0 -g -// Look at assembly with: objdump -drl a.out - -#include -#include - -extern "C" int printf(const char *, ...); - -static int counter = 0; - -int i = TPID; -struct base -{ - virtual void inc() { counter += i; } -}; - -struct derived: public base -{ - virtual void inc() { counter += (10*i); } -}; - -// We don't use this class. It is just here so that the -// compiler does not devirtualize calls to derived::inc() -struct derived2: public derived -{ - virtual void inc() { counter += (20*i); } -}; - -static base * bp = new base(); -static derived * dp = new derived(); -static base * dbp = new derived(); - -// Given 2 pointers to C++ objects (non PODs), exchange the pointers to vtable -void exchange_vtptr(void * object1_ptr, void * object2_ptr) -{ - typedef void * vtptr; - vtptr * object1_vtptr_ptr = (vtptr *)object1_ptr; - vtptr * object2_vtptr_ptr = (vtptr *)object2_ptr; - vtptr object1_vtptr = *object1_vtptr_ptr; - vtptr object2_vtptr = *object2_vtptr_ptr; - *object1_vtptr_ptr = object2_vtptr; - *object2_vtptr_ptr = object1_vtptr; -} - -main() -{ - int prev_counter; - - exchange_vtptr(bp, dp); - exchange_vtptr(bp, dp); - exchange_vtptr(bp, dbp); - exchange_vtptr(bp, dbp); - - counter = 0; - bp->inc(); - dp->inc(); - dbp->inc(); - assert(counter == (TPID + 10*TPID + 10*TPID)); - - prev_counter = counter; - exchange_vtptr(bp, dp); - bp->inc(); // This one should succeed but it is calling the wrong member - assert(counter == (prev_counter + 10*TPID)); - printf("Pass first attack!\n"); - dp->inc(); - printf("TPDI=%d counter %d\n", TPID, counter); - printf("Pass second attack!\n"); - -} diff --git a/libvtv/testsuite/temp_deriv3.cc b/libvtv/testsuite/temp_deriv3.cc deleted file mode 100644 index 924c47e9628..00000000000 --- a/libvtv/testsuite/temp_deriv3.cc +++ /dev/null @@ -1,79 +0,0 @@ -// Compile with /home/llozano/local2/proj/vtable/gcc-root/usr/local/bin/g++ -m32 -fvtable-verify=std -fpic -rdynamic -Wl,-R,/home/llozano/local2/proj/vtable/gcc-root/usr/local/lib32:./lib32 -I/home/llozano/local2/proj/vtable/vt2/gcc-4_6-mobile-vtable-security//libstdc++-v3/libsupc++ temp_deriv.cc -O0 -ldl -lpthread -Wl,--whole-archive,-lvtv_init,--no-whole-archive,-z,relro -DTPID=0 -g -// Look at assembly with: objdump -drl a.out - -#include -#include -#include - -extern "C" int printf(const char *, ...); - -static int counter = 0; - -int i = TPID; -struct base -{ - virtual void inc() { counter += i; } -}; - -struct derived: public base -{ - virtual void inc() { counter += (10*i); } -}; - -// We don't use this class. It is just here so that the -// compiler does not devirtualize calls to derived::inc() -struct derived2: public derived -{ - virtual void inc() { counter += (20*i); } -}; - -static base * bp = new base(); -static derived * dp = new derived(); -static base * dbp = new derived(); - -typedef void * vtptr; - -vtptr get_vtptr(void * object_ptr) -{ - vtptr * object_vtptr_ptr = (vtptr *)object_ptr; - return *object_vtptr_ptr; -} - -void set_vptr(void * object_ptr, vtptr vtp) -{ - vtptr * object_vtptr_ptr = (vtptr *)object_ptr; - *object_vtptr_ptr = vtp; -} - -// Given 2 pointers to C++ objects (non PODs), exchange the pointers to vtable -void exchange_vtptr(void * object1_ptr, void * object2_ptr) -{ - vtptr object1_vtptr = get_vtptr(object1_ptr); - vtptr object2_vtptr = get_vtptr(object2_ptr); - set_vptr(object1_ptr, object2_vtptr); - set_vptr(object2_ptr, object1_vtptr); -} - -main() -{ - int prev_counter; - - counter = 0; - bp->inc(); - dp->inc(); - dbp->inc(); - assert(counter == (TPID + 10*TPID + 10*TPID)); - - prev_counter = counter; - printf("before ex bp vptr=%x dp vptr=%x\n", get_vtptr(bp), get_vtptr(dp)); - exchange_vtptr(bp, dp); - printf("after ex bp vptr=%x dp vptr=%x\n", get_vtptr(bp), get_vtptr(dp)); - bp->inc(); // This one should not abort but it is calling the wrong member - assert(counter == (prev_counter + 10*TPID)); - printf("Pass first attack! Expected!\n"); - printf("TPDI=%d counter %d\n", TPID, counter); - dp->inc(); - printf("Pass second attack! SHOULD NOT BE HERE!\n"); - printf("TPDI=%d counter %d\n", TPID, counter); - exit(1); -} diff --git a/libvtv/testsuite/template-list-iostream.cc b/libvtv/testsuite/template-list-iostream.cc deleted file mode 100644 index a35fd308382..00000000000 --- a/libvtv/testsuite/template-list-iostream.cc +++ /dev/null @@ -1,118 +0,0 @@ -#include -#include -#include - -using std::ofstream; -using std::ifstream; -using std::ios; - -extern "C" int printf(const char *, ...); - -class Subscriptor -{ - public: - - Subscriptor() : counter(1) {} - - virtual ~Subscriptor() - { - counter--; - assert(counter == 0); - } - - private: - mutable int counter; -}; - -template struct Function -{ - Function(int i): value(dim + i) {} - int value; -}; - -template struct Triangulation -{ - -}; - -template struct Exercise_2_3 -{ - enum { DIM = dim }; -}; - - template - struct SetUpBase : public Subscriptor - { - virtual - const Function get_boundary_values () const = 0; - - virtual - const Function get_right_hand_side () const = 0; - - // virtual - // void create_coarse_grid (Triangulation &coarse_grid) const = 0; - }; - - template - struct SetUp : public SetUpBase - { - SetUp () {}; - - virtual - const Function get_boundary_values () const - { return Function(Traits::DIM); } - - virtual - const Function get_right_hand_side () const - { return Function(Traits::DIM); } - - // virtual - // void create_coarse_grid (Triangulation &coarse_grid) const; - - // static const typename Traits::BoundaryValues boundary_values; - // static const typename Traits::RightHandSide right_hand_side; - }; - - -void myread(std::istream * in) -{ - char input_str[50] = "\0"; - if (in->good()) - (*in) >> input_str; - std::cout << input_str << std::endl; - delete in; -} - - - -int main() -{ - /* - - SetUp, 2> s1a; - SetUp, 1> s2; - SetUp, 2> s2a; - return s1->get_boundary_values().value + s1a.get_boundary_values().value + - s2.get_boundary_values().value + s2a.get_boundary_values().value + - s1->get_right_hand_side().value + s1a.get_right_hand_side().value + - s2.get_right_hand_side().value + s2a.get_right_hand_side().value; - */ - - SetUp, 1> * s1 = new SetUp, 1>(); - - printf("%d\n", s1->get_boundary_values().value); - - ifstream * infile = new ifstream("./template-list-iostream.cc"); - - myread(infile); - - ofstream * outfile = new ofstream("/tmp/xxx.txt"); - - if (outfile->good()) - (*outfile) << "hello there" << std::endl; - std::cerr << "Reached End" << std::endl; - - delete outfile; - - return 0; -} diff --git a/libvtv/testsuite/template-list.cc b/libvtv/testsuite/template-list.cc deleted file mode 100644 index 95233f87765..00000000000 --- a/libvtv/testsuite/template-list.cc +++ /dev/null @@ -1,92 +0,0 @@ -#include - -extern "C" int printf(const char *, ...); - -class Subscriptor -{ - public: - - Subscriptor() : counter(1) {} - - virtual ~Subscriptor() - { - counter--; - assert(counter == 0); - } - - private: - mutable int counter; -}; - -template struct Function -{ - Function(int i): value(dim + i) {} - int value; -}; - -template struct Triangulation -{ - -}; - -template struct Exercise_2_3 -{ - enum { DIM = dim }; -}; - - template - struct SetUpBase : public Subscriptor - { - virtual - const Function get_boundary_values () const = 0; - - virtual - const Function get_right_hand_side () const = 0; - - // virtual - // void create_coarse_grid (Triangulation &coarse_grid) const = 0; - }; - - template - struct SetUp : public SetUpBase - { - SetUp () {}; - - virtual - const Function get_boundary_values () const - { return Function(Traits::DIM); } - - virtual - const Function get_right_hand_side () const - { return Function(Traits::DIM); } - - // virtual - // void create_coarse_grid (Triangulation &coarse_grid) const; - - // static const typename Traits::BoundaryValues boundary_values; - // static const typename Traits::RightHandSide right_hand_side; - }; - - -int main() -{ - /* - - SetUp, 2> s1a; - SetUp, 1> s2; - SetUp, 2> s2a; - return s1->get_boundary_values().value + s1a.get_boundary_values().value + - s2.get_boundary_values().value + s2a.get_boundary_values().value + - s1->get_right_hand_side().value + s1a.get_right_hand_side().value + - s2.get_right_hand_side().value + s2a.get_right_hand_side().value; - */ -#ifndef NFAIL - SetUp, 1> * s1 = new SetUp, 1>(); - printf("%d\n", s1->get_boundary_values().value); - return 0; -#else - SetUp, 1> s1; - printf("%d\n", s1.get_boundary_values().value); - return 0; -#endif -} diff --git a/libvtv/testsuite/template-list2.cc b/libvtv/testsuite/template-list2.cc deleted file mode 100644 index f8ec739b6d5..00000000000 --- a/libvtv/testsuite/template-list2.cc +++ /dev/null @@ -1,44 +0,0 @@ -#include - -extern "C" int printf(const char *, ...); - -class Subscriptor -{ - public: - - Subscriptor() - { counter = 1;} - - virtual ~Subscriptor() - { - counter--; - assert(counter == 0); - } - - private: - static int counter; -}; - -int Subscriptor::counter; - -template -class Polynomial : public Subscriptor -{ -}; - -class LagrangeEquidistant: public Polynomial -{ -}; - -template -inline void -_MyDestroy(_Tp* __pointer) - { __pointer->~_Tp(); } - -int main() -{ - LagrangeEquidistant * s1 = new LagrangeEquidistant; - _MyDestroy(s1); - - return 0; -} diff --git a/libvtv/testsuite/thunk.cc b/libvtv/testsuite/thunk.cc deleted file mode 100644 index 6ab81a0dfd4..00000000000 --- a/libvtv/testsuite/thunk.cc +++ /dev/null @@ -1,35 +0,0 @@ -#include -struct A { - A():value(123) {} - int value; - virtual int access() { return this->value; } -}; -struct B { - B():value(456) {} - int value; - virtual int access() { return this->value; } -}; -struct C : public A, public B { - C():better_value(789) {} - int better_value; - virtual int access() { return this->better_value; } -}; -struct D: public C { - D():other_value(987) {} - int other_value; - virtual int access() { return this->other_value; } -}; - -int use(B *b) -{ - return b->access(); -} - -int main() -{ - C c; - assert(use(&c) == 789); - D d; - assert(use(&d) == 987); - return 0; -} diff --git a/libvtv/testsuite/thunk_vtable_map_attack.cc b/libvtv/testsuite/thunk_vtable_map_attack.cc deleted file mode 100644 index 84d4bbf3257..00000000000 --- a/libvtv/testsuite/thunk_vtable_map_attack.cc +++ /dev/null @@ -1,111 +0,0 @@ -#include -#include -#include -#include - -#include -#include - -using std::ofstream; -using std::ifstream; -using std::ios; - -struct A { - A():value(123) {} - int value; - virtual int access() { return this->value; } -}; -struct B { - B():value(456) {} - int value; - virtual int access() { return this->value; } -}; -struct C : public A, public B { - C():better_value(789) {} - int better_value; - virtual int access() { return this->better_value; } -}; -struct D: public C { - D():other_value(987) {} - int other_value; - virtual int access() { return this->other_value; } -}; - -volatile static int signal_count = 0; - -sigjmp_buf before_segv; - -static void -handler(int sig, siginfo_t *si, void *unused) -{ - /* - printf("Got SIGSEGV at address: 0x%lx\n", - (long) si->si_addr); - */ - - signal_count++; - /* You are not supposed to longjmp out of a signal handler but it seems - to work for this test case and it simplifies it */ - siglongjmp(before_segv, 1); - /* exit(1); */ -} - -/* Access one of the vtable_map variables generated by this .o */ -extern void * _ZN4_VTVI1BE12__vtable_mapE; - -/* Access one of the vtable_map variables generated by libstdc++ */ -extern void * _ZN4_VTVISt8ios_baseE12__vtable_mapE; - -int use(B *b) -{ - int ret; - - ret = sigsetjmp(before_segv, 1); - if (ret == 0) - { - /* This should generate a segmentation violation. ie: at this point it should - be protected */ - _ZN4_VTVI1BE12__vtable_mapE = 0; - } - assert(ret == 1 && signal_count == 1); - - ret = sigsetjmp(before_segv, 1); - if (ret == 0) - { - /* Try to modify one of the vtable_map variables in the stdc++ library. - This should generate a segmentation violation. ie: at this point it - should be protected */ - _ZN4_VTVISt8ios_baseE12__vtable_mapE = 0; - } - assert(ret == 1 && signal_count == 2); - - return b->access(); -} - -void myread(std::istream * in) -{ - char input_str[50] = "\0"; - if (in->good()) - (*in) >> input_str; - std::cout << input_str << std::endl; - delete in; -} - -int main() -{ - ifstream * infile = new ifstream("./thunk_vtable_map_attack.cpp"); - myread(infile); - - /* Set up handler for SIGSEGV. */ - struct sigaction sa; - sa.sa_flags = SA_SIGINFO; - sigemptyset(&sa.sa_mask); - sa.sa_sigaction = handler; - if (sigaction(SIGSEGV, &sa, NULL) == -1) - assert(0); - - C c; - assert(use(&c) == 789); - - return 0; -} diff --git a/libvtv/testsuite/virtual_inheritance.cc b/libvtv/testsuite/virtual_inheritance.cc deleted file mode 100644 index 89fe388a856..00000000000 --- a/libvtv/testsuite/virtual_inheritance.cc +++ /dev/null @@ -1,46 +0,0 @@ -#include -struct V { - V(): virtual_value(-123) {} - int virtual_value; - virtual int access_vv() { return virtual_value; } -}; - -struct A: virtual public V { - A():value(123) {} - int value; - virtual int access() { return value; } -}; -struct B: virtual public V { - B():value(456) {} - int value; - virtual int access() { return value; } -}; -struct C : public A, public B { - C():better_value(789) {} - int better_value; - virtual int access() { return better_value; } -}; -struct D: public A, public B { - D():better_virtual_value(-345) {} - int better_virtual_value; - virtual int access_vv() { return better_virtual_value; } -}; - -int use(B *b) -{ - return b->access(); -} - -int v_use(V * v) -{ - return v->access_vv(); -} - -int main() -{ - C c; - assert(v_use(&c) == -123); - D d; - assert(v_use(&d) == -345); - return 0; -} -- cgit v1.2.1