diff --git a/vndk/tools/header-checker/src/repr/symbol/so_file_parser.cpp b/vndk/tools/header-checker/src/repr/symbol/so_file_parser.cpp index 9320a5480..77356db53 100644 --- a/vndk/tools/header-checker/src/repr/symbol/so_file_parser.cpp +++ b/vndk/tools/header-checker/src/repr/symbol/so_file_parser.cpp @@ -101,11 +101,18 @@ ELFSoFileParser::ELFSoFileParser(const llvm::object::ELFObjectFile *obj) { LLVMToIRSymbolBinding(elf_sym->getBinding()); std::string symbol_name = UnWrap(symbol_it.getName()); - llvm::object::SymbolRef::Type type = UnWrap(symbol_it.getType()); - if (type == llvm::object::SymbolRef::Type::ST_Function) { - exported_symbols_->AddFunction(symbol_name, symbol_binding); - } else if (type == llvm::object::SymbolRef::Type::ST_Data) { - exported_symbols_->AddVar(symbol_name, symbol_binding); + switch (symbol_it.getELFType()) { + case llvm::ELF::STT_OBJECT: + case llvm::ELF::STT_COMMON: + case llvm::ELF::STT_TLS: + exported_symbols_->AddVar(symbol_name, symbol_binding); + break; + case llvm::ELF::STT_FUNC: + case llvm::ELF::STT_GNU_IFUNC: + exported_symbols_->AddFunction(symbol_name, symbol_binding); + break; + default: + break; } } } diff --git a/vndk/tools/header-checker/tests/integration/ifunc/Android.bp b/vndk/tools/header-checker/tests/integration/ifunc/Android.bp new file mode 100644 index 000000000..207fd9bfb --- /dev/null +++ b/vndk/tools/header-checker/tests/integration/ifunc/Android.bp @@ -0,0 +1,23 @@ +// +// Copyright (C) 2020 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +cc_library { + name: "libifunc", + srcs: [ + "ifunc.c", + ], + enabled: false, +} diff --git a/vndk/tools/header-checker/tests/integration/ifunc/ifunc.c b/vndk/tools/header-checker/tests/integration/ifunc/ifunc.c new file mode 100644 index 000000000..f2f84df11 --- /dev/null +++ b/vndk/tools/header-checker/tests/integration/ifunc/ifunc.c @@ -0,0 +1,5 @@ +__attribute__((used)) static void *ifunc_resolver() { + return 0; +} + +void ifunc() __attribute__((ifunc("ifunc_resolver"))); diff --git a/vndk/tools/header-checker/tests/integration/ifunc/map.txt b/vndk/tools/header-checker/tests/integration/ifunc/map.txt new file mode 100644 index 000000000..80649a44c --- /dev/null +++ b/vndk/tools/header-checker/tests/integration/ifunc/map.txt @@ -0,0 +1,4 @@ +libifunc { + global: + ifunc; +}; diff --git a/vndk/tools/header-checker/tests/integration/ifunc/prebuilts/libifunc.so b/vndk/tools/header-checker/tests/integration/ifunc/prebuilts/libifunc.so new file mode 100755 index 000000000..ce122eced Binary files /dev/null and b/vndk/tools/header-checker/tests/integration/ifunc/prebuilts/libifunc.so differ diff --git a/vndk/tools/header-checker/tests/module.py b/vndk/tools/header-checker/tests/module.py index c3396153e..338058d13 100755 --- a/vndk/tools/header-checker/tests/module.py +++ b/vndk/tools/header-checker/tests/module.py @@ -413,6 +413,17 @@ TEST_MODULES = [ version_script='integration/c_and_cpp/repro_map.txt', export_include_dirs=['integration/c_and_cpp/include'], ), + LsdumpModule( + name='libifunc', + srcs=['integration/ifunc/ifunc.c'], + version_script='integration/ifunc/map.txt', + export_include_dirs=[], + linker_flags=[ + '-so', relative_to_abs_path( + 'integration/ifunc/prebuilts/libifunc.so' + ), + ] + ), LsdumpModule( name='libgolden_cpp_member_name_changed', srcs=[ diff --git a/vndk/tools/header-checker/tests/reference_dumps/arm/libifunc.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/arm/libifunc.so.lsdump new file mode 100644 index 000000000..3ddc48c4f --- /dev/null +++ b/vndk/tools/header-checker/tests/reference_dumps/arm/libifunc.so.lsdump @@ -0,0 +1,24 @@ +builtin_types { + type_info { + name: "void" + size: 0 + alignment: 0 + referenced_type: "_ZTIv" + source_file: "" + linker_set_key: "_ZTIv" + self_type: "_ZTIv" + } + is_unsigned: false + is_integral: false +} +functions { + return_type: "_ZTIv" + function_name: "ifunc" + source_file: "/development/vndk/tools/header-checker/tests/integration/ifunc/ifunc.c" + linker_set_key: "ifunc" + access: public_access +} +elf_functions { + name: "ifunc" + binding: Global +} diff --git a/vndk/tools/header-checker/tests/reference_dumps/arm64/libifunc.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/arm64/libifunc.so.lsdump new file mode 100644 index 000000000..3ddc48c4f --- /dev/null +++ b/vndk/tools/header-checker/tests/reference_dumps/arm64/libifunc.so.lsdump @@ -0,0 +1,24 @@ +builtin_types { + type_info { + name: "void" + size: 0 + alignment: 0 + referenced_type: "_ZTIv" + source_file: "" + linker_set_key: "_ZTIv" + self_type: "_ZTIv" + } + is_unsigned: false + is_integral: false +} +functions { + return_type: "_ZTIv" + function_name: "ifunc" + source_file: "/development/vndk/tools/header-checker/tests/integration/ifunc/ifunc.c" + linker_set_key: "ifunc" + access: public_access +} +elf_functions { + name: "ifunc" + binding: Global +} diff --git a/vndk/tools/header-checker/tests/reference_dumps/mips/libifunc.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/mips/libifunc.so.lsdump new file mode 100644 index 000000000..3ddc48c4f --- /dev/null +++ b/vndk/tools/header-checker/tests/reference_dumps/mips/libifunc.so.lsdump @@ -0,0 +1,24 @@ +builtin_types { + type_info { + name: "void" + size: 0 + alignment: 0 + referenced_type: "_ZTIv" + source_file: "" + linker_set_key: "_ZTIv" + self_type: "_ZTIv" + } + is_unsigned: false + is_integral: false +} +functions { + return_type: "_ZTIv" + function_name: "ifunc" + source_file: "/development/vndk/tools/header-checker/tests/integration/ifunc/ifunc.c" + linker_set_key: "ifunc" + access: public_access +} +elf_functions { + name: "ifunc" + binding: Global +} diff --git a/vndk/tools/header-checker/tests/reference_dumps/mips64/libifunc.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/mips64/libifunc.so.lsdump new file mode 100644 index 000000000..3ddc48c4f --- /dev/null +++ b/vndk/tools/header-checker/tests/reference_dumps/mips64/libifunc.so.lsdump @@ -0,0 +1,24 @@ +builtin_types { + type_info { + name: "void" + size: 0 + alignment: 0 + referenced_type: "_ZTIv" + source_file: "" + linker_set_key: "_ZTIv" + self_type: "_ZTIv" + } + is_unsigned: false + is_integral: false +} +functions { + return_type: "_ZTIv" + function_name: "ifunc" + source_file: "/development/vndk/tools/header-checker/tests/integration/ifunc/ifunc.c" + linker_set_key: "ifunc" + access: public_access +} +elf_functions { + name: "ifunc" + binding: Global +} diff --git a/vndk/tools/header-checker/tests/reference_dumps/x86/libifunc.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/x86/libifunc.so.lsdump new file mode 100644 index 000000000..3ddc48c4f --- /dev/null +++ b/vndk/tools/header-checker/tests/reference_dumps/x86/libifunc.so.lsdump @@ -0,0 +1,24 @@ +builtin_types { + type_info { + name: "void" + size: 0 + alignment: 0 + referenced_type: "_ZTIv" + source_file: "" + linker_set_key: "_ZTIv" + self_type: "_ZTIv" + } + is_unsigned: false + is_integral: false +} +functions { + return_type: "_ZTIv" + function_name: "ifunc" + source_file: "/development/vndk/tools/header-checker/tests/integration/ifunc/ifunc.c" + linker_set_key: "ifunc" + access: public_access +} +elf_functions { + name: "ifunc" + binding: Global +} diff --git a/vndk/tools/header-checker/tests/reference_dumps/x86_64/libifunc.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/x86_64/libifunc.so.lsdump new file mode 100644 index 000000000..3ddc48c4f --- /dev/null +++ b/vndk/tools/header-checker/tests/reference_dumps/x86_64/libifunc.so.lsdump @@ -0,0 +1,24 @@ +builtin_types { + type_info { + name: "void" + size: 0 + alignment: 0 + referenced_type: "_ZTIv" + source_file: "" + linker_set_key: "_ZTIv" + self_type: "_ZTIv" + } + is_unsigned: false + is_integral: false +} +functions { + return_type: "_ZTIv" + function_name: "ifunc" + source_file: "/development/vndk/tools/header-checker/tests/integration/ifunc/ifunc.c" + linker_set_key: "ifunc" + access: public_access +} +elf_functions { + name: "ifunc" + binding: Global +} diff --git a/vndk/tools/header-checker/tests/test.py b/vndk/tools/header-checker/tests/test.py index b1da06b62..0bbd4cdac 100755 --- a/vndk/tools/header-checker/tests/test.py +++ b/vndk/tools/header-checker/tests/test.py @@ -372,6 +372,10 @@ class HeaderCheckerTest(unittest.TestCase): self.prepare_and_absolute_diff_all_archs( "libanonymous_enum_odr", "libanonymous_enum_odr") + def test_libifunc(self): + self.prepare_and_absolute_diff_all_archs( + "libifunc", "libifunc") + if __name__ == '__main__': unittest.main()