Author: imp
Date: Fri May 22 20:50:35 2015
New Revision: 283297
URL: https://svnweb.freebsd.org/changeset/base/283297

Log:
  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

Modified:
  head/sys/arm/include/elf.h
  head/sys/kern/imgact_elf.c
  head/sys/sys/imgact_elf.h

Modified: head/sys/arm/include/elf.h
==============================================================================
--- head/sys/arm/include/elf.h  Fri May 22 19:04:06 2015        (r283296)
+++ head/sys/arm/include/elf.h  Fri May 22 20:50:35 2015        (r283297)
@@ -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_ */

Modified: head/sys/kern/imgact_elf.c
==============================================================================
--- head/sys/kern/imgact_elf.c  Fri May 22 19:04:06 2015        (r283296)
+++ head/sys/kern/imgact_elf.c  Fri May 22 20:50:35 2015        (r283297)
@@ -972,6 +972,7 @@ __CONCAT(exec_, __elfN(imgact))(struct i
        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
        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,

Modified: head/sys/sys/imgact_elf.h
==============================================================================
--- head/sys/sys/imgact_elf.h   Fri May 22 19:04:06 2015        (r283296)
+++ head/sys/sys/imgact_elf.h   Fri May 22 20:50:35 2015        (r283297)
@@ -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 {
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to