From: Vlad Lungu <vlad@comsys.ro>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] Fixed the _gp/_G_O_T_ confusion for good
Date: Fri, 12 Oct 2007 15:06:17 +0300 [thread overview]
Message-ID: <470F6339.6070102@comsys.ro> (raw)
$gp is loaded with _gp
the GOT is updated starting from _G_O_T_+8 up to (but not including) __got_end
__got_start is unused
num_got_entries is unused and could be removed from ld scripts
To test:
_gp =ALIGN(16)+4;
__got_start = .;
. += 4;
.got : { *(.got) }
__got_end = .;
produces
0x00000000bfc1f564 _gp = (ALIGN (0x10) + 0x4)
0x00000000bfc1f560 __got_start = .
0x00000000bfc1f564 . = (. + 0x4)
.got 0x00000000bfc1f570 0x500
*(.got)
.got 0x00000000bfc1f570 0x500 cpu/mips/start.o
0x00000000bfc1f570 _GLOBAL_OFFSET_TABLE_
0x00000000bfc1fa70 __got_end = .
0x00000000bfc1fa70 . = .
The boards boots and the command line is working
Signed-off-by: Vlad Lungu <vlad@comsys.ro>
---
cpu/mips/start.S | 23 +++++++++++++----------
1 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/cpu/mips/start.S b/cpu/mips/start.S
index e91e213..816c23a 100644
--- a/cpu/mips/start.S
+++ b/cpu/mips/start.S
@@ -234,11 +234,11 @@ reset:
li t0, CONF_CM_UNCACHED
mtc0 t0, CP0_CONFIG
- /* Initialize GOT pointer.
+ /* Initialize $gp.
*/
bal 1f
nop
- .word _GLOBAL_OFFSET_TABLE_
+ .word _gp
1:
move gp, ra
lw t1, 0(ra)
@@ -306,9 +306,9 @@ relocate_code:
move t1, a2
/*
- * Fix GOT pointer:
+ * Fix _gp:
*
- * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address
+ * New _gp = (old _gp - CFG_MONITOR_BASE) + Destination Address
*/
move t6, gp
sub gp, CFG_MONITOR_BASE
@@ -341,25 +341,28 @@ relocate_code:
j t0
nop
+ .gpword _GLOBAL_OFFSET_TABLE_
.word uboot_end_data
.word uboot_end
- .word num_got_entries
+ .gpword __got_end
in_ram:
/* Now we want to update GOT.
*/
- lw t3, -4(t0) /* t3 <-- num_got_entries */
+ lw t3, -16(t0) /* t3 <-- _G_O_T_-_gp */
addi t4, gp, 8 /* Skipping first two entries. */
- li t2, 2
+ add t4, t4, t3 /* Actual &(_G_O_T_[2]) */
+ lw t3, -4(t0) /* t3 <-- __got_end-_gp */
+ add t3,gp
1:
lw t1, 0(t4)
beqz t1, 2f
add t1, t6
sw t1, 0(t4)
2:
- addi t2, 1
- blt t2, t3, 1b
- addi t4, 4 /* delay slot */
+ addi t4, 4
+ blt t4, t3, 1b
+ nop
/* Clear BSS.
*/
--
1.5.2.2
next reply other threads:[~2007-10-12 12:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-12 12:06 Vlad Lungu [this message]
2007-10-21 1:22 ` [U-Boot-Users] [PATCH] Fixed the _gp/_G_O_T_ confusion for good Shinya Kuribayashi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=470F6339.6070102@comsys.ro \
--to=vlad@comsys.ro \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.