Skip to content

Commit

Permalink
kbuild: Don't define ALIGN and ENTRY when preprocessing linker scripts.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Sam Ravnborg <[email protected]>
  • Loading branch information
Tim Abbott authored and sravnborg committed Sep 21, 2009
1 parent 51b563f commit 42f29a2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/linux/linkage.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@

#ifdef __ASSEMBLY__

#ifndef LINKER_SCRIPT
#define ALIGN __ALIGN
#define ALIGN_STR __ALIGN_STR

Expand All @@ -66,6 +67,7 @@
ALIGN; \
name:
#endif
#endif /* LINKER_SCRIPT */

#ifndef WEAK
#define WEAK(name) \
Expand Down
2 changes: 1 addition & 1 deletion scripts/Makefile.build
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 42f29a2

Please sign in to comment.