Make libproc compilable on AArch64.

This commit is contained in:
br 2015-07-01 13:59:26 +00:00
parent 3b0892b249
commit 3f083caafb
2 changed files with 26 additions and 12 deletions

View File

@ -42,18 +42,24 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include "_libproc.h"
#if defined(__i386__) || defined(__amd64__)
#define BREAKPOINT_INSTR 0xcc /* int 0x3 */
#if defined(__aarch64__)
#define AARCH64_BRK 0xd4200000
#define AARCH64_BRK_IMM16_SHIFT 5
#define AARCH64_BRK_IMM16_VAL (0xd << AARCH64_BRK_IMM16_SHIFT)
#define BREAKPOINT_INSTR (AARCH64_BRK | AARCH64_BRK_IMM16_VAL)
#define BREAKPOINT_INSTR_SZ 4
#elif defined(__amd64__) || defined(__i386__)
#define BREAKPOINT_INSTR 0xcc /* int 0x3 */
#define BREAKPOINT_INSTR_SZ 1
#elif defined(__arm__)
#define BREAKPOINT_INSTR 0xe7ffffff /* bkpt */
#define BREAKPOINT_INSTR_SZ 4
#elif defined(__mips__)
#define BREAKPOINT_INSTR 0xd /* break */
#define BREAKPOINT_INSTR 0xd /* break */
#define BREAKPOINT_INSTR_SZ 4
#elif defined(__powerpc__)
#define BREAKPOINT_INSTR 0x7fe00008 /* trap */
#define BREAKPOINT_INSTR_SZ 4
#elif defined(__arm__)
#define BREAKPOINT_INSTR 0xe7ffffff /* bkpt */
#define BREAKPOINT_INSTR_SZ 4
#define BREAKPOINT_INSTR 0x7fe00008 /* trap */
#define BREAKPOINT_INSTR_SZ 4
#else
#error "Add support for your architecture"
#endif

View File

@ -54,7 +54,9 @@ proc_regget(struct proc_handle *phdl, proc_reg_t reg, unsigned long *regvalue)
return (-1);
switch (reg) {
case REG_PC:
#if defined(__amd64__)
#if defined(__aarch64__)
*regvalue = regs.elr;
#elif defined(__amd64__)
*regvalue = regs.r_rip;
#elif defined(__arm__)
*regvalue = regs.r_pc;
@ -67,7 +69,9 @@ proc_regget(struct proc_handle *phdl, proc_reg_t reg, unsigned long *regvalue)
#endif
break;
case REG_SP:
#if defined(__amd64__)
#if defined(__aarch64__)
*regvalue = regs.sp;
#elif defined(__amd64__)
*regvalue = regs.r_rsp;
#elif defined(__arm__)
*regvalue = regs.r_sp;
@ -101,7 +105,9 @@ proc_regset(struct proc_handle *phdl, proc_reg_t reg, unsigned long regvalue)
return (-1);
switch (reg) {
case REG_PC:
#if defined(__amd64__)
#if defined(__aarch64__)
regs.elr = regvalue;
#elif defined(__amd64__)
regs.r_rip = regvalue;
#elif defined(__arm__)
regs.r_pc = regvalue;
@ -114,7 +120,9 @@ proc_regset(struct proc_handle *phdl, proc_reg_t reg, unsigned long regvalue)
#endif
break;
case REG_SP:
#if defined(__amd64__)
#if defined(__aarch64__)
regs.sp = regvalue;
#elif defined(__amd64__)
regs.r_rsp = regvalue;
#elif defined(__arm__)
regs.r_sp = regvalue;