|
| 1 | +/* |
| 2 | + * Copyright (c) 2022, Oracle and/or its affiliates. |
| 3 | + * |
| 4 | + * All rights reserved. |
| 5 | + * |
| 6 | + * Redistribution and use in source and binary forms, with or without modification, are |
| 7 | + * permitted provided that the following conditions are met: |
| 8 | + * |
| 9 | + * 1. Redistributions of source code must retain the above copyright notice, this list of |
| 10 | + * conditions and the following disclaimer. |
| 11 | + * |
| 12 | + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of |
| 13 | + * conditions and the following disclaimer in the documentation and/or other materials provided |
| 14 | + * with the distribution. |
| 15 | + * |
| 16 | + * 3. Neither the name of the copyright holder nor the names of its contributors may be used to |
| 17 | + * endorse or promote products derived from this software without specific prior written |
| 18 | + * permission. |
| 19 | + * |
| 20 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS |
| 21 | + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 22 | + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 23 | + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 24 | + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
| 25 | + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 26 | + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 27 | + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 28 | + * OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | + */ |
| 30 | +#include <stdlib.h> |
| 31 | + |
| 32 | +/* On some platforms this TLS variable will end up being referenced by the |
| 33 | + * global @llvm.used or @llvm.compiler.used array in the final bitcode. This |
| 34 | + * can cause problems during global variable initialization. */ |
| 35 | + |
| 36 | +__attribute__((used)) __thread int tls_val = 4; |
| 37 | + |
| 38 | +int main(void) { |
| 39 | + if (tls_val != 4) { |
| 40 | + abort(); |
| 41 | + } |
| 42 | + return 0; |
| 43 | +} |
0 commit comments