Use a shared_ptr for Elf memory objects.

When supporting a compressed section, it's necessary to create
a memory object to use in the section. Currently, all of the
Elf/ElfInterface/DwarfSection objects have a single Memory object
which is owned by the Elf object with a unique_ptr. All of the other
objects have a pointer only. This means that when creating a new
Memory object to represent compressed data, it's necessary to stick
special unique_ptr variables to contain the object and make sure
it's released properly. For example, the gnu_debugdata_memory_
variable from the Elf object. By changing all of the Memory objects
that represent the elf memory to a shared_ptr, this all goes away,
and there is no longer a need to keep the memory object for
the gnu_debugdata_memory. When creating a new memory object
for the compressed section data, the shared_ptr can contain the
memory and take care of freeing it.

Bug: 309857311

Test: All unit tests pass.
Test: Ran the fuzzer.
Test: Ran each of the tools.
Test: Ran benchmarks.
Test: Ran unit tests on host with the address sanitizer.
Change-Id: I2bebcaf5832a674375e724de0b5d8445282be366
57 files changed
tree: 45842e2fd1b434141588d664df6383532c7fc48d
  1. libunwindstack/
  2. OWNERS
  3. PREUPLOAD.cfg