Files
2026-01-10 16:25:16 +01:00

35 lines
942 B
C

/* Copyright (C) 2025 John Törnblom
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, see
<http://www.gnu.org/licenses/>. */
#include <sys/mman.h>
#include "self.h"
/**
*
**/
#define MAP_SELF 0x80000
void*
self_map_segment(int fd, const Elf64_Phdr *phdr, size_t ind) {
return mmap(0, phdr->p_filesz, PROT_READ,
MAP_PRIVATE | MAP_ALIGNED(phdr->p_align) | MAP_SELF,
fd, ind << 32);
}