Dmitriy Ivanov | d225a5e | 2014-08-28 14:12:12 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | // This one should be preempted by the function |
| 18 | // defined in the main executable. |
| 19 | extern "C" int __attribute__((weak)) main_global_default_serial() { |
| 20 | return 2716057; |
| 21 | } |
| 22 | |
| 23 | // Even though this one is defined by the main |
| 24 | // executable it should not be preempted |
| 25 | // because of protected visibility |
| 26 | extern "C" int __attribute__((weak, visibility("protected"))) main_global_protected_serial() { |
| 27 | return 3370318; |
| 28 | } |
| 29 | |
| 30 | extern "C" int main_global_default_get_serial() { |
| 31 | return main_global_default_serial(); |
| 32 | } |
| 33 | |
| 34 | extern "C" int main_global_protected_get_serial() { |
| 35 | return main_global_protected_serial(); |
| 36 | } |
| 37 | |
| 38 | // Trying to preempt functions from a DT_NEEDED .so |
| 39 | extern "C" int lib_global_default_serial() { |
| 40 | return 3370318; |
| 41 | } |
| 42 | |
| 43 | extern "C" int lib_global_protected_serial() { |
| 44 | return 2716057; |
| 45 | } |