Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ignore Exceptions when searching ELF Files in remote debug since the file containing PyRuntime is the only one that matters.
18 changes: 0 additions & 18 deletions Python/remote_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -572,35 +572,23 @@ search_elf_file_for_section(

int fd = open(elf_file, O_RDONLY);
if (fd < 0) {
PyErr_Format(PyExc_OSError,
"Cannot open ELF file '%s' for section '%s' search: %s",
elf_file, secname, strerror(errno));
goto exit;
}

struct stat file_stats;
if (fstat(fd, &file_stats) != 0) {
PyErr_Format(PyExc_OSError,
"Cannot get file size for ELF file '%s' during section '%s' search: %s",
elf_file, secname, strerror(errno));
goto exit;
}

file_memory = mmap(NULL, file_stats.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (file_memory == MAP_FAILED) {
PyErr_Format(PyExc_OSError,
"Cannot memory map ELF file '%s' (size: %lld bytes) for section '%s' search: %s",
elf_file, (long long)file_stats.st_size, secname, strerror(errno));
goto exit;
}

Elf_Ehdr* elf_header = (Elf_Ehdr*)file_memory;

// Validate ELF header
if (elf_header->e_shstrndx >= elf_header->e_shnum) {
PyErr_Format(PyExc_RuntimeError,
"Invalid ELF file '%s': string table index %u >= section count %u",
elf_file, elf_header->e_shstrndx, elf_header->e_shnum);
goto exit;
}

Expand Down Expand Up @@ -635,9 +623,6 @@ search_elf_file_for_section(
}

if (first_load_segment == NULL) {
PyErr_Format(PyExc_RuntimeError,
"No PT_LOAD segment found in ELF file '%s' (%u program headers examined)",
elf_file, elf_header->e_phnum);
goto exit;
}

Expand All @@ -650,9 +635,6 @@ search_elf_file_for_section(
munmap(file_memory, file_stats.st_size);
}
if (fd >= 0 && close(fd) != 0) {
PyErr_Format(PyExc_OSError,
"Failed to close ELF file '%s': %s",
elf_file, strerror(errno));
result = 0;
}
return result;
Expand Down
Loading