From: Lars Povlsen <lars.povlsen@microsemi.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] Mips: When using CONFIG_OF_SEPARATE, mips-relocs mess up _end symbol
Date: Tue, 23 Oct 2018 13:14:50 +0200 [thread overview]
Message-ID: <87d0s0symt.fsf@soft-dev15.microsemi.net> (raw)
When converting some MIPS-based platforms from CONFIG_OF_EMBED to
CONFIG_OF_SEPARATE and CONFIG_MULTI_DTB_FIT, I had trouble with getting
to the right offset of the DTB blob.
It turns out that the mips-relocs utility chops off unused space in the
".rel" section, but in doing so it bring the "_end" symbol out of sync
with the actual end of the generated binary. When the DT blob is tacked
on, the "_end" symbol will not point to the start of the blob as
desired, but somewhere into the blob - causing the DT parse to fail.
This fix skips the ".rel" section shrinking to keep "_end" pointing to
the right place. Another possible solution would be to update "_end",
but that is beyond my current skills I'm afraid.
Signed-off-by: Lars Povlsen <lars.povlsen@microsemi.com>
---
tools/Makefile | 1 +
tools/mips-relocs.c | 3 +++
2 files changed, 4 insertions(+)
diff --git a/tools/Makefile b/tools/Makefile
index 0c3341e..aabb5b8 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -196,6 +196,7 @@ hostprogs-y += fdtgrep
fdtgrep-objs += $(LIBFDT_OBJS) fdtgrep.o
hostprogs-$(CONFIG_MIPS) += mips-relocs
+HOSTCFLAGS_mips-relocs.o := $(if $(CONFIG_OF_SEPARATE),-DCONFIG_OF_SEPARATE -Wno-unused-but-set-variable -Wno-unused-variable)
# We build some files with extra pedantic flags to try to minimize things
# that won't build on some weird host compiler -- though there are lots of
diff --git a/tools/mips-relocs.c b/tools/mips-relocs.c
index 442cc8f..9c5bf07 100644
--- a/tools/mips-relocs.c
+++ b/tools/mips-relocs.c
@@ -401,6 +401,8 @@ int main(int argc, char *argv[])
return -ENOMEM;
}
+ // Shrinking the .rel section mess up the _end symbol when CONFIG_OF_SEPARATE used
+#if !defined(CONFIG_OF_SEPARATE)
/* Update the .rel section's size */
set_shdr_field(i_rel_shdr, sh_size, rel_actual_size);
@@ -414,6 +416,7 @@ int main(int argc, char *argv[])
set_phdr_field(i, p_filesz, load_sz);
break;
}
+#endif
/* Make sure data is written back to the file */
err = msync(elf, st.st_size, MS_SYNC);
--
2.7.4
reply other threads:[~2018-10-23 11:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=87d0s0symt.fsf@soft-dev15.microsemi.net \
--to=lars.povlsen@microsemi.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.