This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH RL78] Update crt0.S


Hi,
The below patch fixes a minor issue related to clearing of the bss section.
The old code cleared 2 incorrect bytes at end of bss and missed clearing the first 2 bytes
of .bss section.
For example,
__bssstart = 0xF9200
__bsssize = 0x100
__bssend =x 0xF9300

The old code cleared 2 bytes at 0xF9300 and 0xF9301 (0xF9200 + 0x100) and missed clearing the
data at 0xF9200 and 0xF9201.
The below patch fixes this issue.
This is regression tested for rl78 -msim. There are no additional failures, however there is
an increase in code size by 3 bytes due to additional code for 'cmp' and 'bz'.

Requesting to review the below patch and commit it on my behalf if OK.

Best Regards,
Kaushik

p.s. Kindly ignore any disclaimers at end of this e-mail as they are auto-inserted.

2015-10-14  Kaushik Phatak <kaushik.phatak@sandifo@redhat.com>

        * rl78/crt0.S (_start): Fixed code that clears .bss

Index: libgloss/rl78/crt0.S
===================================================================
--- libgloss/rl78/crt0.S	(revision 2805)
+++ libgloss/rl78/crt0.S	(working copy)
@@ -176,17 +176,20 @@
 
 ;; block fill to .bss
 
-	movw	bc, #__bsssize
-	movw	ax, #0
-1:	
-	cmpw	ax, bc
-	bz	$1f
-	movw	__bssstart[bc], ax
-	decw	bc
-	decw	bc
-	br	$1b
-1:	
+        movw    bc, #__bsssize
+        movw    ax, #0
+        cmpw    ax, bc
+        bz      $_bss_zero_done
+1:
+        decw    bc
+        decw    bc
+        movw    __bssstart[bc], ax
+        cmpw    ax, bc
+        bz      $_bss_zero_done
+        br      $1b
 
+_bss_zero_done:
+
 	call	!!__rl78_init
 
 #ifdef PROFILE_SUPPORT	/* Defined in gcrt0.S.  */

Attachment: rl78_crt0.diff
Description: rl78_crt0.diff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]