PERFORCE change 162958 for review

Arnar Mar Sig antab at FreeBSD.org
Thu May 28 18:13:15 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=162958

Change 162958 by antab at 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 <machine/asm.h>
 __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 <sys/types.h>
 #include <machine/reg.h>
 
 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:


More information about the p4-projects mailing list