Bug 1497669 - Relax breakpad's constraints when merging module mappings on Linux r=ted

This makes a few small but significant changes to the logic breakpad uses to
merge module memory mappings:

- First of all we merge areas of reserved space if their offset is either 0 or
  the end of the previous non-reserved mapping.
- Whenever we encounter an executable mapping we flag all the merged modules
  as executable. This shouldn't happen but apparently some older Android
  linkers suffered from a bug that caused the first mapping not to be
  executable.
- Last but not least we record the raw end address of a module on Android.
  This shouldn't affect us but it's done in upstream breakpad so it probably
  doesn't hurt.

Differential Revision: https://phabricator.services.mozilla.com/D12113
This commit is contained in:
Gabriele Svelto committed 2018-11-16 22:43:32 +00:00
1 parent d5f937b788
commit c1047e1e19
1 file changed
+9 -6
@@ -617,14 +617,16 @@ bool LinuxDumper::EnumerateMappings() {
name = kLinuxGateLibraryName;
offset = 0;
}
// Merge adjacent mappings with the same name into one module,
// assuming they're a single library mapped by the dynamic linker
// Merge adjacent mappings into one module, assuming they're a single
// library mapped by the dynamic linker.
if (name && !mappings_.empty()) {
MappingInfo* module = mappings_.back();
if ((start_addr == module->start_addr + module->size) &&
(my_strlen(name) == my_strlen(module->name)) &&
(my_strncmp(name, module->name, my_strlen(name)) == 0)) {
module->system_mapping_info.end_addr = end_addr;
module->size = end_addr - module->start_addr;
module->exec |= exec;
line_reader->PopLine(line_len);
continue;
}
@@ -635,12 +637,13 @@ bool LinuxDumper::EnumerateMappings() {
// and which directly follow an executable mapping.
if (!name && !mappings_.empty()) {
MappingInfo* module = mappings_.back();
if ((start_addr == module->start_addr + module->size) &&
uintptr_t module_end_addr = module->start_addr + module->size;
if ((start_addr == module_end_addr) &&
module->exec &&
module->name[0] == '/' &&
offset == 0 && my_strncmp(i2,
kReservedFlags,
sizeof(kReservedFlags) - 1) == 0) {
((offset == 0) || (offset == module_end_addr)) &&
my_strncmp(i2, kReservedFlags,
sizeof(kReservedFlags) - 1) == 0) {
module->size = end_addr - module->start_addr;
line_reader->PopLine(line_len);
continue;