* [PATCH] Handle R_ALPHA_REFLONG relocation on Alpha (2.6.0-test11) @ 2003-12-13 0:38 Nathan Poznick 2003-12-13 2:27 ` Måns Rullgård 2003-12-17 12:10 ` Richard Henderson 0 siblings, 2 replies; 9+ messages in thread From: Nathan Poznick @ 2003-12-13 0:38 UTC (permalink / raw) To: linux-kernel [-- Attachment #1: Type: text/plain, Size: 1441 bytes --] First off, I'm not positive that this patch is correct or not, but I'd like to pick the brains of people in the know, to find if I'm approaching this in the right way. I've been unable to use modules on my Alpha with 2.6.0-test*. modprobe (from module-init-tools 0.9.15-pre3) would claim an invalid module format, and the kernel would tell me "Unknown relocation: 1" Relocation 1 on Alpha is R_ALPHA_REFLONG, and sure enough, readelf -r on one of the modules showed many, many uses of it. From looking at arch/alpha/kernel/module.c, it appeared that while R_ALPHA_REFQUAD was handled, R_ALPHA_REFLONG was not. R_ALPHA_REFQUAD's handling looked simple enough, so I made the change which is inlined below. Is this the proper way to handle this? After making this change, I've been able to use modules without any problems. --- linux-2.6.0-test11/arch/alpha/kernel/module.c 2003-12-12 18:19:27.000000000 -0600 +++ linux-2.6.0-test11.new/arch/alpha/kernel/module.c 2003-12-12 18:32:51.000000000 -0600 @@ -198,6 +198,9 @@ switch (r_type) { case R_ALPHA_NONE: break; + case R_ALPHA_REFLONG: + *(u32 *)location = value; + break; case R_ALPHA_REFQUAD: /* BUG() can produce misaligned relocations. */ ((u32 *)location)[0] = value; -- Nathan Poznick <kraken@drunkmonkey.org> "So many times you've given me comfort and forgetfulness." --Frank Herbert, Dune [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Handle R_ALPHA_REFLONG relocation on Alpha (2.6.0-test11) 2003-12-13 0:38 [PATCH] Handle R_ALPHA_REFLONG relocation on Alpha (2.6.0-test11) Nathan Poznick @ 2003-12-13 2:27 ` Måns Rullgård 2003-12-13 4:09 ` Nathan Poznick 2003-12-17 12:10 ` Richard Henderson 1 sibling, 1 reply; 9+ messages in thread From: Måns Rullgård @ 2003-12-13 2:27 UTC (permalink / raw) To: linux-kernel Nathan Poznick <kraken@drunkmonkey.org> writes: > First off, I'm not positive that this patch is correct or not, but I'd > like to pick the brains of people in the know, to find if I'm > approaching this in the right way. > > I've been unable to use modules on my Alpha with 2.6.0-test*. modprobe > (from module-init-tools 0.9.15-pre3) would claim an invalid module > format, and the kernel would tell me "Unknown relocation: 1" Relocation > 1 on Alpha is R_ALPHA_REFLONG, and sure enough, readelf -r on one of the > modules showed many, many uses of it. From looking at > arch/alpha/kernel/module.c, it appeared that while R_ALPHA_REFQUAD was > handled, R_ALPHA_REFLONG was not. R_ALPHA_REFQUAD's handling looked > simple enough, so I made the change which is inlined below. Which gcc and binutils versions do you use? I've seen some variation in which relocations they produce. -- Måns Rullgård mru@kth.se ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Handle R_ALPHA_REFLONG relocation on Alpha (2.6.0-test11) 2003-12-13 2:27 ` Måns Rullgård @ 2003-12-13 4:09 ` Nathan Poznick 0 siblings, 0 replies; 9+ messages in thread From: Nathan Poznick @ 2003-12-13 4:09 UTC (permalink / raw) To: linux-kernel [-- Attachment #1: Type: text/plain, Size: 540 bytes --] Thus spake M?ns Rullg?rd: > Which gcc and binutils versions do you use? I've seen some variation > in which relocations they produce. I'm using gcc 3.3.2 and binutils 2.14.90.0.7. The patch shouldn't hurt when using versions which may produce other relocations, correct? If R_ALPHA_REFLONG isn't generated, then that bit of the switch statement just wouldn't be hit. -- Nathan Poznick <kraken@drunkmonkey.org> If you write something wrong enough, I'll be glad to make up a new witticism just for you. -- Larry Wall [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Handle R_ALPHA_REFLONG relocation on Alpha (2.6.0-test11) 2003-12-13 0:38 [PATCH] Handle R_ALPHA_REFLONG relocation on Alpha (2.6.0-test11) Nathan Poznick 2003-12-13 2:27 ` Måns Rullgård @ 2003-12-17 12:10 ` Richard Henderson 2003-12-17 19:31 ` Nathan Poznick 1 sibling, 1 reply; 9+ messages in thread From: Richard Henderson @ 2003-12-17 12:10 UTC (permalink / raw) To: linux-kernel On Fri, Dec 12, 2003 at 06:38:41PM -0600, Nathan Poznick wrote: > I've been unable to use modules on my Alpha with 2.6.0-test*. modprobe > (from module-init-tools 0.9.15-pre3) would claim an invalid module > format, and the kernel would tell me "Unknown relocation: 1" Relocation > 1 on Alpha is R_ALPHA_REFLONG, and sure enough, readelf -r on one of the > modules showed many, many uses of it. Which module? This relocation should never EVER show up in kernel code. (It will show up in dwarf2 debug info, so make sure you're not looking at objects compiled with -g, but debug sections ought to be ignored by the module loading code.) r~ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Handle R_ALPHA_REFLONG relocation on Alpha (2.6.0-test11) 2003-12-17 12:10 ` Richard Henderson @ 2003-12-17 19:31 ` Nathan Poznick 2003-12-18 1:02 ` Richard Henderson 0 siblings, 1 reply; 9+ messages in thread From: Nathan Poznick @ 2003-12-17 19:31 UTC (permalink / raw) To: linux-kernel; +Cc: Richard Henderson [-- Attachment #1: Type: text/plain, Size: 973 bytes --] Thus spake Richard Henderson: > Which module? This relocation should never EVER show up in kernel code. Well, it was happening on anything I attempted to make a module. > (It will show up in dwarf2 debug info, so make sure you're not looking at > objects compiled with -g, but debug sections ought to be ignored by the > module loading code.) I think that may have been the root cause of this; I had CONFIG_DEBUG_INFO enabled from debugging attempts related to a past problem. With that enabled, -g is used for the compile, so the relocations were added, and module loading failed. After disabling it, R_ALPHA_REFLONG did not appear in any of the object files. So I suppose my next question is if this is a known/intended side effect -- enabling CONFIG_DEBUG_INFO means that modules cannot be used? -- Nathan Poznick <kraken@drunkmonkey.org> My school colors were clear. We used to say, "I'm not naked, I'm in the band." -Stephen Wright [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Handle R_ALPHA_REFLONG relocation on Alpha (2.6.0-test11) 2003-12-17 19:31 ` Nathan Poznick @ 2003-12-18 1:02 ` Richard Henderson 2003-12-22 1:08 ` Rusty Russell 2003-12-30 3:57 ` Rusty Russell 0 siblings, 2 replies; 9+ messages in thread From: Richard Henderson @ 2003-12-18 1:02 UTC (permalink / raw) To: linux-kernel On Wed, Dec 17, 2003 at 01:31:24PM -0600, Nathan Poznick wrote: > my next question is if this is a known/intended side effect -- enabling > CONFIG_DEBUG_INFO means that modules cannot be used? No. This means there's a bug in the generic bits of the module loaders, that they're not discarding debugging sections. r~ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Handle R_ALPHA_REFLONG relocation on Alpha (2.6.0-test11) 2003-12-18 1:02 ` Richard Henderson @ 2003-12-22 1:08 ` Rusty Russell 2003-12-30 3:57 ` Rusty Russell 1 sibling, 0 replies; 9+ messages in thread From: Rusty Russell @ 2003-12-22 1:08 UTC (permalink / raw) To: Richard Henderson, Nathan Poznick; +Cc: linux-kernel On Wed, 17 Dec 2003 17:02:03 -0800 Richard Henderson <rth@twiddle.net> wrote: > On Wed, Dec 17, 2003 at 01:31:24PM -0600, Nathan Poznick wrote: > > my next question is if this is a known/intended side effect -- enabling > > CONFIG_DEBUG_INFO means that modules cannot be used? > > No. This means there's a bug in the generic bits of the module > loaders, that they're not discarding debugging sections. Agree with Richard, unless toolchain is setting SHF_ALLOC on those sections for some weird reason. Nathan, can you mail me (off-list) a module which needs this? I'll take a look. Thanks, Rusty. -- there are those who do and those who hang on and you don't see too many doers quoting their contemporaries. -- Larry McVoy ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Handle R_ALPHA_REFLONG relocation on Alpha (2.6.0-test11) 2003-12-18 1:02 ` Richard Henderson 2003-12-22 1:08 ` Rusty Russell @ 2003-12-30 3:57 ` Rusty Russell 2003-12-30 6:14 ` Nathan Poznick 1 sibling, 1 reply; 9+ messages in thread From: Rusty Russell @ 2003-12-30 3:57 UTC (permalink / raw) To: Richard Henderson; +Cc: linux-kernel, Nathan Poznick On Wed, 17 Dec 2003 17:02:03 -0800 Richard Henderson <rth@twiddle.net> wrote: > On Wed, Dec 17, 2003 at 01:31:24PM -0600, Nathan Poznick wrote: > > my next question is if this is a known/intended side effect -- enabling > > CONFIG_DEBUG_INFO means that modules cannot be used? > > No. This means there's a bug in the generic bits of the module > loaders, that they're not discarding debugging sections. Ah, my bad. We suck in the whole module, then copy SHF_ALLOC sections, then apply relocations. We don't skip relocations on sections which haven't been copied. This patch works for me: Nathan, does it solve your problem? Rusty. -- there are those who do and those who hang on and you don't see too many doers quoting their contemporaries. -- Larry McVoy Name: Don't Apply Relocations To Sections We Haven't Copied Author: Rusty Russell Status: Tested on 2.6.0-bk1 D: The module code applies every relocation section given. Obviously, if D: the section has not been copied into the module, there's no point. D: In particular, Alpha has relocs which are only used on debug sections, D: so they don't load with CONFIG_DEBUG_INFO enabled. diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .2481-linux-2.6.0-bk1/kernel/module.c .2481-linux-2.6.0-bk1.updated/kernel/module.c --- .2481-linux-2.6.0-bk1/kernel/module.c 2003-11-24 15:42:33.000000000 +1100 +++ .2481-linux-2.6.0-bk1.updated/kernel/module.c 2003-12-30 14:08:40.000000000 +1100 @@ -1618,9 +1618,13 @@ static struct module *load_module(void _ /* Now do relocations. */ for (i = 1; i < hdr->e_shnum; i++) { const char *strtab = (char *)sechdrs[strindex].sh_addr; - if (sechdrs[i].sh_type == SHT_REL) - err = apply_relocate(sechdrs, strtab, symindex, i,mod); - else if (sechdrs[i].sh_type == SHT_RELA) + + /* Skip relocations on non-allocated (ie. debug) sections */ + if (sechdrs[i].sh_type == SHT_REL + && (sechdrs[sechdrs[i].sh_info].sh_flags & SHF_ALLOC)) + err = apply_relocate(sechdrs, strtab, symindex,i, mod); + else if (sechdrs[i].sh_type == SHT_RELA + && (sechdrs[sechdrs[i].sh_info].sh_flags & SHF_ALLOC)) err = apply_relocate_add(sechdrs, strtab, symindex, i, mod); if (err < 0) ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Handle R_ALPHA_REFLONG relocation on Alpha (2.6.0-test11) 2003-12-30 3:57 ` Rusty Russell @ 2003-12-30 6:14 ` Nathan Poznick 0 siblings, 0 replies; 9+ messages in thread From: Nathan Poznick @ 2003-12-30 6:14 UTC (permalink / raw) To: Rusty Russell; +Cc: Richard Henderson, linux-kernel [-- Attachment #1: Type: text/plain, Size: 300 bytes --] Thus spake Rusty Russell: > This patch works for me: Nathan, does it solve your problem? > Rusty. This did indeed solve my problem on Alpha. I can now use modules with CONFIG_DEBUG_INFO. Thanks! -- Nathan Poznick <kraken@drunkmonkey.org> "Time for go to bed." -Tor Johnson. #320 [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2003-12-30 6:14 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2003-12-13 0:38 [PATCH] Handle R_ALPHA_REFLONG relocation on Alpha (2.6.0-test11) Nathan Poznick 2003-12-13 2:27 ` Måns Rullgård 2003-12-13 4:09 ` Nathan Poznick 2003-12-17 12:10 ` Richard Henderson 2003-12-17 19:31 ` Nathan Poznick 2003-12-18 1:02 ` Richard Henderson 2003-12-22 1:08 ` Rusty Russell 2003-12-30 3:57 ` Rusty Russell 2003-12-30 6:14 ` Nathan Poznick
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).