Date: Thu, 28 Jan 2010 00:48:15 +0000 (UTC) From: Nathan Whitehorn <nwhitehorn@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r203101 - in projects/ppc64: etc/etc.powerpc64 gnu/usr.bin/cc gnu/usr.bin/gdb gnu/usr.bin/gdb/arch gnu/usr.bin/gdb/kgdb lib/bind lib/libc/powerpc64/gen lib/libdisk lib/libstand/powerpc6... Message-ID: <201001280048.o0S0mFc0078496@svn.freebsd.org>
index | next in thread | raw e-mail
Author: nwhitehorn Date: Thu Jan 28 00:48:15 2010 New Revision: 203101 URL: http://svn.freebsd.org/changeset/base/203101 Log: Initial hash at userland. This allows make buildworld TARGET_ARCH=powerpc64 to complete. Statically linked programs appear to partially work, but have intermittent problems with argument passing. RTLD segfaults. Added: projects/ppc64/etc/etc.powerpc64/ - copied from r202947, projects/ppc64/etc/etc.powerpc/ projects/ppc64/gnu/usr.bin/gdb/arch/powerpc64 (contents, props changed) projects/ppc64/gnu/usr.bin/gdb/kgdb/trgt_powerpc64.c - copied, changed from r202947, projects/ppc64/gnu/usr.bin/gdb/kgdb/trgt_powerpc.c projects/ppc64/lib/libstand/powerpc64/ - copied from r202947, projects/ppc64/lib/libstand/powerpc/ projects/ppc64/lib/libthread_db/arch/powerpc64/ - copied from r202947, projects/ppc64/lib/libthread_db/arch/powerpc/ projects/ppc64/libexec/rtld-elf/powerpc64/ - copied from r202947, projects/ppc64/libexec/rtld-elf/powerpc/ projects/ppc64/usr.bin/truss/powerpc64-fbsd.c - copied, changed from r202947, projects/ppc64/usr.bin/truss/powerpc-fbsd.c Modified: projects/ppc64/gnu/usr.bin/cc/Makefile.tgt projects/ppc64/gnu/usr.bin/gdb/Makefile.inc projects/ppc64/lib/bind/config.mk projects/ppc64/lib/libc/powerpc64/gen/_setjmp.S projects/ppc64/lib/libc/powerpc64/gen/setjmp.S projects/ppc64/lib/libc/powerpc64/gen/sigsetjmp.S projects/ppc64/lib/libdisk/Makefile projects/ppc64/lib/libthr/arch/powerpc64/include/pthread_md.h projects/ppc64/libexec/rtld-elf/Makefile projects/ppc64/libexec/rtld-elf/powerpc64/reloc.c projects/ppc64/libexec/rtld-elf/powerpc64/rtld_machdep.h projects/ppc64/libexec/rtld-elf/powerpc64/rtld_start.S projects/ppc64/rescue/rescue/Makefile projects/ppc64/sys/powerpc/include/_stdint.h projects/ppc64/sys/powerpc/include/profile.h projects/ppc64/usr.sbin/crunch/crunchide/Makefile projects/ppc64/usr.sbin/crunch/crunchide/exec_elf32.c projects/ppc64/usr.sbin/named/Makefile projects/ppc64/usr.sbin/pmcstat/pmcstat_log.c Modified: projects/ppc64/gnu/usr.bin/cc/Makefile.tgt ============================================================================== --- projects/ppc64/gnu/usr.bin/cc/Makefile.tgt Wed Jan 27 21:19:25 2010 (r203100) +++ projects/ppc64/gnu/usr.bin/cc/Makefile.tgt Thu Jan 28 00:48:15 2010 (r203101) @@ -22,3 +22,6 @@ TARGET_CPU_DEFAULT= TARGET_CPU_ultraspar TARGET_CPU_DEFAULT= \"powerpc64\" .endif +.if ${MACHINE_ARCH} == "powerpc64" +CFLAGS+= -mminimal-toc +.endif Modified: projects/ppc64/gnu/usr.bin/gdb/Makefile.inc ============================================================================== --- projects/ppc64/gnu/usr.bin/gdb/Makefile.inc Wed Jan 27 21:19:25 2010 (r203100) +++ projects/ppc64/gnu/usr.bin/gdb/Makefile.inc Thu Jan 28 00:48:15 2010 (r203101) @@ -38,6 +38,10 @@ CFLAGS+= -I${CNTRB_GDB}/include CFLAGS+= -I${CNTRB_BU}/include CFLAGS+= -I${CNTRB_BU}/bfd +.if ${MACHINE_ARCH} == "powerpc64" +CFLAGS+= -mminimal-toc +.endif + GENSRCS+= nm.h tm.h .if defined(GDB_CROSS_DEBUGGER) Added: projects/ppc64/gnu/usr.bin/gdb/arch/powerpc64 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/ppc64/gnu/usr.bin/gdb/arch/powerpc64 Thu Jan 28 00:48:15 2010 (r203101) @@ -0,0 +1 @@ +link powerpc \ No newline at end of file Copied and modified: projects/ppc64/gnu/usr.bin/gdb/kgdb/trgt_powerpc64.c (from r202947, projects/ppc64/gnu/usr.bin/gdb/kgdb/trgt_powerpc.c) ============================================================================== --- projects/ppc64/gnu/usr.bin/gdb/kgdb/trgt_powerpc.c Sun Jan 24 20:15:59 2010 (r202947, copy source) +++ projects/ppc64/gnu/usr.bin/gdb/kgdb/trgt_powerpc64.c Thu Jan 28 00:48:15 2010 (r203101) @@ -72,6 +72,8 @@ kgdb_trgt_fetch_registers(int regno __un /* r1 is saved in the sp field */ supply_register(tdep->ppc_gp0_regnum + 1, (char *)&pcb.pcb_sp); + /* r2 is saved in the toc field */ + supply_register(tdep->ppc_gp0_regnum + 2, (char *)&pcb.pcb_toc); supply_register(tdep->ppc_lr_regnum, (char *)&pcb.pcb_lr); supply_register(tdep->ppc_cr_regnum, (char *)&pcb.pcb_cr); @@ -160,7 +162,7 @@ kgdb_trgt_trapframe_prev_register(struct return; cache = kgdb_trgt_frame_cache(next_frame, this_cache); - *addrp = cache->sp + 8 + ofs; + *addrp = cache->sp + 48 + ofs; *lvalp = lval_memory; target_read_memory(*addrp, valuep, regsz); } Modified: projects/ppc64/lib/bind/config.mk ============================================================================== --- projects/ppc64/lib/bind/config.mk Wed Jan 27 21:19:25 2010 (r203100) +++ projects/ppc64/lib/bind/config.mk Thu Jan 28 00:48:15 2010 (r203101) @@ -45,7 +45,7 @@ CFLAGS+= -DOPENSSL CFLAGS+= -DUSE_MD5 # Endianness -.if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "sparc64" +.if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpc64" || ${MACHINE_ARCH} == "sparc64" CFLAGS+= -DWORDS_BIGENDIAN .endif @@ -66,6 +66,8 @@ CFLAGS+= -I${LIB_BIND_DIR} # Use the right version of the atomic.h file from lib/isc .if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" ISC_ATOMIC_ARCH= x86_32 +.elif ${MACHINE_ARCH} == "powerpc64" +ISC_ATOMIC_ARCH= powerpc .else ISC_ATOMIC_ARCH= ${MACHINE_ARCH} .endif Modified: projects/ppc64/lib/libc/powerpc64/gen/_setjmp.S ============================================================================== --- projects/ppc64/lib/libc/powerpc64/gen/_setjmp.S Wed Jan 27 21:19:25 2010 (r203100) +++ projects/ppc64/lib/libc/powerpc64/gen/_setjmp.S Thu Jan 28 00:48:15 2010 (r203101) @@ -55,12 +55,57 @@ ENTRY(_setjmp) mfcr %r12 mr %r10,%r1 mr %r9,%r2 - stmw %r9,20(%r3) + std %r9,40 + 0*8(%r3) + std %r10,40 + 1*8(%r3) + std %r11,40 + 2*8(%r3) + std %r12,40 + 3*8(%r3) + std %r13,40 + 4*8(%r3) + std %r14,40 + 5*8(%r3) + std %r15,40 + 6*8(%r3) + std %r16,40 + 7*8(%r3) + std %r17,40 + 8*8(%r3) + std %r18,40 + 10*8(%r3) + std %r19,40 + 11*8(%r3) + std %r20,40 + 12*8(%r3) + std %r21,40 + 13*8(%r3) + std %r22,40 + 14*8(%r3) + std %r23,40 + 15*8(%r3) + std %r24,40 + 16*8(%r3) + std %r25,40 + 17*8(%r3) + std %r26,40 + 18*8(%r3) + std %r27,40 + 19*8(%r3) + std %r28,40 + 20*8(%r3) + std %r29,40 + 21*8(%r3) + std %r30,40 + 22*8(%r3) + std %r31,40 + 23*8(%r3) li %r3,0 blr ENTRY(_longjmp) - lmw %r9,20(%r3) + ld %r9,40 + 0*8(%r3) + ld %r10,40 + 1*8(%r3) + ld %r11,40 + 2*8(%r3) + ld %r12,40 + 3*8(%r3) + ld %r13,40 + 4*8(%r3) + ld %r14,40 + 5*8(%r3) + ld %r15,40 + 6*8(%r3) + ld %r16,40 + 7*8(%r3) + ld %r17,40 + 8*8(%r3) + ld %r18,40 + 10*8(%r3) + ld %r19,40 + 11*8(%r3) + ld %r20,40 + 12*8(%r3) + ld %r21,40 + 13*8(%r3) + ld %r22,40 + 14*8(%r3) + ld %r23,40 + 15*8(%r3) + ld %r24,40 + 16*8(%r3) + ld %r25,40 + 17*8(%r3) + ld %r26,40 + 18*8(%r3) + ld %r27,40 + 19*8(%r3) + ld %r28,40 + 20*8(%r3) + ld %r29,40 + 21*8(%r3) + ld %r30,40 + 22*8(%r3) + ld %r31,40 + 23*8(%r3) + mtlr %r11 mtcr %r12 mr %r2,%r9 Modified: projects/ppc64/lib/libc/powerpc64/gen/setjmp.S ============================================================================== --- projects/ppc64/lib/libc/powerpc64/gen/setjmp.S Wed Jan 27 21:19:25 2010 (r203100) +++ projects/ppc64/lib/libc/powerpc64/gen/setjmp.S Thu Jan 28 00:48:15 2010 (r203101) @@ -65,14 +65,62 @@ ENTRY(setjmp) mfcr %r12 /* r12 <- condition reg */ mr %r10,%r1 /* r10 <- stackptr */ mr %r9,%r2 /* r9 <- global ptr */ - stmw %r9,20(%r6) + + std %r9,40 + 0*8(%r6) + std %r10,40 + 1*8(%r6) + std %r11,40 + 2*8(%r6) + std %r12,40 + 3*8(%r6) + std %r13,40 + 4*8(%r6) + std %r14,40 + 5*8(%r6) + std %r15,40 + 6*8(%r6) + std %r16,40 + 7*8(%r6) + std %r17,40 + 8*8(%r6) + std %r18,40 + 10*8(%r6) + std %r19,40 + 11*8(%r6) + std %r20,40 + 12*8(%r6) + std %r21,40 + 13*8(%r6) + std %r22,40 + 14*8(%r6) + std %r23,40 + 15*8(%r6) + std %r24,40 + 16*8(%r6) + std %r25,40 + 17*8(%r6) + std %r26,40 + 18*8(%r6) + std %r27,40 + 19*8(%r6) + std %r28,40 + 20*8(%r6) + std %r29,40 + 21*8(%r6) + std %r30,40 + 22*8(%r6) + std %r31,40 + 23*8(%r6) + li %r3,0 /* return (0) */ blr .weak CNAME(longjmp) .set CNAME(longjmp),CNAME(__longjmp) + .weak CNAME(.longjmp) + .set CNAME(.longjmp),CNAME(.__longjmp) ENTRY(__longjmp) - lmw %r9,20(%r3) /* restore regs */ + ld %r9,40 + 0*8(%r3) + ld %r10,40 + 1*8(%r3) + ld %r11,40 + 2*8(%r3) + ld %r12,40 + 3*8(%r3) + ld %r13,40 + 4*8(%r3) + ld %r14,40 + 5*8(%r3) + ld %r15,40 + 6*8(%r3) + ld %r16,40 + 7*8(%r3) + ld %r17,40 + 8*8(%r3) + ld %r18,40 + 10*8(%r3) + ld %r19,40 + 11*8(%r3) + ld %r20,40 + 12*8(%r3) + ld %r21,40 + 13*8(%r3) + ld %r22,40 + 14*8(%r3) + ld %r23,40 + 15*8(%r3) + ld %r24,40 + 16*8(%r3) + ld %r25,40 + 17*8(%r3) + ld %r26,40 + 18*8(%r3) + ld %r27,40 + 19*8(%r3) + ld %r28,40 + 20*8(%r3) + ld %r29,40 + 21*8(%r3) + ld %r30,40 + 22*8(%r3) + ld %r31,40 + 23*8(%r3) mr %r6,%r4 /* save val param */ mtlr %r11 /* r11 -> link reg */ mtcr %r12 /* r12 -> condition reg */ Modified: projects/ppc64/lib/libc/powerpc64/gen/sigsetjmp.S ============================================================================== --- projects/ppc64/lib/libc/powerpc64/gen/sigsetjmp.S Wed Jan 27 21:19:25 2010 (r203100) +++ projects/ppc64/lib/libc/powerpc64/gen/sigsetjmp.S Thu Jan 28 00:48:15 2010 (r203101) @@ -70,12 +70,59 @@ ENTRY(sigsetjmp) mfcr %r12 mr %r10,%r1 mr %r9,%r2 - stmw %r9,20(%r6) + + std %r9,40 + 0*8(%r6) + std %r10,40 + 1*8(%r6) + std %r11,40 + 2*8(%r6) + std %r12,40 + 3*8(%r6) + std %r13,40 + 4*8(%r6) + std %r14,40 + 5*8(%r6) + std %r15,40 + 6*8(%r6) + std %r16,40 + 7*8(%r6) + std %r17,40 + 8*8(%r6) + std %r18,40 + 10*8(%r6) + std %r19,40 + 11*8(%r6) + std %r20,40 + 12*8(%r6) + std %r21,40 + 13*8(%r6) + std %r22,40 + 14*8(%r6) + std %r23,40 + 15*8(%r6) + std %r24,40 + 16*8(%r6) + std %r25,40 + 17*8(%r6) + std %r26,40 + 18*8(%r6) + std %r27,40 + 19*8(%r6) + std %r28,40 + 20*8(%r6) + std %r29,40 + 21*8(%r6) + std %r30,40 + 22*8(%r6) + std %r31,40 + 23*8(%r6) + li %r3,0 blr ENTRY(siglongjmp) - lmw %r9,20(%r3) + ld %r9,40 + 0*8(%r3) + ld %r10,40 + 1*8(%r3) + ld %r11,40 + 2*8(%r3) + ld %r12,40 + 3*8(%r3) + ld %r13,40 + 4*8(%r3) + ld %r14,40 + 5*8(%r3) + ld %r15,40 + 6*8(%r3) + ld %r16,40 + 7*8(%r3) + ld %r17,40 + 8*8(%r3) + ld %r18,40 + 10*8(%r3) + ld %r19,40 + 11*8(%r3) + ld %r20,40 + 12*8(%r3) + ld %r21,40 + 13*8(%r3) + ld %r22,40 + 14*8(%r3) + ld %r23,40 + 15*8(%r3) + ld %r24,40 + 16*8(%r3) + ld %r25,40 + 17*8(%r3) + ld %r26,40 + 18*8(%r3) + ld %r27,40 + 19*8(%r3) + ld %r28,40 + 20*8(%r3) + ld %r29,40 + 21*8(%r3) + ld %r30,40 + 22*8(%r3) + ld %r31,40 + 23*8(%r3) + lwz %r7,0(%r3) mr %r6,%r4 mtlr %r11 Modified: projects/ppc64/lib/libdisk/Makefile ============================================================================== --- projects/ppc64/lib/libdisk/Makefile Wed Jan 27 21:19:25 2010 (r203100) +++ projects/ppc64/lib/libdisk/Makefile Thu Jan 28 00:48:15 2010 (r203101) @@ -12,6 +12,8 @@ SRCS= blocks.c ${_change} chunk.c create rules.c write_disk.c .if ${MACHINE} == "sun4v" SRCS+= write_sparc64_disk.c +.elif ${MACHINE} == "powerpc64" +SRCS+= write_powerpc_disk.c .else SRCS+= write_${MACHINE}_disk.c .endif Modified: projects/ppc64/lib/libthr/arch/powerpc64/include/pthread_md.h ============================================================================== --- projects/ppc64/lib/libthr/arch/powerpc64/include/pthread_md.h Wed Jan 27 21:19:25 2010 (r203100) +++ projects/ppc64/lib/libthr/arch/powerpc64/include/pthread_md.h Thu Jan 28 00:48:15 2010 (r203101) @@ -44,7 +44,7 @@ /* * Variant I tcb. The structure layout is fixed, don't blindly * change it. - * %r2 points to end of the structure. + * %r13 points to end of the structure. */ struct tcb { void *tcb_dtv; Modified: projects/ppc64/libexec/rtld-elf/Makefile ============================================================================== --- projects/ppc64/libexec/rtld-elf/Makefile Wed Jan 27 21:19:25 2010 (r203100) +++ projects/ppc64/libexec/rtld-elf/Makefile Thu Jan 28 00:48:15 2010 (r203101) @@ -11,7 +11,11 @@ MAN= rtld.1 CSTD?= gnu99 CFLAGS+= -Wall -DFREEBSD_ELF -DIN_RTLD CFLAGS+= -I${.CURDIR}/${MACHINE_ARCH} -I${.CURDIR} +.if ${MACHINE_ARCH} == "powerpc64" +LDFLAGS+= -nostdlib -e _rtld_start +.else LDFLAGS+= -nostdlib -e .rtld_start +.endif WARNS?= 2 INSTALLFLAGS= -C -b PRECIOUSPROG= Modified: projects/ppc64/libexec/rtld-elf/powerpc64/reloc.c ============================================================================== --- projects/ppc64/libexec/rtld-elf/powerpc/reloc.c Sun Jan 24 20:15:59 2010 (r202947) +++ projects/ppc64/libexec/rtld-elf/powerpc64/reloc.c Thu Jan 28 00:48:15 2010 (r203101) @@ -43,9 +43,11 @@ #include "debug.h" #include "rtld.h" -#define _ppc_ha(x) ((((u_int32_t)(x) & 0x8000) ? \ - ((u_int32_t)(x) + 0x10000) : (u_int32_t)(x)) >> 16) -#define _ppc_la(x) ((u_int32_t)(x) & 0xffff) +struct funcdesc { + uint64_t addr; + uint64_t toc; + uint64_t env; +}; /* * Process the R_PPC_COPY relocations @@ -262,7 +264,7 @@ reloc_nonplt_object(Obj_Entry *obj_rtld, break; default: - _rtld_error("%s: Unsupported relocation type %d" + _rtld_error("%s: Unsupported relocation type %ld" " in non-PLT relocations\n", obj->path, ELF_R_TYPE(rela->r_info)); return (-1); @@ -321,8 +323,6 @@ static int reloc_plt_object(Obj_Entry *obj, const Elf_Rela *rela) { Elf_Word *where = (Elf_Word *)(obj->relocbase + rela->r_offset); - Elf_Addr *pltresolve; - Elf_Addr distance; int reloff; reloff = rela - obj->pltrela; @@ -331,22 +331,13 @@ reloc_plt_object(Obj_Entry *obj, const E return (-1); } - pltresolve = obj->pltgot + 8; - - distance = (Elf_Addr)pltresolve - (Elf_Addr)(where + 1); - dbg(" reloc_plt_object: where=%p,pltres=%p,reloff=%x,distance=%x", (void *)where, (void *)pltresolve, reloff, distance); - /* li r11,reloff */ - /* b pltresolve */ - where[0] = 0x39600000 | reloff; - where[1] = 0x48000000 | (distance & 0x03fffffc); - - /* - * The icache will be sync'd in init_pltgot, which is called - * after all the slots have been updated - */ + ((struct funcdesc *)(where))->addr = + (uint64_t)_rtld_powerpc64_pltresolve; + ((struct funcdesc *)(where))->toc = reloff; + ((struct funcdesc *)(where))->env = (uint64_t)obj; return (0); } @@ -430,9 +421,6 @@ Elf_Addr reloc_jmpslot(Elf_Addr *wherep, Elf_Addr target, const Obj_Entry *defobj, const Obj_Entry *obj, const Elf_Rel *rel) { - Elf_Addr offset; - const Elf_Rela *rela = (const Elf_Rela *) rel; - dbg(" reloc_jmpslot: where=%p, target=%p", (void *)wherep, (void *)target); @@ -441,112 +429,35 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr * a direct transfer to the now fully resolved function * address. */ - offset = target - (Elf_Addr)wherep; - if (abs(offset) < 32*1024*1024) { /* inside 32MB? */ - /* b value # branch directly */ - *wherep = 0x48000000 | (offset & 0x03fffffc); - __syncicache(wherep, 4); - } else { - Elf_Addr *pltcall, *jmptab; - int distance; - int N = obj->pltrelasize / sizeof(Elf_Rela); - int reloff = rela - obj->pltrela; - - if ((reloff < 0) || (reloff >= 0x8000)) { - return (-1); - } - - pltcall = obj->pltgot; - - dbg(" reloc_jmpslot: indir, reloff=%d, N=%d\n", - reloff, N); - - jmptab = obj->pltgot + 18 + N * 2; - jmptab[reloff] = target; - - distance = (Elf_Addr)pltcall - (Elf_Addr)(wherep + 1); - - /* li r11,reloff */ - /* b pltcall # use indirect pltcall routine */ - wherep[0] = 0x39600000 | reloff; - wherep[1] = 0x48000000 | (distance & 0x03fffffc); - __syncicache(wherep, 8); - } + memcpy(wherep, (void *)target, sizeof(struct funcdesc)); return (target); } - -/* - * Setup the plt glue routines. - */ -#define PLTCALL_SIZE 20 -#define PLTRESOLVE_SIZE 24 - void init_pltgot(Obj_Entry *obj) { - Elf_Word *pltcall, *pltresolve; - Elf_Word *jmptab; + struct funcdesc *pltcall; int N = obj->pltrelasize / sizeof(Elf_Rela); - pltcall = obj->pltgot; + pltcall = (struct funcdesc *)obj->pltgot; if (pltcall == NULL) { return; } /* - * From the SVR4 PPC ABI: - * - * 'The first 18 words (72 bytes) of the PLT are reserved for - * use by the dynamic linker. - * ... - * 'If the executable or shared object requires N procedure - * linkage table entries, the link editor shall reserve 3*N - * words (12*N bytes) following the 18 reserved words. The - * first 2*N of these words are the procedure linkage table - * entries themselves. The static linker directs calls to bytes - * (72 + (i-1)*8), for i between 1 and N inclusive. The remaining - * N words (4*N bytes) are reserved for use by the dynamic linker.' - */ - - /* - * Copy the absolute-call assembler stub into the first part of - * the reserved PLT area. + * Copy the function description into the PLT slot */ - memcpy(pltcall, _rtld_powerpc_pltcall, PLTCALL_SIZE); - - /* - * Determine the address of the jumptable, which is the dyn-linker - * reserved area after the call cells. Write the absolute address - * of the jumptable into the absolute-call assembler code so it - * can determine this address. - */ - jmptab = pltcall + 18 + N * 2; - pltcall[1] |= _ppc_ha(jmptab); /* addis 11,11,jmptab@ha */ - pltcall[2] |= _ppc_la(jmptab); /* lwz 11,jmptab@l(11) */ - - /* - * Skip down 32 bytes into the initial reserved area and copy - * in the standard resolving assembler call. Into this assembler, - * insert the absolute address of the _rtld_bind_start routine - * and the address of the relocation object. - */ - pltresolve = obj->pltgot + 8; - - memcpy(pltresolve, _rtld_powerpc_pltresolve, PLTRESOLVE_SIZE); - pltresolve[0] |= _ppc_ha(_rtld_bind_start); - pltresolve[1] |= _ppc_la(_rtld_bind_start); - pltresolve[3] |= _ppc_ha(obj); - pltresolve[4] |= _ppc_la(obj); + memcpy(pltcall, _rtld_powerpc64_pltresolve, sizeof(*pltcall)); /* - * Sync the icache for the byte range represented by the - * trampoline routines and call slots. + * Now fake the two arguments we get in the descriptor to + * pass information to the resolver. */ - __syncicache(pltcall, 72 + N * 8); + pltcall->toc = N; + pltcall->env = (uint64_t)obj; } void Modified: projects/ppc64/libexec/rtld-elf/powerpc64/rtld_machdep.h ============================================================================== --- projects/ppc64/libexec/rtld-elf/powerpc/rtld_machdep.h Sun Jan 24 20:15:59 2010 (r202947) +++ projects/ppc64/libexec/rtld-elf/powerpc64/rtld_machdep.h Thu Jan 28 00:48:15 2010 (r203101) @@ -57,8 +57,7 @@ void _rtld_bind_start(void); * PLT functions. Not really correct prototypes, but the * symbol values are needed. */ -void _rtld_powerpc_pltresolve(void); -void _rtld_powerpc_pltcall(void); +void _rtld_powerpc64_pltresolve(void); /* * TLS Modified: projects/ppc64/libexec/rtld-elf/powerpc64/rtld_start.S ============================================================================== --- projects/ppc64/libexec/rtld-elf/powerpc/rtld_start.S Sun Jan 24 20:15:59 2010 (r202947) +++ projects/ppc64/libexec/rtld-elf/powerpc64/rtld_start.S Thu Jan 28 00:48:15 2010 (r203101) @@ -34,53 +34,19 @@ .extern _GLOBAL_OFFSET_TABLE_ .extern _DYNAMIC -_ENTRY(.rtld_start) - stwu %r1,-48(%r1) /* 16-byte aligned stack for reg saves + +_ENTRY(_rtld_start) + stdu %r1,-96(%r1) /* 16-byte aligned stack for reg saves + exit_proc & obj _rtld args + backchain & lrsave stack frame */ - stw %r3,16(%r1) /* argc */ - stw %r4,20(%r1) /* argv */ - stw %r5,24(%r1) /* envp */ -/* stw %r6,28(%r1) *//* obj (always 0) */ -/* stw %r7,32(%r1) *//* cleanup (always 0) */ - stw %r8,36(%r1) /* ps_strings */ + std %r3,48(%r1) /* argc */ + std %r4,56(%r1) /* argv */ + std %r5,64(%r1) /* envp */ +/* std %r6,72(%r1) *//* obj (always 0) */ +/* std %r7,80(%r1) *//* cleanup (always 0) */ + std %r8,88(%r1) /* ps_strings */ - /* - * Perform initial relocation of ld-elf.so. Not as easy as it - * sounds. - * - perform small forward branch to put PC into link reg - * - use link-time constants to determine offset to the - * _DYNAMIC section and the GOT. Add these to the PC to - * convert to absolute addresses. - * - sync icache to allow execution of the SVR4 ABI-specified - * blrl instruction preceding the GOT - * - Use this instruction to determine the GOT absolute address - * - read GOT[0], which is the SVR4 ABI-specified link-time - * value of _DYNAMIC. Subtract this value from the absolute - * value to determine the load address - * - call reloc_non_plt_self() to fix up ld-elf.so's relocations - */ - bl 1f - .long _DYNAMIC-. - .long _GLOBAL_OFFSET_TABLE_-. /* branch lr + 4 */ -1: - mflr %r3 /* PC value at .long */ - lwz %r4,4(%r3) - add %r4,%r4,%r3 /* &_GLOBAL_OFFSET_TABLE-4, blrl insn. */ - dcbst %r0,%r4 /* sync i-cache with d-cache */ - sync - icbi %r0,%r4 - isync - - lwz %r4,0(%r3) /* offset to _DYNAMIC */ - add %r3,%r4,%r3 /* r3 = &_DYNAMIC, absolute value */ - - bl _GLOBAL_OFFSET_TABLE_@local-4 - mflr %r4 /* &_GLOBAL_OFFSET_TABLE_, absolute value */ - lwz %r4,0(%r4) /* linker &_DYNAMIC, from got[0] */ - subf %r4,%r4,%r3 /* subtract to calculate relocbase */ - - bl reloc_non_plt_self@plt /* reloc_non_plt_self(&_DYNAMIC,base) */ + bl .reloc_non_plt_self /* reloc_non_plt_self(&_DYNAMIC,base) */ + nop /* * The _rtld() function likes to see a stack layout containing @@ -89,25 +55,26 @@ _ENTRY(.rtld_start) * original stack layout has to be found by moving back a word * from the argv pointer. */ - lwz %r4,20(%r1) /* restore argv */ - addi %r3,%r4,-4 /* locate argc ptr, &argv[-1] */ + ld %r4,56(%r1) /* restore argv */ + addi %r3,%r4,-8 /* locate argc ptr, &argv[-1] */ - addi %r4,%r1,8 /* &exit_proc on stack */ - addi %r5,%r1,12 /* &obj_main on stack */ + addi %r4,%r1,16 /* &exit_proc on stack */ + addi %r5,%r1,24 /* &obj_main on stack */ - bl _rtld@plt /* &_start = _rtld(sp, &exit_proc, &obj_main)*/ + bl ._rtld /* &_start = _rtld(sp, &exit_proc, &obj_main)*/ + nop mtlr %r3 /* * Restore args, with new obj/exit proc */ - lwz %r3,16(%r1) /* argc */ - lwz %r4,20(%r1) /* argv */ - lwz %r5,24(%r1) /* envp */ - lwz %r6,12(%r1) /* obj */ - lwz %r7,8(%r1) /* exit proc */ - lwz %r8,36(%r1) /* ps_strings */ - addi %r1,%r1,48 /* restore original stackptr */ + ld %r3,48(%r1) /* argc */ + ld %r4,56(%r1) /* argv */ + ld %r5,64(%r1) /* envp */ + ld %r6,72(%r1) /* obj */ + ld %r7,80(%r1) /* exit proc */ + ld %r8,88(%r1) /* ps_strings */ + addi %r1,%r1,96 /* restore original stackptr */ blrl /* _start(argc, argv, envp, obj, cleanup, ps_strings) */ @@ -119,7 +86,7 @@ _ENTRY(.rtld_start) * * Call into the MI binder. This routine is reached via the PLT call cell, * and then _rtld_powerpc_pltresolve(). - * On entry, %r11 contains the index of the PLT cell, and %r12 contains + * On entry, %r13 contains the index of the PLT cell, and %r12 contains * a pointer to the ELF object for the file. * Save all registers, call into the binder to resolve and fixup the external * routine, and then transfer to the external routine on return. @@ -137,7 +104,8 @@ _ENTRY(_rtld_bind_start) mr %r3,%r12 # obj mulli %r4,%r11,12 # rela index * sizeof(Elf_Rela) - bl _rtld_bind@PLT # target addr = _rtld_bind(obj, reloff) + bl ._rtld_bind # target addr = _rtld_bind(obj, reloff) + nop mtctr %r3 # move absolute target addr into ctr lmw %r3,24(%r1) # restore r3-r31 @@ -152,43 +120,20 @@ _ENTRY(_rtld_bind_start) /* - * _rtld_powerpc_pltresolve() + * _rtld_powerpc64_pltresolve() * - * This routine is copied into the latter part of the 72-byte reserved - * area at the start of the PLT. The absolute address of the _rtld_bind_start - * routine, and the ELF object for the loaded file, are inserted into - * the code by the reloc.c:init_pltgot() routine. * The first time an external routine is called, the PLT slot will - * set up %r11 to the offset of the slot, and will jump to this routine. - * The ELF object is shifted into %r11, and _rtld_bind_start is called + * set up %r2 to the offset of the slot, and will jump to this routine. + * The ELF object is in %r11, and _rtld_bind_start is called * to complete the binding. */ -_ENTRY(_rtld_powerpc_pltresolve) - lis %r12,0 # lis 12,_rtld_bind_start@ha - addi %r12,%r12,0 # addi 12,12,_rtld_bind_start@l +_ENTRY(_rtld_powerpc64_pltresolve) + mr %r13,%r2 + ld %r2,40(%r1) + addis %r12,%r2,_rtld_bind_start@toc@ha + addi %r12,%r12,_rtld_bind_start@toc@l + ld %r2,8(%r12) + ld %r12,0(%r12) mtctr %r12 - lis %r12,0 # lis 12,obj@ha - addi %r12,%r12,0 # addi 12,12,obj@l bctr -/* - * _rtld_powerpc_pltcall() - * - * This routine is copied into the 72-byte reserved area at the - * start of the PLT. The reloc.c:init_pltgot() routine inserts - * the absolute address of the jumptable. - * Control is transferred to this routine when the binder has - * located the external routine, but determined that it is > 32Mb - * from the PLT slot. Code is inserted into the PLT slot to set up - * %r11 with the jumptable index, and jump to here, where the - * absolute address of the external routine is loaded from the - * jumptable and transferred to - */ -_ENTRY(_rtld_powerpc_pltcall) - slwi %r11,%r11,2 # jmptab offset = index * 4 - addis %r11,%r11,0 # addis 11,11,jmptab@ha - lwz %r11,0(%r11) # lwz 11,jmptab@l(11) - mtctr %r11 - bctr # (*jmptab[index])() - - Modified: projects/ppc64/rescue/rescue/Makefile ============================================================================== --- projects/ppc64/rescue/rescue/Makefile Wed Jan 27 21:19:25 2010 (r203100) +++ projects/ppc64/rescue/rescue/Makefile Thu Jan 28 00:48:15 2010 (r203101) @@ -47,7 +47,11 @@ CLEANFILES+= dhclient_FIXED # Define Makefile variable RESCUE CRUNCH_BUILDOPTS+= -DRESCUE # Define compile-time RESCUE symbol when compiling components +.if ${TARGET_ARCH} == powerpc64 +CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS=\"-DRESCUE -mminimal-toc\" +.else CRUNCH_BUILDOPTS+= CRUNCH_CFLAGS=-DRESCUE +.endif # An experiment that failed: try overriding bsd.lib.mk and bsd.prog.mk # rather than incorporating rescue-specific logic into standard files. Modified: projects/ppc64/sys/powerpc/include/_stdint.h ============================================================================== --- projects/ppc64/sys/powerpc/include/_stdint.h Wed Jan 27 21:19:25 2010 (r203100) +++ projects/ppc64/sys/powerpc/include/_stdint.h Thu Jan 28 00:48:15 2010 (r203101) @@ -80,13 +80,21 @@ #define INT8_MAX 0x7f #define INT16_MAX 0x7fff #define INT32_MAX 0x7fffffff +#ifdef __powerpc64__ +#define INT64_MAX 0x7fffffffffffffffL +#else #define INT64_MAX 0x7fffffffffffffffLL +#endif /* Maximum values of exact-width unsigned integer types. */ #define UINT8_MAX 0xff #define UINT16_MAX 0xffff #define UINT32_MAX 0xffffffffU +#ifdef __powerpc64__ +#define UINT64_MAX 0xffffffffffffffffUL +#else #define UINT64_MAX 0xffffffffffffffffULL +#endif /* * ISO/IEC 9899:1999 Modified: projects/ppc64/sys/powerpc/include/profile.h ============================================================================== --- projects/ppc64/sys/powerpc/include/profile.h Wed Jan 27 21:19:25 2010 (r203100) +++ projects/ppc64/sys/powerpc/include/profile.h Thu Jan 28 00:48:15 2010 (r203101) @@ -173,7 +173,11 @@ void __mcount(uintfptr_t frompc, uintfpt #else /* !_KERNEL */ +#ifdef __powerpc64__ +typedef u_long uintfptr_t; +#else typedef u_int uintfptr_t; +#endif #endif /* _KERNEL */ Copied and modified: projects/ppc64/usr.bin/truss/powerpc64-fbsd.c (from r202947, projects/ppc64/usr.bin/truss/powerpc-fbsd.c) ============================================================================== --- projects/ppc64/usr.bin/truss/powerpc-fbsd.c Sun Jan 24 20:15:59 2010 (r202947, copy source) +++ projects/ppc64/usr.bin/truss/powerpc64-fbsd.c Thu Jan 28 00:48:15 2010 (r203101) @@ -118,9 +118,6 @@ powerpc_syscall_entry(struct trussinfo * unsigned int regargs; struct syscall *sc; - /* Account for a 64-bit argument with corresponding alignment. */ - nargs += 2; - cpid = trussinfo->curthread->tid; clear_fsc(); @@ -137,14 +134,10 @@ powerpc_syscall_entry(struct trussinfo * regargs = NARGREG; syscall_num = regs.fixreg[0]; args = ®s.fixreg[3]; - if (syscall_num == SYS_syscall) { + if (syscall_num == SYS_syscall || syscall_num == SYS___syscall) { args = ®s.fixreg[4]; regargs -= 1; syscall_num = regs.fixreg[3]; - } else if (syscall_num == SYS___syscall) { - args = ®s.fixreg[5]; - regargs -= 2; - syscall_num = regs.fixreg[4]; } fsc.number = syscall_num; @@ -172,7 +165,7 @@ powerpc_syscall_entry(struct trussinfo * memmove(&fsc.args[0], args, regargs * sizeof(fsc.args[0])); iorequest.piod_op = PIOD_READ_D; - iorequest.piod_offs = (void *)(regs.fixreg[1] + 8); + iorequest.piod_offs = (void *)(regs.fixreg[1] + 48); iorequest.piod_addr = &fsc.args[regargs]; iorequest.piod_len = (nargs - regargs) * sizeof(fsc.args[0]); ptrace(PT_IO, cpid, (caddr_t)&iorequest, 0); @@ -292,14 +285,6 @@ powerpc_syscall_exit(struct trussinfo *t asprintf(&fsc.s_args[i], "0x%lx", fsc.args[i]); } else { /* - * On 32-bit big-endian, the low word of a 64-bit return is - * in the greater address. Switch to this. XXX note that - * print_syscall_ret can't handle 64-bit return values (llseek) - */ - if (sc->ret_type == 2) - retval = regs.fixreg[4]; - - /* * Here, we only look for arguments that have OUT masked in -- * otherwise, they were handled in the syscall_entry function. */ Modified: projects/ppc64/usr.sbin/crunch/crunchide/Makefile ============================================================================== --- projects/ppc64/usr.sbin/crunch/crunchide/Makefile Wed Jan 27 21:19:25 2010 (r203100) +++ projects/ppc64/usr.sbin/crunch/crunchide/Makefile Thu Jan 28 00:48:15 2010 (r203101) @@ -10,7 +10,7 @@ CFLAGS+=-DNLIST_AOUT SRCS+= exec_aout.c .endif -.if ${TARGET_ARCH} == ia64 || \ +.if ${TARGET_ARCH} == ia64 || ${TARGET_ARCH} == powerpc64 || \ ${TARGET_ARCH} == sparc64 || ${TARGET_ARCH} == amd64 CFLAGS+=-DNLIST_ELF64 SRCS+= exec_elf64.c Modified: projects/ppc64/usr.sbin/crunch/crunchide/exec_elf32.c ============================================================================== --- projects/ppc64/usr.sbin/crunch/crunchide/exec_elf32.c Wed Jan 27 21:19:25 2010 (r203100) +++ projects/ppc64/usr.sbin/crunch/crunchide/exec_elf32.c Thu Jan 28 00:48:15 2010 (r203101) @@ -176,6 +176,10 @@ ELFNAMEEND(check)(int fd, const char *fn #define EM_PPC 20 #endif case EM_PPC: break; +#ifndef EM_PPC64 +#define EM_PPC64 21 +#endif + case EM_PPC64: break; #ifndef EM_SPARCV9 #define EM_SPARCV9 43 #endif Modified: projects/ppc64/usr.sbin/named/Makefile ============================================================================== --- projects/ppc64/usr.sbin/named/Makefile Wed Jan 27 21:19:25 2010 (r203100) +++ projects/ppc64/usr.sbin/named/Makefile Thu Jan 28 00:48:15 2010 (r203101) @@ -48,6 +48,10 @@ CFLAGS+= -DCONFIGARGS="\"${CONFIGARGS}\" CFLAGS+= -I${SRCDIR}/unix/include -I${SRCDIR}/include -I${LIB_BIND_DIR} CFLAGS+= -I${BIND_DIR}/lib/isc/${ISC_ATOMIC_ARCH}/include +.if ${MACHINE_ARCH} == powerpc64 +CFLAGS+= -mminimal-toc +.endif + # Remove the date stamp to make it more obvious when real changes happen CFLAGS+= -U__DATE__ Modified: projects/ppc64/usr.sbin/pmcstat/pmcstat_log.c ============================================================================== --- projects/ppc64/usr.sbin/pmcstat/pmcstat_log.c Wed Jan 27 21:19:25 2010 (r203100) +++ projects/ppc64/usr.sbin/pmcstat/pmcstat_log.c Thu Jan 28 00:48:15 2010 (r203101) @@ -1965,6 +1965,9 @@ pmcstat_callgraph_do_gmon_arcs(void) * callgraph is generated if FLAG_DO_CALLGRAPHS is set. gmon.out * files usable by gprof(1) are created if FLAG_DO_GPROF is set. */ + +int foo[sizeof(uintfptr_t) - 7]; + static int pmcstat_analyze_log(struct pmcstat_args *a) {help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001280048.o0S0mFc0078496>
