Commit ebd99675 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] H8/300: pic support

From: Yoshinori Sato <ysato@users.sourceforge.jp>

- add PIC binary support
parent e51c5d04
...@@ -192,6 +192,7 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext *usc, void *fp, ...@@ -192,6 +192,7 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext *usc, void *fp,
regs->er1 = context.sc_er1; regs->er1 = context.sc_er1;
regs->er2 = context.sc_er2; regs->er2 = context.sc_er2;
regs->er3 = context.sc_er3; regs->er3 = context.sc_er3;
regs->er5 = context.sc_er5;
regs->ccr = (regs->ccr & 0x10)|(context.sc_ccr & 0xef); regs->ccr = (regs->ccr & 0x10)|(context.sc_ccr & 0xef);
regs->pc = context.sc_pc; regs->pc = context.sc_pc;
regs->orig_er0 = -1; /* disable syscall checks */ regs->orig_er0 = -1; /* disable syscall checks */
...@@ -308,6 +309,7 @@ static void setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs, ...@@ -308,6 +309,7 @@ static void setup_sigcontext(struct sigcontext *sc, struct pt_regs *regs,
sc->sc_er1 = regs->er1; sc->sc_er1 = regs->er1;
sc->sc_er2 = regs->er2; sc->sc_er2 = regs->er2;
sc->sc_er3 = regs->er3; sc->sc_er3 = regs->er3;
sc->sc_er5 = regs->er5;
sc->sc_ccr = regs->ccr; sc->sc_ccr = regs->ccr;
sc->sc_pc = regs->pc; sc->sc_pc = regs->pc;
} }
...@@ -384,6 +386,7 @@ static void setup_frame (int sig, struct k_sigaction *ka, ...@@ -384,6 +386,7 @@ static void setup_frame (int sig, struct k_sigaction *ka,
? current_thread_info()->exec_domain->signal_invmap[sig] ? current_thread_info()->exec_domain->signal_invmap[sig]
: sig); : sig);
regs->er1 = (unsigned long)&(frame->sc); regs->er1 = (unsigned long)&(frame->sc);
regs->er5 = current->mm->start_data; /* GOT base */
return; return;
...@@ -435,6 +438,7 @@ static void setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info, ...@@ -435,6 +438,7 @@ static void setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info,
: sig); : sig);
regs->er1 = (unsigned long)&(frame->info); regs->er1 = (unsigned long)&(frame->info);
regs->er2 = (unsigned long)&frame->uc; regs->er2 = (unsigned long)&frame->uc;
regs->er5 = current->mm->start_data; /* GOT base */
return; return;
......
...@@ -723,7 +723,7 @@ static int load_flat_file(struct linux_binprm * bprm, ...@@ -723,7 +723,7 @@ static int load_flat_file(struct linux_binprm * bprm,
return -ENOEXEC; return -ENOEXEC;
/* Get the pointer's value. */ /* Get the pointer's value. */
addr = flat_get_addr_from_rp(rp, relval); addr = flat_get_addr_from_rp(rp, relval, flags);
if (addr != 0) { if (addr != 0) {
/* /*
* Do the relocation. PIC relocs in the data section are * Do the relocation. PIC relocs in the data section are
......
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
*/ */
#define flat_get_relocate_addr(rel) (rel) #define flat_get_relocate_addr(rel) (rel)
#define flat_get_addr_from_rp(rp, relval) (get_unaligned(rp) & 0x0ffffff) #define flat_get_addr_from_rp(rp, relval, flags) \
(get_unaligned(rp) & ((flags & FLAT_FLAG_GOTPIC) ? 0xffffffff: 0x00ffffff))
#define flat_put_addr_at_rp(rp, addr, rel) \ #define flat_put_addr_at_rp(rp, addr, rel) \
put_unaligned (((*(char *)(rp)) << 24) | ((addr) & 0x00ffffff), rp) put_unaligned (((*(char *)(rp)) << 24) | ((addr) & 0x00ffffff), rp)
......
...@@ -23,12 +23,12 @@ ...@@ -23,12 +23,12 @@
#include <asm/ptrace.h> #include <asm/ptrace.h>
#include <asm/current.h> #include <asm/current.h>
extern inline unsigned long rdusp(void) { static inline unsigned long rdusp(void) {
extern unsigned int sw_usp; extern unsigned int sw_usp;
return(sw_usp); return(sw_usp);
} }
extern inline void wrusp(unsigned long usp) { static inline void wrusp(unsigned long usp) {
extern unsigned int sw_usp; extern unsigned int sw_usp;
sw_usp = usp; sw_usp = usp;
} }
...@@ -62,8 +62,14 @@ struct thread_struct { ...@@ -62,8 +62,14 @@ struct thread_struct {
}; };
#define INIT_THREAD { \ #define INIT_THREAD { \
sizeof(init_stack) + (unsigned long) init_stack, 0, \ .ksp = sizeof(init_stack) + (unsigned long)init_stack, \
PS_S, 0, {(unsigned short *)-1, 0}, \ .usp = 0, \
.ccr = PS_S, \
.esp0 = 0, \
.breakinfo = { \
.addr = (unsigned short *)-1, \
.inst = 0 \
} \
} }
/* /*
...@@ -78,6 +84,7 @@ do { \ ...@@ -78,6 +84,7 @@ do { \
set_fs(USER_DS); /* reads from user space */ \ set_fs(USER_DS); /* reads from user space */ \
(_regs)->pc = (_pc); \ (_regs)->pc = (_pc); \
(_regs)->ccr &= 0x00; /* clear kernel flag */ \ (_regs)->ccr &= 0x00; /* clear kernel flag */ \
(_regs)->er5 = current->mm->start_data; /* GOT base */ \
wrusp((unsigned long)(_usp) - sizeof(unsigned long)*3); \ wrusp((unsigned long)(_usp) - sizeof(unsigned long)*3); \
} while(0) } while(0)
#endif #endif
...@@ -88,6 +95,7 @@ do { \ ...@@ -88,6 +95,7 @@ do { \
(_regs)->pc = (_pc); \ (_regs)->pc = (_pc); \
(_regs)->ccr = 0x00; /* clear kernel flag */ \ (_regs)->ccr = 0x00; /* clear kernel flag */ \
(_regs)->exr = 0x78; /* enable all interrupts */ \ (_regs)->exr = 0x78; /* enable all interrupts */ \
(_regs)->er5 = current->mm->start_data; /* GOT base */ \
/* 14 = space for retaddr(4), vector(4), er0(4) and ext(2) on stack */ \ /* 14 = space for retaddr(4), vector(4), er0(4) and ext(2) on stack */ \
wrusp(((unsigned long)(_usp)) - 14); \ wrusp(((unsigned long)(_usp)) - 14); \
} while(0) } while(0)
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#define flat_argvp_envp_on_stack() 1 #define flat_argvp_envp_on_stack() 1
#define flat_old_ram_flag(flags) (flags) #define flat_old_ram_flag(flags) (flags)
#define flat_reloc_valid(reloc, size) ((reloc) <= (size)) #define flat_reloc_valid(reloc, size) ((reloc) <= (size))
#define flat_get_addr_from_rp(rp, relval) get_unaligned(rp) #define flat_get_addr_from_rp(rp, relval, flags) get_unaligned(rp)
#define flat_put_addr_at_rp(rp, val, relval) put_unaligned(val,rp) #define flat_put_addr_at_rp(rp, val, relval) put_unaligned(val,rp)
#define flat_get_relocate_addr(rel) (rel) #define flat_get_relocate_addr(rel) (rel)
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#define flat_argvp_envp_on_stack() 1 #define flat_argvp_envp_on_stack() 1
#define flat_old_ram_flag(flags) (flags) #define flat_old_ram_flag(flags) (flags)
#define flat_reloc_valid(reloc, size) ((reloc) <= (size)) #define flat_reloc_valid(reloc, size) ((reloc) <= (size))
#define flat_get_addr_from_rp(rp, relval) get_unaligned(rp) #define flat_get_addr_from_rp(rp, relval, flags) get_unaligned(rp)
#define flat_put_addr_at_rp(rp, val, relval) put_unaligned(val,rp) #define flat_put_addr_at_rp(rp, val, relval) put_unaligned(val,rp)
#define flat_get_relocate_addr(rel) (rel) #define flat_get_relocate_addr(rel) (rel)
......
...@@ -45,7 +45,8 @@ flat_get_relocate_addr (unsigned long relval) ...@@ -45,7 +45,8 @@ flat_get_relocate_addr (unsigned long relval)
RELVAL is the raw relocation-table entry from which RP is derived. RELVAL is the raw relocation-table entry from which RP is derived.
For the v850, RP should always be half-word aligned. */ For the v850, RP should always be half-word aligned. */
static inline unsigned long flat_get_addr_from_rp (unsigned long *rp, static inline unsigned long flat_get_addr_from_rp (unsigned long *rp,
unsigned long relval) unsigned long relval,
unsigned long flags)
{ {
short *srp = (short *)rp; short *srp = (short *)rp;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment