shithub: riscv

Download patch

ref: 8ab9c6d38864362d3683883f22d7539de742cf56
parent: 0a9e7e34ceb24dac229b704d320a53515ddc1855
author: cinap_lenrek <[email protected]>
date: Tue Mar 24 18:54:26 EDT 2015

vc: fix coffsect.lnno overflow into nreloc

the coffsect.lnno field is 16 bit and can overflow into
the nreloc field confusing arc firmware on load. just
mask it to prevent overflow.

--- a/sys/src/cmd/vl/asm.c
+++ b/sys/src/cmd/vl/asm.c
@@ -314,7 +314,7 @@
 		lput(HEADR);
 		lput(0L);
 		lput(HEADR+textsize+datsize+symsize);
-		lput(lcsize);			/* line number size */
+		lput(lcsize & 0xffff);		/* line number size */
 		lput(0x20L);			/* flags */
 
 		strnput(".data", 8);		/* data segment */
@@ -338,7 +338,6 @@
 		lput(0x80L);			/* flags */
 		break;
 	case 4:
-
 		lput((0x160L<<16)|3L);		/* magic and sections */
 		lput(time(0));			/* time and date */
 		lput(rnd(HEADR+textsize, 4096)+datsize);
@@ -367,7 +366,7 @@
 		lput(HEADR);
 		lput(0L);
 		lput(HEADR+textsize+datsize+symsize);
-		lput(lcsize);			/* line number size */
+		lput(lcsize & 0xffff);		/* line number size */
 		lput(0x20L);			/* flags */
 
 		strnput(".data", 8);		/* data segment */