Skip to contentSkip to conversation

MIPS: simplify relocated _G_O_T_ address calculation

PATCH New Gabor Juhos 2 participants 2 messages Jan 30, 2013 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 MIPS: simplify relocated _G_O_T_ address calculation

The difference between the address of the original and the relocated _GLOBAL_OFFSET_TABLE_ is always the same as the relocation offset.

The relocation offset is already computed and it is available in the 's1/t6' register. Use that to adjust the relocated _G_O_T_ address, instead of calculating the offset again from the _gp value.

Cc Daniel Schwierzeck <[email protected]>
Cc Xiangfu Liu <[email protected]>

---
Changes since v1: modify Xburst code as well

This depends on the:

'MIPS: xburst: simplify relocation offset calculation' patch
http://patchwork.ozlabs.org/patch/216934/

and supersedes this one:
http://patchwork.ozlabs.org/patch/214350/

---
 arch/mips/cpu/mips32/start.S |    5 +----
 arch/mips/cpu/mips64/start.S |    5 +----
 arch/mips/cpu/xburst/start.S |    5 +----
 3 files changed, 3 insertions(+), 12 deletions(-)
arch/mips/cpu/mips32/start.S +1 -4
index 77f1103..51ce914 100644
@@ -314,7 +314,6 @@ relocate_code:
 	jr	t0
 	 nop
 
-	.word	_gp
 	.word	_GLOBAL_OFFSET_TABLE_
 	.word	uboot_end_data
 	.word	uboot_end
@@ -329,9 +328,7 @@ in_ram:
 	 */
 	lw	t3, -4(t0)		# t3 <-- num_got_entries
 	lw	t4, -16(t0)		# t4 <-- _GLOBAL_OFFSET_TABLE_
-	lw	t5, -20(t0)		# t5 <-- _gp
-	sub	t4, t5			# compute offset
-	add	t4, t4, gp		# t4 now holds relocated _G_O_T_
+	add	t4, s1			# t4 now holds relocated _G_O_T_
 	addi	t4, t4, 8		# skipping first two entries
 	li	t2, 2
 1:
arch/mips/cpu/mips64/start.S +1 -4
index 80e6bb1..1522594 100644
@@ -193,7 +193,6 @@ relocate_code:
 	jr	t0
 	 nop
 
-	.dword	_gp
 	.dword	_GLOBAL_OFFSET_TABLE_
 	.dword	uboot_end_data
 	.dword	uboot_end
@@ -208,9 +207,7 @@ in_ram:
 	 */
 	ld	t3, -8(t0)		# t3 <-- num_got_entries
 	ld	t8, -32(t0)		# t8 <-- _GLOBAL_OFFSET_TABLE_
-	ld	t9, -40(t0)		# t9 <-- _gp
-	dsub	t8, t9			# compute offset
-	dadd	t8, t8, gp		# t8 now holds relocated _G_O_T_
+	dadd	t8, s1			# t8 now holds relocated _G_O_T_
 	daddi	t8, t8, 16		# skipping first two entries
 	dli	t2, 2
 1:
arch/mips/cpu/xburst/start.S +1 -4
index 35728eb..50b7fb1 100644
@@ -116,7 +116,6 @@ relocate_code:
 	jr	t0
 	 nop
 
-	.word	_gp
 	.word	_GLOBAL_OFFSET_TABLE_
 	.word	uboot_end_data
 	.word	uboot_end
@@ -131,9 +130,7 @@ in_ram:
 	 */
 	lw	t3, -4(t0)		# t3 <-- num_got_entries
 	lw	t4, -16(t0)		# t4 <-- _GLOBAL_OFFSET_TABLE_
-	lw	t5, -20(t0)		# t5 <-- _gp
-	sub	t4, t5			# compute offset
-	add	t4, t4, gp		# t4 now holds relocated _G_O_T_
+	add	t4, t6			# t4 now holds relocated _G_O_T_
 	addi	t4, t4, 8		# skipping first two entries
 	li	t2, 2
 1:
Signature · 1 line
1.7.10
#1 lore raw

PATCH v2 1/1 MIPS: simplify relocated _G_O_T_ address calculation

2013/1/30 Gabor Juhos <[email protected]>:

Quoted 20 lines

The difference between the address of the original and the relocated _GLOBAL_OFFSET_TABLE_ is always the same as the relocation offset.

The relocation offset is already computed and it is available in the 's1/t6' register. Use that to adjust the relocated _G_O_T_ address, instead of calculating the offset again from the _gp value.

Cc Daniel Schwierzeck <[email protected]>
Cc Xiangfu Liu <[email protected]>

---
Changes since v1: modify Xburst code as well

This depends on the:

'MIPS: xburst: simplify relocation offset calculation' patch
http://patchwork.ozlabs.org/patch/216934/

Quoted 7 lines

and supersedes this one:
http://patchwork.ozlabs.org/patch/214350/

---
 arch/mips/cpu/mips32/start.S |    5 +----
 arch/mips/cpu/mips64/start.S |    5 +----
 arch/mips/cpu/xburst/start.S |    5 +----
 3 files changed, 3 insertions(+), 12 deletions(-)

applied to u-boot-mips/master, thanks

Signature · 2 lines
Best regards,
Daniel