Brian Silverman | 7d89e28 | 2021-11-17 17:36:54 -0800 | [diff] [blame^] | 1 | // Copyright 2021 The Bazel Authors. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0(the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http: // www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #if defined(__linux__) && defined(_GNU_SOURCE) |
| 16 | #include <dlfcn.h> |
| 17 | #include <assert.h> |
| 18 | |
| 19 | // Checks that pthread symbols are loadable. |
| 20 | // |
| 21 | // This test verifies that dynamically linked libraries which |
| 22 | // rely on pthread symbols can still access them. |
| 23 | // Incorrect order of linking dependencies may remove unused |
| 24 | // symbols and break shared libraries that are linked later. |
| 25 | int main() { |
| 26 | // Find symbol |
| 27 | void* symbol = dlsym(RTLD_NEXT, "pthread_getspecific"); |
| 28 | // Check that there is no error |
| 29 | assert(dlerror() == nullptr && symbol != nullptr); |
| 30 | |
| 31 | } |
| 32 | |
| 33 | #else//defined(__linux__) && defined(_GNU_SOURCE) |
| 34 | |
| 35 | int main() { |
| 36 | } |
| 37 | |
| 38 | #endif//defined(__linux__) && defined(_GNU_SOURCE) |