| 311 | } |
| 312 | |
| 313 | bool ElfParser::parseFile(CodeCache* cc, const char* base, const char* file_name, bool use_debug) { |
| 314 | int fd = open(file_name, O_RDONLY); |
| 315 | if (fd == -1) { |
| 316 | return false; |
| 317 | } |
| 318 | |
| 319 | size_t length = (size_t)lseek(fd, 0, SEEK_END); |
| 320 | void* addr = mmap(NULL, length, PROT_READ, MAP_PRIVATE, fd, 0); |
| 321 | close(fd); |
| 322 | |
| 323 | if (addr == MAP_FAILED) { |
| 324 | Log::warn("Could not parse symbols from %s: %s", file_name, strerror(errno)); |
| 325 | } else { |
| 326 | ElfParser elf(cc, base, addr, file_name, false); |
| 327 | if (elf.validHeader()) { |
| 328 | elf.calcVirtualLoadAddress(); |
| 329 | elf.loadSymbols(use_debug); |
| 330 | } |
| 331 | munmap(addr, length); |
| 332 | } |
| 333 | return true; |
| 334 | } |
| 335 | |
| 336 | void ElfParser::parseProgramHeaders(CodeCache* cc, const char* base, const char* end, bool relocate_dyn) { |
| 337 | ElfParser elf(cc, base, base, NULL, relocate_dyn); |
nothing calls this directly
no test coverage detected