diff options
author | imp <imp@FreeBSD.org> | 2015-05-22 20:50:35 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2015-05-22 20:50:35 +0000 |
commit | b8ed2d07c4d59d2f5a3198cb1c2b79538d14e0d7 (patch) | |
tree | 83b35d75e3358fb581b2d01f8303b7f705007fea | |
parent | e69f995011be8cb49bae9a5cd1e3149e06cfe729 (diff) | |
download | FreeBSD-src-b8ed2d07c4d59d2f5a3198cb1c2b79538d14e0d7.zip FreeBSD-src-b8ed2d07c4d59d2f5a3198cb1c2b79538d14e0d7.tar.gz |
Export the eflags field from the elf header. This allows better
discrimination between different subarch binaries, at least for mips
and arm. Arm is implemented, mips is still tbd, so not currently
exported. aarch64 does not export this because aarch64 binaries use
different tags and flags than arm.
Differential Revision: https://reviews.freebsd.org/D2611
-rw-r--r-- | sys/arm/include/elf.h | 45 | ||||
-rw-r--r-- | sys/kern/imgact_elf.c | 4 | ||||
-rw-r--r-- | sys/sys/imgact_elf.h | 1 |
3 files changed, 28 insertions, 22 deletions
diff --git a/sys/arm/include/elf.h b/sys/arm/include/elf.h index abe7b47..9262682 100644 --- a/sys/arm/include/elf.h +++ b/sys/arm/include/elf.h @@ -63,21 +63,21 @@ __ElfType(Auxinfo); */ /* Values for a_type. */ -#define AT_NULL 0 /* Terminates the vector. */ -#define AT_IGNORE 1 /* Ignored entry. */ -#define AT_EXECFD 2 /* File descriptor of program to load. */ -#define AT_PHDR 3 /* Program header of program already loaded. */ -#define AT_PHENT 4 /* Size of each program header entry. */ -#define AT_PHNUM 5 /* Number of program header entries. */ -#define AT_PAGESZ 6 /* Page size in bytes. */ -#define AT_BASE 7 /* Interpreter's base address. */ -#define AT_FLAGS 8 /* Flags (unused). */ -#define AT_ENTRY 9 /* Where interpreter should transfer control. */ -#define AT_NOTELF 10 /* Program is not ELF ?? */ -#define AT_UID 11 /* Real uid. */ -#define AT_EUID 12 /* Effective uid. */ -#define AT_GID 13 /* Real gid. */ -#define AT_EGID 14 /* Effective gid. */ +#define AT_NULL 0 /* Terminates the vector. */ +#define AT_IGNORE 1 /* Ignored entry. */ +#define AT_EXECFD 2 /* File descriptor of program to load. */ +#define AT_PHDR 3 /* Program header of program already loaded. */ +#define AT_PHENT 4 /* Size of each program header entry. */ +#define AT_PHNUM 5 /* Number of program header entries. */ +#define AT_PAGESZ 6 /* Page size in bytes. */ +#define AT_BASE 7 /* Interpreter's base address. */ +#define AT_FLAGS 8 /* Flags (unused). */ +#define AT_ENTRY 9 /* Where interpreter should transfer control. */ +#define AT_NOTELF 10 /* Program is not ELF ?? */ +#define AT_UID 11 /* Real uid. */ +#define AT_EUID 12 /* Effective uid. */ +#define AT_GID 13 /* Real gid. */ +#define AT_EGID 14 /* Effective gid. */ #define AT_EXECPATH 15 /* Path to the executable. */ #define AT_CANARY 16 /* Canary for SSP */ #define AT_CANARYLEN 17 /* Length of the canary. */ @@ -87,10 +87,11 @@ __ElfType(Auxinfo); #define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ #define AT_TIMEKEEP 22 /* Pointer to timehands. */ #define AT_STACKPROT 23 /* Initial stack protection. */ +#define AT_EHDRFLAGS 24 /* e_flags field from elf hdr */ -#define AT_COUNT 24 /* Count of defined aux entry types. */ +#define AT_COUNT 25 /* Count of defined aux entry types. */ -#define R_ARM_COUNT 33 /* Count of defined relocation types. */ +#define R_ARM_COUNT 33 /* Count of defined relocation types. */ /* Define "machine" characteristics */ @@ -104,16 +105,16 @@ __ElfType(Auxinfo); #define ELF_TARG_VER 1 /* Defines specific for arm headers */ -#define EF_ARM_EABI_VERSION(x) (((x) & EF_ARM_EABIMASK) >> 24) -#define EF_ARM_EABI_VERSION_UNKNOWN 0 -#define EF_ARM_EABI_FREEBSD_MIN 4 +#define EF_ARM_EABI_VERSION(x) (((x) & EF_ARM_EABIMASK) >> 24) +#define EF_ARM_EABI_VERSION_UNKNOWN 0 +#define EF_ARM_EABI_FREEBSD_MIN 4 /* * Magic number for the elf trampoline, chosen wisely to be an immediate * value. */ -#define MAGIC_TRAMP_NUMBER 0x5c000003 +#define MAGIC_TRAMP_NUMBER 0x5c000003 -#define ET_DYN_LOAD_ADDR 0x12000 +#define ET_DYN_LOAD_ADDR 0x12000 #endif /* !_MACHINE_ELF_H_ */ diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 3ff3440..ca0048a 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -972,6 +972,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) elf_auxargs->base = addr; elf_auxargs->flags = 0; elf_auxargs->entry = entry; + elf_auxargs->hdr_eflags = hdr->e_flags; imgp->auxargs = elf_auxargs; imgp->interpreted = 0; @@ -1002,6 +1003,9 @@ __elfN(freebsd_fixup)(register_t **stack_base, struct image_params *imgp) AUXARGS_ENTRY(pos, AT_FLAGS, args->flags); AUXARGS_ENTRY(pos, AT_ENTRY, args->entry); AUXARGS_ENTRY(pos, AT_BASE, args->base); +#ifdef AT_EHDREFLAGS + AUXARGS_ENTRY(pos, AT_EHDRFLAGS, args->hdr_eflags); +#endif if (imgp->execpathp != 0) AUXARGS_ENTRY(pos, AT_EXECPATH, imgp->execpathp); AUXARGS_ENTRY(pos, AT_OSRELDATE, diff --git a/sys/sys/imgact_elf.h b/sys/sys/imgact_elf.h index e8d5567..d1d4f21 100644 --- a/sys/sys/imgact_elf.h +++ b/sys/sys/imgact_elf.h @@ -52,6 +52,7 @@ typedef struct { Elf_Size base; Elf_Size flags; Elf_Size entry; + Elf_Word hdr_eflags; /* e_flags field from ehdr */ } __ElfN(Auxargs); typedef struct { |