blob: 363ec2f6d22ee529f958950f2ef924233654b68a [file] [log] [blame]
Brian Silverman7d89e282021-11-17 17:36:54 -08001// 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.
25int 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
35int main() {
36}
37
38#endif//defined(__linux__) && defined(_GNU_SOURCE)