#!/usr/bin/env python3 # Copyright 2019 The Chromium Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Extracts an LLD partition from an ELF file."""
def _ComputeNewBuildId(old_build_id, file_path): """
Computes the new build-id from old build-id and file_path.
Args:
old_build_id: Original build-id in bytearray.
file_path: Path to output ELF file.
Returns:
New build id with the same length as |old_build_id|. """
m = hashlib.sha256()
m.update(old_build_id)
m.update(os.path.basename(file_path).encode('utf-8'))
hash_bytes = m.digest() # In case build_id is longer than hash computed, repeat the hash # to the desired length first.
id_size = len(old_build_id)
hash_size = len(hash_bytes) return (hash_bytes * (id_size // hash_size + 1))[:id_size]
def _ExtractPartition(objcopy, input_elf, output_elf, partition): """
Extracts a partition from an ELF file.
For partitions other than main partition, we need to rewrite
the .note.gnu.build-id section so that the build-id remains
unique.
Note:
- `objcopy` does not modify build-id when partitioning the
combined ELF file by default.
- The new build-id is calculated as hash of original build-id and partitioned ELF file name.
Args:
objcopy: Path to objcopy binary.
input_elf: Path to input ELF file.
output_elf: Path to output ELF file.
partition: Partition to extract from combined ELF file. None when
extracting main partition. """ ifnot partition: # main partition # We do not overwrite build-id on main partition to allow the expected # partition build ids to be synthesized given a libchrome.so binary, # if necessary.
subprocess.check_call(
[objcopy, '--extract-main-partition', input_elf, output_elf]) return
# Debug info for partitions is the same as for the main library, so just # symlink the .dwp files. if args.split_dwarf:
dest = args.unstripped_output + '.dwp' try:
os.unlink(dest) except OSError: pass
relpath = os.path.relpath(args.input + '.dwp', os.path.dirname(dest))
os.symlink(relpath, dest)
if __name__ == '__main__':
sys.exit(main())
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-08-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.