Mips: When using CONFIG_OF_SEPARATE, mips-relocs mess up _end symbol
PATCH 1/1 Mips: When using CONFIG_OF_SEPARATE, mips-relocs mess up _end symbol
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.
--- tools/Makefile | 1 + tools/mips-relocs.c | 3 +++ 2 files changed, 4 insertions(+)
tools/Makefile +1 -0
@@ -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
tools/mips-relocs.c +3 -0
@@ -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 );
Signature · 1 line
2.7.4