[PATCH RL78] Update crt0.S

Kaushik Phatak Kaushik.Phatak@kpit.com
Wed Oct 14 18:09:00 GMT 2015

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,

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
-	cmpw	ax, bc
-	bz	$1f
-	movw	__bssstart[bc], ax
-	decw	bc
-	decw	bc
-	br	$1b
+        movw    bc, #__bsssize
+        movw    ax, #0
+        cmpw    ax, bc
+        bz      $_bss_zero_done
+        decw    bc
+        decw    bc
+        movw    __bssstart[bc], ax
+        cmpw    ax, bc
+        bz      $_bss_zero_done
+        br      $1b
 	call	!!__rl78_init
 #ifdef PROFILE_SUPPORT	/* Defined in gcrt0.S.  */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rl78_crt0.diff
Type: application/octet-stream
Size: 716 bytes
Desc: rl78_crt0.diff
URL: <http://sourceware.org/pipermail/newlib/attachments/20151014/44811d7a/attachment.obj>

More information about the Newlib mailing list