1*ac615257Sskrll# $NetBSD: t_static_destructor.sh,v 1.6 2022/06/12 15:08:38 skrll Exp $ 2d1be05c0Skamil# 3d1be05c0Skamil# Copyright (c) 2017 The NetBSD Foundation, Inc. 4d1be05c0Skamil# All rights reserved. 5d1be05c0Skamil# 6d1be05c0Skamil# This code is derived from software contributed to The NetBSD Foundation 7d1be05c0Skamil# by Kamil Rytarowski. 8d1be05c0Skamil# 9d1be05c0Skamil# Redistribution and use in source and binary forms, with or without 10d1be05c0Skamil# modification, are permitted provided that the following conditions 11d1be05c0Skamil# are met: 12d1be05c0Skamil# 1. Redistributions of source code must retain the above copyright 13d1be05c0Skamil# notice, this list of conditions and the following disclaimer. 14d1be05c0Skamil# 2. Redistributions in binary form must reproduce the above copyright 15d1be05c0Skamil# notice, this list of conditions and the following disclaimer in the 16d1be05c0Skamil# documentation and/or other materials provided with the distribution. 17d1be05c0Skamil# 18d1be05c0Skamil# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19d1be05c0Skamil# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20d1be05c0Skamil# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21d1be05c0Skamil# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22d1be05c0Skamil# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23d1be05c0Skamil# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24d1be05c0Skamil# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25d1be05c0Skamil# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26d1be05c0Skamil# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27d1be05c0Skamil# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28d1be05c0Skamil# POSSIBILITY OF SUCH DAMAGE. 29d1be05c0Skamil# 30d1be05c0Skamil 31d1be05c0Skamilatf_test_case static_destructor 32d1be05c0Skamilstatic_destructor_head() { 33d1be05c0Skamil atf_set "descr" "compile and run \"hello world\"" 34d1be05c0Skamil atf_set "require.progs" "c++" 35d1be05c0Skamil} 36d1be05c0Skamil 3777dc83faSkamilatf_test_case static_destructor_profile 3877dc83faSkamilstatic_destructor_profile_head() { 3977dc83faSkamil atf_set "descr" "compile and run \"hello world\" with profiling option" 4077dc83faSkamil atf_set "require.progs" "c++" 4177dc83faSkamil} 4277dc83faSkamil 4377dc83faSkamilatf_test_case static_destructor_static 4477dc83faSkamilstatic_destructor_static_head() { 4577dc83faSkamil atf_set "descr" "compile and run \"hello world\" with static option" 4677dc83faSkamil atf_set "require.progs" "c++" 4777dc83faSkamil} 4877dc83faSkamil 49d1be05c0Skamilatf_test_case static_destructor_pic 50d1be05c0Skamilstatic_destructor_pic_head() { 51d1be05c0Skamil atf_set "descr" "compile and run PIC \"hello world\"" 52d1be05c0Skamil atf_set "require.progs" "c++" 53d1be05c0Skamil} 54d1be05c0Skamil 5577dc83faSkamilatf_test_case static_destructor_pic_32 5677dc83faSkamilstatic_destructor_pic_32_head() { 5777dc83faSkamil atf_set "descr" "compile and run 32-bit PIC \"hello world\"" 5877dc83faSkamil atf_set "require.progs" "c++" 5977dc83faSkamil} 6077dc83faSkamil 6177dc83faSkamilatf_test_case static_destructor_pic_profile 6277dc83faSkamilstatic_destructor_pic_profile_head() { 6377dc83faSkamil atf_set "descr" "compile and run PIC \"hello world\" with profiling option" 6477dc83faSkamil atf_set "require.progs" "c++" 6577dc83faSkamil} 6677dc83faSkamil 6777dc83faSkamilatf_test_case static_destructor_pic_profile_32 6877dc83faSkamilstatic_destructor_pic_profile_32_head() { 6977dc83faSkamil atf_set "descr" "compile and run 32-bit PIC \"hello world\" with profiling option" 7077dc83faSkamil atf_set "require.progs" "c++" 7177dc83faSkamil} 7277dc83faSkamil 7377dc83faSkamilatf_test_case static_destructor_profile_32 7477dc83faSkamilstatic_destructor_profile_32_head() { 7577dc83faSkamil atf_set "descr" "compile and run 32-bit \"hello world\" with profiling option" 7677dc83faSkamil atf_set "require.progs" "c++" 7777dc83faSkamil} 7877dc83faSkamil 79d1be05c0Skamilatf_test_case static_destructor_pie 80d1be05c0Skamilstatic_destructor_pie_head() { 81d1be05c0Skamil atf_set "descr" "compile and run position independent (PIE) \"hello world\"" 82d1be05c0Skamil atf_set "require.progs" "c++" 83d1be05c0Skamil} 84d1be05c0Skamil 85d1be05c0Skamilatf_test_case static_destructor32 86d1be05c0Skamilstatic_destructor32_head() { 87d1be05c0Skamil atf_set "descr" "compile and run \"hello world\" for/in netbsd32 emulation" 88d1be05c0Skamil atf_set "require.progs" "c++ file diff cat" 89d1be05c0Skamil} 90d1be05c0Skamil 91d1be05c0Skamilstatic_destructor_body() { 92d1be05c0Skamil cat > test.cpp << EOF 93d1be05c0Skamil#include <iostream> 94d1be05c0Skamilstruct A { 95d1be05c0Skamil int i; 96d1be05c0Skamil A(int i):i(i){std::cout << "CTOR A" << std::endl;} 97d1be05c0Skamil ~A() {std::cout << "DTOR A:" << i << std::endl;} 98d1be05c0Skamil}; 99d1be05c0Skamilstruct B { 100d1be05c0Skamil A *m_a; 101d1be05c0Skamil B(){static A s_a(10);m_a=&s_a;std::cout << "CTOR B" << std::endl;} 102d1be05c0Skamil ~B(){std::cout << "DTOR B:" << (*m_a).i << std::endl;(*m_a).i = 20;} 103d1be05c0Skamil}; 104d1be05c0Skamilint main(void) {struct B b;return 0;} 105d1be05c0SkamilEOF 106d1be05c0Skamil atf_check -s exit:0 -o ignore -e ignore c++ -o hello test.cpp 107d1be05c0Skamil atf_check -s exit:0 -o inline:"CTOR A\nCTOR B\nDTOR B:10\nDTOR A:20\n" ./hello 108d1be05c0Skamil} 109d1be05c0Skamil 11077dc83faSkamilstatic_destructor_profile_body() { 11177dc83faSkamil cat > test.cpp << EOF 11277dc83faSkamil#include <iostream> 11377dc83faSkamilstruct A { 11477dc83faSkamil int i; 11577dc83faSkamil A(int i):i(i){std::cout << "CTOR A" << std::endl;} 11677dc83faSkamil ~A() {std::cout << "DTOR A:" << i << std::endl;} 11777dc83faSkamil}; 11877dc83faSkamilstruct B { 11977dc83faSkamil A *m_a; 12077dc83faSkamil B(){static A s_a(10);m_a=&s_a;std::cout << "CTOR B" << std::endl;} 12177dc83faSkamil ~B(){std::cout << "DTOR B:" << (*m_a).i << std::endl;(*m_a).i = 20;} 12277dc83faSkamil}; 12377dc83faSkamilint main(void) {struct B b;return 0;} 12477dc83faSkamilEOF 125*ac615257Sskrll atf_check -s exit:0 -o ignore -e ignore c++ -static -pg -o hello test.cpp 12677dc83faSkamil atf_check -s exit:0 -o inline:"CTOR A\nCTOR B\nDTOR B:10\nDTOR A:20\n" ./hello 12777dc83faSkamil} 12877dc83faSkamil 12977dc83faSkamilstatic_destructor_profile_32_body() { 13077dc83faSkamil # check whether this arch is 64bit 13177dc83faSkamil if ! c++ -dM -E - < /dev/null | fgrep -q _LP64; then 13277dc83faSkamil atf_skip "this is not a 64 bit architecture" 13377dc83faSkamil fi 13477dc83faSkamil if ! c++ -m32 -dM -E - < /dev/null 2>/dev/null > ./def32; then 13577dc83faSkamil atf_skip "c++ -m32 not supported on this architecture" 13677dc83faSkamil else 13777dc83faSkamil if fgrep -q _LP64 ./def32; then 13877dc83faSkamil atf_fail "c++ -m32 does not generate netbsd32 binaries" 13977dc83faSkamil fi 14077dc83faSkamil fi 14177dc83faSkamil 14277dc83faSkamil cat > test.cpp << EOF 14377dc83faSkamil#include <iostream> 14477dc83faSkamilstruct A { 14577dc83faSkamil int i; 14677dc83faSkamil A(int i):i(i){std::cout << "CTOR A" << std::endl;} 14777dc83faSkamil ~A() {std::cout << "DTOR A:" << i << std::endl;} 14877dc83faSkamil}; 14977dc83faSkamilstruct B { 15077dc83faSkamil A *m_a; 15177dc83faSkamil B(){static A s_a(10);m_a=&s_a;std::cout << "CTOR B" << std::endl;} 15277dc83faSkamil ~B(){std::cout << "DTOR B:" << (*m_a).i << std::endl;(*m_a).i = 20;} 15377dc83faSkamil}; 15477dc83faSkamilint main(void) {struct B b;return 0;} 15577dc83faSkamilEOF 156*ac615257Sskrll atf_check -s exit:0 -o ignore -e ignore c++ -static -m32 -pg -o hello test.cpp 15777dc83faSkamil atf_check -s exit:0 -o inline:"CTOR A\nCTOR B\nDTOR B:10\nDTOR A:20\n" ./hello 15877dc83faSkamil} 15977dc83faSkamil 16077dc83faSkamil 16177dc83faSkamilstatic_destructor_static_body() { 16277dc83faSkamil cat > test.cpp << EOF 16377dc83faSkamil#include <iostream> 16477dc83faSkamilstruct A { 16577dc83faSkamil int i; 16677dc83faSkamil A(int i):i(i){std::cout << "CTOR A" << std::endl;} 16777dc83faSkamil ~A() {std::cout << "DTOR A:" << i << std::endl;} 16877dc83faSkamil}; 16977dc83faSkamilstruct B { 17077dc83faSkamil A *m_a; 17177dc83faSkamil B(){static A s_a(10);m_a=&s_a;std::cout << "CTOR B" << std::endl;} 17277dc83faSkamil ~B(){std::cout << "DTOR B:" << (*m_a).i << std::endl;(*m_a).i = 20;} 17377dc83faSkamil}; 17477dc83faSkamilint main(void) {struct B b;return 0;} 17577dc83faSkamilEOF 17677dc83faSkamil atf_check -s exit:0 -o ignore -e ignore c++ -static -o hello test.cpp 17777dc83faSkamil atf_check -s exit:0 -o inline:"CTOR A\nCTOR B\nDTOR B:10\nDTOR A:20\n" ./hello 17877dc83faSkamil} 17977dc83faSkamil 180d1be05c0Skamilstatic_destructor_pic_body() { 181d1be05c0Skamil cat > test.cpp << EOF 182d1be05c0Skamil#include <cstdlib> 183d1be05c0Skamilint callpic(void); 184d1be05c0Skamilint main(void) {callpic();exit(0);} 185d1be05c0SkamilEOF 186d1be05c0Skamil cat > pic.cpp << EOF 187d1be05c0Skamil#include <iostream> 188d1be05c0Skamilstruct A { 189d1be05c0Skamil int i; 190d1be05c0Skamil A(int i):i(i){std::cout << "CTOR A" << std::endl;} 191d1be05c0Skamil ~A() {std::cout << "DTOR A:" << i << std::endl;} 192d1be05c0Skamil}; 193d1be05c0Skamilstruct B { 194d1be05c0Skamil A *m_a; 195d1be05c0Skamil B(){static A s_a(10);m_a=&s_a;std::cout << "CTOR B" << std::endl;} 196d1be05c0Skamil ~B(){std::cout << "DTOR B:" << (*m_a).i << std::endl;(*m_a).i = 20;} 197d1be05c0Skamil}; 198d1be05c0Skamilint callpic(void) {struct B b;} 199d1be05c0SkamilEOF 200d1be05c0Skamil 201d1be05c0Skamil atf_check -s exit:0 -o ignore -e ignore \ 202d1be05c0Skamil c++ -fPIC -shared -o libtest.so pic.cpp 203d1be05c0Skamil atf_check -s exit:0 -o ignore -e ignore \ 204d1be05c0Skamil c++ -o hello test.cpp -L. -ltest 205d1be05c0Skamil 206d1be05c0Skamil export LD_LIBRARY_PATH=. 207d1be05c0Skamil atf_check -s exit:0 -o inline:"CTOR A\nCTOR B\nDTOR B:10\nDTOR A:20\n" ./hello 208d1be05c0Skamil} 209d1be05c0Skamil 21077dc83faSkamilstatic_destructor_pic_32_body() { 21177dc83faSkamil # check whether this arch is 64bit 21277dc83faSkamil if ! c++ -dM -E - < /dev/null | fgrep -q _LP64; then 21377dc83faSkamil atf_skip "this is not a 64 bit architecture" 21477dc83faSkamil fi 21577dc83faSkamil if ! c++ -m32 -dM -E - < /dev/null 2>/dev/null > ./def32; then 21677dc83faSkamil atf_skip "c++ -m32 not supported on this architecture" 21777dc83faSkamil else 21877dc83faSkamil if fgrep -q _LP64 ./def32; then 21977dc83faSkamil atf_fail "c++ -m32 does not generate netbsd32 binaries" 22077dc83faSkamil fi 22177dc83faSkamil fi 22277dc83faSkamil 22377dc83faSkamil cat > test.cpp << EOF 22477dc83faSkamil#include <cstdlib> 22577dc83faSkamilint callpic(void); 22677dc83faSkamilint main(void) {callpic();exit(0);} 22777dc83faSkamilEOF 22877dc83faSkamil cat > pic.cpp << EOF 22977dc83faSkamil#include <iostream> 23077dc83faSkamilstruct A { 23177dc83faSkamil int i; 23277dc83faSkamil A(int i):i(i){std::cout << "CTOR A" << std::endl;} 23377dc83faSkamil ~A() {std::cout << "DTOR A:" << i << std::endl;} 23477dc83faSkamil}; 23577dc83faSkamilstruct B { 23677dc83faSkamil A *m_a; 23777dc83faSkamil B(){static A s_a(10);m_a=&s_a;std::cout << "CTOR B" << std::endl;} 23877dc83faSkamil ~B(){std::cout << "DTOR B:" << (*m_a).i << std::endl;(*m_a).i = 20;} 23977dc83faSkamil}; 24077dc83faSkamilint callpic(void) {struct B b;} 24177dc83faSkamilEOF 24277dc83faSkamil 24377dc83faSkamil atf_check -s exit:0 -o ignore -e ignore \ 24477dc83faSkamil c++ -m32 -fPIC -shared -o libtest.so pic.cpp 24577dc83faSkamil atf_check -s exit:0 -o ignore -e ignore \ 24677dc83faSkamil c++ -m32 -o hello test.cpp -L. -ltest 24777dc83faSkamil 24877dc83faSkamil export LD_LIBRARY_PATH=. 24977dc83faSkamil atf_check -s exit:0 -o inline:"CTOR A\nCTOR B\nDTOR B:10\nDTOR A:20\n" ./hello 25077dc83faSkamil} 25177dc83faSkamil 25277dc83faSkamilstatic_destructor_pic_profile_body() { 25377dc83faSkamil cat > test.cpp << EOF 25477dc83faSkamil#include <cstdlib> 25577dc83faSkamilint callpic(void); 25677dc83faSkamilint main(void) {callpic();exit(0);} 25777dc83faSkamilEOF 25877dc83faSkamil cat > pic.cpp << EOF 25977dc83faSkamil#include <iostream> 26077dc83faSkamilstruct A { 26177dc83faSkamil int i; 26277dc83faSkamil A(int i):i(i){std::cout << "CTOR A" << std::endl;} 26377dc83faSkamil ~A() {std::cout << "DTOR A:" << i << std::endl;} 26477dc83faSkamil}; 26577dc83faSkamilstruct B { 26677dc83faSkamil A *m_a; 26777dc83faSkamil B(){static A s_a(10);m_a=&s_a;std::cout << "CTOR B" << std::endl;} 26877dc83faSkamil ~B(){std::cout << "DTOR B:" << (*m_a).i << std::endl;(*m_a).i = 20;} 26977dc83faSkamil}; 27077dc83faSkamilint callpic(void) {struct B b;} 27177dc83faSkamilEOF 27277dc83faSkamil 27377dc83faSkamil atf_check -s exit:0 -o ignore -e ignore \ 27477dc83faSkamil c++ -pg -fPIC -shared -o libtest.so pic.cpp 27577dc83faSkamil atf_check -s exit:0 -o ignore -e ignore \ 27677dc83faSkamil c++ -pg -o hello test.cpp -L. -ltest 27777dc83faSkamil 27877dc83faSkamil export LD_LIBRARY_PATH=. 27977dc83faSkamil atf_check -s exit:0 -o inline:"CTOR A\nCTOR B\nDTOR B:10\nDTOR A:20\n" ./hello 28077dc83faSkamil} 28177dc83faSkamil 28277dc83faSkamilstatic_destructor_pic_profile_32_body() { 28377dc83faSkamil # check whether this arch is 64bit 28477dc83faSkamil if ! c++ -dM -E - < /dev/null | fgrep -q _LP64; then 28577dc83faSkamil atf_skip "this is not a 64 bit architecture" 28677dc83faSkamil fi 28777dc83faSkamil if ! c++ -m32 -dM -E - < /dev/null 2>/dev/null > ./def32; then 28877dc83faSkamil atf_skip "c++ -m32 not supported on this architecture" 28977dc83faSkamil else 29077dc83faSkamil if fgrep -q _LP64 ./def32; then 29177dc83faSkamil atf_fail "c++ -m32 does not generate netbsd32 binaries" 29277dc83faSkamil fi 29377dc83faSkamil fi 29477dc83faSkamil 29577dc83faSkamil cat > test.cpp << EOF 29677dc83faSkamil#include <cstdlib> 29777dc83faSkamilint callpic(void); 29877dc83faSkamilint main(void) {callpic();exit(0);} 29977dc83faSkamilEOF 30077dc83faSkamil cat > pic.cpp << EOF 30177dc83faSkamil#include <iostream> 30277dc83faSkamilstruct A { 30377dc83faSkamil int i; 30477dc83faSkamil A(int i):i(i){std::cout << "CTOR A" << std::endl;} 30577dc83faSkamil ~A() {std::cout << "DTOR A:" << i << std::endl;} 30677dc83faSkamil}; 30777dc83faSkamilstruct B { 30877dc83faSkamil A *m_a; 30977dc83faSkamil B(){static A s_a(10);m_a=&s_a;std::cout << "CTOR B" << std::endl;} 31077dc83faSkamil ~B(){std::cout << "DTOR B:" << (*m_a).i << std::endl;(*m_a).i = 20;} 31177dc83faSkamil}; 31277dc83faSkamilint callpic(void) {struct B b;} 31377dc83faSkamilEOF 31477dc83faSkamil 31577dc83faSkamil atf_check -s exit:0 -o ignore -e ignore \ 31677dc83faSkamil c++ -m32 -pg -fPIC -shared -o libtest.so pic.cpp 31777dc83faSkamil atf_check -s exit:0 -o ignore -e ignore \ 31877dc83faSkamil c++ -m32 -pg -o hello test.cpp -L. -ltest 31977dc83faSkamil 32077dc83faSkamil export LD_LIBRARY_PATH=. 32177dc83faSkamil atf_check -s exit:0 -o inline:"CTOR A\nCTOR B\nDTOR B:10\nDTOR A:20\n" ./hello 32277dc83faSkamil} 32377dc83faSkamil 324d1be05c0Skamilstatic_destructor_pie_body() { 325d1be05c0Skamil # check whether this arch supports -pie 326d1be05c0Skamil if ! c++ -pie -dM -E - < /dev/null 2>/dev/null >/dev/null; then 327d1be05c0Skamil atf_skip "c++ -pie not supported on this architecture" 328d1be05c0Skamil fi 329d1be05c0Skamil cat > test.cpp << EOF 330d1be05c0Skamil#include <iostream> 331d1be05c0Skamilstruct A { 332d1be05c0Skamil int i; 333d1be05c0Skamil A(int i):i(i){std::cout << "CTOR A" << std::endl;} 334d1be05c0Skamil ~A() {std::cout << "DTOR A:" << i << std::endl;} 335d1be05c0Skamil}; 336d1be05c0Skamilstruct B { 337d1be05c0Skamil A *m_a; 338d1be05c0Skamil B(){static A s_a(10);m_a=&s_a;std::cout << "CTOR B" << std::endl;} 339d1be05c0Skamil ~B(){std::cout << "DTOR B:" << (*m_a).i << std::endl;(*m_a).i = 20;} 340d1be05c0Skamil}; 341d1be05c0Skamilint main(void) {struct B b;return 0;} 342d1be05c0SkamilEOF 343d1be05c0Skamil atf_check -s exit:0 -o ignore -e ignore c++ -fpie -pie -o hello test.cpp 344d1be05c0Skamil atf_check -s exit:0 -o inline:"CTOR A\nCTOR B\nDTOR B:10\nDTOR A:20\n" ./hello 345d1be05c0Skamil} 346d1be05c0Skamil 347d1be05c0Skamilstatic_destructor32_body() { 348d1be05c0Skamil # check whether this arch is 64bit 349d1be05c0Skamil if ! c++ -dM -E - < /dev/null | fgrep -q _LP64; then 350d1be05c0Skamil atf_skip "this is not a 64 bit architecture" 351d1be05c0Skamil fi 352d1be05c0Skamil if ! c++ -m32 -dM -E - < /dev/null 2>/dev/null > ./def32; then 353d1be05c0Skamil atf_skip "c++ -m32 not supported on this architecture" 354d1be05c0Skamil else 355d1be05c0Skamil if fgrep -q _LP64 ./def32; then 356d1be05c0Skamil atf_fail "c++ -m32 does not generate netbsd32 binaries" 357d1be05c0Skamil fi 358d1be05c0Skamil fi 359d1be05c0Skamil 360d1be05c0Skamil cat > test.cpp << EOF 361d1be05c0Skamil#include <iostream> 362d1be05c0Skamilstruct A { 363d1be05c0Skamil int i; 364d1be05c0Skamil A(int i):i(i){std::cout << "CTOR A" << std::endl;} 365d1be05c0Skamil ~A() {std::cout << "DTOR A:" << i << std::endl;} 366d1be05c0Skamil}; 367d1be05c0Skamilstruct B { 368d1be05c0Skamil A *m_a; 369d1be05c0Skamil B(){static A s_a(10);m_a=&s_a;std::cout << "CTOR B" << std::endl;} 370d1be05c0Skamil ~B(){std::cout << "DTOR B:" << (*m_a).i << std::endl;(*m_a).i = 20;} 371d1be05c0Skamil}; 372d1be05c0Skamilint main(void) {struct B b;return 0;} 373d1be05c0SkamilEOF 374d1be05c0Skamil atf_check -s exit:0 -o ignore -e ignore c++ -o hello32 -m32 test.cpp 375d1be05c0Skamil atf_check -s exit:0 -o ignore -e ignore c++ -o hello64 test.cpp 376d1be05c0Skamil file -b ./hello32 > ./ftype32 377d1be05c0Skamil file -b ./hello64 > ./ftype64 378d1be05c0Skamil if diff ./ftype32 ./ftype64 >/dev/null; then 379d1be05c0Skamil atf_fail "generated binaries do not differ" 380d1be05c0Skamil fi 381d1be05c0Skamil echo "32bit binaries on this platform are:" 382d1be05c0Skamil cat ./ftype32 383d1be05c0Skamil echo "While native (64bit) binaries are:" 384d1be05c0Skamil cat ./ftype64 385d1be05c0Skamil atf_check -s exit:0 -o inline:"CTOR A\nCTOR B\nDTOR B:10\nDTOR A:20\n" ./hello32 386d1be05c0Skamil 387d1be05c0Skamil # do another test with static 32bit binaries 388d1be05c0Skamil cat > test.cpp << EOF 389d1be05c0Skamil#include <iostream> 390d1be05c0Skamilstruct A { 391d1be05c0Skamil int i; 392d1be05c0Skamil A(int i):i(i){std::cout << "CTOR A" << std::endl;} 393d1be05c0Skamil ~A() {std::cout << "DTOR A:" << i << std::endl;} 394d1be05c0Skamil}; 395d1be05c0Skamilstruct B { 396d1be05c0Skamil A *m_a; 397d1be05c0Skamil B(){static A s_a(10);m_a=&s_a;std::cout << "CTOR B" << std::endl;} 398d1be05c0Skamil ~B(){std::cout << "DTOR B:" << (*m_a).i << std::endl;(*m_a).i = 20;} 399d1be05c0Skamil}; 400d1be05c0Skamilint main(void) {struct B b;return 0;} 401d1be05c0SkamilEOF 402d1be05c0Skamil atf_check -s exit:0 -o ignore -e ignore c++ -o hello -m32 \ 403d1be05c0Skamil -static test.cpp 404d1be05c0Skamil atf_check -s exit:0 -o inline:"CTOR A\nCTOR B\nDTOR B:10\nDTOR A:20\n" ./hello 405d1be05c0Skamil} 406d1be05c0Skamil 407d1be05c0Skamilatf_init_test_cases() 408d1be05c0Skamil{ 409d1be05c0Skamil 410d1be05c0Skamil atf_add_test_case static_destructor 41177dc83faSkamil atf_add_test_case static_destructor_profile 412d1be05c0Skamil atf_add_test_case static_destructor_pic 413d1be05c0Skamil atf_add_test_case static_destructor_pie 414d1be05c0Skamil atf_add_test_case static_destructor32 41577dc83faSkamil atf_add_test_case static_destructor_static 41677dc83faSkamil atf_add_test_case static_destructor_pic_32 41777dc83faSkamil atf_add_test_case static_destructor_pic_profile 41877dc83faSkamil atf_add_test_case static_destructor_pic_profile_32 41977dc83faSkamil atf_add_test_case static_destructor_profile_32 420d1be05c0Skamil} 421