Skip to content

Commit

Permalink
orderfile: Handle symbols that are neither local nor global.
Browse files Browse the repository at this point in the history
Orderfile generation stumbled upon one of these symbols. This is valid, per
objdump's documentation, though it wasn't seen before.

Make the asserts more lenient to avoid crashing in this case. See the attached
bug for details.

Bug: 992884
Change-Id: I029822853fb0bf3e1fbe6cc3abbdfd50f23d8716
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1747999
Reviewed-by: Ben Mason <benmason@chromium.org>
Cr-Commit-Position: refs/branch-heads/3880@{#3}
Cr-Branched-From: fd7bab0-refs/heads/master@{#685903}
  • Loading branch information
Benoît Lizé authored and Ben Mason committed Aug 12, 2019
1 parent 2935038 commit 2704a09
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tools/cygprofile/symbol_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ def _FromObjdumpLine(line):
if not m:
return None

assert m.group('assert_scope') in set(['g', 'l']), line
# A symbol can be (g)lobal, (l)ocal, or neither (a space). Per objdump's
# manpage, "A symbol can be neither local or global for a variety of reasons".
assert m.group('assert_scope') in set(['g', 'l', ' ']), line
assert m.group('assert_weak_or_strong') in set(['w', ' ']), line
assert m.group('assert_tab') == '\t', line
assert m.group('assert_4spaces') == ' ' * 4, line
Expand Down
10 changes: 10 additions & 0 deletions tools/cygprofile/symbol_extractor_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ def testOutlinedFunction(self):
self.assertEquals('OUTLINED_FUNCTION_4', symbol_info.name)
self.assertEquals('.text', symbol_info.section)

def testNeitherLocalNorGlobalSymbol(self):
# This happens, see crbug.com/992884.
# Symbol which is neither local nor global.
line = '0287ae50 w F .text\t000001e8 log2l'
symbol_info = symbol_extractor._FromObjdumpLine(line)
self.assertIsNotNone(symbol_info)
self.assertEquals(0x287ae50, symbol_info.offset)
self.assertEquals(0x1e8, symbol_info.size)
self.assertEquals('log2l', symbol_info.name)
self.assertEquals('.text', symbol_info.section)

class TestSymbolInfosFromStream(unittest.TestCase):

Expand Down

0 comments on commit 2704a09

Please sign in to comment.