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
This commit is contained in:
parent
61b6fd5ab2
commit
b15dc00338
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=277259
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user