Commit 91eaa1ed authored by Samuel Huang's avatar Samuel Huang Committed by Commit Bot

[Supersize] Add preliminary string literal extraction under LLD.

Previously Supersize archive for binaries linked with LLD (no LTO) did
not support string literals, and required '--no-string-literals' to
avoid triggering assert. This CL fixes this this by adding preliminary
support for merged strings. Wrinkles:
- LLD .map files does not discern string literals from data literals
  (and testing align=1 seems insufficient), so we count everything as
  string literals for now.
- llvm-readobj (AKA llvm-readelf)'s dump for .a files is missing
  'File: libray.a(file.o)' output. For now we work around this by
  using regular readelf instead.

Bug: 723798
Change-Id: Ic0c9a48dfd9ab157ed19471127a5216ee98b8d65
Reviewed-on: https://chromium-review.googlesource.com/777441
Commit-Queue: Samuel Huang <huangs@chromium.org>
Reviewed-by: default avataragrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517752}
parent 0a830ccc
......@@ -653,8 +653,9 @@ def CreateSizeInfo(map_path, elf_path, tool_prefix, output_directory,
bulk_analyzer.AnalyzePaths(missed_object_paths)
bulk_analyzer.SortPaths()
if track_string_literals:
merge_string_syms = [
s for s in raw_symbols if s.full_name == '** merge strings']
merge_string_syms = [s for s in raw_symbols if
s.full_name == '** merge strings' or
s.full_name == '** lld merge strings']
# More likely for there to be a bug in supersize than an ELF to not have a
# single string literal.
assert merge_string_syms
......
......@@ -330,7 +330,9 @@ class MapFileParserLld(object):
# merged data. Feature request is filed under:
# https://bugs.llvm.org/show_bug.cgi?id=35248
if cur_obj == '<internal>':
sym_maker.cur_sym.full_name = '** lld merge section'
# Treat all literals as stirng literals.
# FIXME(huangs): Refine this. Checking align == 1 is insufficient.
sym_maker.cur_sym.full_name = '** lld merge strings'
else:
sym_maker.cur_sym.object_path = cur_obj
......
......@@ -157,4 +157,8 @@ def GetObjDumpPath(tool_prefix):
def GetReadElfPath(tool_prefix):
# Work-around for llvm-readobj bug where 'File: ...' info is not printed:
# https://bugs.llvm.org/show_bug.cgi?id=35351
if tool_prefix[-5:] == 'llvm-':
return 'readelf'
return tool_prefix + 'readelf'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment