diff options
| author | Segher Boessenkool <segher@kernel.crashing.org> | 2008-07-21 19:03:45 -0400 |
|---|---|---|
| committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2008-07-21 20:39:37 -0400 |
| commit | c69cccc95fe4b90dde5fe33e6a3b77880b534fa4 (patch) | |
| tree | a66214423a1eb987ee0e54e8c8a67f9d955d6055 /arch | |
| parent | f36c5227cd88b6340c40d62b05859e8213740a97 (diff) | |
powerpc: Fix build bug with binutils < 2.18 and GCC < 4.2
binutils < 2.18 has a bug that makes it misbehave when taking an
ELF file with all segments at load address 0 as input. This
happens when running "strip" on vmlinux, because of the AT() magic
in this linker script. People using GCC >= 4.2 won't run into
this problem, because the "build-id" support will put some data
into the "notes" segment (at a non-zero load address).
To work around this, we force some data into both the "dummy"
segment and the kernel segment, so the dummy segment will get a
non-zero load address. It's not enough to always create the
"notes" segment, since if nothing gets assigned to it, its load
address will be zero.
Signed-off-by: Segher Boessenkool <segher@kernel.crashing.org>
Tested-By: Milton Miller <miltonm@bga.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/powerpc/kernel/vmlinux.lds.S | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S index 87a72c66ce27..a914411bced5 100644 --- a/arch/powerpc/kernel/vmlinux.lds.S +++ b/arch/powerpc/kernel/vmlinux.lds.S | |||
| @@ -9,6 +9,25 @@ | |||
| 9 | 9 | ||
| 10 | ENTRY(_stext) | 10 | ENTRY(_stext) |
| 11 | 11 | ||
| 12 | PHDRS { | ||
| 13 | kernel PT_LOAD FLAGS(7); /* RWX */ | ||
| 14 | notes PT_NOTE FLAGS(0); | ||
| 15 | dummy PT_NOTE FLAGS(0); | ||
| 16 | |||
| 17 | /* binutils < 2.18 has a bug that makes it misbehave when taking an | ||
| 18 | ELF file with all segments at load address 0 as input. This | ||
| 19 | happens when running "strip" on vmlinux, because of the AT() magic | ||
| 20 | in this linker script. People using GCC >= 4.2 won't run into | ||
| 21 | this problem, because the "build-id" support will put some data | ||
| 22 | into the "notes" segment (at a non-zero load address). | ||
| 23 | |||
| 24 | To work around this, we force some data into both the "dummy" | ||
| 25 | segment and the kernel segment, so the dummy segment will get a | ||
| 26 | non-zero load address. It's not enough to always create the | ||
| 27 | "notes" segment, since if nothing gets assigned to it, its load | ||
| 28 | address will be zero. */ | ||
| 29 | } | ||
| 30 | |||
| 12 | #ifdef CONFIG_PPC64 | 31 | #ifdef CONFIG_PPC64 |
| 13 | OUTPUT_ARCH(powerpc:common64) | 32 | OUTPUT_ARCH(powerpc:common64) |
| 14 | jiffies = jiffies_64; | 33 | jiffies = jiffies_64; |
| @@ -50,7 +69,7 @@ SECTIONS | |||
| 50 | . = ALIGN(PAGE_SIZE); | 69 | . = ALIGN(PAGE_SIZE); |
| 51 | _etext = .; | 70 | _etext = .; |
| 52 | PROVIDE32 (etext = .); | 71 | PROVIDE32 (etext = .); |
| 53 | } | 72 | } :kernel |
| 54 | 73 | ||
| 55 | /* Read-only data */ | 74 | /* Read-only data */ |
| 56 | RODATA | 75 | RODATA |
| @@ -62,7 +81,13 @@ SECTIONS | |||
| 62 | __stop___ex_table = .; | 81 | __stop___ex_table = .; |
| 63 | } | 82 | } |
| 64 | 83 | ||
| 65 | NOTES | 84 | NOTES :kernel :notes |
| 85 | |||
| 86 | /* The dummy segment contents for the bug workaround mentioned above | ||
| 87 | near PHDRS. */ | ||
| 88 | .dummy : { | ||
| 89 | LONG(0xf177) | ||
| 90 | } :kernel :dummy | ||
| 66 | 91 | ||
| 67 | /* | 92 | /* |
| 68 | * Init sections discarded at runtime | 93 | * Init sections discarded at runtime |
| @@ -74,7 +99,7 @@ SECTIONS | |||
| 74 | _sinittext = .; | 99 | _sinittext = .; |
| 75 | INIT_TEXT | 100 | INIT_TEXT |
| 76 | _einittext = .; | 101 | _einittext = .; |
| 77 | } | 102 | } :kernel |
| 78 | 103 | ||
| 79 | /* .exit.text is discarded at runtime, not link time, | 104 | /* .exit.text is discarded at runtime, not link time, |
| 80 | * to deal with references from __bug_table | 105 | * to deal with references from __bug_table |
