Commit c70f74a081c2005b0a4749cf8762fc14b7369ddb

Authored by Simon Glass
Committed by Alexander Graf
1 parent c7ae3dfdcc

elf: arm: Add a few ARM relocation types

Rather than hard-coding the relocation type, add it to the ELF header file
and use it from there.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Graf <agraf@suse.de>

Showing 3 changed files with 17 additions and 2 deletions Side-by-side Diff

arch/arm/lib/relocate.S
... ... @@ -8,6 +8,7 @@
8 8  
9 9 #include <asm-offsets.h>
10 10 #include <config.h>
  11 +#include <elf.h>
11 12 #include <linux/linkage.h>
12 13 #ifdef CONFIG_CPU_V7M
13 14 #include <asm/armv7m.h>
... ... @@ -96,7 +97,7 @@
96 97 fixloop:
97 98 ldmia r2!, {r0-r1} /* (r0,r1) <- (SRC location,fixup) */
98 99 and r1, r1, #0xff
99   - cmp r1, #23 /* relative fixup? */
  100 + cmp r1, #R_ARM_RELATIVE
100 101 bne fixnext
101 102  
102 103 /* relative fix: increase location by offset */
arch/arm/lib/relocate_64.S
... ... @@ -10,6 +10,7 @@
10 10  
11 11 #include <asm-offsets.h>
12 12 #include <config.h>
  13 +#include <elf.h>
13 14 #include <linux/linkage.h>
14 15 #include <asm/macro.h>
15 16  
... ... @@ -47,7 +48,7 @@
47 48 ldp x0, x1, [x2], #16 /* (x0,x1) <- (SRC location, fixup) */
48 49 ldr x4, [x2], #8 /* x4 <- addend */
49 50 and x1, x1, #0xffffffff
50   - cmp x1, #1027 /* relative fixup? */
  51 + cmp x1, #R_AARCH64_RELATIVE
51 52 bne fixnext
52 53  
53 54 /* relative fix: store addend plus offset at dest location */
... ... @@ -13,6 +13,7 @@
13 13 #ifndef _ELF_H
14 14 #define _ELF_H
15 15  
  16 +#ifndef __ASSEMBLER__
16 17 #include "compiler.h"
17 18  
18 19 /*
... ... @@ -517,6 +518,8 @@
517 518  
518 519 #define ELF_TARG_VER 1 /* The ver for which this code is intended */
519 520  
  521 +#endif /* __ASSEMBLER */
  522 +
520 523 /*
521 524 * XXX - PowerPC defines really don't belong in here,
522 525 * but we'll put them in for simplicity.
523 526  
... ... @@ -602,7 +605,17 @@
602 605 that may still be in object files. */
603 606 #define R_PPC_TOC16 255
604 607  
  608 + /* ARM relocs */
  609 +#define R_ARM_NONE 0 /* No reloc */
  610 +#define R_ARM_RELATIVE 23 /* Adjust by program base */
  611 +
  612 +/* AArch64 relocs */
  613 +#define R_AARCH64_NONE 0 /* No relocation. */
  614 +#define R_AARCH64_RELATIVE 1027 /* Adjust by program base. */
  615 +
  616 +#ifndef __ASSEMBLER__
605 617 int valid_elf_image(unsigned long addr);
  618 +#endif
606 619  
607 620 #endif /* _ELF_H */