Commit fce244762775f662f5a278a05a6e494b6e4f2774

Authored by Mark Salter
1 parent 18d14704d6

C6X: add support to build with BINFMT_ELF_FDPIC

C6x userspace supports a shared library mechanism called DSBT for systems with
no MMU. DSBT is similar to FDPIC in allowing shared text segments and private
copies of data segments without an MMU. Both methods access data using a base
register and offset. With FDPIC, the caller of an external function sets up the
base register for the callee. With DSBT, the called function sets up its own
base register. Other details differ but both userspaces need the same thing
from the kernel loader: a map of where each ELF segment was loaded. The FDPIC
loader already provides this, so DSBT just uses it.

This patch enables BINFMT_ELF_FDPIC by default for C6X and provides the
necessary architecture hooks for the generic loader.

Signed-off-by: Mark Salter <msalter@redhat.com>

Showing 4 changed files with 23 additions and 2 deletions Side-by-side Diff

arch/c6x/include/asm/elf.h
... ... @@ -30,7 +30,19 @@
30 30 */
31 31 #define elf_check_arch(x) ((x)->e_machine == EM_TI_C6000)
32 32  
33   -#define elf_check_const_displacement(x) (1)
  33 +#define elf_check_fdpic(x) (1)
  34 +#define elf_check_const_displacement(x) (0)
  35 +
  36 +#define ELF_FDPIC_PLAT_INIT(_regs, _exec_map, _interp_map, _dynamic_addr) \
  37 +do { \
  38 + _regs->b4 = (_exec_map); \
  39 + _regs->a6 = (_interp_map); \
  40 + _regs->b6 = (_dynamic_addr); \
  41 +} while (0)
  42 +
  43 +#define ELF_FDPIC_CORE_EFLAGS 0
  44 +
  45 +#define ELF_CORE_COPY_FPREGS(...) 0 /* No FPU regs to copy */
34 46  
35 47 /*
36 48 * These are used to set parameters in the core dumps.
arch/c6x/include/asm/mmu.h
... ... @@ -13,6 +13,10 @@
13 13  
14 14 typedef struct {
15 15 unsigned long end_brk;
  16 +#ifdef CONFIG_BINFMT_ELF_FDPIC
  17 + unsigned long exec_fdpic_loadmap;
  18 + unsigned long interp_fdpic_loadmap;
  19 +#endif
16 20 } mm_context_t;
17 21  
18 22 #endif /* _ASM_C6X_MMU_H */
arch/c6x/include/asm/ptrace.h
... ... @@ -97,6 +97,11 @@
97 97 #define PT_DP PT_B14 /* Data Segment Pointer (B14) */
98 98 #define PT_SP PT_B15 /* Stack Pointer (B15) */
99 99  
  100 +#define PTRACE_GETFDPIC 31 /* get the ELF fdpic loadmap address */
  101 +
  102 +#define PTRACE_GETFDPIC_EXEC 0 /* [addr] request the executable loadmap */
  103 +#define PTRACE_GETFDPIC_INTERP 1 /* [addr] request the interpreter loadmap */
  104 +
100 105 #ifndef __ASSEMBLY__
101 106  
102 107 #ifdef _BIG_ENDIAN
... ... @@ -33,7 +33,7 @@
33 33 config BINFMT_ELF_FDPIC
34 34 bool "Kernel support for FDPIC ELF binaries"
35 35 default y
36   - depends on (FRV || BLACKFIN || (SUPERH32 && !MMU))
  36 + depends on (FRV || BLACKFIN || (SUPERH32 && !MMU) || C6X)
37 37 help
38 38 ELF FDPIC binaries are based on ELF, but allow the individual load
39 39 segments of a binary to be located in memory independently of each