* [PATCH] powerpc: Fix build bug with binutils < 2.18 and GCC < 4.2
@ 2008-07-21 23:03 Segher Boessenkool
[not found] ` <48872AB4.3010001@mindspring.com>
0 siblings, 1 reply; 4+ messages in thread
From: Segher Boessenkool @ 2008-07-21 23:03 UTC (permalink / raw)
To: linuxppc-dev, benh
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>
---
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 87a72c6..a914411 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -9,6 +9,25 @@
ENTRY(_stext)
+PHDRS {
+ kernel PT_LOAD FLAGS(7); /* RWX */
+ notes PT_NOTE FLAGS(0);
+ dummy PT_NOTE FLAGS(0);
+
+ /* 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. */
+}
+
#ifdef CONFIG_PPC64
OUTPUT_ARCH(powerpc:common64)
jiffies = jiffies_64;
@@ -50,7 +69,7 @@ SECTIONS
. = ALIGN(PAGE_SIZE);
_etext = .;
PROVIDE32 (etext = .);
- }
+ } :kernel
/* Read-only data */
RODATA
@@ -62,7 +81,13 @@ SECTIONS
__stop___ex_table = .;
}
- NOTES
+ NOTES :kernel :notes
+
+ /* The dummy segment contents for the bug workaround mentioned above
+ near PHDRS. */
+ .dummy : {
+ LONG(0xf177)
+ } :kernel :dummy
/*
* Init sections discarded at runtime
@@ -74,7 +99,7 @@ SECTIONS
_sinittext = .;
INIT_TEXT
_einittext = .;
- }
+ } :kernel
/* .exit.text is discarded at runtime, not link time,
* to deal with references from __bug_table
--
1.5.6.4.gf1ba5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] powerpc: Fix build bug with binutils < 2.18 and GCC < 4.2
[not found] ` <48882217.5010609@mindspring.com>
@ 2008-07-24 22:27 ` Segher Boessenkool
2008-07-24 23:39 ` Chuck Meade
0 siblings, 1 reply; 4+ messages in thread
From: Segher Boessenkool @ 2008-07-24 22:27 UTC (permalink / raw)
To: Chuck Meade; +Cc: linuxppc-dev list
[putting linuxppc-dev on Cc:, hope you don't mind]
On 24 jul 2008, at 08:32, Chuck Meade wrote:
>>> I wanted to reply to your original message regarding this, but sadly
>>> I
>>> had
>>> already deleted it. So I am sending directly to you.
>>>
>>> This patch broke my link.
>>
>> Sorry. I didn't test with anything _that_ ancient.
>>
>>> Reverting it, I am again able to link the latest
>>> git fetch of the kernel, but with your patch, my ld breaks.
>>>
>>> I am using binutils 2.15, successfully until this patch was applied
>>> yesterday.
>>
>> What target / what config / what exact GCC version / what
>> exact binutils version / why are you using such an ancient
>> toolchain anyway? :-)
> I have been using gcc 3.4.4 and binutils 2.15 up to this point without
> problems. Yes they are not cutting-edge by any means,
Updating to GCC 3.4.6 might be a good idea, it's the latest bug fix
release in the 3.4 series. I agree PowerPC Linux should still be
buildable with GCC 3.4; I don't think we really care about 3.3 or
older anymore though.
> but the concern
> here is that this patch causes the linker to fail for the first time.
> Up until now the link has worked fine, and if I revert this patch, the
> link continues to work well.
Yeah, I understand. I'm not saying you need to upgrade your toolchain
(or, I'm not yet saying that anyway; will have to see what causes this
problem first); I just said I neglected to test with anything that old.
> For one of my customers, we use a customized build system that can
> share
> cross toolsets for builds of multiple platforms. So the fact that
> these tools have worked for us cross several 83xx platforms for a long
> time is valuable. It would be highly desirable to have the linker
> continue to work.
Sure, I'll try my best to find out what is wrong, and fix it for you
if possible.
> I am very willing to work with you and test the alternative patch ideas
> you have for vmlinux.lds.S on my tools here. This patch was in the
> general interest of backwards-compatibility with pre-2.18 binutils
> anyway.
Yes, exactly: 2.6.26 does not build with binutils 2.17.
> I can help you by testing on 2.15. Send me alternate vmlinux.lds.S
> files
> to try, and I will test and get back to you ASAP.
No, I will not send you randomly changed source files and hope they
will do something useful for you. Instead, why not provide me the
information I asked for? What target (arch/powerpc it sounds like?)
What _exact_ binutils version (FSF 2.15?) What _exact_ GCC version
(FSF 3.4.4?) What Linux config (either the full .config, or the
name of a defconfig)?
> The link error, in case you were wondering, was:
Yes, I forgot to ask for that :-)
> powerpc-8325-linux-gnu-ld: final link failed: File truncated
What was the command line here? Was it the linking of vmlinux?
Segher
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] powerpc: Fix build bug with binutils < 2.18 and GCC < 4.2
2008-07-24 22:27 ` Segher Boessenkool
@ 2008-07-24 23:39 ` Chuck Meade
2008-07-25 0:18 ` Segher Boessenkool
0 siblings, 1 reply; 4+ messages in thread
From: Chuck Meade @ 2008-07-24 23:39 UTC (permalink / raw)
To: Segher Boessenkool; +Cc: linuxppc-dev list
Segher Boessenkool wrote:
> [putting linuxppc-dev on Cc:, hope you don't mind]
>
> On 24 jul 2008, at 08:32, Chuck Meade wrote:
>
>>>> I wanted to reply to your original message regarding this, but sadly I
>>>> had
>>>> already deleted it. So I am sending directly to you.
>>>>
>>>> This patch broke my link.
>>>
>>> Sorry. I didn't test with anything _that_ ancient.
>>>
>>>> Reverting it, I am again able to link the latest
>>>> git fetch of the kernel, but with your patch, my ld breaks.
>>>>
>>>> I am using binutils 2.15, successfully until this patch was applied
>>>> yesterday.
>>>
>>> What target / what config / what exact GCC version / what
>>> exact binutils version / why are you using such an ancient
>>> toolchain anyway? :-)
>
>> I have been using gcc 3.4.4 and binutils 2.15 up to this point without
>> problems. Yes they are not cutting-edge by any means,
>
> Updating to GCC 3.4.6 might be a good idea, it's the latest bug fix
> release in the 3.4 series. I agree PowerPC Linux should still be
> buildable with GCC 3.4; I don't think we really care about 3.3 or
> older anymore though.
>
>> but the concern
>> here is that this patch causes the linker to fail for the first time.
>> Up until now the link has worked fine, and if I revert this patch, the
>> link continues to work well.
>
> Yeah, I understand. I'm not saying you need to upgrade your toolchain
> (or, I'm not yet saying that anyway; will have to see what causes this
> problem first); I just said I neglected to test with anything that old.
>
>> For one of my customers, we use a customized build system that can share
>> cross toolsets for builds of multiple platforms. So the fact that
>> these tools have worked for us cross several 83xx platforms for a long
>> time is valuable. It would be highly desirable to have the linker
>> continue to work.
>
> Sure, I'll try my best to find out what is wrong, and fix it for you
> if possible.
>
>> I am very willing to work with you and test the alternative patch ideas
>> you have for vmlinux.lds.S on my tools here. This patch was in the
>> general interest of backwards-compatibility with pre-2.18 binutils
>> anyway.
>
> Yes, exactly: 2.6.26 does not build with binutils 2.17.
>
>> I can help you by testing on 2.15. Send me alternate vmlinux.lds.S files
>> to try, and I will test and get back to you ASAP.
>
> No, I will not send you randomly changed source files and hope they
> will do something useful for you. Instead, why not provide me the
> information I asked for? What target (arch/powerpc it sounds like?)
> What _exact_ binutils version (FSF 2.15?) What _exact_ GCC version
> (FSF 3.4.4?) What Linux config (either the full .config, or the
> name of a defconfig)?
No problem -- I thought it would be helpful to offer to test changes for you,
so we could work together toward a solution.
The gcc version is 3.4.4. This is from source tarball gcc-3.4.4.tar.bz2,
downloaded from ftp.gnu.org, built myself using crosstool.
Here is the version output:
$ ./powerpc-8325-linux-gnu-gcc --version
powerpc-8325-linux-gnu-gcc (GCC) 3.4.4
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
The binutils are version 2.15, from source tarball binutils-2.15.tar.bz2.
Downloaded from ftp.gnu.org. Built myself using crosstool.
Here is the version output:
$ ./powerpc-8325-linux-gnu-ld --version
GNU ld version 2.15
Copyright 2002 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License. This program has absolutely no warranty.
The target arch/powerpc. The Linux defconfig was mpc836x_rdk_defconfig.
>> The link error, in case you were wondering, was:
>
> Yes, I forgot to ask for that :-)
>
>> powerpc-8325-linux-gnu-ld: final link failed: File truncated
>
> What was the command line here? Was it the linking of vmlinux?
The command line was "make ARCH=powerpc uImage". The step that failed
was the linking of vmlinux.
If you look at the email to the linuxppc-dev list from this evening at
7:07 pm (about 30 minutes ago), Jon Tollefson is encountering the same
error now.
At the risk of providing too much detail -- if you issue the same build
command with "V=1" appended, it shows the failing link command. Entering
that failing link command at the command line, I can remove all of the files
from the link, one by one, until only kernel/built-in.o is left, and still get
the "File truncated" error.
Of course once you remove enough files from the link line there are other
errors -- "undefined reference" problems that show up -- but the "File truncated"
error is related to kernel/built-in.o. Hope that helps a bit.
Let me know if you have any questions.
Thanks,
Chuck
>
>
> Segher
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] powerpc: Fix build bug with binutils < 2.18 and GCC < 4.2
2008-07-24 23:39 ` Chuck Meade
@ 2008-07-25 0:18 ` Segher Boessenkool
0 siblings, 0 replies; 4+ messages in thread
From: Segher Boessenkool @ 2008-07-25 0:18 UTC (permalink / raw)
To: Chuck Meade; +Cc: linuxppc-dev list, Sean MacLennan
>>> I can help you by testing on 2.15. Send me alternate vmlinux.lds.S
>>> files
>>> to try, and I will test and get back to you ASAP.
>>
>> No, I will not send you randomly changed source files and hope they
>> will do something useful for you. Instead, why not provide me the
>> information I asked for? What target (arch/powerpc it sounds like?)
>> What _exact_ binutils version (FSF 2.15?) What _exact_ GCC version
>> (FSF 3.4.4?) What Linux config (either the full .config, or the
>> name of a defconfig)?
>
> No problem -- I thought it would be helpful to offer to test changes
> for you,
> so we could work together toward a solution.
Sure, and thanks for that! I need to be able to reproduce it myself
to create a patch in the first place though (or spend a few hundred
hours in a senseless guessing game) :-)
I now managed to reproduce it with 2.15 on powerpc64. You should see
the patch soon (I sent it, but for seem reason it takes a while to
get through ozlabs, half an hour or so the last time).
Please test, and thank you! Reply to the patch mail saying if it
worked please (Jon, Sean, you as well?).
Segher
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-07-25 0:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-21 23:03 [PATCH] powerpc: Fix build bug with binutils < 2.18 and GCC < 4.2 Segher Boessenkool
[not found] ` <48872AB4.3010001@mindspring.com>
[not found] ` <bd512e1b36a954819f09379908e342fb@kernel.crashing.org>
[not found] ` <48882217.5010609@mindspring.com>
2008-07-24 22:27 ` Segher Boessenkool
2008-07-24 23:39 ` Chuck Meade
2008-07-25 0:18 ` Segher Boessenkool
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).