• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Unwinder Support Per Android Release
2This document describes the changes in the way the libunwindstack
3unwinder works on different Android versions. It does not describe
4every change in the code made between different versions, but is
5meant to allow an app developer to know what might be supported
6on different versions. It also describes the different way an unwind
7will display on different versions of Android.
8
9## Android 9 ("Pie", API level 28)
10libunwindstack was first introduced in API level 28.
11
12* Supports up to and including Dwarf 4 unwinding information.
13  See http://dwarfstd.org/ for Dwarf standards.
14* Supports Arm exidx unwinding.
15* Supports the gdb JIT unwinding interface, which is how ART creates unwinding
16  information for the JIT'd Java frames.
17* Supports special frames added to represent an ART Java interpreter frame.
18  ART has marked the dex pc using cfi information that the unwinder
19  understands and handles by adding a new frame in the stacktrace.
20
21## Note
22By default, lld creates two separate maps of the elf in memory, one read-only
23and one read/executable. The libunwindstack on P and the unwinder on older
24versions of Android will not unwind properly in this case. For apps that
25target API level 28 or older, make sure that `-Wl,--no-rosegment` is
26included in linker arguments when using lld.
27
28## Android 10 ("Q", API level 29)
29* Fix bug (b/109824792) that handled load bias data incorrectly when
30  FDEs use pc relative addressing in the eh\_frame\_hdr.
31  Unfortunately, this wasn't fixed correctly in Q since it assumes
32  that the bias is coming from the program header for the executable
33  load. The real fix was to use the bias from the actual section data and
34  is not completely fixed until API level 30. For apps targeting API level 29,
35  if it is being compiled with the llvm linker lld, it might be necessary
36  to add the linker option `-Wl,-zseparate-code` to avoid creating an elf
37  created this way.
38* Change the way the exidx section offset is found (b/110704153). Before
39  the p\_vaddr value from the program header minus the load bias was used
40  to find the start of the exidx data. Changed to use the p\_offset since
41  it doesn't require any load bias manipulations.
42* Fix bug handling of dwarf sections without any header (b/110235461).
43  Previously, the code assumed that FDEs are non-overlapping, and the FDEs
44  are always in sorted order from low pc to high pc. Thus the code would
45  read the entire set of CIEs/FDEs and then do a binary search to find
46  the appropriate FDE for a given pc. Now the code does a sequential read
47  and stops when it finds the FDE for a pc. It also understands the
48  overlapping FDEs, so find the first FDE that matches a pc. In practice,
49  elf files with this format only ever occurs if the file was generated
50  without an eh\_frame/eh\_frame\_hdr section and only a debug\_frame. The
51  other way this has been observed is when running simpleperf to unwind since
52  sometimes there is not enough information in the eh\_frame for all points
53  in the executable. On API level 28, this would result in some incorrect
54  unwinds coming from simpleperf. Nearly all crashes from API level 28 should
55  be correct since the eh\_frame information was enough to do the unwind
56  properly.
57* Be permissive of badly formed elf files. Previously, any detected error
58  would result in unwinds stopping even if there is enough valid information
59  to do an unwind.
60  * The code now allows program header/section header offsets to point
61    to unreadable memory. As long as the code can find the unwind tables,
62    that is good enough.
63  * The code allows program headers/section headers to be missing.
64  * Allow a symbol table section header to point to invalid symbol table
65    values.
66* Support for the linker read-only segment option (b/109657296).
67  This is a feature of lld whereby there are two sections that
68  contain elf data. The first is read-only and contains the elf header data,
69  and the second is read-execute or execute only that
70  contains the executable code from the elf. Before this, the unwinder
71  always assumed that there was only a single read-execute section that
72  contained the elf header data and the executable code.
73* Build ID information for elf objects added. This will display the
74  NT\_GNU\_BUILD\_ID note found in elf files. This information can be used
75  to identify the exact version of a shared library to help get symbol
76  information when looking at a crash.
77* Add support for displaying the soname from an apk frame. Previously,
78  a frame map name would be only the apk, but now if the shared library
79  in the apk has set a soname, the map name will be `app.apk!libexample.so`
80  instead of only `app.apk`.
81* Minimal support for Dwarf 5. This merely treats a Dwarf 5 version
82  elf file as Dwarf 4. It does not support the new dwarf ops in Dwarf 5.
83  Since the new ops are not likely to be used very often, this allows
84  continuing to unwind even when encountering Dwarf 5 elf files.
85* Fix bug in pc handling of signal frames (b/130302288). In the previous
86  version, the pc would be wrong in the signal frame. The rest of the
87  unwind was correct, only the frame in the signal handler was incorrect
88  in API level 28.
89* Detect when an elf file is not readable so that a message can be
90  displayed indicating that. This can happen when an app puts the shared
91  libraries in non-standard locations that are not readable due to
92  security restrictions (selinux rules).
93
94## Android 11 ("R", API level 30)
95* Display the offsets for Java interpreter frames. If this frame came
96  from a non-zero offset map, no offset is printed. Previously, the
97  line would look like:
98
99    #17 pc 00500d7a  GoogleCamera.apk (com.google.camera.AndroidPriorityThread.run+10)
100
101  to:
102
103    #17 pc 00500d7a  GoogleCamera.apk (offset 0x11d0000) (com.google.camera.AndroidPriorityThread.run+10)
104* Fix bug where the load bias was set from the first PT\_LOAD program
105  header that has a zero p\_offset value. Now it is set from the first
106  executable PT\_LOAD program header. This has only ever been a problem
107  for host executables compiled for the x86\_64 architecture.
108* Switched to the libc++ demangler for function names. Previously, the
109  demangler used was not complete, so some less common demangled function
110  names would not be properly demangled or the function name would not be
111  demangled at all.
112* Fix bug in load bias handling. If the unwind information in the eh\_frame
113  or eh\_frame\_hdr does not have the same bias as the executable section,
114  and uses pc relative FDEs, the unwind will be incorrect. This tends
115  to truncate unwinds since the unwinder could not find the correct unwind
116  information for a given pc.
117