x86: linker script syntax nits
PATCH 1/1 x86: linker script syntax nits
The following changes since commit 80f506918fdaaca6b574ba931536a58ce015c7be:
Linus Torvalds (1):
Merge branch 'for-linus' of git://git.kernel.dk/linux-2.6-block
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/frob/linux-2.6-roland.git topic/x86-lds-nits
Roland McGrath (1):
x86: linker script syntax nits
arch/x86/kernel/acpi/realmode/wakeup.lds.S | 4 ++-- arch/x86/kernel/vmlinux.lds.S | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-)
---
[PATCH] x86: linker script syntax nits
The linker scripts grew some use of weirdly wrong linker script syntax. It happens to work, but it's not what the syntax is documented to be. Clean it up to use the official syntax.
--- arch/x86/kernel/acpi/realmode/wakeup.lds.S | 4 ++-- arch/x86/kernel/vmlinux.lds.S | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-)
arch/x86/kernel/acpi/realmode/wakeup.lds.S +2 -2
@@ -56,6 +56,6 @@ SECTIONS /DISCARD/ : { *(.note*) } - - . = ASSERT(_end <= WAKEUP_SIZE, "Wakeup too big!"); } + +ASSERT(_end <= WAKEUP_SIZE, "Wakeup too big!");
arch/x86/kernel/vmlinux.lds.S +8 -9
@@ -305,8 +305,8 @@ SECTIONS #ifdef CONFIG_X86_32 -. = ASSERT((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE), - "kernel image bigger than KERNEL_IMAGE_SIZE"); +ASSERT((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE), + "kernel image bigger than KERNEL_IMAGE_SIZE"); #else /* * Per-cpu symbols which need to be offset from __per_cpu_load
@@ -319,12 +319,12 @@ INIT_PER_CPU(irq_stack_union); /* * Build-time check on the image size: */ -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE), - "kernel image bigger than KERNEL_IMAGE_SIZE"); +ASSERT((_end - _text <= KERNEL_IMAGE_SIZE), + "kernel image bigger than KERNEL_IMAGE_SIZE"); #ifdef CONFIG_SMP -. = ASSERT((per_cpu__irq_stack_union == 0), - "irq_stack_union is not at start of per-cpu area"); +ASSERT((per_cpu__irq_stack_union == 0), + "irq_stack_union is not at start of per-cpu area"); #endif #endif /* CONFIG_X86_32 */
@@ -332,7 +332,6 @@ INIT_PER_CPU(irq_stack_union); #ifdef CONFIG_KEXEC #include <asm/kexec.h> -. = ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE, - "kexec control code size is too big"); +ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE, + "kexec control code size is too big"); #endif -
H. Peter Anvin
reviewerQuoted 6 lines · Roland McGrath
The following changes since commit
80f506918fdaaca6b574ba931536a58ce015c7be:
Linus Torvalds (1):
Merge branch 'for-linus' ofgit://git.kernel.dk/linux-2.6-blockare available in the git repository at:
Quoted 8 lines
git://git.kernel.org/pub/scm/linux/kernel/git/frob/linux-2.6-roland.gittopic/x86-lds-nitsRoland McGrath (1):
x86: linker script syntax nitsarch/x86/kernel/acpi/realmode/wakeup.lds.S | 4 ++-- arch/x86/kernel/vmlinux.lds.S | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-)
arch/x86/kernel/acpi/realmode/wakeup.lds.S SECTIONS · line 61
Quoted 4 lines
arch/x86/kernel/acpi/realmode/wakeup.lds.S +2
-1- . = ASSERT(_end <= WAKEUP_SIZE, "Wakeup too big!"); } + +ASSERT(_end <= WAKEUP_SIZE, "Wakeup too big!");
Sinkless asserts are broken in older versions of ld.
-hpa
[tip:x86/urgent] Revert "x86: linker script syntax nits"
Commit-ID: db8590f5043f3436a65b24155a3a7af2604df876 Gitweb: http://git.kernel.org/tip/db8590f5043f3436a65b24155a3a7af2604df876 Author: Ingo Molnar <[email protected]> AuthorDate: Thu, 15 Oct 2009 08:08:12 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 15 Oct 2009 08:09:55 +0200
Revert "x86: linker script syntax nits"
This reverts commit e9a63a4e559fbdc522072281d05e6b13c1022f4b.
This breaks older binutils, where sink-less asserts are broken.
See this commit for further details:
d2ba8b2: x86: Fix assert syntax in vmlinux.lds.S
LKML-Reference: <[email protected]>
--- arch/x86/kernel/acpi/realmode/wakeup.lds.S | 4 ++-- arch/x86/kernel/vmlinux.lds.S | 17 +++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-)
arch/x86/kernel/acpi/realmode/wakeup.lds.S +2 -2
@@ -56,6 +56,6 @@ SECTIONS /DISCARD/ : { *(.note*) } -} -ASSERT(_end <= WAKEUP_SIZE, "Wakeup too big!"); + . = ASSERT(_end <= WAKEUP_SIZE, "Wakeup too big!"); +}
arch/x86/kernel/vmlinux.lds.S +9 -8
@@ -305,8 +305,8 @@ SECTIONS #ifdef CONFIG_X86_32 -ASSERT((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE), - "kernel image bigger than KERNEL_IMAGE_SIZE"); +. = ASSERT((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE), + "kernel image bigger than KERNEL_IMAGE_SIZE"); #else /* * Per-cpu symbols which need to be offset from __per_cpu_load
@@ -319,12 +319,12 @@ INIT_PER_CPU(irq_stack_union); /* * Build-time check on the image size: */ -ASSERT((_end - _text <= KERNEL_IMAGE_SIZE), - "kernel image bigger than KERNEL_IMAGE_SIZE"); +. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE), + "kernel image bigger than KERNEL_IMAGE_SIZE"); #ifdef CONFIG_SMP -ASSERT((per_cpu__irq_stack_union == 0), - "irq_stack_union is not at start of per-cpu area"); +. = ASSERT((per_cpu__irq_stack_union == 0), + "irq_stack_union is not at start of per-cpu area"); #endif #endif /* CONFIG_X86_32 */
@@ -332,6 +332,7 @@ ASSERT((per_cpu__irq_stack_union == 0), #ifdef CONFIG_KEXEC #include <asm/kexec.h> -ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE, - "kexec control code size is too big"); +. = ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE, + "kexec control code size is too big"); #endif +
[tip:x86/urgent] x86: Document linker script ASSERT() quirk
In reply to H. Peter AnvinCommit-ID: a5912f6b3e20c137172460e6d4dd180866c00963 Gitweb: http://git.kernel.org/tip/a5912f6b3e20c137172460e6d4dd180866c00963 Author: Ingo Molnar <[email protected]> AuthorDate: Fri, 16 Oct 2009 07:18:46 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 16 Oct 2009 07:18:46 +0200
x86: Document linker script ASSERT() quirk
Older binutils breaks if ASSERT() is used without a sink for the output.
For example 2.14.90.0.6 is known to be broken, the link fails with:
LD .tmp_vmlinux1
ld:arch/x86/kernel/vmlinux.lds:678: parse error
Document this quirk in all three files that use it.
See: http://marc.info/?l=linux-kbuild&m=124930110427870&w=2
See[2]: d2ba8b2 ("x86: Fix assert syntax in vmlinux.lds.S")
Cc: Linus Torvalds <[email protected]>
Cc: Roland McGrath <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Sam Ravnborg <[email protected]>
LKML-Reference: <[email protected]>
--- arch/x86/boot/setup.ld | 3 +++ arch/x86/kernel/acpi/realmode/wakeup.lds.S | 3 +++ arch/x86/kernel/vmlinux.lds.S | 3 +++ 3 files changed, 9 insertions(+), 0 deletions(-)
arch/x86/boot/setup.ld +3 -0
@@ -53,6 +53,9 @@ SECTIONS /DISCARD/ : { *(.note*) } + /* + * The ASSERT() sink to . is intentional, for binutils 2.14 compatibility: + */ . = ASSERT(_end <= 0x8000, "Setup too big!"); . = ASSERT(hdr == 0x1f1, "The setup header has the wrong offset!"); /* Necessary for the very-old-loader check to work... */
arch/x86/kernel/acpi/realmode/wakeup.lds.S +3 -0
@@ -57,5 +57,8 @@ SECTIONS *(.note*) } + /* + * The ASSERT() sink to . is intentional, for binutils 2.14 compatibility: + */ . = ASSERT(_end <= WAKEUP_SIZE, "Wakeup too big!"); }
arch/x86/kernel/vmlinux.lds.S +3 -0
@@ -305,6 +305,9 @@ SECTIONS #ifdef CONFIG_X86_32 +/* + * The ASSERT() sink to . is intentional, for binutils 2.14 compatibility: + */ . = ASSERT((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE), "kernel image bigger than KERNEL_IMAGE_SIZE"); #else
Quoted 33 lines · Roland McGrath
The following changes since commit
80f506918fdaaca6b574ba931536a58ce015c7be:
Linus Torvalds (1):
Merge branch 'for-linus' ofgit://git.kernel.dk/linux-2.6-blockare available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/frob/linux-2.6-roland.gittopic/x86-lds-nitsRoland McGrath (1):
x86: linker script syntax nitsarch/x86/kernel/acpi/realmode/wakeup.lds.S | 4 ++-- arch/x86/kernel/vmlinux.lds.S | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-)---
[PATCH] x86: linker script syntax nitsThe linker scripts grew some use of weirdly wrong linker script syntax. It happens to work, but it's not what the syntax is documented to be. Clean it up to use the official syntax.
Signed-off-by Roland McGrath <[email protected]>CC Ian Lance Taylor <[email protected]>--- arch/x86/kernel/acpi/realmode/wakeup.lds.S | 4 ++-- arch/x86/kernel/vmlinux.lds.S | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-)arch/x86/kernel/acpi/realmode/wakeup.lds.S +0
-0
arch/x86/kernel/acpi/realmode/wakeup.lds.S SECTIONS · line 61
Quoted 8 lines
arch/x86/kernel/acpi/realmode/wakeup.lds.S +2
-2@@ -56,6 +56,6 @@ SECTIONS /DISCARD/ : { *(.note*) } - - . = ASSERT(_end <= WAKEUP_SIZE, "Wakeup too big!"); } + +ASSERT(_end <= WAKEUP_SIZE, "Wakeup too big!");
This breaks with older binutils.
See d2ba8b211bb8abc29aa627dbd4dce08cfbc8082b for reference.
Same goes for the other cahnges in this post.
Yup - it looks ugly :-(
Sam
Quoted 46 lines · Sam Ravnborg
Quoted 33 lines · Roland McGrath
The following changes since commit
80f506918fdaaca6b574ba931536a58ce015c7be:
Linus Torvalds (1):
Merge branch 'for-linus' ofgit://git.kernel.dk/linux-2.6-blockare available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/frob/linux-2.6-roland.gittopic/x86-lds-nitsRoland McGrath (1):
x86: linker script syntax nitsarch/x86/kernel/acpi/realmode/wakeup.lds.S | 4 ++-- arch/x86/kernel/vmlinux.lds.S | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-)---
[PATCH] x86: linker script syntax nitsThe linker scripts grew some use of weirdly wrong linker script syntax. It happens to work, but it's not what the syntax is documented to be. Clean it up to use the official syntax.
Signed-off-by Roland McGrath <[email protected]>CC Ian Lance Taylor <[email protected]>--- arch/x86/kernel/acpi/realmode/wakeup.lds.S | 4 ++-- arch/x86/kernel/vmlinux.lds.S | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-)arch/x86/kernel/acpi/realmode/wakeup.lds.S +0
-0arch/x86/kernel/acpi/realmode/wakeup.lds.S SECTIONS · line 61
Quoted 8 lines
arch/x86/kernel/acpi/realmode/wakeup.lds.S +2
-2@@ -56,6 +56,6 @@ SECTIONS /DISCARD/ : { *(.note*) } - - . = ASSERT(_end <= WAKEUP_SIZE, "Wakeup too big!"); } + +ASSERT(_end <= WAKEUP_SIZE, "Wakeup too big!");This breaks with older binutils. See
d2ba8b211bb8abc29aa627dbd4dce08cfbc8082bfor reference.
Quoted 3 lines
Same goes for the other cahnges in this post.
Yup - it looks ugly :-(
We could introduce a COMPAT_ASSERT() wrapper perhaps, to move it more in line with the 'official' syntax.
Or we could wrap ASSERT() itself (this runs through the preprocessor before going to the linker) - although that would be a pretty obfuscated move.
At minimum we should add a comment to the first use of ASSERT() here that we assign the current address due to compatibility reasons. (same goes for arch/x86/boot/setup.ld)
Anyway - any such cleanup would be .33 material.
Ingo
H. Peter Anvin
reviewerQuoted 8 lines · Ingo Molnar
We could introduce a
COMPAT_ASSERT()wrapper perhaps, to move it more in line with the 'official' syntax.Or we could wrap
ASSERT()itself (this runs through the preprocessor before going to the linker) - although that would be a pretty obfuscated move.
Quoted 6 lines
At minimum we should add a comment to the first use of
ASSERT()here that we assign the current address due to compatibility reasons. (same goes forarch/x86/boot/setup.ld)Anyway - any such cleanup would be .33 material.
The tricky part about wrapping ASSERT() is that you have to have a sink for the old versions of ld. We use . as the sink, but that changes . which you don't want to do silently.
The other -- and somewhat less cantankerous way -- is to use a dummy symbol:
#define LINUX_ASSERT(expr, name, string) name = ASSERT(expr, string)
"name" would have to be unique for each instance.
-hpa
Quoted 5 lines
The other -- and somewhat less cantankerous way -- is to use a dummy symbol:
#define
LINUX_ASSERT(expr, name, string)name =ASSERT(expr, string)"name" would have to be unique for each instance.
I wouldn't like to pollute the symtabs with those useless symbols.
#define LINUX_ASSERT(expr, string) PROVIDE(_assert_bogon = ASSERT(expr, string))
works with a recent ld. I don't know what the problematic old ld versions were. Do you have such on hand to test?
Ian may have another suggestion.
Thanks,
Roland
H. Peter Anvin
reviewerQuoted 6 lines · Roland McGrath
Quoted 5 lines
The other -- and somewhat less cantankerous way -- is to use a dummy symbol:
#define
LINUX_ASSERT(expr, name, string)name =ASSERT(expr, string)"name" would have to be unique for each instance.
Quoted 9 lines
I wouldn't like to pollute the symtabs with those useless symbols.
#define
LINUX_ASSERT(expr, string)PROVIDE(_assert_bogon = ASSERT(expr, string))works with a recent ld. I don't know what the problematic old ld versions were. Do you have such on hand to test?
Ian may have another suggestion.
I don't remember how old they have to be... I think RHEL 4 timeframe, though.
-hpa
Quoted 4 lines · Roland McGrath
Quoted 4 lines
The other -- and somewhat less cantankerous way -- is to use a dummy symbol:
#define
LINUX_ASSERT(expr, name, string)name =ASSERT(expr, string)
Quoted 8 lines
Quoted 1 line
"name" would have to be unique for each instance.
I wouldn't like to pollute the symtabs with those useless symbols.
#define
LINUX_ASSERT(expr, string)PROVIDE(_assert_bogon = ASSERT(expr, string))works with a recent ld. I don't know what the problematic old ld versions were. Do you have such on hand to test?
Jean reported binutils 2.14.90.0.6.
See: http://marc.info/?l=linux-kbuild&m=124930110427870&w=2
Sam
Quoted 14 lines · Roland McGrath
The following changes since commit
80f506918fdaaca6b574ba931536a58ce015c7be:
Linus Torvalds (1):
Merge branch 'for-linus' ofgit://git.kernel.dk/linux-2.6-blockare available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/frob/linux-2.6-roland.gittopic/x86-lds-nitsRoland McGrath (1):
x86: linker script syntax nitsarch/x86/kernel/acpi/realmode/wakeup.lds.S | 4 ++-- arch/x86/kernel/vmlinux.lds.S | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-)
Quoted 6 lines
---
[PATCH] x86: linker script syntax nitsThe linker scripts grew some use of weirdly wrong linker script syntax. It happens to work, but it's not what the syntax is documented to be. Clean it up to use the official syntax.
I've queued up a revert based on Peter's and Sam's objections.
I'd also like to point out a few commit log quality nits. A standard x86 commit should have the following title:
x86: Clean up linker script syntax nits
not:
x86: linker script syntax nits
Note that we always try to add a verb to that sentence, so that it's more natural-language alike. (also note the capitalization (we capitalize the sentence after the 'x86:' prefix))
(Plus i always try to line-wrap the commit log to 65 columns, to make it easy to quote to several levels and still be within the various viewer column widths that people use - and to allow for the +4 columns used up by git log's indentation.)
Thanks,
Ingo