aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/crunch/crunchide/exec_elf32.c
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2015-01-16 18:59:15 +0000
committerEd Maste <emaste@FreeBSD.org>2015-01-16 18:59:15 +0000
commitb15dc00338d618de121f2b08e238ed9593362106 (patch)
tree4e2687c840d3402666106862fcc76d3e2e4b8d45 /usr.sbin/crunch/crunchide/exec_elf32.c
parent61b6fd5ab2422fdd16ab876281ae62d0e7f45335 (diff)
downloadsrc-b15dc00338d618de121f2b08e238ed9593362106.tar.gz
src-b15dc00338d618de121f2b08e238ed9593362106.zip
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(). Differential Revision: https://reviews.freebsd.org/D1543 MFC after: 1 week Sponsored by: The FreeBSD Foundation
Notes
Notes: svn path=/head/; revision=277259
Diffstat (limited to 'usr.sbin/crunch/crunchide/exec_elf32.c')
-rw-r--r--usr.sbin/crunch/crunchide/exec_elf32.c3
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 d7f45b00d40f..10e7d278c38e 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)