aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <basile@opensource.dyc.edu>2011-04-13 17:25:55 -0400
committerAnthony G. Basile <basile@opensource.dyc.edu>2011-04-13 17:25:55 -0400
commit8aa93ea66bb4fac089d757c7eb68bc8d6cf3d696 (patch)
tree7a13f3d20db14264b4a68164d0c523a120b7fa67
parentfix-gnustack.c: fixed open() to RDWR (diff)
downloadelfix-8aa93ea66bb4fac089d757c7eb68bc8d6cf3d696.tar.gz
elfix-8aa93ea66bb4fac089d757c7eb68bc8d6cf3d696.tar.bz2
elfix-8aa93ea66bb4fac089d757c7eb68bc8d6cf3d696.zip
fix-gnustack.c: added needed gelf_update_phdr()
-rw-r--r--TODO27
-rw-r--r--fix-gnustack.c15
2 files changed, 34 insertions, 8 deletions
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..3743b1d
--- /dev/null
+++ b/TODO
@@ -0,0 +1,27 @@
+
+1. Addec check for yasm to configure.ac
+
+2. Fix for 32-bit make check. This entails editing the yasm line in the chec and asm itself
+
+3. Fix the following print format errors that arrise on 32-bit:
+
+parse-elf.c:112: warning: format '%lu' expects type 'long unsigned int', but argument 6 has type 'Elf64_Addr'
+parse-elf.c:112: warning: format '%lu' expects type 'long unsigned int', but argument 7 has type 'Elf64_Off'
+parse-elf.c:112: warning: format '%lu' expects type 'long unsigned int', but argument 8 has type 'Elf64_Off'
+parse-elf.c:115: warning: format '%lu' expects type 'long unsigned int', but argument 2 has type 'size_t'
+parse-elf.c:164: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'Elf64_Off'
+parse-elf.c:164: warning: format '%lu' expects type 'long unsigned int', but argument 5 has type 'Elf64_Addr'
+parse-elf.c:164: warning: format '%lu' expects type 'long unsigned int', but argument 6 has type 'Elf64_Addr'
+parse-elf.c:164: warning: format '%lu' expects type 'long unsigned int', but argument 7 has type 'Elf64_Xword'
+parse-elf.c:164: warning: format '%lu' expects type 'long unsigned int', but argument 8 has type 'Elf64_Xword'
+parse-elf.c:164: warning: format '%lu' expects type 'long unsigned int', but argument 9 has type 'Elf64_Xword'
+parse-elf.c:207: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'Elf64_Xword'
+parse-elf.c:207: warning: format '%lu' expects type 'long unsigned int', but argument 5 has type 'Elf64_Addr'
+parse-elf.c:207: warning: format '%lu' expects type 'long unsigned int', but argument 6 has type 'Elf64_Off'
+parse-elf.c:207: warning: format '%lu' expects type 'long unsigned int', but argument 7 has type 'Elf64_Xword'
+parse-elf.c:207: warning: format '%lu' expects type 'long unsigned int', but argument 10 has type 'Elf64_Xword'
+parse-elf.c:207: warning: format '%lu' expects type 'long unsigned int', but argument 11 has type 'Elf64_Xword'
+parse-elf.c:220: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'size_t'
+parse-elf.c:220: warning: format '%lu' expects type 'long unsigned int', but argument 5 has type 'loff_t'
+parse-elf.c:220: warning: format '%lu' expects type 'long unsigned int', but argument 6 has type 'size_t'
+
diff --git a/fix-gnustack.c b/fix-gnustack.c
index 357c76f..cb558ba 100644
--- a/fix-gnustack.c
+++ b/fix-gnustack.c
@@ -27,10 +27,10 @@ int main( int argc, char *argv[])
if(argc != 2)
error(EXIT_FAILURE, 0, "Usage: %s <filename>", argv[0]);
- if((fd = open(argv[1], O_RDWR)) == -1)
+ if((fd = open(argv[1], O_RDWR)) < 0)
error(EXIT_FAILURE, 0, "open() fail.");
- if((elf = elf_begin(fd, ELF_C_RDWR, (Elf *)0)) == NULL)
+ if((elf = elf_begin(fd, ELF_C_RDWR_MMAP, NULL)) == NULL)
error(EXIT_FAILURE, 0, "elf_begin() fail: %s", elf_errmsg(-1));
if(elf_kind(elf) != ELF_K_ELF)
@@ -40,7 +40,7 @@ int main( int argc, char *argv[])
error(EXIT_FAILURE, 0, "gelf_getehdr() fail: %s", elf_errmsg(-1));
elf_getphdrnum(elf, &phnum);
- for (i=0; i<phnum; ++i)
+ for(i=0; i<phnum; ++i)
{
if(gelf_getphdr(elf, i, &phdr) != &phdr)
error(EXIT_FAILURE, 0, "gelf_getphdr(): %s", elf_errmsg(-1));
@@ -59,12 +59,11 @@ int main( int argc, char *argv[])
nflags = phdr.p_flags ^ PF_X;
printf("oflags=%u PF_X=%d nflags=%u\n", phdr.p_flags, PF_X, nflags);
- //if(elf_update(elf, ELF_C_NULL ) < 0)
- // error (EXIT_FAILURE, 0, "elf_update(ELF_C_NULL) failed: %s.", elf_errmsg(-1));
phdr.p_flags = nflags ;
- if(elf_flagphdr(elf, ELF_C_SET, ELF_F_DIRTY) == 0)
- error(EXIT_FAILURE, 0, "gelf_flagphdr() fail: %s", elf_errmsg(-1));
- if(elf_update(elf, ELF_C_WRITE) < 0)
+ gelf_update_phdr(elf, i, &phdr);
+ //if(elf_flagphdr(elf, ELF_C_SET, ELF_F_DIRTY) == 0)
+ // error(EXIT_FAILURE, 0, "elf_flagphdr() fail: %s", elf_errmsg(-1));
+ if(elf_update(elf, ELF_C_WRITE_MMAP) < 0)
error (EXIT_FAILURE, 0, "elf_update(ELF_C_WRITE) failed: %s.", elf_errmsg(-1));
}
}