diff options
author | DJ Delorie <dj@redhat.com> | 2005-12-14 03:38:27 +0000 |
---|---|---|
committer | DJ Delorie <dj@redhat.com> | 2005-12-14 03:38:27 +0000 |
commit | fbe7cb7681a4def929729940fb298a3c46ecad32 (patch) | |
tree | 1578332d606f49cc256bed7b167614e8f07f41e7 /libgloss/m32c | |
parent | b24dda0b9d0eea3c18de6b2a973b1f33936adcae (diff) | |
download | newlib-fbe7cb7681a4def929729940fb298a3c46ecad32.zip newlib-fbe7cb7681a4def929729940fb298a3c46ecad32.tar.gz newlib-fbe7cb7681a4def929729940fb298a3c46ecad32.tar.bz2 |
* m32c/crt0.S: Add support for preinit, init, and fini arrays, and
.init and .fini processing.
* m32c/crtn.S: Likewise.
* m32c/exit.S: Likewise.
Diffstat (limited to 'libgloss/m32c')
-rw-r--r-- | libgloss/m32c/crt0.S | 60 | ||||
-rw-r--r-- | libgloss/m32c/crtn.S | 13 | ||||
-rw-r--r-- | libgloss/m32c/exit.S | 5 |
3 files changed, 76 insertions, 2 deletions
diff --git a/libgloss/m32c/crt0.S b/libgloss/m32c/crt0.S index 44e9e5c..9b29ffc 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 4bbf858..d4e86b8 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 3e7af20..7279d13 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) |