arm: module: add support for R_ARM_REL32 relocations

Message ID 1484863892-5818-1-git-send-email-ard.biesheuvel@linaro.org
State New
Headers show

Commit Message

Ard Biesheuvel Jan. 19, 2017, 10:11 p.m.
Add support for R_ARM_REL32 relocations in the module loader,
which will be used by the modversions code when (if) it switches
to using relative references to refer to CRC values.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

---
 arch/arm/include/asm/elf.h | 1 +
 arch/arm/kernel/module.c   | 4 ++++
 2 files changed, 5 insertions(+)

-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Comments

Russell King - ARM Linux Jan. 19, 2017, 11:56 p.m. | #1
On Thu, Jan 19, 2017 at 10:11:32PM +0000, Ard Biesheuvel wrote:
> Add support for R_ARM_REL32 relocations in the module loader,

> which will be used by the modversions code when (if) it switches

> to using relative references to refer to CRC values.


Thanks, please keep this patch handy for when (if) that does happen.
I won't apply this until it is actually needed - no point adding stuff
that never gets used (and therefore doesn't get tested.)

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Ard Biesheuvel Jan. 20, 2017, 10:28 a.m. | #2
On 19 January 2017 at 23:56, Russell King - ARM Linux
<linux@armlinux.org.uk> wrote:
> On Thu, Jan 19, 2017 at 10:11:32PM +0000, Ard Biesheuvel wrote:

>> Add support for R_ARM_REL32 relocations in the module loader,

>> which will be used by the modversions code when (if) it switches

>> to using relative references to refer to CRC values.

>

> Thanks, please keep this patch handy for when (if) that does happen.

> I won't apply this until it is actually needed - no point adding stuff

> that never gets used (and therefore doesn't get tested.)

>


Fair enough

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Patch

diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
index d2315ffd8f12..d450a59ca121 100644
--- a/arch/arm/include/asm/elf.h
+++ b/arch/arm/include/asm/elf.h
@@ -50,6 +50,7 @@  typedef struct user_fp elf_fpregset_t;
 #define R_ARM_NONE		0
 #define R_ARM_PC24		1
 #define R_ARM_ABS32		2
+#define R_ARM_REL32		3
 #define R_ARM_CALL		28
 #define R_ARM_JUMP24		29
 #define R_ARM_TARGET1		38
diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index 4f14b5ce6535..29629fe02ce5 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -159,6 +159,10 @@  apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
 			*(u32 *)loc = offset & 0x7fffffff;
 			break;
 
+		case R_ARM_REL32:
+			*(u32 *)loc += sym->st_value - loc;
+			break;
+
 		case R_ARM_MOVW_ABS_NC:
 		case R_ARM_MOVT_ABS:
 			offset = tmp = __mem_to_opcode_arm(*(u32 *)loc);