xref: /netbsd-src/tests/libexec/ld.elf_so/helper_use_static/h_use_static.c (revision 111bb99c35d487354b7f99348522f61348ea84a4)
1*111bb99cSriastradh /*	$NetBSD: h_use_static.c,v 1.2 2023/05/31 00:46:11 riastradh Exp $	*/
212037d6aSriastradh 
312037d6aSriastradh /*-
412037d6aSriastradh  * Copyright (c) 2023 The NetBSD Foundation, Inc.
512037d6aSriastradh  * All rights reserved.
612037d6aSriastradh  *
712037d6aSriastradh  * Redistribution and use in source and binary forms, with or without
812037d6aSriastradh  * modification, are permitted provided that the following conditions
912037d6aSriastradh  * are met:
1012037d6aSriastradh  * 1. Redistributions of source code must retain the above copyright
1112037d6aSriastradh  *    notice, this list of conditions and the following disclaimer.
1212037d6aSriastradh  * 2. Redistributions in binary form must reproduce the above copyright
1312037d6aSriastradh  *    notice, this list of conditions and the following disclaimer in the
1412037d6aSriastradh  *    documentation and/or other materials provided with the distribution.
1512037d6aSriastradh  *
1612037d6aSriastradh  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1712037d6aSriastradh  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1812037d6aSriastradh  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1912037d6aSriastradh  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2012037d6aSriastradh  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2112037d6aSriastradh  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2212037d6aSriastradh  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2312037d6aSriastradh  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2412037d6aSriastradh  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2512037d6aSriastradh  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2612037d6aSriastradh  * POSSIBILITY OF SUCH DAMAGE.
2712037d6aSriastradh  */
2812037d6aSriastradh 
29*111bb99cSriastradh extern __thread int mysym __attribute__((tls_model("initial-exec")));
3012037d6aSriastradh 
3112037d6aSriastradh int *fuse(void);
3212037d6aSriastradh int *
fuse(void)3312037d6aSriastradh fuse(void)
3412037d6aSriastradh {
3512037d6aSriastradh 
3612037d6aSriastradh 	return &mysym;
3712037d6aSriastradh }
38