]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc: Fix -mcmodel=medium breakage in prom_init.c
authorAnton Blanchard <anton@samba.org>
Tue, 12 Mar 2013 01:51:51 +0000 (01:51 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Tue, 12 Mar 2013 23:06:52 +0000 (10:06 +1100)
commit8a9300fbea909a9d0ef09c69ef55538e9c5ec4ff
tree8c0d6a0f12e9e5aa309b0e572311999d2aee0d89
parent6b3876d7e7f81ab0859e34a95fb2e9f0b627a0ac
powerpc: Fix -mcmodel=medium breakage in prom_init.c

Commit d753aebd4b4c (powerpc: Relocate prom_init.c on 64bit) made
prom_init.c position independent by manually relocating its entries
in the TOC.

We get the address of the TOC entries with the __prom_init_toc_start
linker symbol. If __prom_init_toc_start ends up as an entry in the
TOC then we need to add an offset to get the current address. This is
the case for older toolchains.

On the other hand, if we have a newer toolchain that supports
-mcmodel=medium then __prom_init_toc_start will be created by a
relative offset from r2 (the TOC pointer). Since r2 has already been
relocated, nothing more needs to be done.  Adding an offset in this
case is wrong and Aaro Koskinen and Alexander Graf have noticed noticed
G5 and OpenBIOS breakage.

Alan Modra suggested we just use r2 to get at the TOC which is simpler
and works with both old and new toolchains.

Reported-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Anton Blanchard <anton@samba.org>
Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/kernel/prom_init.c