tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: lib/csu and compilers other than GCC



Hi all,
this is the second iteration of moving ahead with the CSU code.

- Split crt0.c into the assembler stub and the shared C module.
- Slightly modify the ELF linker script to provide __eprol directly.
- Use genassym to compute most of sysident code. I plan to drop the
  copy in ld.so_elf at a some point later, it is essentially the same.
  The only hard-coded constants are some strings as genassym can't
  extract strings yet.
- crti.o and crtn.o are now assembler files as well. This replaces the
  dot_init.h file which had essentially the same content.
- crtbegin.S and crtend.S are implemented for i386 and amd64. I'm going
  with the plain csu/i386, but I have no strong opinion on the name.
  The Makefile diff is primary intended to increase robustness.

I have committed test cases for the major functions
(/usr/tests/lib/csu).

Not included is the change to GCC's and PCC's build system to skip the
crtstuff in those places for architectures that use the new layout.

Joerg
Index: Makefile
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/csu/Makefile,v
retrieving revision 1.26
diff -u -p -r1.26 Makefile
--- Makefile    5 Jul 2010 21:27:55 -0000       1.26
+++ Makefile    31 Jul 2010 07:15:00 -0000
@@ -2,15 +2,17 @@
 
 .include <bsd.own.mk>
 
-.if exists(${CSU_MACHINE_ARCH}_elf)
+.if exists(${CSU_MACHINE_ARCH}_elf/Makefile)
 SUBDIR=        ${CSU_MACHINE_ARCH}_elf
-.elif exists(${MACHINE_ARCH}_elf)
+.elif exists(${CSU_MACHINE_ARCH}/Makefile)
+SUBDIR=        ${CSU_MACHINE_ARCH}
+.elif exists(${MACHINE_ARCH}_elf/Makefile)
 SUBDIR=        ${MACHINE_ARCH}_elf
-.elif exists(${MACHINE_CPU}_elf)
+.elif exists(${MACHINE_CPU}_elf/Makefile)
 SUBDIR=        ${MACHINE_CPU}_elf
-.elif exists(${MACHINE_ARCH})
+.elif exists(${MACHINE_ARCH}/Makefile)
 SUBDIR=        ${MACHINE_ARCH}
-.elif exists(${MACHINE_CPU})
+.elif exists(${MACHINE_CPU}/Makefile)
 SUBDIR=        ${MACHINE_CPU}
 .else
 .BEGIN:
Index: common/Makefile.inc
===================================================================
RCS file: common/Makefile.inc
diff -N common/Makefile.inc
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ common/Makefile.inc 31 Jul 2010 00:07:49 -0000
@@ -0,0 +1,94 @@
+#      $NetBSD: Makefile.inc,v 1.32 2009/12/13 08:52:38 mrg Exp $
+
+CPPFLAGS+=     -I${NETBSDSRCDIR}/libexec/ld.elf_so -I${.CURDIR}/../common -I.
+
+.include <bsd.own.mk>
+
+COMMON_DIR=    ${.CURDIR}/../common
+.PATH:         ${COMMON_DIR}
+
+OBJS+=         crt0.o gcrt0.o crti.o crtn.o
+OBJS+=         crtbegin.o crtbeginS.o crtend.o crtendS.o
+
+
+realall: ${OBJS}
+
+crtbegin.o: crtbegin.S
+       ${_MKTARGET_COMPILE}
+       ${COMPILE.c} ${.CURDIR}/crtbegin.S -o ${.TARGET}.o
+       ${LD} -x -r -o ${.TARGET} ${.TARGET}.o
+       rm -f ${.TARGET}.o
+.if ${MKSTRIPIDENT} != "no"
+       ${OBJCOPY} -R .ident ${.TARGET}
+.endif
+
+crtbeginS.o: crtbegin.S
+       ${_MKTARGET_COMPILE}
+       ${COMPILE.c} -DSHARED ${.CURDIR}/crtbegin.S -o ${.TARGET}.o
+       ${LD} -x -r -o ${.TARGET} ${.TARGET}.o
+       rm -f ${.TARGET}.o
+.if ${MKSTRIPIDENT} != "no"
+       ${OBJCOPY} -R .ident ${.TARGET}
+.endif
+
+crtend.o: crtend.S
+       ${_MKTARGET_COMPILE}
+       ${COMPILE.c} ${.CURDIR}/crtend.S -o ${.TARGET}.o
+       ${LD} -x -r -o ${.TARGET} ${.TARGET}.o
+       rm -f ${.TARGET}.o
+.if ${MKSTRIPIDENT} != "no"
+       ${OBJCOPY} -R .ident ${.TARGET}
+.endif
+
+crtendS.o: crtend.S
+       ${_MKTARGET_COMPILE}
+       ${COMPILE.c} -DSHARED ${.CURDIR}/crtend.S -o ${.TARGET}.o
+       ${LD} -x -r -o ${.TARGET} ${.TARGET}.o
+       rm -f ${.TARGET}.o
+.if ${MKSTRIPIDENT} != "no"
+       ${OBJCOPY} -R .ident ${.TARGET}
+.endif
+
+.if ${MKPIC} != "no"
+PICFLAGS=      -fPIC
+.else
+PICFLAGS=
+.endif
+
+crt0.o: crt0-common.c crt0.S
+       ${_MKTARGET_COMPILE}
+       ${COMPILE.c} ${PICFLAGS} ${COMMON_DIR}/crt0-common.c -o ${.TARGET}.c.o
+       ${COMPILE.c} ${.CURDIR}/crt0.S -o ${.TARGET}.S.o
+       ${LD} -x -r -o ${.TARGET} ${.TARGET}.c.o ${.TARGET}.S.o
+       rm -f ${.TARGET}.c.o ${.TARGET}.S.o
+.if ${MKSTRIPIDENT} != "no"
+       ${OBJCOPY} -R .ident ${.TARGET}
+.endif
+
+gcrt0.o: crt0-common.c crt0.S
+       ${_MKTARGET_COMPILE}
+       ${COMPILE.c} ${PICFLAGS} -DMCRT0 ${COMMON_DIR}/crt0-common.c -o 
${.TARGET}.c.o
+       ${COMPILE.c} ${.CURDIR}/crt0.S -o ${.TARGET}.S.o
+       ${LD} -x -r -o ${.TARGET} ${.TARGET}.c.o ${.TARGET}.S.o
+       rm -f ${.TARGET}.c.o ${.TARGET}.S.o
+.if ${MKSTRIPIDENT} != "no"
+       ${OBJCOPY} -R .ident ${.TARGET}
+.endif
+
+sysident_assym.h: ${GENASSYM_CONF} ${GENASSYM_EXTRAS}
+       ${_MKTARGET_CREATE}
+       cat ${COMMON_DIR}/sysident_assym.cf | \
+           ${TOOL_GENASSYM} -- ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
+           > sysident_assym.h.tmp && \
+       mv -f sysident_assym.h.tmp sysident_assym.h
+
+CLEANFILES+=   sysident_assym.h
+
+crti.o: crti.S sysident_assym.h
+crtn.o: crtn.S
+
+FILES=${OBJS}
+FILESDIR=${LIBDIR}
+CLEANFILES=${OBJS}
+
+.include <bsd.prog.mk>
Index: common/crt0-common.c
===================================================================
RCS file: common/crt0-common.c
diff -N common/crt0-common.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ common/crt0-common.c        31 Jul 2010 22:35:45 -0000
@@ -0,0 +1,124 @@
+/* $NetBSD$ */
+
+/*
+ * Copyright (c) 1998 Christos Zoulas
+ * Copyright (c) 1995 Christopher G. Demetriou
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *          This product includes software developed for the
+ *          NetBSD Project.  See http://www.NetBSD.org/ for
+ *          information about NetBSD.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD$");
+
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <machine/profile.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "rtld.h"
+
+extern int main(int, char **, char **);
+
+extern void    _init(void);
+extern void    _fini(void);
+
+/*
+ * Arrange for _DYNAMIC to be weak and undefined (and therefore to show up
+ * as being at address zero, unless something else defines it).  That way,
+ * if we happen to be compiling without -static but with without any
+ * shared libs present, things will still work.
+ */
+extern int _DYNAMIC __weak_reference(_DYNAMIC);
+
+#ifdef MCRT0
+extern void    monstartup(u_long, u_long);
+extern void    _mcleanup(void);
+extern unsigned char __etext, __eprol;
+#endif /* MCRT0 */
+
+char           **environ;
+struct ps_strings *__ps_strings = 0;
+
+static char     empty_string[] = "";
+char           *__progname = empty_string;
+
+void           __start(int, char **, char **, void (*)(void),
+    const Obj_Entry *, struct ps_strings *);
+
+#define        write(fd, s, n) __syscall(SYS_write, (fd), (s), (n))
+
+#define        _FATAL(str)                             \
+do {                                           \
+       write(2, str, sizeof(str)-1);           \
+       _exit(1);                               \
+} while (0)
+
+void
+___start(int argc, char **argv, char **envp,
+    void (*cleanup)(void),                     /* from shared loader */
+    const Obj_Entry *obj,                      /* from shared loader */
+    struct ps_strings *ps_strings)
+{
+       environ = envp;
+
+       if (argv[0] != NULL) {
+               char *c;
+               __progname = argv[0];
+               for (c = argv[0]; *c; ++c) {
+                       if (*c == '/')
+                               __progname = c + 1;
+               }
+       } else {
+               __progname = empty_string;
+       }
+
+       if (ps_strings != NULL)
+               __ps_strings = ps_strings;
+
+       if (&_DYNAMIC != NULL) {
+               if ((obj == NULL) || (obj->magic != RTLD_MAGIC))
+                       _FATAL("Corrupt Obj_Entry pointer in GOT\n");
+               if (obj->version != RTLD_VERSION)
+                       _FATAL("Dynamic linker version mismatch\n");
+               atexit(cleanup);
+       }
+
+#ifdef MCRT0
+       atexit(_mcleanup);
+       monstartup((u_long)&__eprol, (u_long)&__etext);
+#endif
+
+       atexit(_fini);
+       _init();
+
+       exit(main(argc, argv, environ));
+}
Index: common/sysident.S
===================================================================
RCS file: common/sysident.S
diff -N common/sysident.S
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ common/sysident.S   23 Jul 2010 13:13:13 -0000
@@ -0,0 +1,77 @@
+/* $NetBSD$ */
+
+/*
+ * Copyright (c) 1997 Christopher G. Demetriou
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *          This product includes software developed for the
+ *          NetBSD Project.  See http://www.NetBSD.org/ for
+ *          information about NetBSD.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
+ */
+
+/*
+ * Here we define the NetBSD OS Version in an ELF .note section, structured
+ * like:
+ *
+ * [NOTE HEADER]
+ *     long            name size
+ *     long            description size
+ *     long            note type
+ *
+ * [NOTE DATUM]
+ *     string          OS name
+ *
+ * OSVERSION notes also have:
+ *     long            OS version (__NetBSD_Version__ constant from param.h)
+ *
+ * The DATUM fields should be padded out such that their actual (not
+ * declared) sizes % 4 == 0.
+ *
+ * These are used by the kernel to determine if this binary is really a
+ * NetBSD binary, or some other OS's.
+ */
+
+#include "sysident_assym.h"
+
+       .section ".note.netbsd.ident", "a"
+       .align 4
+
+       .long   ELF_NOTE_NETBSD_NAMESZ
+       .long   ELF_NOTE_NETBSD_DESCSZ
+       .long   ELF_NOTE_TYPE_NETBSD_TAG
+       .ascii  "NetBSD\0\0"    /* ELF_NOTE_NETBSD_NAME */
+       .long   __NetBSD_Version__
+
+       .section ".note.netbsd.pax", "a"
+       .align 4
+
+       .long   ELF_NOTE_PAX_NAMESZ
+       .long   ELF_NOTE_PAX_DESCSZ
+       .long   ELF_NOTE_TYPE_PAX_TAG
+       .ascii  "PaX\0"         /* ELF_NOTE_PAX_NAME */
+       .long   0
Index: common/sysident_assym.cf
===================================================================
RCS file: common/sysident_assym.cf
diff -N common/sysident_assym.cf
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ common/sysident_assym.cf    23 Jul 2010 13:09:07 -0000
@@ -0,0 +1,12 @@
+include <sys/param.h>
+include <sys/exec_elf.h>
+
+define ELF_NOTE_NETBSD_NAMESZ          ELF_NOTE_NETBSD_NAMESZ
+define ELF_NOTE_NETBSD_DESCSZ          ELF_NOTE_NETBSD_DESCSZ
+define ELF_NOTE_TYPE_NETBSD_TAG        ELF_NOTE_TYPE_NETBSD_TAG
+#define        ELF_NOTE_NETBSD_NAME            ELF_NOTE_NETBSD_NAME
+define __NetBSD_Version__              __NetBSD_Version__
+define ELF_NOTE_PAX_NAMESZ             ELF_NOTE_PAX_NAMESZ
+define ELF_NOTE_PAX_DESCSZ             ELF_NOTE_PAX_DESCSZ
+define ELF_NOTE_TYPE_PAX_TAG           ELF_NOTE_TYPE_PAX_TAG
+#define        ELF_NOTE_PAX_NAME               ELF_NOTE_PAX_NAME
Index: i386/Makefile
===================================================================
RCS file: i386/Makefile
diff -N i386/Makefile
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ i386/Makefile       31 Jul 2010 03:25:18 -0000
@@ -0,0 +1,5 @@
+#      $NetBSD$
+
+CPPFLAGS+=     -DELFSIZE=32
+
+.include "${.CURDIR}/../common/Makefile.inc"
Index: i386/crt0.S
===================================================================
RCS file: i386/crt0.S
diff -N i386/crt0.S
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ i386/crt0.S 31 Jul 2010 22:36:42 -0000
@@ -0,0 +1,57 @@
+/* $NetBSD$ */
+
+/*
+ * Copyright (c) 1998 Christos Zoulas
+ * Copyright (c) 1995 Christopher G. Demetriou
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *          This product includes software developed for the
+ *          NetBSD Project.  See http://www.NetBSD.org/ for
+ *          information about NetBSD.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD$")
+
+       .text
+       .align  4
+       .globl  _start
+_start:
+       .globl  __start
+__start:
+       pushl   %ebx
+       pushl   %ecx
+       pushl   %edx
+       movl    12(%esp),%eax
+       leal    16(%esp),%edx
+       leal    20(%esp,%eax,4),%ecx
+       pushl   %ecx
+       pushl   %edx
+       pushl   %eax
+       call    ___start
Index: i386/crtbegin.S
===================================================================
RCS file: i386/crtbegin.S
diff -N i386/crtbegin.S
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ i386/crtbegin.S     31 Jul 2010 03:17:33 -0000
@@ -0,0 +1,174 @@
+/*     $NetBSD$        */
+/*-
+ * Copyright (c) 2010 Joerg Sonnenberger <joerg%NetBSD.org@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD$")
+
+       .section        .ctors, "aw", @progbits
+       .align 4
+__CTOR_LIST__:
+       .long -1
+
+       .section        .dtors, "aw", @progbits
+       .align 4
+__DTOR_LIST__:
+       .long -1
+
+       .section        .eh_frame, "a", @progbits
+       .align 4
+__EH_FRAME_LIST__:
+
+       .section        .jcr, "aw", @progbits
+       .align 4
+__JCR_LIST__:
+
+       .section        .data.rel, "aw", @progbits
+       .align 4
+       .type   __dso_handle, @object
+       .size   __dso_handle, 4
+       .globl  __dso_handle
+       .hidden __dso_handle
+__dso_handle:
+#ifdef SHARED
+       .long   __dso_handle
+#else
+       .long   0
+#endif
+
+__dwarf_eh_object:
+       .zero   32
+
+__initialized:
+       .zero   1
+__finished:
+       .zero   1
+
+       .text
+       .weak   __cxa_finalize
+       .weak   __deregister_frame_info
+       .weak   __register_frame_info
+       .weak   _Jv_RegisterClasses
+
+__get_thunk:
+       movl    (%esp), %ebx
+       ret
+
+__do_global_dtors_aux:
+       pushl   %ebx
+       pushl   %edi
+       subl    $8, %esp
+       call    __get_thunk
+       addl    $_GLOBAL_OFFSET_TABLE_, %ebx
+
+       cmpb    $0, __finished@GOTOFF(%ebx)
+       jne     4f
+       movb    $1, __finished@GOTOFF(%ebx)
+
+#ifdef SHARED
+       cmpl    $0, __cxa_finalize@GOT(%ebx)
+       je      1f
+       movl    __dso_handle@GOTOFF(%ebx), %eax
+       movl    %eax, (%esp)
+       call    __cxa_finalize@PLT
+1:
+#endif
+
+       leal    4+__DTOR_LIST__@GOTOFF(%ebx), %edi
+2:
+       movl    (%edi), %eax
+       testl   %eax, %eax
+       je      3f
+       call    *%eax
+       addl    $8, %edi
+       jmp     2b
+3:
+
+       cmpl    $0, __deregister_frame_info@GOT(%ebx)
+       je      4f
+       leal    __EH_FRAME_LIST__@GOTOFF(%ebx), %eax
+       movl    %eax, (%esp)
+       call    __deregister_frame_info@PLT
+4:
+       addl    $8, %esp
+       popl    %edi
+       popl    %ebx
+       ret
+
+
+__do_global_ctors_aux:
+       pushl   %ebx
+       pushl   %edi
+       subl    $8, %esp
+       call    __get_thunk
+       addl    $_GLOBAL_OFFSET_TABLE_, %ebx
+
+       cmpb    $0, __initialized@GOTOFF(%ebx)
+       jne     4f
+       movb    $1, __initialized@GOTOFF(%ebx)
+
+       cmpl    $0, __register_frame_info@GOT(%ebx)
+       je      1f
+       leal    __dwarf_eh_object@GOTOFF(%ebx), %edi
+       movl    %edi, 4(%esp)
+       leal    __EH_FRAME_LIST__@GOTOFF(%ebx), %edi
+       movl    %edi, (%esp)
+       call    __register_frame_info@PLT
+
+1:
+       cmpl    $0, _Jv_RegisterClasses@GOT(%ebx)
+       je      2f
+       leal    __JCR_LIST__@GOTOFF(%ebx), %edi
+       movl    (%edi), %edi
+       testl   %edi, %edi
+       je      2f
+       movl    %edi, (%esp)
+       call    _Jv_RegisterClasses@PLT
+2:
+
+       leal    -4+__CTOR_LIST_END__@GOTOFF(%ebx), %edi
+3:
+       movl    (%edi), %eax
+       cmpl    $-1, %eax
+       je      4f
+       call    *%eax
+       subl    $4, %edi
+       jmp     3b
+
+4:
+       addl    $8, %esp
+       popl    %edi
+       popl    %ebx
+       ret
+
+       .section        .init, "ax", @progbits
+       call    __do_global_ctors_aux
+       .section        .fini, "ax", @progbits
+       call    __do_global_dtors_aux
Index: i386/crtend.S
===================================================================
RCS file: i386/crtend.S
diff -N i386/crtend.S
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ i386/crtend.S       31 Jul 2010 03:17:43 -0000
@@ -0,0 +1,52 @@
+/*     $NetBSD$        */
+/*-
+ * Copyright (c) 2010 Joerg Sonnenberger <joerg%NetBSD.org@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD$")
+
+       .section        .ctors, "aw", @progbits
+       .align 4
+       .global         __CTOR_LIST_END__
+       .hidden         __CTOR_LIST_END__
+__CTOR_LIST_END__:
+       .long 0
+
+       .section        .dtors, "aw", @progbits
+       .align 4
+       .long 0
+
+       .section        .eh_frame, "a", @progbits
+       .align 4
+       .long 0
+
+       .section        .jcr, "aw", @progbits
+       .align 4
+       .long 0
Index: i386/crti.S
===================================================================
RCS file: i386/crti.S
diff -N i386/crti.S
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ i386/crti.S 31 Jul 2010 03:22:00 -0000
@@ -0,0 +1,21 @@
+/* $NetBSD$ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD$")
+
+#include "sysident.S"
+
+       .section ".init", "ax", @progbits
+       .align 16
+       .globl _init
+_init:
+       pushl   %ebp
+       movl    %esp, %ebp
+
+       .section ".fini", "ax", @progbits
+       .align 16
+       .globl _fini
+_fini:
+       pushl   %ebp
+       movl    %esp, %ebp
Index: i386/crtn.S
===================================================================
RCS file: i386/crtn.S
diff -N i386/crtn.S
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ i386/crtn.S 31 Jul 2010 03:22:08 -0000
@@ -0,0 +1,13 @@
+/* $NetBSD$ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD$")
+
+       .section ".init", "ax", @progbits
+       leave
+       ret
+
+       .section ".fini", "ax", @progbits
+       leave
+       ret
Index: i386_elf/Makefile
===================================================================
RCS file: i386_elf/Makefile
diff -N i386_elf/Makefile
--- i386_elf/Makefile   19 May 2006 19:11:12 -0000      1.9
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,6 +0,0 @@
-#      $NetBSD: Makefile,v 1.9 2006/05/19 19:11:12 christos Exp $
-
-#Uncomment the next line to enable the new .init fallthru
-CPPFLAGS+=     -I${.CURDIR}
-
-.include "${.CURDIR}/../common_elf/Makefile.inc"
Index: i386_elf/crt0.c
===================================================================
RCS file: i386_elf/crt0.c
diff -N i386_elf/crt0.c
--- i386_elf/crt0.c     1 Dec 2007 10:16:06 -0000       1.17
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,105 +0,0 @@
-/* $NetBSD: crt0.c,v 1.17 2007/12/01 10:16:06 yamt Exp $ */
-
-/*
- * Copyright (c) 1998 Christos Zoulas
- * Copyright (c) 1995 Christopher G. Demetriou
- * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *          This product includes software developed for the
- *          NetBSD Project.  See http://www.NetBSD.org/ for
- *          information about NetBSD.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
- * <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
- */
-
-#include "common.h"
-
-void ___start __P((int, char **, char **, void (*cleanup) __P((void)),
-    const Obj_Entry *, struct ps_strings *));
-
-__asm("        .text                           \n"
-"      .align  4                       \n"
-"      .globl  __start                 \n"
-"      .globl  _start                  \n"
-"_start:                               \n"
-"__start:                              \n"
-"      pushl   %ebx                    # ps_strings    \n"
-"      pushl   %ecx                    # obj           \n"
-"      pushl   %edx                    # cleanup       \n"
-"      movl    12(%esp),%eax           \n"
-"      leal    20(%esp,%eax,4),%ecx    \n"
-"      leal    16(%esp),%edx           \n"
-"      pushl   %ecx                    \n"
-"      pushl   %edx                    \n"
-"      pushl   %eax                    \n"
-"      call    ___start");
-
-void
-___start(argc, argv, envp, cleanup, obj, ps_strings)
-       int argc;
-       char **argv;
-       char **envp;
-       void (*cleanup) __P((void));            /* from shared loader */
-       const Obj_Entry *obj;                   /* from shared loader */
-       struct ps_strings *ps_strings;
-{
-       environ = envp;
-
-       if ((__progname = argv[0]) != NULL) {   /* NULL ptr if argc = 0 */
-               if ((__progname = _strrchr(__progname, '/')) == NULL)
-                       __progname = argv[0];
-               else
-                       __progname++;
-       }
-
-       if (ps_strings != (struct ps_strings *)0)
-               __ps_strings = ps_strings;
-
-#ifdef DYNAMIC
-       if (&_DYNAMIC != NULL) {
-               _rtld_setup(cleanup, obj);
-       }
-#endif
-
-#ifdef MCRT0
-       atexit(_mcleanup);
-       monstartup((u_long)&_eprol, (u_long)&_etext);
-#endif
-
-       atexit(_fini);
-       _init();
-
-       exit(main(argc, argv, environ));
-}
-
-/*
- * NOTE: Leave the RCS ID _after_ __start(), in case it gets placed in .text.
- */
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: crt0.c,v 1.17 2007/12/01 10:16:06 yamt Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#include "common.c"
Index: i386_elf/dot_init.h
===================================================================
RCS file: i386_elf/dot_init.h
diff -N i386_elf/dot_init.h
--- i386_elf/dot_init.h 10 May 2008 15:31:04 -0000      1.8
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,65 +0,0 @@
-/* $NetBSD: dot_init.h,v 1.8 2008/05/10 15:31:04 martin Exp $ */
-
-/*-
- * Copyright (c) 2001 Ross Harvey
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the NetBSD
- *     Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- *    contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
-
-#define        MD_SECTION_PROLOGUE(sect, entry_pt)             \
-               __asm (                                 \
-               ".section "#sect",\"ax\",@progbits      \n"\
-               ".global "#entry_pt"                    \n"\
-               "       .align  16                      \n"\
-               #entry_pt":                             \n"\
-               "       pushl   %ebp                    \n"\
-               "       movl    %esp, %ebp              \n"\
-               "       /* fall thru */                 \n"\
-               ".previous")
-
-               /* placement of the .align _after_ the label is intentional */
-
-#define        MD_SECTION_EPILOGUE(sect)                       \
-               __asm (                                 \
-               ".section "#sect",\"ax\",@progbits      \n"\
-               "       leave                           \n"\
-               "       ret                             \n"\
-               ".previous")
-
-#define        MD_INIT_SECTION_PROLOGUE MD_SECTION_PROLOGUE(.init, _init)
-#define        MD_FINI_SECTION_PROLOGUE MD_SECTION_PROLOGUE(.fini, _fini)
-
-#define        MD_INIT_SECTION_EPILOGUE MD_SECTION_EPILOGUE(.init)
-#define        MD_FINI_SECTION_EPILOGUE MD_SECTION_EPILOGUE(.fini)
-
-#define MD_CALL_STATIC_FUNCTION(section, func) \
-__asm(".section " #section "; call " #func "; .previous");
Index: x86_64/Makefile
===================================================================
RCS file: /home/joerg/repo/netbsd/src/lib/csu/x86_64/Makefile,v
retrieving revision 1.5
diff -u -p -r1.5 Makefile
--- x86_64/Makefile     19 May 2006 19:11:13 -0000      1.5
+++ x86_64/Makefile     16 Jul 2010 19:37:43 -0000
@@ -1,6 +1,5 @@
 #      $NetBSD: Makefile,v 1.5 2006/05/19 19:11:13 christos Exp $
 
-ELFSIZE=64
-CPPFLAGS+=      -I${.CURDIR} -D__EH_FRAME_CONST=const
+CPPFLAGS+=     -DELFSIZE=64
 
-.include "${.CURDIR}/../common_elf/Makefile.inc"
+.include "${.CURDIR}/../common/Makefile.inc"
Index: x86_64/crt0.S
===================================================================
RCS file: x86_64/crt0.S
diff -N x86_64/crt0.S
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ x86_64/crt0.S       31 Jul 2010 15:39:55 -0000
@@ -0,0 +1,55 @@
+/* $NetBSD$ */
+
+/*
+ * Copyright (c) 1998 Christos Zoulas
+ * Copyright (c) 1995 Christopher G. Demetriou
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *          This product includes software developed for the
+ *          NetBSD Project.  See http://www.NetBSD.org/ for
+ *          information about NetBSD.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD$")
+
+       .text
+       .align  8
+       .globl  _start
+       .globl  __start
+_start:
+__start:
+       movq    %rbx,%r9
+       movq    %rcx,%r8
+       movq    %rdx,%rcx
+       movq    (%rsp),%rdi
+       leaq    16(%rsp,%rdi,8),%rdx
+       leaq    8(%rsp),%rsi
+       subq    $8,%rsp
+       andq    $~15,%rsp
+       addq    $8,%rsp
+       jmp     ___start
Index: x86_64/crt0.c
===================================================================
RCS file: x86_64/crt0.c
diff -N x86_64/crt0.c
--- x86_64/crt0.c       27 Sep 2007 10:51:18 -0000      1.5
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,104 +0,0 @@
-/* $NetBSD: crt0.c,v 1.5 2007/09/27 10:51:18 dogcow Exp $ */
-
-/*
- * Copyright (c) 1998 Christos Zoulas
- * Copyright (c) 1995 Christopher G. Demetriou
- * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *          This product includes software developed for the
- *          NetBSD Project.  See http://www.NetBSD.org/ for
- *          information about NetBSD.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
- * <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
- */
-
-#include <sys/types.h>
-#include <machine/profile.h>
-
-#include "common.h"
-
-void ___start(int, char **, char **, void (*cleanup)(void),
-    const Obj_Entry *, struct ps_strings *);
-
-__asm(" .text                                          ; \
-       .align  8                                       ; \
-       .globl  __start                                 ; \
-       .globl  _start                                  ; \
-_start:                                                        ; \
-__start:                                               ; \
-       movq    %rbx,%r9                                ; \
-       movq    %rcx,%r8                                ; \
-       movq    %rdx,%rcx                               ; \
-       movq    (%rsp),%rdi                             ; \
-       leaq    16(%rsp,%rdi,8),%rdx                    ; \
-       leaq    8(%rsp),%rsi                            ; \
-       subq    $8,%rsp                                 ; \
-       andq    $~15,%rsp                               ; \
-       addq    $8,%rsp                                 ; \
-       jmp     ___start                                ; ");
-
-void
-___start(int argc, char **argv, char **envp,
-    void (*cleanup)(void),                     /* from shared loader */
-    const Obj_Entry *obj,                      /* from shared loader */
-    struct ps_strings *ps_strings)
-{
-       environ = envp;
-
-       if ((__progname = argv[0]) != NULL) {   /* NULL ptr if argc = 0 */
-               if ((__progname = _strrchr(__progname, '/')) == NULL)
-                       __progname = argv[0];
-               else
-                       __progname++;
-       }
-
-       if (ps_strings != (struct ps_strings *)0)
-               __ps_strings = ps_strings;
-
-#ifdef DYNAMIC
-       if (&_DYNAMIC != NULL)
-               _rtld_setup(cleanup, obj);
-#endif
-
-#ifdef MCRT0
-       atexit(_mcleanup);
-       monstartup((u_long)&_eprol, (u_long)&_etext);
-#endif
-
-       atexit(_fini);
-       _init();
-
-       exit(main(argc, argv, environ));
-}
-
-/*
- * NOTE: Leave the RCS ID _after_ __start(), in case it gets placed in .text.
- */
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: crt0.c,v 1.5 2007/09/27 10:51:18 dogcow Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#include "common.c"
Index: x86_64/crtbegin.S
===================================================================
RCS file: x86_64/crtbegin.S
diff -N x86_64/crtbegin.S
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ x86_64/crtbegin.S   14 Jul 2010 19:52:49 -0000
@@ -0,0 +1,157 @@
+/*     $NetBSD$        */
+/*-
+ * Copyright (c) 2010 Joerg Sonnenberger <joerg%NetBSD.org@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD$")
+
+       .section        .ctors, "aw", @progbits
+       .align 8
+__CTOR_LIST__:
+       .quad -1
+
+       .section        .dtors, "aw", @progbits
+       .align 8
+__DTOR_LIST__:
+       .quad -1
+
+       .section        .eh_frame, "a", @progbits
+       .align 8
+__EH_FRAME_LIST__:
+
+       .section        .jcr, "aw", @progbits
+       .align 8
+__JCR_LIST__:
+
+       .section        .data.rel, "aw", @progbits
+       .align 8
+       .type   __dso_handle, @object
+       .size   __dso_handle, 8
+       .globl  __dso_handle
+       .hidden __dso_handle
+__dso_handle:
+#ifdef SHARED
+       .quad   __dso_handle
+#else
+       .quad   0
+#endif
+
+__dwarf_eh_object:
+       .zero   64
+
+__initialized:
+       .zero   1
+__finished:
+       .zero   1
+
+       .text
+       .weak   __cxa_finalize
+       .weak   __deregister_frame_info
+       .weak   __register_frame_info
+       .weak   _Jv_RegisterClasses
+
+__do_global_dtors_aux:
+       cmpb    $0, __finished(%rip)
+       je      1f
+       ret
+1:
+       movb    $1, __finished(%rip)
+
+
+#ifdef SHARED
+       cmpq    $0, __cxa_finalize@GOTPCREL(%rip)
+       je      2f
+       movq    __dso_handle(%rip), %rax
+       call    __cxa_finalize@PLT
+2:
+#endif
+
+       pushq   %rbx
+       leaq    8+__DTOR_LIST__(%rip), %rbx
+3:
+       movq    (%rbx), %rax
+       testq   %rax, %rax
+       je      4f
+       call    *%rax
+       addq    $8, %rbx
+       jmp     3b      
+4:
+       popq    %rbx
+
+       cmpq    $0, __deregister_frame_info@GOTPCREL(%rip)
+       je      5f
+       leaq    __EH_FRAME_LIST__(%rip), %rdi
+       call    __deregister_frame_info@PLT
+5:
+
+       ret
+
+
+__do_global_ctors_aux:
+       cmpb    $0, __initialized(%rip)
+       je      1f
+       ret
+1:
+       movb    $1, __initialized(%rip)
+
+       cmpq    $0, __register_frame_info@GOTPCREL(%rip)
+       je      2f
+       leaq    __dwarf_eh_object(%rip), %rsi
+       leaq    __EH_FRAME_LIST__(%rip), %rdi
+       call    __register_frame_info@PLT
+
+2:
+       cmpq    $0, _Jv_RegisterClasses@GOTPCREL(%rip)
+       je      3f
+       leaq    __JCR_LIST__(%rip), %rdi
+       cmpq    $0, (%rdi)
+       je      3f
+       call    _Jv_RegisterClasses@PLT
+3:
+
+       pushq   %rbx
+       leaq    -8+__CTOR_LIST_END__(%rip), %rbx
+4:
+       movq    (%rbx), %rax
+       cmpq    $-1, %rax
+       je      5f
+       call    *%rax
+       subq    $8, %rbx
+       jmp     4b
+
+5:
+       popq    %rbx
+
+       ret
+
+       .section        .init, "ax", @progbits
+       call    __do_global_ctors_aux
+       .section        .fini, "ax", @progbits
+       call    __do_global_dtors_aux
Index: x86_64/crtend.S
===================================================================
RCS file: x86_64/crtend.S
diff -N x86_64/crtend.S
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ x86_64/crtend.S     14 Jul 2010 19:54:00 -0000
@@ -0,0 +1,52 @@
+/*     $NetBSD$        */
+/*-
+ * Copyright (c) 2010 Joerg Sonnenberger <joerg%NetBSD.org@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD$")
+
+       .section        .ctors, "aw", @progbits
+       .align 8
+       .global         __CTOR_LIST_END__
+       .hidden         __CTOR_LIST_END__
+__CTOR_LIST_END__:
+       .quad 0
+
+       .section        .dtors, "aw", @progbits
+       .align 8
+       .quad 0
+
+       .section        .eh_frame, "a", @progbits
+       .align 8
+       .quad 0
+
+       .section        .jcr, "aw", @progbits
+       .align 8
+       .quad 0
Index: x86_64/crti.S
===================================================================
RCS file: x86_64/crti.S
diff -N x86_64/crti.S
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ x86_64/crti.S       30 Jul 2010 19:36:58 -0000
@@ -0,0 +1,19 @@
+/* $NetBSD$ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD$")
+
+#include "sysident.S"
+
+       .section ".init", "ax", @progbits
+       .align 16
+       .globl _init
+_init:
+       subq    $8, %rsp
+
+       .section ".fini", "ax", @progbits
+       .align 16
+       .globl _fini
+_fini:
+       subq    $8, %rsp
Index: x86_64/crtn.S
===================================================================
RCS file: x86_64/crtn.S
diff -N x86_64/crtn.S
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ x86_64/crtn.S       30 Jul 2010 19:37:01 -0000
@@ -0,0 +1,13 @@
+/* $NetBSD$ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD$")
+
+       .section ".init", "ax", @progbits
+       addq    $8, %rsp
+       ret
+
+       .section ".fini", "ax", @progbits
+       addq    $8, %rsp
+       ret
Index: x86_64/dot_init.h
===================================================================
RCS file: x86_64/dot_init.h
diff -N x86_64/dot_init.h
--- x86_64/dot_init.h   10 May 2008 15:31:04 -0000      1.7
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,64 +0,0 @@
-/* $NetBSD: dot_init.h,v 1.7 2008/05/10 15:31:04 martin Exp $ */
-
-/*-
- * Copyright (c) 2001 Ross Harvey
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the NetBSD
- *     Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- *    contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
-
-#define        MD_SECTION_PROLOGUE(sect, entry_pt)             \
-               __asm (                                 \
-               ".section "#sect",\"ax\",@progbits      \n"\
-               ".global "#entry_pt"                    \n"\
-               "       .align  16                      \n"\
-               #entry_pt":                             \n"\
-               "       subq    $8,%rsp                 \n"\
-               "       /* fall thru */                 \n"\
-               ".previous")
-
-               /* placement of the .align _after_ the label is intentional */
-
-#define        MD_SECTION_EPILOGUE(sect)                       \
-               __asm (                                 \
-               ".section "#sect",\"ax\",@progbits      \n"\
-               "       addq    $8,%rsp                 \n"\
-               "       ret                             \n"\
-               ".previous")
-
-#define        MD_INIT_SECTION_PROLOGUE MD_SECTION_PROLOGUE(.init, _init)
-#define        MD_FINI_SECTION_PROLOGUE MD_SECTION_PROLOGUE(.fini, _fini)
-
-#define        MD_INIT_SECTION_EPILOGUE MD_SECTION_EPILOGUE(.init)
-#define        MD_FINI_SECTION_EPILOGUE MD_SECTION_EPILOGUE(.fini)
-
-#define MD_CALL_STATIC_FUNCTION(section, func) \
-__asm(".section " #section "; call " #func "; .previous");
Index: external/gpl3/binutils/dist/ld/scripttempl/elf.sc
===================================================================
RCS file: 
/home/joerg/repo/netbsd/src/external/gpl3/binutils/dist/ld/scripttempl/elf.sc,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 elf.sc
--- external/gpl3/binutils/dist/ld/scripttempl/elf.sc   18 Aug 2009 10:05:54 
-0000      1.1.1.1
+++ external/gpl3/binutils/dist/ld/scripttempl/elf.sc   31 Jul 2010 07:56:17 
-0000
@@ -86,6 +86,7 @@
 #
 #  Each of these can also have corresponding .rel.* and .rela.* sections.
 
+test -z "$TEXT_START_SYMBOLS" && TEXT_START_SYMBOLS="PROVIDE_HIDDEN (__eprol = 
.);"
 test -z "$ENTRY" && ENTRY=_start
 test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
 test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}


Home | Main Index | Thread Index | Old Index