Subversion Repositories HelenOS

Rev

Rev 2968 | Rev 2978 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2968 Rev 2973
1
/*
1
/*
2
 * Copyright (c) 2008 Jiri Svoboda
2
 * Copyright (c) 2008 Jiri Svoboda
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
/** @addtogroup rtld
29
/** @addtogroup rtld
30
 * @brief   Test dynamic linking capabilities.
30
 * @brief   Test dynamic linking capabilities.
31
 * @{
31
 * @{
32
 */
32
 */
33
/**
33
/**
34
 * @file
34
 * @file
35
 */
35
 */
36
 
36
 
-
 
37
#include <libtest.h>
-
 
38
 
37
void __io_init(void);
39
void __io_init(void);
38
void __main(void);
40
void __main(void);
39
void __exit(void);
41
void __exit(void);
40
 
42
 
41
static void kputint(unsigned i)
43
static void kputint(unsigned i)
42
{
44
{
43
    unsigned dummy;
45
    unsigned dummy;
44
    asm volatile (
46
    asm volatile (
45
        "movl $30, %%eax;"
47
        "movl $30, %%eax;"
46
        "int $0x30"
48
        "int $0x30"
47
        : "=d" (dummy) /* output - %edx clobbered */
49
        : "=d" (dummy) /* output - %edx clobbered */
48
        : "d" (i) /* input */
50
        : "d" (i) /* input */
49
        : "%eax","%ecx" /* all scratch registers clobbered */
51
        : "%eax","%ecx" /* all scratch registers clobbered */
50
    );
52
    );
51
}
53
}
52
 
54
 
53
 
55
 
54
static void test(void)
56
static void test(void)
55
{
57
{
56
    kputint(-1);
58
    kputint(-1);
57
    kputint(42);
59
    kputint(42);
58
    while(1);
60
    while(1);
59
}
61
}
60
 
62
 
61
int main(int argc, char *argv[])
63
int main(int argc, char *argv[])
62
{
64
{
63
    test();
65
    test();
-
 
66
    /* Unreachable, yet. Just to create a relocation entry */
-
 
67
    test_func();
64
    return 0;
68
    return 0;
65
}
69
}
66
 
70
 
67
void __io_init(void)
71
void __io_init(void)
68
{
72
{
69
}
73
}
70
 
74
 
71
void __main(void)
75
void __main(void)
72
{
76
{
73
    main(0, 0);
77
    main(0, 0);
74
}
78
}
75
 
79
 
76
void __exit(void)
80
void __exit(void)
77
{
81
{
78
}
82
}
79
 
83
 
80
 
84
 
81
/** @}
85
/** @}
82
 */
86
 */
83
 
87
 
84
 
88