[U-Boot] [PATCH v4 12/13] arm: Move over to generic relocation

Simon Glass sjg at chromium.org
Tue Feb 21 02:32:54 CET 2012


Add a function to process a single ELF relocation and switch ARM over
to use generic relocation.

Signed-off-by: Simon Glass <sjg at chromium.org>
---
Changes in v2:
- Use an inline relocation function to reduce code size

Changes in v4:
- Remove proc.S file from Makefiles
- Split out board changes into separate patches

 arch/arm/config.mk           |    3 --
 arch/arm/include/asm/reloc.h |   56 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/include/asm/reloc.h

diff --git a/arch/arm/config.mk b/arch/arm/config.mk
index f47d4f7..45f9dca 100644
--- a/arch/arm/config.mk
+++ b/arch/arm/config.mk
@@ -81,6 +81,3 @@ endif
 ifndef CONFIG_NAND_SPL
 LDFLAGS_u-boot += -pie
 endif
-
-# We use legacy relocation for now
-CONFIG_SYS_SKIP_RELOC := y
diff --git a/arch/arm/include/asm/reloc.h b/arch/arm/include/asm/reloc.h
new file mode 100644
index 0000000..3b6491d
--- /dev/null
+++ b/arch/arm/include/asm/reloc.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <elf.h>
+
+/**
+ * Process a single ELF relocation entry
+ *
+ * @param addr		Pointer to address of intruction/data to relocate
+ * @param info		The ELF information word / flags
+ * @param symtab	The ELF relocation symbol table
+ * @param reloc_off	Offset of relocated U-Boot relative to load address
+ * @return 0 if ok, -1 on error
+ */
+static inline int arch_elf_relocate_entry(Elf32_Addr *addr, Elf32_Word info,
+			    Elf32_Sym *symtab, ulong reloc_off)
+{
+	int sym;
+
+	switch (ELF32_R_TYPE(info)) {
+	/* relative fix: increase location by offset */
+	case 23: /* TODO: add R_ARM_... defines to elf.h */
+		*addr += reloc_off;
+		break;
+
+	/* absolute fix: set location to (offset) symbol value */
+	case 2:
+		sym = ELF32_R_SYM(info);
+		*addr = symtab[sym].st_value + reloc_off;
+		break;
+
+	default:
+		debug("*** Invalid relocation\n");
+		return -1;
+	}
+	return 0;
+}
-- 
1.7.7.3



More information about the U-Boot mailing list