diff options
author | emaste <emaste@FreeBSD.org> | 2015-01-23 02:39:00 +0000 |
---|---|---|
committer | emaste <emaste@FreeBSD.org> | 2015-01-23 02:39:00 +0000 |
commit | 23ccab912a903dc5714f61e29d179fb7a18525d0 (patch) | |
tree | 571826ef286691d28bdb27cf57c02764bb59a1d0 | |
parent | fb31f7e88b7e2fdedda30a82110a080b8e71fc0e (diff) | |
download | FreeBSD-src-23ccab912a903dc5714f61e29d179fb7a18525d0.zip FreeBSD-src-23ccab912a903dc5714f61e29d179fb7a18525d0.tar.gz |
crunchide: Correct 64-bit section header offset
For 64-bit binaries the Elf_Ehdr e_shoff is at offset 40, not 44.
Instead of using an incorrect hardcoded offset, let the compiler
figure it out for us with offsetof().
MFC of r277259
-rw-r--r-- | usr.sbin/crunch/crunchide/exec_elf32.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/usr.sbin/crunch/crunchide/exec_elf32.c b/usr.sbin/crunch/crunchide/exec_elf32.c index 752007f..8813497 100644 --- a/usr.sbin/crunch/crunchide/exec_elf32.c +++ b/usr.sbin/crunch/crunchide/exec_elf32.c @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include <errno.h> #include <limits.h> +#include <stddef.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -464,7 +465,7 @@ ELFNAMEEND(hide)(int fd, const char *fn) if (layoutp[i].shdr == &shdrshdr && ehdr.e_shoff != shdrshdr.sh_offset) { ehdr.e_shoff = shdrshdr.sh_offset; - off = (ELFSIZE == 32) ? 32 : 44; + off = offsetof(Elf_Ehdr, e_shoff); size = sizeof(Elf_Off); if ((size_t)xwriteatoff(fd, &ehdr.e_shoff, off, size, fn) != size) |