diff options
-rw-r--r-- | libgloss/ChangeLog | 7 | ||||
-rw-r--r-- | libgloss/m32c/crt0.S | 60 | ||||
-rw-r--r-- | libgloss/m32c/crtn.S | 13 | ||||
-rw-r--r-- | libgloss/m32c/exit.S | 5 |
4 files changed, 83 insertions, 2 deletions
diff --git a/libgloss/ChangeLog b/libgloss/ChangeLog index 80e7f7680..639e58f44 100644 --- a/libgloss/ChangeLog +++ b/libgloss/ChangeLog @@ -1,3 +1,10 @@ +2005-12-13 DJ Delorie <dj@redhat.com> + + * m32c/crt0.S: Add support for preinit, init, and fini arrays, and + .init and .fini processing. + * m32c/crtn.S: Likewise. + * m32c/exit.S: Likewise. + 2005-12-13 Nathan Sidwell <nathan@codesourcery.com> * mt/16-002.ld: Change architecture to 'mt'. Remove diff --git a/libgloss/m32c/crt0.S b/libgloss/m32c/crt0.S index 44e9e5c35..9b29ffc9b 100644 --- a/libgloss/m32c/crt0.S +++ b/libgloss/m32c/crt0.S @@ -74,6 +74,8 @@ _start: mov.w #0,r0 sstr.w + jsr.a __m32c_init + jsr.a _main .LFE2: @@ -85,6 +87,61 @@ _start: jsr.a _exit + .text + + .global _m32c_run_preinit_array + .type _m32c_run_preinit_array,@function +_m32c_run_preinit_array: + mov.W #__preinit_array_start,a0 + mov.W #__preinit_array_end,a1 + jmp.w _m32c_run_inilist + + .global _m32c_run_init_array + .type _m32c_run_init_array,@function +_m32c_run_init_array: + mov.W #__init_array_start,a0 + mov.W #__init_array_end,a1 + jmp.w _m32c_run_inilist + + .global _m32c_run_fini_array + .type _m32c_run_fini_array,@function +_m32c_run_fini_array: + mov.W #__fini_array_start,a0 + mov.W #__fini_array_end,a1 + /* fall through */ + +_m32c_run_inilist: +next_inilist: + cmp.W a0,a1 + jeq done_inilist + pushm a0,a1 + mov.W [a0],a0 +#ifdef A16 + mov.b:s #0,a1 /* zero extends */ + jsri.a a1a0 +#else + jsri.a a0 +#endif + popm a0,a1 + add.W A(#2,#4),a0 + jmp.b next_inilist +done_inilist: + rts + + .section .init,"ax",@progbits + + .global __m32c_init +__m32c_init: + enter #0 + + .section .fini,"ax",@progbits + + .global __m32c_fini +__m32c_fini: + enter #0 + jsr.a _m32c_run_fini_array + + ;;; Provide Dwarf unwinding information that will help GDB stop ;;; backtraces at the right place. This is stolen from assembly ;;; code generated by GCC with -dA. @@ -116,4 +173,5 @@ _start: .byte 0x30 ; DW_OP_lit0 .p2align ALIGN .LEFDE0: -.text + + .text diff --git a/libgloss/m32c/crtn.S b/libgloss/m32c/crtn.S index 4bbf858c6..d4e86b8a5 100644 --- a/libgloss/m32c/crtn.S +++ b/libgloss/m32c/crtn.S @@ -41,5 +41,18 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define W l #endif + .section .init,"ax",@progbits + jsr.a _m32c_run_preinit_array + jsr.a _m32c_run_init_array + exitd + .global __m32c_init_end +__m32c_init_end: + + .section .fini,"ax",@progbits + + exitd + .global __m32c_fini_end +__m32c_fini_end: + .text diff --git a/libgloss/m32c/exit.S b/libgloss/m32c/exit.S index 3e7af20c7..7279d13a1 100644 --- a/libgloss/m32c/exit.S +++ b/libgloss/m32c/exit.S @@ -32,4 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "m32csys.h" -S(_exit) + .global __exit +__exit: + jsr.a __m32c_fini + SYSCALL(SYS_exit) |