From owner-p4-projects@FreeBSD.ORG Thu May 28 18:13:14 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 730E51065674; Thu, 28 May 2009 18:13:14 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 303F1106566C for ; Thu, 28 May 2009 18:13:13 +0000 (UTC) (envelope-from antab@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id ED8A88FC1F for ; Thu, 28 May 2009 18:13:12 +0000 (UTC) (envelope-from antab@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n4SIDCsm079655 for ; Thu, 28 May 2009 18:13:12 GMT (envelope-from antab@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n4SIDChX079653 for perforce@freebsd.org; Thu, 28 May 2009 18:13:12 GMT (envelope-from antab@FreeBSD.org) Date: Thu, 28 May 2009 18:13:12 GMT Message-Id: <200905281813.n4SIDChX079653@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to antab@FreeBSD.org using -f From: Arnar Mar Sig To: Perforce Change Reviews Cc: Subject: PERFORCE change 162958 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 May 2009 18:13:15 -0000 http://perforce.freebsd.org/chv.cgi?CH=162958 Change 162958 by antab@antab_farm on 2009/05/28 18:12:20 Try to get dynamic linked executables to work, however binutils is broken and does not generate working shared exectuables and libraries. All RELA entries and GOT are zeroed. Affected files ... .. //depot/projects/avr32/src/lib/csu/avr32/crt1.c#5 edit .. //depot/projects/avr32/src/libexec/rtld-elf/avr32/rtld_start.S#2 edit .. //depot/projects/avr32/src/sys/avr32/avr32/elf_machdep.c#4 edit .. //depot/projects/avr32/src/sys/avr32/avr32/pm_machdep.c#10 edit .. //depot/projects/avr32/src/sys/avr32/avr32/switch.S#14 edit .. //depot/projects/avr32/src/sys/avr32/include/signal.h#5 edit .. //depot/projects/avr32/src/usr.bin/elfdump/elfdump.c#2 edit Differences ... ==== //depot/projects/avr32/src/lib/csu/avr32/crt1.c#5 (text+ko) ==== @@ -56,7 +56,7 @@ extern void _fini(void); extern void _init(void); extern int main(int, char **, char **); -extern void _start(char **ap, struct ps_strings *, fptr cleanup); +extern void _start(char **ap, struct ps_strings *, fptr cleanup) __attribute__((naked)); #ifdef GCRT extern void _mcleanup(void); @@ -77,6 +77,14 @@ char **env; const char *s; + /* + * _start has no prolog and the first 2 arguments ar passed in r6-r5 + */ + __asm __volatile( + "mov r12, r6\n" + "mov r11, r5\n" + ); + argc = *(long *)(void *)ap; argv = ap + 1; env = ap + 2 + argc; ==== //depot/projects/avr32/src/libexec/rtld-elf/avr32/rtld_start.S#2 (text+ko) ==== @@ -27,11 +27,39 @@ #include __FBSDID("$FreeBSD: $"); - .text - .align 0 - .globl .rtld_start - .type .rtld_start,%function +.text +.extern _GLOBAL_OFFSET_TABLE_ +.extern _DYNAMIC + +/* + * r5 stack + * r4 ps_strings + */ ENTRY(.rtld_start) + lddpc r12, 1f + lddpc r11, 2f + rjmp 3f +1: .word _DYNAMIC - (. + 8) +2: .word _GLOBAL_OFFSET_TABLE_ - (. + 8) +3: add r12, pc + nop + add r11, pc + rcall _C_LABEL(_rtld_relocate_nonplt_self) + + breakpoint + mov r12, r6 /* Stack is first argument */ + sub r11, sp, 4 /* &exit_proc (cleanup) */ + sub r10, sp, 8 /* &objp */ + sub sp, 8 /* Make room for arguments */ + rcall _C_LABEL(_rtld) /* _rtld(sp, &exit_proc, &objp) */ + breakpoint + + /* + * Load cleanup argument and jump to entry, first 2 arguments + * to _start() are stored in r7-r6 + */ + ldm sp++, r10,pc /* Load cleanup argument and jump to entry */ + breakpoint END(.rtld_start) ==== //depot/projects/avr32/src/sys/avr32/avr32/elf_machdep.c#4 (text+ko) ==== @@ -85,7 +85,11 @@ .emul_path = NULL, .interp_path = "/libexec/ld-elf.so.1", .sysvec = &elf32_freebsd_sysvec, - .interp_newpath = NULL, + /* + * toolchain sets PT_INTERP to "--relax", and i have no idea why, + * this will force the right loader + */ + .interp_newpath = "/libexec/ld-elf.so.1", .brand_note = &elf32_freebsd_brandnote, .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE }; ==== //depot/projects/avr32/src/sys/avr32/avr32/pm_machdep.c#10 (text+ko) ==== @@ -81,9 +81,8 @@ { /* Clear frame and set init register values, SP must be word aligned */ bzero((char *)td->td_frame, sizeof(struct trapframe)); - td->td_frame->regs.r10 = 0; - td->td_frame->regs.r11 = ps_strings; - td->td_frame->regs.r12 = stack; + td->td_frame->regs.r5 = ps_strings; + td->td_frame->regs.r6 = stack; td->td_frame->regs.sp = ((register_t)stack) & ~(sizeof(register_t) - 1); td->td_frame->regs.pc = entry; ==== //depot/projects/avr32/src/sys/avr32/avr32/switch.S#14 (text+ko) ==== ==== //depot/projects/avr32/src/sys/avr32/include/signal.h#5 (text+ko) ==== @@ -41,6 +41,7 @@ #if __BSD_VISIBLE +#include #include struct sigcontext { ==== //depot/projects/avr32/src/usr.bin/elfdump/elfdump.c#2 (text+ko) ==== @@ -233,6 +233,7 @@ case 0x6ffffff0: return "DT_GNU_VERSYM"; /* 0x70000000 - 0x7fffffff processor-specific semantics */ case 0x70000000: return "DT_IA_64_PLT_RESERVE"; + case 0x70000001: return "DT_AVR32_GOTSZ"; case 0x7ffffffd: return "DT_SUNW_AUXILIARY"; case 0x7ffffffe: return "DT_SUNW_USED"; case 0x7fffffff: return "DT_SUNW_FILTER"; @@ -257,6 +258,7 @@ case EM_PPC: return "EM_PPC"; case EM_ARM: return "EM_ARM"; case EM_ALPHA: return "EM_ALPHA (legacy)"; + case EM_AVR32: return "EM_AVR32"; case EM_SPARCV9:return "EM_SPARCV9"; case EM_IA_64: return "EM_IA_64"; case EM_X86_64: return "EM_X86_64"; @@ -772,6 +774,7 @@ case DT_RELSZ: case DT_RELENT: case DT_PLTREL: + case DT_AVR32_GOTSZ: fprintf(out, "\td_val: %jd\n", (intmax_t)val); break; case DT_PLTGOT: