All of lore.kernel.org
 help / color / mirror / Atom feed
* R_PPC_ADDR16_HI relocs in PPC modules ?
@ 2007-01-02 16:25 Simon Vallet
  2007-01-02 17:16 ` Segher Boessenkool
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Simon Vallet @ 2007-01-02 16:25 UTC (permalink / raw)
  To: linuxppc-dev

Hi,

I'm currently trying to port a binary-only driver to Linux/PPC using a
MacOS X driver as a starting point. "Translating" this driver to ELF32
gives an object that links into a .ko without too much problems.

However, trying to insmod the resulting object gives the following
error message:

unknown ADD relocation: 5

which refers to R_PPC_ADDR16_HI relocations. The error message comes
from apply_relocate_add() in arch/powerpc/kernel/module_32.c, which
deals with R_PPC_ADDR16_LO and R_PPC_ADDR16_HA relocs, but not
R_PPC_ADDR16_HI ones.

Is there a reason for this ? Those relocs directly come from the
mapping of PPC_RELOC_HI16 in the original driver, and i'd rather not
transpose them into R_PPC_ADDR16_HA.

If there are no reasons, then how about the following patch ?
(this is against 2.6.18.1, but the problem is still present in 2.6.19 kernels)

--- arch/powerpc/kernel/module_32.c.orig	2007-01-02 17:07:21.000000000 +0100
+++ arch/powerpc/kernel/module_32.c	2007-01-02 17:11:55.000000000 +0100
@@ -222,6 +222,11 @@ int apply_relocate_add(Elf32_Shdr *sechd
 			*(uint16_t *)location = value;
 			break;
 		
+		case R_PPC_ADDR16_HI:
+			/* Higher half of the symbol */
+			*(uint16_t *)location = (value >> 16);
+			break;
+
 		case R_PPC_ADDR16_HA:
 			/* Sign-adjusted lower 16 bits: PPC ELF ABI says:
 			   (((x >> 16) + ((x & 0x8000) ? 1 : 0))) & 0xFFFF.


Note that I'm quite new to the kernel in general, so feel free to point me to 
another list if you think my questions are inappropriate here.

Simon

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2007-01-03 20:37 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-02 16:25 R_PPC_ADDR16_HI relocs in PPC modules ? Simon Vallet
2007-01-02 17:16 ` Segher Boessenkool
2007-01-02 18:09   ` Simon Vallet
2007-01-02 20:48     ` Segher Boessenkool
2007-01-03  0:47       ` Paul Mackerras
2007-01-03  1:20         ` Segher Boessenkool
2007-01-02 20:41 ` Benjamin Herrenschmidt
2007-01-03  7:01   ` Simon Vallet
2007-01-03  9:58     ` Benjamin Herrenschmidt
2007-01-03 10:32       ` Simon Vallet
2007-01-03 20:36         ` Benjamin Herrenschmidt
2007-01-02 21:31 ` Alan Modra
2007-01-03  6:49 ` [PATCH] Add support for R_PPC_ADDR16_HI relocations Simon Vallet

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.