grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ijc@hellion.org.uk>
To: grub-devel@gnu.org
Cc: Vladimir Serbinenko <phcoder@gmail.com>,
	Leif Lindholm <leif.lindholm@linaro.org>,
	Ian Campbell <ijc@hellion.org.uk>
Subject: [PATCH 7/7] arm-uboot: support relocation at installation time
Date: Sun, 29 Dec 2013 18:47:36 +0000	[thread overview]
Message-ID: <1388342856-18317-7-git-send-email-ijc@hellion.org.uk> (raw)
In-Reply-To: <1388342839.32105.25.camel@hastur.hellion.org.uk>

Partially link kernel.img and take advantage of the new
PLATFORM_FLAGS_ABS_RELOC support to link the final kernel image for a
particular address.

Signed-off-by: Ian Campbell <ijc@hellion.org.uk>
---
 grub-core/Makefile.core.def | 2 +-
 include/grub/offsets.h      | 2 +-
 util/mkimage.c              | 8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index e5e558c..f14a2c4 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -95,7 +95,7 @@ kernel = {
   i386_qemu_cppflags     = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
   emu_cflags = '$(CFLAGS_GNULIB)';
   emu_cppflags = '$(CPPFLAGS_GNULIB)';
-  arm_uboot_ldflags       = '-Wl,-Ttext=0x08000000';
+  arm_uboot_ldflags       = '-Wl,-r,-d';
   arm_uboot_stripflags    = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
 
   i386_pc_startup = kern/i386/pc/startup.S;
diff --git a/include/grub/offsets.h b/include/grub/offsets.h
index 85e7401..bb14190 100644
--- a/include/grub/offsets.h
+++ b/include/grub/offsets.h
@@ -120,7 +120,7 @@
 
 #define GRUB_KERNEL_ARM_UBOOT_MOD_ALIGN 	0x8
 #define GRUB_KERNEL_ARM_UBOOT_TOTAL_MODULE_SIZE	0x4
-#define GRUB_KERNEL_ARM_UBOOT_LINK_ADDR		0x08000000
+#define GRUB_KERNEL_ARM_UBOOT_DEFAULT_LINK_ADDR 0x08000000
 
 /* Minimal gap between _end and the start of the modules.  It's a hack
    for PowerMac to prevent "CLAIM failed" error.  The real fix is to
diff --git a/util/mkimage.c b/util/mkimage.c
index 7b29acf..112092e 100644
--- a/util/mkimage.c
+++ b/util/mkimage.c
@@ -549,14 +549,14 @@ static const struct grub_install_image_target_desc image_targets[] =
       .voidp_sizeof = 4,
       .bigendian = 0,
       .id = IMAGE_UBOOT, 
-      .flags = PLATFORM_FLAGS_NONE,
+      .flags = PLATFORM_FLAGS_ABS_RELOC,
       .total_module_size = GRUB_KERNEL_ARM_UBOOT_TOTAL_MODULE_SIZE,
       .decompressor_compressed_size = TARGET_NO_FIELD,
       .decompressor_uncompressed_size = TARGET_NO_FIELD,
       .decompressor_uncompressed_addr = TARGET_NO_FIELD,
       .section_align = GRUB_KERNEL_ARM_UBOOT_MOD_ALIGN,
       .vaddr_offset = 0,
-      .link_addr = GRUB_KERNEL_ARM_UBOOT_LINK_ADDR,
+      .link_addr = GRUB_KERNEL_ARM_UBOOT_DEFAULT_LINK_ADDR,
       .elf_target = EM_ARM,
       .mod_gap = GRUB_KERNEL_ARM_UBOOT_MOD_GAP,
       .mod_align = GRUB_KERNEL_ARM_UBOOT_MOD_ALIGN,
@@ -1802,8 +1802,8 @@ grub_install_generate_image (const char *dir, const char *prefix,
       hdr->ih_magic = grub_cpu_to_be32_compile_time (GRUB_UBOOT_IH_MAGIC);
       hdr->ih_time = grub_cpu_to_be32 (time (0));
       hdr->ih_size = grub_cpu_to_be32 (core_size);
-      hdr->ih_load = grub_cpu_to_be32 (image_target->link_addr);
-      hdr->ih_ep = grub_cpu_to_be32 (image_target->link_addr);
+      hdr->ih_load = grub_cpu_to_be32 (target_address);
+      hdr->ih_ep = grub_cpu_to_be32 (start_address);
       hdr->ih_type = GRUB_UBOOT_IH_TYPE_KERNEL;
       hdr->ih_os = GRUB_UBOOT_IH_OS_LINUX;
       hdr->ih_arch = GRUB_UBOOT_IH_ARCH_ARM;
-- 
1.8.4.rc3



  parent reply	other threads:[~2013-12-29 18:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-29 18:47 [PATCH 0/7] arm-uboot: support for different RAM bases Ian Campbell
2013-12-29 18:47 ` [PATCH 1/7] mkimage: Refactor IMAGE_EFI checks into a function grub_image_needs_reloc Ian Campbell
2013-12-29 18:47 ` [PATCH 2/7] mkimage: Replace hardcoded 0x400 in R_ARM_ABS32 relocation Ian Campbell
2013-12-29 18:47 ` [PATCH 3/7] mkimage: account for space for trampolines earlier Ian Campbell
2013-12-29 18:47 ` [PATCH 4/7] mkimage: make R_ARM_ABS32 debug output more consistent Ian Campbell
2013-12-29 18:47 ` [PATCH 5/7] mkimage: allow linking at address 0 Ian Campbell
2013-12-29 18:47 ` [PATCH 6/7] mkimage: support images which require full relocation at mkimage time Ian Campbell
2013-12-29 22:53   ` Leif Lindholm
2013-12-30  3:49     ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-12-30 10:54     ` Ian Campbell
2013-12-30 15:46   ` Andrey Borzenkov
2013-12-31 14:19   ` Francesco Lavra
2013-12-31 16:44     ` Ian Campbell
2013-12-29 18:47 ` Ian Campbell [this message]
2013-12-29 19:10 ` [PATCH 0/7] arm-uboot: support for different RAM bases Ian Campbell
2013-12-29 23:04 ` Leif Lindholm
2013-12-30  1:55 ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-12-30 10:48   ` Ian Campbell

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=1388342856-18317-7-git-send-email-ijc@hellion.org.uk \
    --to=ijc@hellion.org.uk \
    --cc=grub-devel@gnu.org \
    --cc=leif.lindholm@linaro.org \
    --cc=phcoder@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).