From 810e7ea2895eb44ad65e692e3a913dd6a059fc4d Mon Sep 17 00:00:00 2001 From: matt Date: Sun, 16 Jan 2011 02:41:55 +0000 Subject: [PATCH] Add PIC_GOTSETUP and PIC_TOCSETUP which replace the old methods to get the GOT (via a bl) to the new REL16 based relocs. This is another step to supporting secure plt. --- sys/arch/powerpc/include/asm.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/sys/arch/powerpc/include/asm.h b/sys/arch/powerpc/include/asm.h index 3797540800c1..26104f1f82fc 100644 --- a/sys/arch/powerpc/include/asm.h +++ b/sys/arch/powerpc/include/asm.h @@ -1,4 +1,4 @@ -/* $NetBSD: asm.h,v 1.31 2011/01/15 07:23:49 matt Exp $ */ +/* $NetBSD: asm.h,v 1.32 2011/01/16 02:41:55 matt Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -46,6 +46,24 @@ #define PIC_PROLOGUE XXX #define PIC_EPILOGUE XXX #define PIC_PLT(x) x@plt +#ifdef __STDC__ +#define PIC_TOCNAME(name) .LCTOC_##name +#else +#define PIC_TOCNAME(name) .LCTOC_/**/name +#endif +#define PIC_TOCSETUP(name, reg) \ + .pushsection ".got2","aw" ;\ + PIC_TOCNAME(name) = . + 32768 ;\ + .popsection ;\ + bcl 20,31,1001f ;\ + 1001: mflr reg ;\ + addis reg,reg,PIC_TOCNAME(name)-1001b@ha ;\ + addi reg,reg,PIC_TOCNAME(name)-1001b@l +#define PIC_GOTSETUP(reg) \ + bcl 20,31,2002f ;\ + 2002: mflr reg ;\ + addis reg,reg,_GLOBAL_OFFSET_TABLE_-2002b@ha ;\ + addi reg,reg,_GLOBAL_OFFSET_TABLE_-2002b@l #ifdef __STDC__ #define PIC_GOT(x) XXX #define PIC_GOTOFF(x) XXX @@ -59,6 +77,8 @@ #define PIC_PLT(x) x #define PIC_GOT(x) x #define PIC_GOTOFF(x) x +#define PIC_GOTSETUP(r) +#define PIC_TOCSETUP(n, r) #endif #endif