From 9b9e675934bcd56f7a91b19417b6cdf274baf123 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Thu, 25 Aug 2011 13:58:57 +0800 Subject: [PATCH] Kernel/ELF - Fixed ELF segment permissions --- Kernel/bin/elf.c | 4 ++-- Kernel/bin/elf.h | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Kernel/bin/elf.c b/Kernel/bin/elf.c index c844ff08..73154c14 100644 --- a/Kernel/bin/elf.c +++ b/Kernel/bin/elf.c @@ -128,9 +128,9 @@ tBinary *Elf_Load(int fp) ret->LoadSections[j].Virtual = phtab[i].VAddr; ret->LoadSections[j].MemSize = phtab[i].MemSize; ret->LoadSections[j].Flags = 0; - if( !(phtab[i].Flags & SHF_WRITE) ) + if( !(phtab[i].Flags & PF_W) ) ret->LoadSections[j].Flags |= BIN_SECTFLAG_RO; - if( phtab[i].Flags & SHF_EXECINSTR ) + if( phtab[i].Flags & PF_X ) ret->LoadSections[j].Flags |= BIN_SECTFLAG_EXEC; j ++; } diff --git a/Kernel/bin/elf.h b/Kernel/bin/elf.h index 13724eb3..b038766b 100644 --- a/Kernel/bin/elf.h +++ b/Kernel/bin/elf.h @@ -139,6 +139,10 @@ struct sElf32_Phdr { Uint32 Align; } __attribute__ ((packed)); +#define PF_X 1 +#define PF_W 2 +#define PF_R 4 + struct elf32_rel_s { Uint32 r_offset; Uint32 r_info; -- 2.20.1