Alignment in linker script
This commit is contained in:
		
							parent
							
								
									3725cbe58d
								
							
						
					
					
						commit
						005ad4e987
					
				
					 4 changed files with 23 additions and 1 deletions
				
			
		
							
								
								
									
										17
									
								
								add.s
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								add.s
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,17 @@ | ||||||
|  | .globl add
 | ||||||
|  | .text | ||||||
|  | .align  2
 | ||||||
|  | .type   add, @function
 | ||||||
|  | add: | ||||||
|  |     addi    sp,sp,-32 | ||||||
|  |     sw      ra,28(sp) | ||||||
|  |     sw      s0,24(sp) | ||||||
|  |     addi    s0,sp,32 | ||||||
|  |     sw      a0,-20(s0) | ||||||
|  |     lw      a5,-20(s0) | ||||||
|  |     slli    a5,a5,1 | ||||||
|  |     mv      a0,a5 | ||||||
|  |     lw      ra,28(sp) | ||||||
|  |     lw      s0,24(sp) | ||||||
|  |     addi    sp,sp,32 | ||||||
|  |     jr      ra | ||||||
							
								
								
									
										3
									
								
								link.ld
									
										
									
									
									
								
							
							
						
						
									
										3
									
								
								link.ld
									
										
									
									
									
								
							|  | @ -7,12 +7,15 @@ SECTIONS { | ||||||
|     .text : { |     .text : { | ||||||
|         main.o(.text.*) |         main.o(.text.*) | ||||||
|         *(.text) |         *(.text) | ||||||
|  |         . = ALIGN(4); | ||||||
|     } > DRAM |     } > DRAM | ||||||
|     .data : { |     .data : { | ||||||
|         *(.data) |         *(.data) | ||||||
|  |         . = ALIGN(4); | ||||||
|     } > DRAM AT > SRAM |     } > DRAM AT > SRAM | ||||||
|     .bss : { |     .bss : { | ||||||
|         *(.bss) |         *(.bss) | ||||||
|  |         . = ALIGN(4); | ||||||
|     } > DRAM |     } > DRAM | ||||||
|     /DISCARD/ : { |     /DISCARD/ : { | ||||||
|         *(.riscv.attributes) |         *(.riscv.attributes) | ||||||
|  |  | ||||||
							
								
								
									
										1
									
								
								main.s
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								main.s
									
										
									
									
									
								
							|  | @ -1,6 +1,5 @@ | ||||||
| # Define variables | # Define variables | ||||||
| .data | .data | ||||||
| .align 4
 |  | ||||||
|     num1: .word 5     # First number |     num1: .word 5     # First number | ||||||
|     num2: .word 7     # Second number |     num2: .word 7     # Second number | ||||||
|     result: .word 0   # Variable to store the result |     result: .word 0   # Variable to store the result | ||||||
|  |  | ||||||
							
								
								
									
										3
									
								
								makefile
									
										
									
									
									
								
							
							
						
						
									
										3
									
								
								makefile
									
										
									
									
									
								
							|  | @ -84,6 +84,9 @@ data: all | ||||||
| size: all | size: all | ||||||
| 	$(SIZE) $(TARGET) | 	$(SIZE) $(TARGET) | ||||||
| 
 | 
 | ||||||
|  | format: | ||||||
|  | 	clang-format -i *.s | ||||||
|  | 
 | ||||||
| # Clean up
 | # Clean up
 | ||||||
| clean: | clean: | ||||||
| 	rm -f $(TARGET) $(OBJS) | 	rm -f $(TARGET) $(OBJS) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Imbus
						Imbus