kotlin-native/runtime/src/main/cpp/ExecFormat.cpp
Elf_Ehdr* findElfHeader() {
  int fd = open("/proc/self/exe", O_RDONLY);
  if (fd < 0) return nullptr;
  struct stat fd_stat;
  if (fstat(fd, &fd_stat) < 0) return nullptr;
  void* result = mmap(nullptr, fd_stat.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
  if (result == MAP_FAILED) return nullptr;
  return (Elf_Ehdr*)result;
}
// Unfortunately, symbol tables are stored in ELF sections not mapped
// during regular execution, so we have to map binary ourselves.
Unfortunately, symbol tables are stored in ELF sections not mapped
during regular execution, so we have to map binary ourselves.
Unfortunately symbol tables are stored in ELF sections not mapped during regular execution so we have to map binary ourselves .
Elf_Ehdr* findElfHeader() {
  int fd = open("/proc/self/exe", O_RDONLY);
  if (fd < 0) return nullptr;
  struct stat fd_stat;
  if (fstat(fd, &fd_stat) < 0) return nullptr;
  void* result = mmap(nullptr, fd_stat.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
  if (result == MAP_FAILED) return nullptr;
  return (Elf_Ehdr*)result;
}
Elf_Ehdr * findElfHeader ( ) { int fd = open ( " " , O_RDONLY ) ; if ( fd < 0 ) return nullptr ; struct stat fd_stat ; if ( fstat ( fd , & fd_stat ) < 0 ) return nullptr ; void * result = mmap ( nullptr , fd_stat . st_size , PROT_READ , MAP_PRIVATE , fd , 0 ) ; if ( result == MAP_FAILED ) return nullptr ; return ( Elf_Ehdr * ) result ; }
Unfortunately, symbol tables are stored in ELF sections not mapped
during regular execution, so we have to map binary ourselves.
Unfortunately symbol tables are stored in ELF sections not mapped during regular execution so we have to map binary ourselves .