From b9471eaca9ec770008413868ed3dc9476e9121c9 Mon Sep 17 00:00:00 2001 From: Hsin-Yi Chen Date: Mon, 3 Sep 2018 11:22:40 +0800 Subject: [PATCH] Add ELF symbol binding to JSON dump - Remove unused ConvertElfFunctionIR and ConvertElfObjectIR. - Convert ELF symbol binding from IR to JSON in AddElfSymbolMessageIR. Bug: 112877706 Test: ./test.py Change-Id: Ib07b19f76dbbebe751583a3fb95eabe7e2ac7e40 --- .../include/ir_representation_json.h | 4 -- .../src/ir_representation_json.cpp | 37 +++++++++---------- .../arm/libgolden_cpp_json.so.lsdump | 12 ++++++ .../arm64/libgolden_cpp_json.so.lsdump | 12 ++++++ .../mips/libgolden_cpp_json.so.lsdump | 12 ++++++ .../mips64/libgolden_cpp_json.so.lsdump | 12 ++++++ .../x86/libgolden_cpp_json.so.lsdump | 12 ++++++ .../x86_64/libgolden_cpp_json.so.lsdump | 12 ++++++ 8 files changed, 90 insertions(+), 23 deletions(-) diff --git a/vndk/tools/header-checker/header-abi-util/include/ir_representation_json.h b/vndk/tools/header-checker/header-abi-util/include/ir_representation_json.h index d4b7dd0f8..977b805d0 100644 --- a/vndk/tools/header-checker/header-abi-util/include/ir_representation_json.h +++ b/vndk/tools/header-checker/header-abi-util/include/ir_representation_json.h @@ -85,10 +85,6 @@ class IRToJsonConverter { static JsonObject ConvertRvalueReferenceTypeIR( const RvalueReferenceTypeIR *rvalue_reference_typep); - - static JsonObject ConvertElfFunctionIR(const ElfFunctionIR *elf_function_ir); - - static JsonObject ConvertElfObjectIR(const ElfObjectIR *elf_object_ir); }; class JsonIRDumper : public IRDumper, public IRToJsonConverter { diff --git a/vndk/tools/header-checker/header-abi-util/src/ir_representation_json.cpp b/vndk/tools/header-checker/header-abi-util/src/ir_representation_json.cpp index c41a30a31..037ee8a9c 100644 --- a/vndk/tools/header-checker/header-abi-util/src/ir_representation_json.cpp +++ b/vndk/tools/header-checker/header-abi-util/src/ir_representation_json.cpp @@ -49,6 +49,12 @@ static const std::map {VTableComponentIR::Kind::UnusedFunctionPointer, "unused_function_pointer"}, }; +static const std::map + elf_symbol_binding_ir_to_json{ + {ElfSymbolIR::ElfSymbolBinding::Weak, "weak"}, + {ElfSymbolIR::ElfSymbolBinding::Global, "global"}, +}; + // If m contains k, this function returns the value. // Otherwise, it prints error_msg and exits. template @@ -79,6 +85,12 @@ VTableComponentKindIRToJson(VTableComponentIR::Kind kind) { "Failed to convert VTableComponentIR::Kind to JSON"); } +static inline const std::string & +ElfSymbolBindingIRToJson(ElfSymbolIR::ElfSymbolBinding binding) { + return FindInMap(elf_symbol_binding_ir_to_json, binding, + "Failed to convert ElfSymbolBinding to JSON"); +} + void IRToJsonConverter::AddTemplateInfo( JsonObject &type_decl, const abi_util::TemplatedArtifactIR *template_ir) { Json::Value &elements = type_decl["template_info"]; @@ -183,20 +195,6 @@ JsonObject IRToJsonConverter::ConvertRecordTypeIR(const RecordTypeIR *recordp) { return record_type; } -JsonObject -IRToJsonConverter::ConvertElfObjectIR(const ElfObjectIR *elf_object_ir) { - JsonObject elf_object; - elf_object["name"] = elf_object_ir->GetName(); - return elf_object; -} - -JsonObject -IRToJsonConverter::ConvertElfFunctionIR(const ElfFunctionIR *elf_function_ir) { - JsonObject elf_function; - elf_function["name"] = elf_function_ir->GetName(); - return elf_function; -} - void IRToJsonConverter::AddFunctionParametersAndSetReturnType( JsonObject &function, const CFunctionLikeIR *cfunction_like_ir) { function["return_type"] = cfunction_like_ir->GetReturnType(); @@ -377,11 +375,9 @@ bool JsonIRDumper::AddLinkableMessageIR(const LinkableMessageIR *lm) { return true; } -bool JsonIRDumper::AddElfSymbolMessageIR(const ElfSymbolIR *em) { +bool JsonIRDumper::AddElfSymbolMessageIR(const ElfSymbolIR *elf_symbol_ir) { std::string key; - JsonObject elf_symbol; - elf_symbol["name"] = em->GetName(); - switch (em->GetKind()) { + switch (elf_symbol_ir->GetKind()) { case ElfSymbolIR::ElfFunctionKind: key = "elf_functions"; break; @@ -391,7 +387,10 @@ bool JsonIRDumper::AddElfSymbolMessageIR(const ElfSymbolIR *em) { default: return false; } - translation_unit_[key].append(elf_symbol); + Json::Value &elf_symbol = translation_unit_[key].append(JsonObject()); + elf_symbol["name"] = elf_symbol_ir->GetName(); + elf_symbol["binding"] = + ElfSymbolBindingIRToJson(elf_symbol_ir->GetBinding()); return true; } diff --git a/vndk/tools/header-checker/tests/reference_dumps/arm/libgolden_cpp_json.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/arm/libgolden_cpp_json.so.lsdump index 1b3bd289c..625463c4a 100644 --- a/vndk/tools/header-checker/tests/reference_dumps/arm/libgolden_cpp_json.so.lsdump +++ b/vndk/tools/header-checker/tests/reference_dumps/arm/libgolden_cpp_json.so.lsdump @@ -68,42 +68,52 @@ [ { + "binding" : "global", "name" : "_Z26test_virtual_function_callP12SuperSpeaker" }, { + "binding" : "global", "name" : "_ZN12NotReferenced" }, { + "binding" : "global", "name" : "_ZN12SuperSpeaker11SpeakLouderEv" }, { + "binding" : "global", "name" : "_ZN12SuperSpeaker18CreateSuperSpeakerEi" }, { + "binding" : "global", "name" : "_ZN12SuperSpeaker9SpeakLoudEv" }, { + "binding" : "global", "name" : "_ZN16LowVolumeSpeaker5SpeakEv" }, { + "binding" : "global", "name" : "_ZN16LowVolumeSpeaker6ListenEv" }, { + "binding" : "global", "name" : "_ZN17HighVolumeSpeaker11BadPracticeEf" }, { + "binding" : "global", "name" : "_ZN17HighVolumeSpeaker5SpeakEv" }, { + "binding" : "global", "name" : "_ZN17HighVolumeSpeaker6ListenEv" } ], @@ -111,10 +121,12 @@ [ { + "binding" : "global", "name" : "_ZTV16LowVolumeSpeaker" }, { + "binding" : "global", "name" : "_ZTV17HighVolumeSpeaker" } ], diff --git a/vndk/tools/header-checker/tests/reference_dumps/arm64/libgolden_cpp_json.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/arm64/libgolden_cpp_json.so.lsdump index 6f5250eb6..3e4faa2c6 100644 --- a/vndk/tools/header-checker/tests/reference_dumps/arm64/libgolden_cpp_json.so.lsdump +++ b/vndk/tools/header-checker/tests/reference_dumps/arm64/libgolden_cpp_json.so.lsdump @@ -68,42 +68,52 @@ [ { + "binding" : "global", "name" : "_Z26test_virtual_function_callP12SuperSpeaker" }, { + "binding" : "global", "name" : "_ZN12NotReferenced" }, { + "binding" : "global", "name" : "_ZN12SuperSpeaker11SpeakLouderEv" }, { + "binding" : "global", "name" : "_ZN12SuperSpeaker18CreateSuperSpeakerEi" }, { + "binding" : "global", "name" : "_ZN12SuperSpeaker9SpeakLoudEv" }, { + "binding" : "global", "name" : "_ZN16LowVolumeSpeaker5SpeakEv" }, { + "binding" : "global", "name" : "_ZN16LowVolumeSpeaker6ListenEv" }, { + "binding" : "global", "name" : "_ZN17HighVolumeSpeaker11BadPracticeEf" }, { + "binding" : "global", "name" : "_ZN17HighVolumeSpeaker5SpeakEv" }, { + "binding" : "global", "name" : "_ZN17HighVolumeSpeaker6ListenEv" } ], @@ -111,10 +121,12 @@ [ { + "binding" : "global", "name" : "_ZTV16LowVolumeSpeaker" }, { + "binding" : "global", "name" : "_ZTV17HighVolumeSpeaker" } ], diff --git a/vndk/tools/header-checker/tests/reference_dumps/mips/libgolden_cpp_json.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/mips/libgolden_cpp_json.so.lsdump index 1b3bd289c..625463c4a 100644 --- a/vndk/tools/header-checker/tests/reference_dumps/mips/libgolden_cpp_json.so.lsdump +++ b/vndk/tools/header-checker/tests/reference_dumps/mips/libgolden_cpp_json.so.lsdump @@ -68,42 +68,52 @@ [ { + "binding" : "global", "name" : "_Z26test_virtual_function_callP12SuperSpeaker" }, { + "binding" : "global", "name" : "_ZN12NotReferenced" }, { + "binding" : "global", "name" : "_ZN12SuperSpeaker11SpeakLouderEv" }, { + "binding" : "global", "name" : "_ZN12SuperSpeaker18CreateSuperSpeakerEi" }, { + "binding" : "global", "name" : "_ZN12SuperSpeaker9SpeakLoudEv" }, { + "binding" : "global", "name" : "_ZN16LowVolumeSpeaker5SpeakEv" }, { + "binding" : "global", "name" : "_ZN16LowVolumeSpeaker6ListenEv" }, { + "binding" : "global", "name" : "_ZN17HighVolumeSpeaker11BadPracticeEf" }, { + "binding" : "global", "name" : "_ZN17HighVolumeSpeaker5SpeakEv" }, { + "binding" : "global", "name" : "_ZN17HighVolumeSpeaker6ListenEv" } ], @@ -111,10 +121,12 @@ [ { + "binding" : "global", "name" : "_ZTV16LowVolumeSpeaker" }, { + "binding" : "global", "name" : "_ZTV17HighVolumeSpeaker" } ], diff --git a/vndk/tools/header-checker/tests/reference_dumps/mips64/libgolden_cpp_json.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/mips64/libgolden_cpp_json.so.lsdump index 6f5250eb6..3e4faa2c6 100644 --- a/vndk/tools/header-checker/tests/reference_dumps/mips64/libgolden_cpp_json.so.lsdump +++ b/vndk/tools/header-checker/tests/reference_dumps/mips64/libgolden_cpp_json.so.lsdump @@ -68,42 +68,52 @@ [ { + "binding" : "global", "name" : "_Z26test_virtual_function_callP12SuperSpeaker" }, { + "binding" : "global", "name" : "_ZN12NotReferenced" }, { + "binding" : "global", "name" : "_ZN12SuperSpeaker11SpeakLouderEv" }, { + "binding" : "global", "name" : "_ZN12SuperSpeaker18CreateSuperSpeakerEi" }, { + "binding" : "global", "name" : "_ZN12SuperSpeaker9SpeakLoudEv" }, { + "binding" : "global", "name" : "_ZN16LowVolumeSpeaker5SpeakEv" }, { + "binding" : "global", "name" : "_ZN16LowVolumeSpeaker6ListenEv" }, { + "binding" : "global", "name" : "_ZN17HighVolumeSpeaker11BadPracticeEf" }, { + "binding" : "global", "name" : "_ZN17HighVolumeSpeaker5SpeakEv" }, { + "binding" : "global", "name" : "_ZN17HighVolumeSpeaker6ListenEv" } ], @@ -111,10 +121,12 @@ [ { + "binding" : "global", "name" : "_ZTV16LowVolumeSpeaker" }, { + "binding" : "global", "name" : "_ZTV17HighVolumeSpeaker" } ], diff --git a/vndk/tools/header-checker/tests/reference_dumps/x86/libgolden_cpp_json.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/x86/libgolden_cpp_json.so.lsdump index 1b3bd289c..625463c4a 100644 --- a/vndk/tools/header-checker/tests/reference_dumps/x86/libgolden_cpp_json.so.lsdump +++ b/vndk/tools/header-checker/tests/reference_dumps/x86/libgolden_cpp_json.so.lsdump @@ -68,42 +68,52 @@ [ { + "binding" : "global", "name" : "_Z26test_virtual_function_callP12SuperSpeaker" }, { + "binding" : "global", "name" : "_ZN12NotReferenced" }, { + "binding" : "global", "name" : "_ZN12SuperSpeaker11SpeakLouderEv" }, { + "binding" : "global", "name" : "_ZN12SuperSpeaker18CreateSuperSpeakerEi" }, { + "binding" : "global", "name" : "_ZN12SuperSpeaker9SpeakLoudEv" }, { + "binding" : "global", "name" : "_ZN16LowVolumeSpeaker5SpeakEv" }, { + "binding" : "global", "name" : "_ZN16LowVolumeSpeaker6ListenEv" }, { + "binding" : "global", "name" : "_ZN17HighVolumeSpeaker11BadPracticeEf" }, { + "binding" : "global", "name" : "_ZN17HighVolumeSpeaker5SpeakEv" }, { + "binding" : "global", "name" : "_ZN17HighVolumeSpeaker6ListenEv" } ], @@ -111,10 +121,12 @@ [ { + "binding" : "global", "name" : "_ZTV16LowVolumeSpeaker" }, { + "binding" : "global", "name" : "_ZTV17HighVolumeSpeaker" } ], diff --git a/vndk/tools/header-checker/tests/reference_dumps/x86_64/libgolden_cpp_json.so.lsdump b/vndk/tools/header-checker/tests/reference_dumps/x86_64/libgolden_cpp_json.so.lsdump index 6f5250eb6..3e4faa2c6 100644 --- a/vndk/tools/header-checker/tests/reference_dumps/x86_64/libgolden_cpp_json.so.lsdump +++ b/vndk/tools/header-checker/tests/reference_dumps/x86_64/libgolden_cpp_json.so.lsdump @@ -68,42 +68,52 @@ [ { + "binding" : "global", "name" : "_Z26test_virtual_function_callP12SuperSpeaker" }, { + "binding" : "global", "name" : "_ZN12NotReferenced" }, { + "binding" : "global", "name" : "_ZN12SuperSpeaker11SpeakLouderEv" }, { + "binding" : "global", "name" : "_ZN12SuperSpeaker18CreateSuperSpeakerEi" }, { + "binding" : "global", "name" : "_ZN12SuperSpeaker9SpeakLoudEv" }, { + "binding" : "global", "name" : "_ZN16LowVolumeSpeaker5SpeakEv" }, { + "binding" : "global", "name" : "_ZN16LowVolumeSpeaker6ListenEv" }, { + "binding" : "global", "name" : "_ZN17HighVolumeSpeaker11BadPracticeEf" }, { + "binding" : "global", "name" : "_ZN17HighVolumeSpeaker5SpeakEv" }, { + "binding" : "global", "name" : "_ZN17HighVolumeSpeaker6ListenEv" } ], @@ -111,10 +121,12 @@ [ { + "binding" : "global", "name" : "_ZTV16LowVolumeSpeaker" }, { + "binding" : "global", "name" : "_ZTV17HighVolumeSpeaker" } ],