summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHsin-Yi Chen <hsinyichen@google.com>2019-05-03 19:22:12 +0800
committerHsin-Yi Chen <hsinyichen@google.com>2019-11-14 12:04:07 +0800
commitdfab3b169880f8ffd6076dfd6d49462c2c9c61b9 (patch)
tree5e1399dc92bd51185d1122d5c7b84542fbe46edd
parent7a3a3f6f66974e771568413f42ddfe6136a6e0b2 (diff)
downloadvndk-dfab3b169880f8ffd6076dfd6d49462c2c9c61b9.tar.gz
Get mangled name from unique_id and linker_set_key in ABI dumps
unique_id has been replaced with linker_set_key since Android R. extract_lsdump and VtsVndkAbi need to support both old and new formats. Test: ./dump_abi.py Test: vts-tradefed run vts -m VtsVndkAbi Bug: 74764811 Change-Id: I87f0f9ec954725c2fdab79583657406acf46cc70
-rw-r--r--abi/VtsVndkAbiTest.py8
-rwxr-xr-xgolden/extract_lsdump.py31
2 files changed, 32 insertions, 7 deletions
diff --git a/abi/VtsVndkAbiTest.py b/abi/VtsVndkAbiTest.py
index 554dd14..7516569 100644
--- a/abi/VtsVndkAbiTest.py
+++ b/abi/VtsVndkAbiTest.py
@@ -175,8 +175,14 @@ class VtsVndkAbiTest(base_test.BaseTestClass):
vtables_diff = []
for record_type in dump_obj.get("record_types", []):
+ # Since Android R, unique_id has been replaced with linker_set_key.
+ # unique_id starts with "_ZTI"; linker_set_key starts with "_ZTS".
type_name_symbol = record_type.get("unique_id", "")
- vtable_symbol = type_name_symbol.replace("_ZTS", "_ZTV", 1)
+ if type_name_symbol:
+ vtable_symbol = type_name_symbol.replace("_ZTS", "_ZTV", 1)
+ else:
+ type_name_symbol = record_type.get("linker_set_key", "")
+ vtable_symbol = type_name_symbol.replace("_ZTI", "_ZTV", 1)
# Skip if the vtable symbol isn't global.
if vtable_symbol not in global_symbols:
diff --git a/golden/extract_lsdump.py b/golden/extract_lsdump.py
index 45e9c38..a6d95c7 100755
--- a/golden/extract_lsdump.py
+++ b/golden/extract_lsdump.py
@@ -41,6 +41,25 @@ class AttrDict(dict):
self[key] = value
+def _GetTypeSymbol(record_type):
+ """Gets the mangled name of a record type.
+
+ Before Android R, unique_id was mangled name starting with "_ZTS".
+ linker_set_key was unmangled.
+ Since Android R, unique_id has been removed, and linker_set_key has
+ been changed to mangled name starting with "_ZTI".
+
+ Args:
+ record_type: An AttrDict, a record type in lsdump.
+
+ Returns:
+ A string, the mangled name starting with "_ZTI".
+ """
+ if "unique_id" in record_type:
+ return record_type["unique_id"].replace("_ZTS", "_ZTI", 1)
+ return record_type["linker_set_key"]
+
+
def _OpenFileOrGzipped(file_name):
"""Opens a file that is either in gzip or uncompressed format.
@@ -141,15 +160,15 @@ def _FilterElfObjects(lsdump):
"""
global_vars = {global_var.linker_set_key
for global_var in lsdump.global_vars}
- record_names = {record_type.unique_id[len('_ZTS'):]
+ record_names = {_GetTypeSymbol(record_type)[len('_ZTI'):]
for record_type in lsdump.record_types}
for elf_object in lsdump.elf_objects:
name = elf_object.name
if name in global_vars:
yield elf_object
- elif (name[:len('_ZTS')] in {'_ZTV', '_ZTT', '_ZTI', '_ZTS'} and
- name[len('_ZTS'):] in record_names):
+ elif (name[:len('_ZTI')] in {'_ZTV', '_ZTT', '_ZTI', '_ZTS'} and
+ name[len('_ZTI'):] in record_names):
yield elf_object
@@ -176,12 +195,12 @@ def _ParseVtablesFromLsdump(lsdump, output_dump):
output_dump.record_types = []
for lsdump_record_type in lsdump.record_types:
- type_symbol = lsdump_record_type.unique_id
- vtable_symbol = '_ZTV' + type_symbol[len('_ZTS'):]
+ type_symbol = _GetTypeSymbol(lsdump_record_type)
+ vtable_symbol = '_ZTV' + type_symbol[len('_ZTI'):]
if vtable_symbol not in vtable_symbols:
continue
record_type = AttrDict()
- record_type.unique_id = lsdump_record_type.unique_id
+ record_type.linker_set_key = type_symbol
record_type.vtable_components = lsdump_record_type.vtable_components
output_dump.record_types.append(record_type)