Skip to content

Commit 50b2b2e

Browse files
author
Nicolas Pitre
committed
ARM: add ELF_FDPIC support
This includes the necessary code to recognise the FDPIC format on ARM and the ptrace command definitions used by the common ptrace code. Based on patches originally from Mickael Guene <mickael.guene@st.com>. Signed-off-by: Nicolas Pitre <nico@linaro.org> Acked-by: Mickael GUENE <mickael.guene@st.com> Tested-by: Vincent Abriou <vincent.abriou@st.com> Tested-by: Andras Szemzo <szemzo.andras@gmail.com>
1 parent 5c16595 commit 50b2b2e

4 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎arch/arm/include/asm/elf.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ struct elf32_hdr;
100100
extern int elf_check_arch(const struct elf32_hdr *);
101101
#define elf_check_arch elf_check_arch
102102

103+
#define ELFOSABI_ARM_FDPIC 65 /* ARM FDPIC platform */
104+
#define elf_check_fdpic(x) ((x)->e_ident[EI_OSABI] == ELFOSABI_ARM_FDPIC)
105+
#define elf_check_const_displacement(x) ((x)->e_flags & EF_ARM_PIC)
106+
#define ELF_FDPIC_CORE_EFLAGS 0
107+
103108
#define vmcore_elf64_check_arch(x) (0)
104109

105110
extern int arm_elf_read_implies_exec(int);
@@ -120,6 +125,13 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
120125
have no such handler. */
121126
#define ELF_PLAT_INIT(_r, load_addr) (_r)->ARM_r0 = 0
122127

128+
#define ELF_FDPIC_PLAT_INIT(_r, _exec_map_addr, _interp_map_addr, dynamic_addr) \
129+
do { \
130+
(_r)->ARM_r7 = _exec_map_addr; \
131+
(_r)->ARM_r8 = _interp_map_addr; \
132+
(_r)->ARM_r9 = dynamic_addr; \
133+
} while(0)
134+
123135
extern void elf_set_personality(const struct elf32_hdr *);
124136
#define SET_PERSONALITY(ex) elf_set_personality(&(ex))
125137

‎arch/arm/include/asm/mmu.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ typedef struct {
3333
*/
3434
typedef struct {
3535
unsigned long end_brk;
36+
#ifdef CONFIG_BINFMT_ELF_FDPIC
37+
unsigned long exec_fdpic_loadmap;
38+
unsigned long interp_fdpic_loadmap;
39+
#endif
3640
} mm_context_t;
3741

3842
#endif

‎arch/arm/include/uapi/asm/ptrace.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
#define PTRACE_SETVFPREGS 28
3232
#define PTRACE_GETHBPREGS 29
3333
#define PTRACE_SETHBPREGS 30
34+
#define PTRACE_GETFDPIC 31
35+
36+
#define PTRACE_GETFDPIC_EXEC 0
37+
#define PTRACE_GETFDPIC_INTERP 1
3438

3539
/*
3640
* PSR bits

‎fs/Kconfig.binfmt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ config ARCH_BINFMT_ELF_STATE
3535
config BINFMT_ELF_FDPIC
3636
bool "Kernel support for FDPIC ELF binaries"
3737
default y
38-
depends on (FRV || BLACKFIN || (SUPERH32 && !MMU) || C6X)
38+
depends on ((ARM && !MMU) || FRV || BLACKFIN || (SUPERH32 && !MMU) || C6X)
3939
select ELFCORE
4040
help
4141
ELF FDPIC binaries are based on ELF, but allow the individual load

0 commit comments

Comments
 (0)