* [PATCH] alpha: link failure fix
@ 2008-06-20 23:26 Ivan Kokshaysky
2008-06-21 20:17 ` Sam Ravnborg
0 siblings, 1 reply; 3+ messages in thread
From: Ivan Kokshaysky @ 2008-06-20 23:26 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Richard Henderson, Andrew Morton, linux-kernel
With built-in scsi disk driver, the final link fails with a following
error:
`.exit.text' referenced in section `.rodata' of drivers/built-in.o:
defined in discarded section `.exit.text' of drivers/built-in.o
This happens with -Os (CONFIG_CC_OPTIMIZE_FOR_SIZE=y) with all gcc-4
versions, and also with -O2 and gcc-4.3.
The problem is in sd.c:sd_major() being inlined into __exit function
exit_sd(), and the compiler generating a jump table in .rodata section
for the 'switch' statement in sd_major(). So we have references to
discarded section.
Fixed with a big hammer in the form of -fno-jump-tables.
Note that jump tables vs. discarded sections is a generic problem,
other architectures are just lucky not to suffer from it. But with
a slightly more complex switch/case statement it can be reproduced
on x86 as well. So maybe at some point we should consider
-fno-jump-tables as a generic compile option...
Signed-off-by: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
---
arch/alpha/Makefile | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/arch/alpha/Makefile b/arch/alpha/Makefile
index 4e1a8e2..4759fe7 100644
--- a/arch/alpha/Makefile
+++ b/arch/alpha/Makefile
@@ -13,6 +13,7 @@ NM := $(NM) -B
LDFLAGS_vmlinux := -static -N #-relax
CHECKFLAGS += -D__alpha__ -m64
cflags-y := -pipe -mno-fp-regs -ffixed-8 -msmall-data
+cflags-y += $(call cc-option, -fno-jump-tables)
cpuflags-$(CONFIG_ALPHA_EV4) := -mcpu=ev4
cpuflags-$(CONFIG_ALPHA_EV5) := -mcpu=ev5
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] alpha: link failure fix
2008-06-20 23:26 [PATCH] alpha: link failure fix Ivan Kokshaysky
@ 2008-06-21 20:17 ` Sam Ravnborg
2008-06-24 12:36 ` Ivan Kokshaysky
0 siblings, 1 reply; 3+ messages in thread
From: Sam Ravnborg @ 2008-06-21 20:17 UTC (permalink / raw)
To: Ivan Kokshaysky
Cc: Linus Torvalds, Richard Henderson, Andrew Morton, linux-kernel
On Sat, Jun 21, 2008 at 03:26:21AM +0400, Ivan Kokshaysky wrote:
> With built-in scsi disk driver, the final link fails with a following
> error:
> `.exit.text' referenced in section `.rodata' of drivers/built-in.o:
> defined in discarded section `.exit.text' of drivers/built-in.o
>
> This happens with -Os (CONFIG_CC_OPTIMIZE_FOR_SIZE=y) with all gcc-4
> versions, and also with -O2 and gcc-4.3.
>
> The problem is in sd.c:sd_major() being inlined into __exit function
> exit_sd(), and the compiler generating a jump table in .rodata section
> for the 'switch' statement in sd_major(). So we have references to
> discarded section.
>
> Fixed with a big hammer in the form of -fno-jump-tables.
>
> Note that jump tables vs. discarded sections is a generic problem,
> other architectures are just lucky not to suffer from it.
Most other architectures would only notice when the exit function
is called because they do late discardning og the exit section.
alpha (and sparc) are some of the few architectures that discard exit
section at link time thus you will see this much sooner
than the others.
> But with
> a slightly more complex switch/case statement it can be reproduced
> on x86 as well. So maybe at some point we should consider
> -fno-jump-tables as a generic compile option...
Are the any size penalties here?
I assume there are a minimal performance penalty.
Sam
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] alpha: link failure fix
2008-06-21 20:17 ` Sam Ravnborg
@ 2008-06-24 12:36 ` Ivan Kokshaysky
0 siblings, 0 replies; 3+ messages in thread
From: Ivan Kokshaysky @ 2008-06-24 12:36 UTC (permalink / raw)
To: Sam Ravnborg
Cc: Linus Torvalds, Richard Henderson, Andrew Morton, linux-kernel
On Sat, Jun 21, 2008 at 10:17:42PM +0200, Sam Ravnborg wrote:
> Most other architectures would only notice when the exit function
> is called because they do late discardning og the exit section.
> alpha (and sparc) are some of the few architectures that discard exit
> section at link time thus you will see this much sooner
> than the others.
Ah, indeed. Then it's not so critical on x86 and others.
> Are the any size penalties here?
Just checked: quite the contrary, on alpha with -fno-jump-tables
resulting kernel image is a few kilobytes smaller (~17Kb in my config,
vmlinux is ~5Mb).
> I assume there are a minimal performance penalty.
Yeah, I don't think there are lots of big switch statements in the
hot paths.
Ivan.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-06-24 12:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-20 23:26 [PATCH] alpha: link failure fix Ivan Kokshaysky
2008-06-21 20:17 ` Sam Ravnborg
2008-06-24 12:36 ` Ivan Kokshaysky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®