From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 7555013894D for ; Sat, 9 Feb 2013 21:50:11 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 431DB21C05A; Sat, 9 Feb 2013 21:50:10 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 9F47021C05A for ; Sat, 9 Feb 2013 21:50:09 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B095533E36D for ; Sat, 9 Feb 2013 21:50:04 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id E06D9E4073 for ; Sat, 9 Feb 2013 21:50:02 +0000 (UTC) From: "Anthony G. Basile" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Anthony G. Basile" Message-ID: <1360446586.590ee3ea903fcf3fa6baf5194cc339ccc4c67bba.blueness@gentoo> Subject: [gentoo-commits] proj/elfix:master commit in: misc/ X-VCS-Repository: proj/elfix X-VCS-Files: misc/remove-ptpax.c X-VCS-Directories: misc/ X-VCS-Committer: blueness X-VCS-Committer-Name: Anthony G. Basile X-VCS-Revision: 590ee3ea903fcf3fa6baf5194cc339ccc4c67bba X-VCS-Branch: master Date: Sat, 9 Feb 2013 21:50:02 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 01210b26-cb66-4648-a0d8-e950eb12f258 X-Archives-Hash: 84375baf7a346bcb645a81931a42f8ef commit: 590ee3ea903fcf3fa6baf5194cc339ccc4c67bba Author: Anthony G. Basile gentoo org> AuthorDate: Sat Feb 9 21:49:46 2013 +0000 Commit: Anthony G. Basile gentoo org> CommitDate: Sat Feb 9 21:49:46 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=590ee3ea misc/remove-ptpax.c: code to convert PT_PAX_FLAGS to PT_NULL phdr --- misc/remove-ptpax.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 103 insertions(+), 0 deletions(-) diff --git a/misc/remove-ptpax.c b/misc/remove-ptpax.c new file mode 100644 index 0000000..ba441a5 --- /dev/null +++ b/misc/remove-ptpax.c @@ -0,0 +1,103 @@ +/* + remove-ptpax.c: this file is part of the elfix package + Copyright (C) 2013 Anthony G. Basile + + 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 of the License, 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. If not, see . +*/ + +#include +#include +#include +#include +#include +#include + +#ifndef PT_PAX_FLAGS + #define PT_PAX_FLAGS 0x65041580 +#endif + +int +remove_ptpax(int fd) +{ + Elf *elf; + GElf_Phdr phdr; + size_t i, phnum; + + if(elf_version(EV_CURRENT) == EV_NONE) + { + printf("\tELF ERROR: Library out of date.\n"); + return EXIT_FAILURE; + } + + if((elf = elf_begin(fd, ELF_C_RDWR_MMAP, NULL)) == NULL) + { + printf("\tELF ERROR: elf_begin() fail: %s\n", elf_errmsg(elf_errno())); + return EXIT_FAILURE; + } + + if(elf_kind(elf) != ELF_K_ELF) + { + elf_end(elf); + printf("\tELF ERROR: elf_kind() fail: this is not an elf file.\n"); + return EXIT_FAILURE; + } + + elf_getphdrnum(elf, &phnum); + + for(i=0; i\n", argv[0]) ; + exit(EXIT_SUCCESS); + } + + if((fd = open(argv[1], O_RDWR)) < 0) + { + printf("\topen(O_RDWR) failed: cannot change PT_PAX flags\n"); + exit(EXIT_FAILURE); + } + else + exit(remove_ptpax(fd)); + +}