From: Darius Augulis <augulis.darius@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] ARM: problem with linker option -pie
Date: Sat, 30 Oct 2010 23:37:26 +0300 [thread overview]
Message-ID: <4CCC8206.40206@gmail.com> (raw)
Hi all,
I've found solution which solves problem of empty command table.
Actually the problem is -pie linker option. I removed it and added -fPIC
flag to compiler options. Because relocation with such changes fails, I
set TEXT_BASE equal to runtime calculated relocation address.
And it works! All commands are there.
There is this dummy patch:
diff --git a/arch/arm/config.mk b/arch/arm/config.mk
index 4e165bf..2046c32 100644
--- a/arch/arm/config.mk
+++ b/arch/arm/config.mk
@@ -33,7 +33,7 @@ STANDALONE_LOAD_ADDR = 0xc100000
endif
endif
-PLATFORM_CPPFLAGS += -DCONFIG_ARM -D__ARM__
+PLATFORM_CPPFLAGS += -DCONFIG_ARM -D__ARM__ -fPIC
# Explicitly specifiy 32-bit ARM ISA since toolchain default can be
-mthumb:
PLATFORM_CPPFLAGS += $(call cc-option,-marm,)
@@ -67,5 +67,4 @@ LDSCRIPT := $(SRCTREE)/$(CPUDIR)/u-boot.lds
# needed for relocation
ifndef CONFIG_NAND_SPL
-PLATFORM_LDFLAGS += -pie
endif
And there is small patch for debugging command table:
diff --git a/common/hush.c b/common/hush.c
index 2188fd4..be92968 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -1675,6 +1675,10 @@ static int run_pipe_real(struct pipe *pi)
/* Look up command in command table */
+ printf("%s %d: cmd_tbl_s: %X, cmd_tbl_e: %X,
len: %d\n",
+ __func__, __LINE__,
+ &__u_boot_cmd_start, &__u_boot_cmd_end,
+ &__u_boot_cmd_end - &__u_boot_cmd_start);
if ((cmdtp = find_cmd(child->argv[i])) == NULL) {
printf ("Unknown command '%s' - try
'help'\n", child->argv[i]);
return -1; /* give up after bad
command */
Also I did one test with linker script.
I defined variable in start.S:
.globl _cmd_start
_cmd_start:
.word __u_boot_cmd_start
__u_boot_cmd_start is exported in linker script.
Without my patch, disassembled elf looks like this:
<...>
57e00048 <_cmd_start>:
57e00048: 00000000 .word 0x00000000
<...>
while with patch applied:
<..>
57fcb048 <_cmd_start>:
57fcb048: 57fea2b0 .word 0x57fea2b0
<..>
Also disassembling u-boot-spl shows good result because there isn't -pie
linker option.
It's interesting, because if I define .word __u_boot_cmd_start - _start,
then *offset* is calculated correctly.
So, I assume, with -pie, linker doesn't export variables correctly and
in my case pointer to command table is always null.
Eric, could your please test your board in the same way I have described
and find out whether it helps? This could be toolchain version dependent
and other people may not have this problem.
Darius.
next reply other threads:[~2010-10-30 20:37 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-30 20:37 Darius Augulis [this message]
2010-10-30 20:43 ` [U-Boot] ARM: problem with linker option -pie Wolfgang Denk
2010-10-30 20:53 ` Darius Augulis
2010-10-30 21:17 ` Wolfgang Denk
2010-10-30 21:42 ` Albert ARIBAUD
2010-10-30 23:31 ` Albert ARIBAUD
2010-10-31 8:20 ` Albert ARIBAUD
2010-10-31 8:40 ` Reinhard Meyer
2010-10-31 8:51 ` Albert ARIBAUD
2010-10-31 9:25 ` Wolfgang Denk
2010-10-31 9:24 ` Wolfgang Denk
2010-10-31 9:44 ` Albert ARIBAUD
2010-10-31 10:35 ` Wolfgang Denk
2010-10-31 10:57 ` Albert ARIBAUD
2010-10-31 11:30 ` Albert ARIBAUD
2010-10-31 11:31 ` Albert ARIBAUD
2010-10-31 13:29 ` Albert ARIBAUD
2010-10-31 17:38 ` Darius Augulis
2010-10-31 7:46 ` Heiko Schocher
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=4CCC8206.40206@gmail.com \
--to=augulis.darius@gmail.com \
--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.