third_party/android_crazy_linker/src/tests/pylib/elf_utils.py
def CSourceForElfSymbolListMacro(variable_prefix, names, name_offsets,
                                 base_address=0x10000, symbol_size=16,
                                 spacing_size=16):
  """Generate C source definition for a macro listing ELF symbols.

  Args:
    macro_suffix: Macro name suffix.
    names: List of symbol names.
    name_offsets: List of symbol offsets.
    base_address: Base starting address for symbols,
    symbol_size: Symbol size in bytes (all have the same size).
    spacing_size: Additionnal bytes between symbols.
  Returns:
    String containing C source fragment.
  """
  out = (
r'''// Auto-generated macro used to list all symbols
// XX must be a macro that takes the following parameters:
//   name: symbol name (quoted).
//   str_offset: symbol name offset in string table
//   address: virtual address.
//   size: size in bytes
''')
  out += '#define LIST_ELF_SYMBOLS_%s(XX) \\\n' % variable_prefix
  address = base_address
  for sym, offset in zip(names, name_offsets):
    out += '    XX("%s", %d, 0x%x, %d) \\\n' % (
        sym, offset, address, symbol_size)
    address += symbol_size + spacing_size
  out += '    // END OF LIST\n'
  return out
Generate C source definition for a macro listing ELF symbols.

  Args:
    macro_suffix: Macro name suffix.
    names: List of symbol names.
    name_offsets: List of symbol offsets.
    base_address: Base starting address for symbols,
    symbol_size: Symbol size in bytes (all have the same size).
    spacing_size: Additionnal bytes between symbols.
  Returns:
    String containing C source fragment.
  
Generate C source definition for a macro listing ELF symbols.
Generate C source definition for a macro listing ELF symbols .
def CSourceForElfSymbolListMacro(variable_prefix, names, name_offsets,
                                 base_address=0x10000, symbol_size=16,
                                 spacing_size=16):
  out = (
r'''// Auto-generated macro used to list all symbols
// XX must be a macro that takes the following parameters:
//   name: symbol name (quoted).
//   str_offset: symbol name offset in string table
//   address: virtual address.
//   size: size in bytes
''')
  out += '#define LIST_ELF_SYMBOLS_%s(XX) \\\n' % variable_prefix
  address = base_address
  for sym, offset in zip(names, name_offsets):
    out += '    XX("%s", %d, 0x%x, %d) \\\n' % (
        sym, offset, address, symbol_size)
    address += symbol_size + spacing_size
  out += '    // END OF LIST\n'
  return out
def CSourceForElfSymbolListMacro ( variable_prefix , names , name_offsets , base_address = 0x10000 , symbol_size = 16 , spacing_size = 16 ) : out = ( r'''// Auto-generated macro used to list all symbols
// XX must be a macro that takes the following parameters:
//   name: symbol name (quoted).
//   str_offset: symbol name offset in string table
//   address: virtual address.
//   size: size in bytes
''' ) out += '#define LIST_ELF_SYMBOLS_%s(XX) \\\n' % variable_prefix address = base_address for sym , offset in zip ( names , name_offsets ) : out += '    XX("%s", %d, 0x%x, %d) \\\n' % ( sym , offset , address , symbol_size ) address += symbol_size + spacing_size out += '    // END OF LIST\n' return out
Generate C source definition for a macro listing ELF symbols.
Generate C source definition for a macro listing ELF symbols .
"""Generate C source definition for a macro listing ELF symbols.

  Args:
    macro_suffix: Macro name suffix.
    names: List of symbol names.
    name_offsets: List of symbol offsets.
    base_address: Base starting address for symbols,
    symbol_size: Symbol size in bytes (all have the same size).
    spacing_size: Additionnal bytes between symbols.
  Returns:
    String containing C source fragment.
  """
String containing C source fragment.
String containing C source fragment .
variable_prefix
names
List of symbol names.
List of symbol names .
name_offsets
List of symbol offsets.
List of symbol offsets .
base_address
Base starting address for symbols.
Base starting address for symbols .
symbol_size
Symbol size in bytes (all have the same size).
Symbol size in bytes ( all have the same size ) .
spacing_size
Additionnal bytes between symbols.
Additionnal bytes between symbols .
macro_suffix
Macro name suffix.
Macro name suffix .