From ef53c1929d4297bffe2730fb992e1b4bb2d422c3 Mon Sep 17 00:00:00 2001 From: Tess Strickland Date: Thu, 29 Sep 2022 09:36:37 +0000 Subject: [PATCH] [vm/test] Fix assumption about dynamic symbol table. The original code assumed that only the initial symbol in the dynamic symbol table had an empty name, and so any symbol with an empty name was checked as if it was the initial symbol. However, it turns out that in at least one case on our testing infrastructure, the assembler generates a dynamic symbol with an empty name. Thus, we change the test to check the initial symbol separately from the rest of the symbols in the symbol table. TEST=vm/dart{,_2}/use_add_readonly_data_symbols_flag Bug: https://github.com/dart-lang/sdk/issues/50071 Change-Id: Ie5d443ee2a45f8fb3400955d8bdfb3e726ab028a Fixed: 50071 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261820 Reviewed-by: Daco Harkes Commit-Queue: Tess Strickland --- ...e_add_readonly_data_symbols_flag_test.dart | 38 +++++++++---------- ...e_add_readonly_data_symbols_flag_test.dart | 36 +++++++++--------- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/runtime/tests/vm/dart/use_add_readonly_data_symbols_flag_test.dart b/runtime/tests/vm/dart/use_add_readonly_data_symbols_flag_test.dart index b8895c59b08..3e5b7753a5b 100644 --- a/runtime/tests/vm/dart/use_add_readonly_data_symbols_flag_test.dart +++ b/runtime/tests/vm/dart/use_add_readonly_data_symbols_flag_test.dart @@ -94,27 +94,27 @@ void checkElf(String filename, {bool isAssembled = false}) { // dynamic symbol table, have STB_LOCAL binding, and are of type STT_OBJECT. final elf = Elf.fromFile(filename); Expect.isNotNull(elf); - final dynamicSymbols = elf!.dynamicSymbols.toList(); + final dynamicSymbols = elf!.dynamicSymbols; + // All symbol tables have an initial entry with zero-valued fields. + Expect.isNotEmpty(dynamicSymbols); print('Dynamic symbols:'); - for (final symbol in dynamicSymbols) { - // All symbol tables have an initial entry with zero-valued fields. - if (symbol.name == '') { - print(symbol); - Expect.equals(SymbolBinding.STB_LOCAL, symbol.bind); - Expect.equals(SymbolType.STT_NOTYPE, symbol.type); - Expect.equals(0, symbol.value); - } else { - if (!symbol.name.startsWith('_kDart')) { - // The VM only adds symbols with names starting with _kDart, so this - // must be an assembled snapshot. - Expect.isTrue(isAssembled); - continue; - } - Expect.equals(SymbolBinding.STB_GLOBAL, symbol.bind); - Expect.equals(SymbolType.STT_OBJECT, symbol.type); - // All VM-generated read-only object symbols should have a non-zero size. - Expect.notEquals(0, symbol.size); + final initialDynamic = dynamicSymbols.first; + print(initialDynamic); + Expect.equals(SymbolBinding.STB_LOCAL, initialDynamic.bind); + Expect.equals(SymbolType.STT_NOTYPE, initialDynamic.type); + Expect.equals(0, initialDynamic.value); + for (final symbol in dynamicSymbols.skip(1)) { + print(symbol); + if (!symbol.name.startsWith('_kDart')) { + // The VM only adds symbols with names starting with _kDart, so this + // must be an assembled snapshot. + Expect.isTrue(isAssembled); + continue; } + Expect.equals(SymbolBinding.STB_GLOBAL, symbol.bind); + Expect.equals(SymbolType.STT_OBJECT, symbol.type); + // All VM-generated read-only object symbols should have a non-zero size. + Expect.notEquals(0, symbol.size); } print(""); final onlyStaticSymbols = elf.staticSymbols diff --git a/runtime/tests/vm/dart_2/use_add_readonly_data_symbols_flag_test.dart b/runtime/tests/vm/dart_2/use_add_readonly_data_symbols_flag_test.dart index 35fe667ad2c..8fae223e17f 100644 --- a/runtime/tests/vm/dart_2/use_add_readonly_data_symbols_flag_test.dart +++ b/runtime/tests/vm/dart_2/use_add_readonly_data_symbols_flag_test.dart @@ -96,27 +96,27 @@ void checkElf(String filename, {bool isAssembled = false}) { // dynamic symbol table, have STB_LOCAL binding, and are of type STT_OBJECT. final elf = Elf.fromFile(filename); Expect.isNotNull(elf); - final dynamicSymbols = elf.dynamicSymbols.toList(); + final dynamicSymbols = elf.dynamicSymbols; + // All symbol tables have an initial entry with zero-valued fields. + Expect.isNotEmpty(dynamicSymbols); print('Dynamic symbols:'); - for (final symbol in dynamicSymbols) { + final initialDynamic = dynamicSymbols.first; + print(initialDynamic); + Expect.equals(SymbolBinding.STB_LOCAL, initialDynamic.bind); + Expect.equals(SymbolType.STT_NOTYPE, initialDynamic.type); + Expect.equals(0, initialDynamic.value); + for (final symbol in dynamicSymbols.skip(1)) { print(symbol); - // All symbol tables have an initial entry with zero-valued fields. - if (symbol.name == '') { - Expect.equals(SymbolBinding.STB_LOCAL, symbol.bind); - Expect.equals(SymbolType.STT_NOTYPE, symbol.type); - Expect.equals(0, symbol.value); - } else { - if (!symbol.name.startsWith('_kDart')) { - // The VM only adds symbols with names starting with _kDart, so this - // must be an assembled snapshot. - Expect.isTrue(isAssembled); - continue; - } - Expect.equals(SymbolBinding.STB_GLOBAL, symbol.bind); - Expect.equals(SymbolType.STT_OBJECT, symbol.type); - // All VM-generated read-only object symbols should have a non-zero size. - Expect.notEquals(0, symbol.size); + if (!symbol.name.startsWith('_kDart')) { + // The VM only adds symbols with names starting with _kDart, so this + // must be an assembled snapshot. + Expect.isTrue(isAssembled); + continue; } + Expect.equals(SymbolBinding.STB_GLOBAL, symbol.bind); + Expect.equals(SymbolType.STT_OBJECT, symbol.type); + // All VM-generated read-only object symbols should have a non-zero size. + Expect.notEquals(0, symbol.size); } print(""); final onlyStaticSymbols = elf.staticSymbols