xref: /haiku/src/tests/system/runtime_loader/test_suite/load_resolve_weak1 (revision 888652929c4c95ab2d639a85ffa2691a6e6df81f)
1*88865292SJérôme Duval#!/bin/sh
2*88865292SJérôme Duval
3*88865292SJérôme Duval# program
4*88865292SJérôme Duval# <- liba.so
5*88865292SJérôme Duval#
6*88865292SJérôme Duval# Expected: Weak symbol in liba.so resolves to symbol in program,
7*88865292SJérôme Duval# not to symbol in liba.so.
8*88865292SJérôme Duval
9*88865292SJérôme Duval
10*88865292SJérôme Duval. ./test_setup
11*88865292SJérôme Duval
12*88865292SJérôme Duval
13*88865292SJérôme Duval# create liba.so
14*88865292SJérôme Duvalcat > liba.c << EOI
15*88865292SJérôme Duvalint __attribute__((weak)) c() { return 2; }
16*88865292SJérôme Duvalint __attribute__((weak)) a() { return c(); }
17*88865292SJérôme Duvalint (*a_p)() = &c;
18*88865292SJérôme Duvalint b() { return (*a_p)(); }
19*88865292SJérôme DuvalEOI
20*88865292SJérôme Duval
21*88865292SJérôme Duval# build
22*88865292SJérôme Duvalcompile_lib -o liba.so liba.c
23*88865292SJérôme Duval
24*88865292SJérôme Duval# create program
25*88865292SJérôme Duvalcat > program.c << EOI
26*88865292SJérôme Duvalextern int a();
27*88865292SJérôme Duvalextern int b();
28*88865292SJérôme Duval
29*88865292SJérôme Duvalint c()
30*88865292SJérôme Duval{
31*88865292SJérôme Duval	return 4;
32*88865292SJérôme Duval}
33*88865292SJérôme Duval
34*88865292SJérôme Duvalint
35*88865292SJérôme Duvalmain()
36*88865292SJérôme Duval{
37*88865292SJérôme Duval	return a() + b();
38*88865292SJérôme Duval}
39*88865292SJérôme DuvalEOI
40*88865292SJérôme Duval
41*88865292SJérôme Duval# build
42*88865292SJérôme Duvalcompile_program -o program program.c ./liba.so
43*88865292SJérôme Duval
44*88865292SJérôme Duval# run
45*88865292SJérôme Duvaltest_run_ok ./program 8
46*88865292SJérôme Duval
47