kbuild: Don't define ALIGN and ENTRY when preprocessing linker scripts.
authorTim Abbott <tabbott@ksplice.com>
Sun, 20 Sep 2009 22:14:12 +0000 (18:14 -0400)
committerSam Ravnborg <sam@ravnborg.org>
Mon, 21 Sep 2009 04:27:08 +0000 (06:27 +0200)
Adding a reference to <linux/linkage.h> to x86's <asm/cache.h> causes
the x86 linker script to have syntax errors, because the ALIGN and
ENTRY keywords get redefined to the assembly implementations of those.
One could fix this by adjusting the include structure, but I think any
solution based on that approach would be fragile.

Currently, it is impossible when writing a header to do something
different for assembly files and linker scripts, even though there are
clearly cases where one wants them to define macros differently for
the two (ENTRY being an excellent example).
So I think the right solution here is to introduce a new preprocessor
definition, called LINKER_SCRIPT that is set along with __ASSEMBLY__
for linker scripts, and to use that to not define ALIGN and ENTRY in
linker scripts.
I suspect we'll find other uses for this mechanism in
the future.

Signed-off-by: Tim Abbott <tabbott@ksplice.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
include/linux/linkage.h
scripts/Makefile.build

index 691f59171c6c722e52faaeaed4e086d46f646eb2..5126cceb6ae97c7d401f197497f0a1311e55fe6f 100644 (file)
@@ -57,6 +57,7 @@
 
 #ifdef __ASSEMBLY__
 
+#ifndef LINKER_SCRIPT
 #define ALIGN __ALIGN
 #define ALIGN_STR __ALIGN_STR
 
@@ -66,6 +67,7 @@
   ALIGN; \
   name:
 #endif
+#endif /* LINKER_SCRIPT */
 
 #ifndef WEAK
 #define WEAK(name)        \
index d5425660a3df195d02d2942d079b4de79843d7a2..341b58902ffced6d70801f6e90ea85f60bcee88d 100644 (file)
@@ -271,7 +271,7 @@ targets += $(extra-y) $(MAKECMDGOALS) $(always)
 # ---------------------------------------------------------------------------
 quiet_cmd_cpp_lds_S = LDS     $@
       cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -C -U$(ARCH) \
-                            -D__ASSEMBLY__ -o $@ $<
+                            -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $<
 
 $(obj)/%.lds: $(src)/%.lds.S FORCE
        $(call if_changed_dep,cpp_lds_S)
This page took 0.026725 seconds and 5 git commands to generate.