diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-05 17:10:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-05 17:10:07 -0400 |
commit | da9e82b3b8989fc09e2a4c45b9da604ba2b4c46d (patch) | |
tree | 7355d2afe95be27fddb8fa4baa46476c76aeb8ee | |
parent | 90d3417a3a4e810d67081dd106f0e603a856978f (diff) | |
parent | 772320e84588dcbe1600ffb83e5f328f2209ac2a (diff) |
Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6
* 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6:
modpost: support objects with more than 64k sections
trivial: fix a typo in a filename
frv: clean up arch/frv/Makefile
kbuild: allow assignment to {A,C}FLAGS_KERNEL on the command line
kbuild: allow assignment to {A,C,LD}FLAGS_MODULE on the command line
Kbuild: Add option to set -femit-struct-debug-baseonly
Makefile: "make kernelrelease" should show the correct full kernel version
Makefile.build: make KBUILD_SYMTYPES work again
-rw-r--r-- | Documentation/kbuild/kbuild.txt | 26 | ||||
-rw-r--r-- | Documentation/kbuild/makefiles.txt | 27 | ||||
-rw-r--r-- | Makefile | 29 | ||||
-rw-r--r-- | arch/avr32/Makefile | 2 | ||||
-rw-r--r-- | arch/blackfin/Makefile | 4 | ||||
-rw-r--r-- | arch/frv/Makefile | 22 | ||||
-rw-r--r-- | arch/ia64/Makefile | 6 | ||||
-rw-r--r-- | arch/m32r/Makefile | 4 | ||||
-rw-r--r-- | arch/m68k/Makefile | 2 | ||||
-rw-r--r-- | arch/mips/Makefile | 6 | ||||
-rw-r--r-- | arch/powerpc/Makefile | 2 | ||||
-rw-r--r-- | arch/s390/Makefile | 3 | ||||
-rw-r--r-- | arch/score/Makefile | 3 | ||||
-rw-r--r-- | lib/Kconfig.debug | 13 | ||||
-rw-r--r-- | scripts/Makefile.build | 37 | ||||
-rw-r--r-- | scripts/Makefile.modpost | 9 | ||||
-rw-r--r-- | scripts/mod/file2alias.c | 6 | ||||
-rw-r--r-- | scripts/mod/modpost.c | 102 | ||||
-rw-r--r-- | scripts/mod/modpost.h | 43 |
19 files changed, 246 insertions, 100 deletions
diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt index 0d8addbb0fae..1e5165aa9e4e 100644 --- a/Documentation/kbuild/kbuild.txt +++ b/Documentation/kbuild/kbuild.txt | |||
@@ -22,11 +22,33 @@ building C files and assembler files. | |||
22 | 22 | ||
23 | KAFLAGS | 23 | KAFLAGS |
24 | -------------------------------------------------- | 24 | -------------------------------------------------- |
25 | Additional options to the assembler. | 25 | Additional options to the assembler (for built-in and modules). |
26 | |||
27 | AFLAGS_MODULE | ||
28 | -------------------------------------------------- | ||
29 | Addtional module specific options to use for $(AS). | ||
30 | |||
31 | AFLAGS_KERNEL | ||
32 | -------------------------------------------------- | ||
33 | Addtional options for $(AS) when used for assembler | ||
34 | code for code that is compiled as built-in. | ||
26 | 35 | ||
27 | KCFLAGS | 36 | KCFLAGS |
28 | -------------------------------------------------- | 37 | -------------------------------------------------- |
29 | Additional options to the C compiler. | 38 | Additional options to the C compiler (for built-in and modules). |
39 | |||
40 | CFLAGS_KERNEL | ||
41 | -------------------------------------------------- | ||
42 | Addtional options for $(CC) when used to compile | ||
43 | code that is compiled as built-in. | ||
44 | |||
45 | CFLAGS_MODULE | ||
46 | -------------------------------------------------- | ||
47 | Addtional module specific options to use for $(CC). | ||
48 | |||
49 | LDFLAGS_MODULE | ||
50 | -------------------------------------------------- | ||
51 | Additional options used for $(LD) when linking modules. | ||
30 | 52 | ||
31 | KBUILD_VERBOSE | 53 | KBUILD_VERBOSE |
32 | -------------------------------------------------- | 54 | -------------------------------------------------- |
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index 8abd041b605d..c375313cb128 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt | |||
@@ -921,16 +921,33 @@ When kbuild executes, the following steps are followed (roughly): | |||
921 | The first example utilises the trick that a config option expands | 921 | The first example utilises the trick that a config option expands |
922 | to 'y' when selected. | 922 | to 'y' when selected. |
923 | 923 | ||
924 | CFLAGS_KERNEL $(CC) options specific for built-in | 924 | KBUILD_AFLAGS_KERNEL $(AS) options specific for built-in |
925 | 925 | ||
926 | $(CFLAGS_KERNEL) contains extra C compiler flags used to compile | 926 | $(KBUILD_AFLAGS_KERNEL) contains extra C compiler flags used to compile |
927 | resident kernel code. | 927 | resident kernel code. |
928 | 928 | ||
929 | CFLAGS_MODULE $(CC) options specific for modules | 929 | KBUILD_AFLAGS_MODULE Options for $(AS) when building modules |
930 | 930 | ||
931 | $(CFLAGS_MODULE) contains extra C compiler flags used to compile code | 931 | $(KBUILD_AFLAGS_MODULE) is used to add arch specific options that |
932 | for loadable kernel modules. | 932 | are used for $(AS). |
933 | From commandline AFLAGS_MODULE shall be used (see kbuild.txt). | ||
933 | 934 | ||
935 | KBUILD_CFLAGS_KERNEL $(CC) options specific for built-in | ||
936 | |||
937 | $(KBUILD_CFLAGS_KERNEL) contains extra C compiler flags used to compile | ||
938 | resident kernel code. | ||
939 | |||
940 | KBUILD_CFLAGS_MODULE Options for $(CC) when building modules | ||
941 | |||
942 | $(KBUILD_CFLAGS_MODULE) is used to add arch specific options that | ||
943 | are used for $(CC). | ||
944 | From commandline CFLAGS_MODULE shall be used (see kbuild.txt). | ||
945 | |||
946 | KBUILD_LDFLAGS_MODULE Options for $(LD) when linking modules | ||
947 | |||
948 | $(KBUILD_LDFLAGS_MODULE) is used to add arch specific options | ||
949 | used when linking modules. This is often a linker script. | ||
950 | From commandline LDFLAGS_MODULE shall be used (see kbuild.txt). | ||
934 | 951 | ||
935 | --- 6.2 Add prerequisites to archprepare: | 952 | --- 6.2 Add prerequisites to archprepare: |
936 | 953 | ||
@@ -332,10 +332,9 @@ CHECK = sparse | |||
332 | 332 | ||
333 | CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ | 333 | CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ |
334 | -Wbitwise -Wno-return-void $(CF) | 334 | -Wbitwise -Wno-return-void $(CF) |
335 | MODFLAGS = -DMODULE | 335 | CFLAGS_MODULE = |
336 | CFLAGS_MODULE = $(MODFLAGS) | 336 | AFLAGS_MODULE = |
337 | AFLAGS_MODULE = $(MODFLAGS) | 337 | LDFLAGS_MODULE = |
338 | LDFLAGS_MODULE = -T $(srctree)/scripts/module-common.lds | ||
339 | CFLAGS_KERNEL = | 338 | CFLAGS_KERNEL = |
340 | AFLAGS_KERNEL = | 339 | AFLAGS_KERNEL = |
341 | CFLAGS_GCOV = -fprofile-arcs -ftest-coverage | 340 | CFLAGS_GCOV = -fprofile-arcs -ftest-coverage |
@@ -354,7 +353,12 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ | |||
354 | -Werror-implicit-function-declaration \ | 353 | -Werror-implicit-function-declaration \ |
355 | -Wno-format-security \ | 354 | -Wno-format-security \ |
356 | -fno-delete-null-pointer-checks | 355 | -fno-delete-null-pointer-checks |
356 | KBUILD_AFLAGS_KERNEL := | ||
357 | KBUILD_CFLAGS_KERNEL := | ||
357 | KBUILD_AFLAGS := -D__ASSEMBLY__ | 358 | KBUILD_AFLAGS := -D__ASSEMBLY__ |
359 | KBUILD_AFLAGS_MODULE := -DMODULE | ||
360 | KBUILD_CFLAGS_MODULE := -DMODULE | ||
361 | KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds | ||
358 | 362 | ||
359 | # Read KERNELRELEASE from include/config/kernel.release (if it exists) | 363 | # Read KERNELRELEASE from include/config/kernel.release (if it exists) |
360 | KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) | 364 | KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) |
@@ -369,6 +373,8 @@ export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS | |||
369 | export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS | 373 | export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS |
370 | export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV | 374 | export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV |
371 | export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE | 375 | export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE |
376 | export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE | ||
377 | export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL | ||
372 | 378 | ||
373 | # When compiling out-of-tree modules, put MODVERDIR in the module | 379 | # When compiling out-of-tree modules, put MODVERDIR in the module |
374 | # tree rather than in the kernel tree. The kernel tree might | 380 | # tree rather than in the kernel tree. The kernel tree might |
@@ -414,7 +420,7 @@ endif | |||
414 | no-dot-config-targets := clean mrproper distclean \ | 420 | no-dot-config-targets := clean mrproper distclean \ |
415 | cscope TAGS tags help %docs check% \ | 421 | cscope TAGS tags help %docs check% \ |
416 | include/linux/version.h headers_% \ | 422 | include/linux/version.h headers_% \ |
417 | kernelrelease kernelversion | 423 | kernelversion |
418 | 424 | ||
419 | config-targets := 0 | 425 | config-targets := 0 |
420 | mixed-targets := 0 | 426 | mixed-targets := 0 |
@@ -557,6 +563,10 @@ KBUILD_CFLAGS += -g | |||
557 | KBUILD_AFLAGS += -gdwarf-2 | 563 | KBUILD_AFLAGS += -gdwarf-2 |
558 | endif | 564 | endif |
559 | 565 | ||
566 | ifdef CONFIG_DEBUG_INFO_REDUCED | ||
567 | KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) | ||
568 | endif | ||
569 | |||
560 | ifdef CONFIG_FUNCTION_TRACER | 570 | ifdef CONFIG_FUNCTION_TRACER |
561 | KBUILD_CFLAGS += -pg | 571 | KBUILD_CFLAGS += -pg |
562 | endif | 572 | endif |
@@ -603,7 +613,7 @@ endif | |||
603 | # Use --build-id when available. | 613 | # Use --build-id when available. |
604 | LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\ | 614 | LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\ |
605 | $(call cc-ldoption, -Wl$(comma)--build-id,)) | 615 | $(call cc-ldoption, -Wl$(comma)--build-id,)) |
606 | LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID) | 616 | KBUILD_LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID) |
607 | LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID) | 617 | LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID) |
608 | 618 | ||
609 | ifeq ($(CONFIG_STRIP_ASM_SYMS),y) | 619 | ifeq ($(CONFIG_STRIP_ASM_SYMS),y) |
@@ -1393,9 +1403,9 @@ checkstack: | |||
1393 | $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \ | 1403 | $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \ |
1394 | $(PERL) $(src)/scripts/checkstack.pl $(CHECKSTACK_ARCH) | 1404 | $(PERL) $(src)/scripts/checkstack.pl $(CHECKSTACK_ARCH) |
1395 | 1405 | ||
1396 | kernelrelease: | 1406 | kernelrelease: include/config/kernel.release |
1397 | $(if $(wildcard include/config/kernel.release), $(Q)echo $(KERNELRELEASE), \ | 1407 | @echo $(KERNELRELEASE) |
1398 | $(error kernelrelease not valid - run 'make prepare' to update it)) | 1408 | |
1399 | kernelversion: | 1409 | kernelversion: |
1400 | @echo $(KERNELVERSION) | 1410 | @echo $(KERNELVERSION) |
1401 | 1411 | ||
@@ -1472,6 +1482,7 @@ cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \ | |||
1472 | $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*) | 1482 | $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*) |
1473 | 1483 | ||
1474 | a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \ | 1484 | a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \ |
1485 | $(KBUILD_AFLAGS_KERNEL) \ | ||
1475 | $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(KBUILD_CPPFLAGS) \ | 1486 | $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(KBUILD_CPPFLAGS) \ |
1476 | $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o) | 1487 | $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o) |
1477 | 1488 | ||
diff --git a/arch/avr32/Makefile b/arch/avr32/Makefile index ead8a75203a9..22fb66590dcd 100644 --- a/arch/avr32/Makefile +++ b/arch/avr32/Makefile | |||
@@ -13,7 +13,7 @@ KBUILD_DEFCONFIG := atstk1002_defconfig | |||
13 | 13 | ||
14 | KBUILD_CFLAGS += -pipe -fno-builtin -mno-pic | 14 | KBUILD_CFLAGS += -pipe -fno-builtin -mno-pic |
15 | KBUILD_AFLAGS += -mrelax -mno-pic | 15 | KBUILD_AFLAGS += -mrelax -mno-pic |
16 | CFLAGS_MODULE += -mno-relax | 16 | KBUILD_CFLAGS_MODULE += -mno-relax |
17 | LDFLAGS_vmlinux += --relax | 17 | LDFLAGS_vmlinux += --relax |
18 | 18 | ||
19 | cpuflags-$(CONFIG_PLATFORM_AT32AP) += -march=ap | 19 | cpuflags-$(CONFIG_PLATFORM_AT32AP) += -march=ap |
diff --git a/arch/blackfin/Makefile b/arch/blackfin/Makefile index 5a97a31d4bbd..9d5ffaf5492a 100644 --- a/arch/blackfin/Makefile +++ b/arch/blackfin/Makefile | |||
@@ -18,8 +18,8 @@ ifeq ($(CONFIG_ROMKERNEL),y) | |||
18 | KBUILD_CFLAGS += -mlong-calls | 18 | KBUILD_CFLAGS += -mlong-calls |
19 | endif | 19 | endif |
20 | KBUILD_AFLAGS += $(call cc-option,-mno-fdpic) | 20 | KBUILD_AFLAGS += $(call cc-option,-mno-fdpic) |
21 | CFLAGS_MODULE += -mlong-calls | 21 | KBUILD_CFLAGS_MODULE += -mlong-calls |
22 | LDFLAGS_MODULE += -m elf32bfin | 22 | KBUILD_LDFLAGS_MODULE += -m elf32bfin |
23 | KALLSYMS += --symbol-prefix=_ | 23 | KALLSYMS += --symbol-prefix=_ |
24 | 24 | ||
25 | KBUILD_DEFCONFIG := BF537-STAMP_defconfig | 25 | KBUILD_DEFCONFIG := BF537-STAMP_defconfig |
diff --git a/arch/frv/Makefile b/arch/frv/Makefile index 310c47a663f8..7ff84575b186 100644 --- a/arch/frv/Makefile +++ b/arch/frv/Makefile | |||
@@ -23,20 +23,14 @@ | |||
23 | # Copyright (C) 1994 by Hamish Macdonald | 23 | # Copyright (C) 1994 by Hamish Macdonald |
24 | # | 24 | # |
25 | 25 | ||
26 | CCSPECS := $(shell $(CC) -v 2>&1 | grep "^Reading specs from " | head -1 | cut -c20-) | ||
27 | CCDIR := $(strip $(patsubst %/specs,%,$(CCSPECS))) | ||
28 | CPUCLASS := fr400 | ||
29 | |||
30 | # test for cross compiling | ||
31 | COMPILE_ARCH = $(shell uname -m) | ||
32 | |||
33 | ifdef CONFIG_MMU | 26 | ifdef CONFIG_MMU |
34 | UTS_SYSNAME = -DUTS_SYSNAME=\"Linux\" | 27 | UTS_SYSNAME = -DUTS_SYSNAME=\"Linux\" |
35 | else | 28 | else |
36 | UTS_SYSNAME = -DUTS_SYSNAME=\"uClinux\" | 29 | UTS_SYSNAME = -DUTS_SYSNAME=\"uClinux\" |
37 | endif | 30 | endif |
38 | 31 | ||
39 | ARCHMODFLAGS += -G0 -mlong-calls | 32 | KBUILD_AFLAGS_MODULE += -G0 -mlong-calls |
33 | KBUILD_CFLAGS_MODULE += -G0 -mlong-calls | ||
40 | 34 | ||
41 | ifdef CONFIG_GPREL_DATA_8 | 35 | ifdef CONFIG_GPREL_DATA_8 |
42 | KBUILD_CFLAGS += -G8 | 36 | KBUILD_CFLAGS += -G8 |
@@ -54,7 +48,6 @@ endif | |||
54 | 48 | ||
55 | ifdef CONFIG_GC_SECTIONS | 49 | ifdef CONFIG_GC_SECTIONS |
56 | KBUILD_CFLAGS += -ffunction-sections -fdata-sections | 50 | KBUILD_CFLAGS += -ffunction-sections -fdata-sections |
57 | LINKFLAGS += --gc-sections | ||
58 | endif | 51 | endif |
59 | 52 | ||
60 | ifndef CONFIG_FRAME_POINTER | 53 | ifndef CONFIG_FRAME_POINTER |
@@ -64,16 +57,13 @@ endif | |||
64 | ifdef CONFIG_CPU_FR451_COMPILE | 57 | ifdef CONFIG_CPU_FR451_COMPILE |
65 | KBUILD_CFLAGS += -mcpu=fr450 | 58 | KBUILD_CFLAGS += -mcpu=fr450 |
66 | KBUILD_AFLAGS += -mcpu=fr450 | 59 | KBUILD_AFLAGS += -mcpu=fr450 |
67 | ASFLAGS += -mcpu=fr450 | ||
68 | else | 60 | else |
69 | ifdef CONFIG_CPU_FR551_COMPILE | 61 | ifdef CONFIG_CPU_FR551_COMPILE |
70 | KBUILD_CFLAGS += -mcpu=fr550 | 62 | KBUILD_CFLAGS += -mcpu=fr550 |
71 | KBUILD_AFLAGS += -mcpu=fr550 | 63 | KBUILD_AFLAGS += -mcpu=fr550 |
72 | ASFLAGS += -mcpu=fr550 | ||
73 | else | 64 | else |
74 | KBUILD_CFLAGS += -mcpu=fr400 | 65 | KBUILD_CFLAGS += -mcpu=fr400 |
75 | KBUILD_AFLAGS += -mcpu=fr400 | 66 | KBUILD_AFLAGS += -mcpu=fr400 |
76 | ASFLAGS += -mcpu=fr400 | ||
77 | endif | 67 | endif |
78 | endif | 68 | endif |
79 | 69 | ||
@@ -83,14 +73,12 @@ endif | |||
83 | KBUILD_CFLAGS += -mno-fdpic -mgpr-32 -msoft-float -mno-media | 73 | KBUILD_CFLAGS += -mno-fdpic -mgpr-32 -msoft-float -mno-media |
84 | KBUILD_CFLAGS += -ffixed-fcc3 -ffixed-cc3 -ffixed-gr15 -ffixed-icc2 | 74 | KBUILD_CFLAGS += -ffixed-fcc3 -ffixed-cc3 -ffixed-gr15 -ffixed-icc2 |
85 | KBUILD_AFLAGS += -mno-fdpic | 75 | KBUILD_AFLAGS += -mno-fdpic |
86 | ASFLAGS += -mno-fdpic | ||
87 | 76 | ||
88 | # make sure the .S files get compiled with debug info | 77 | # make sure the .S files get compiled with debug info |
89 | # and disable optimisations that are unhelpful whilst debugging | 78 | # and disable optimisations that are unhelpful whilst debugging |
90 | ifdef CONFIG_DEBUG_INFO | 79 | ifdef CONFIG_DEBUG_INFO |
91 | #KBUILD_CFLAGS += -O1 | 80 | #KBUILD_CFLAGS += -O1 |
92 | KBUILD_AFLAGS += -Wa,--gdwarf2 | 81 | KBUILD_AFLAGS += -Wa,--gdwarf2 |
93 | ASFLAGS += -Wa,--gdwarf2 | ||
94 | endif | 82 | endif |
95 | 83 | ||
96 | head-y := arch/frv/kernel/head.o arch/frv/kernel/init_task.o | 84 | head-y := arch/frv/kernel/head.o arch/frv/kernel/init_task.o |
@@ -105,11 +93,5 @@ all: Image | |||
105 | Image: vmlinux | 93 | Image: vmlinux |
106 | $(Q)$(MAKE) $(build)=arch/frv/boot $@ | 94 | $(Q)$(MAKE) $(build)=arch/frv/boot $@ |
107 | 95 | ||
108 | bootstrap: | ||
109 | $(Q)$(MAKEBOOT) bootstrap | ||
110 | |||
111 | archclean: | 96 | archclean: |
112 | $(Q)$(MAKE) $(clean)=arch/frv/boot | 97 | $(Q)$(MAKE) $(clean)=arch/frv/boot |
113 | |||
114 | archdep: scripts/mkdep symlinks | ||
115 | $(Q)$(MAKE) $(build)=arch/frv/boot dep | ||
diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile index 8ae0d2604ce1..be7bfa12b705 100644 --- a/arch/ia64/Makefile +++ b/arch/ia64/Makefile | |||
@@ -22,13 +22,13 @@ CHECKFLAGS += -m64 -D__ia64=1 -D__ia64__=1 -D_LP64 -D__LP64__ | |||
22 | 22 | ||
23 | OBJCOPYFLAGS := --strip-all | 23 | OBJCOPYFLAGS := --strip-all |
24 | LDFLAGS_vmlinux := -static | 24 | LDFLAGS_vmlinux := -static |
25 | LDFLAGS_MODULE += -T $(srctree)/arch/ia64/module.lds | 25 | KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/ia64/module.lds |
26 | AFLAGS_KERNEL := -mconstant-gp | 26 | KBUILD_AFLAGS_KERNEL := -mconstant-gp |
27 | EXTRA := | 27 | EXTRA := |
28 | 28 | ||
29 | cflags-y := -pipe $(EXTRA) -ffixed-r13 -mfixed-range=f12-f15,f32-f127 \ | 29 | cflags-y := -pipe $(EXTRA) -ffixed-r13 -mfixed-range=f12-f15,f32-f127 \ |
30 | -falign-functions=32 -frename-registers -fno-optimize-sibling-calls | 30 | -falign-functions=32 -frename-registers -fno-optimize-sibling-calls |
31 | CFLAGS_KERNEL := -mconstant-gp | 31 | KBUILD_CFLAGS_KERNEL := -mconstant-gp |
32 | 32 | ||
33 | GAS_STATUS = $(shell $(srctree)/arch/ia64/scripts/check-gas "$(CC)" "$(OBJDUMP)") | 33 | GAS_STATUS = $(shell $(srctree)/arch/ia64/scripts/check-gas "$(CC)" "$(OBJDUMP)") |
34 | KBUILD_CPPFLAGS += $(shell $(srctree)/arch/ia64/scripts/toolchain-flags "$(CC)" "$(OBJDUMP)" "$(READELF)") | 34 | KBUILD_CPPFLAGS += $(shell $(srctree)/arch/ia64/scripts/toolchain-flags "$(CC)" "$(OBJDUMP)" "$(READELF)") |
diff --git a/arch/m32r/Makefile b/arch/m32r/Makefile index 469766b24e22..8ff5ba0ea26c 100644 --- a/arch/m32r/Makefile +++ b/arch/m32r/Makefile | |||
@@ -12,8 +12,8 @@ OBJCOPYFLAGS := -O binary -R .note -R .comment -S | |||
12 | LDFLAGS_vmlinux := | 12 | LDFLAGS_vmlinux := |
13 | 13 | ||
14 | KBUILD_CFLAGS += -pipe -fno-schedule-insns | 14 | KBUILD_CFLAGS += -pipe -fno-schedule-insns |
15 | CFLAGS_KERNEL += -mmodel=medium | 15 | KBUILD_CFLAGS_KERNEL += -mmodel=medium |
16 | CFLAGS_MODULE += -mmodel=large | 16 | KBUILD_CFLAGS_MODULE += -mmodel=large |
17 | 17 | ||
18 | ifdef CONFIG_CHIP_VDEC2 | 18 | ifdef CONFIG_CHIP_VDEC2 |
19 | cflags-$(CONFIG_ISA_M32R2) += -DNO_FPU -Wa,-bitinst | 19 | cflags-$(CONFIG_ISA_M32R2) += -DNO_FPU -Wa,-bitinst |
diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile index 570d85c3f97f..b06a7e3cbcd6 100644 --- a/arch/m68k/Makefile +++ b/arch/m68k/Makefile | |||
@@ -18,7 +18,7 @@ KBUILD_DEFCONFIG := multi_defconfig | |||
18 | # override top level makefile | 18 | # override top level makefile |
19 | AS += -m68020 | 19 | AS += -m68020 |
20 | LDFLAGS := -m m68kelf | 20 | LDFLAGS := -m m68kelf |
21 | LDFLAGS_MODULE += -T $(srctree)/arch/m68k/kernel/module.lds | 21 | KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/m68k/kernel/module.lds |
22 | ifneq ($(SUBARCH),$(ARCH)) | 22 | ifneq ($(SUBARCH),$(ARCH)) |
23 | ifeq ($(CROSS_COMPILE),) | 23 | ifeq ($(CROSS_COMPILE),) |
24 | CROSS_COMPILE := $(call cc-cross-prefix, \ | 24 | CROSS_COMPILE := $(call cc-cross-prefix, \ |
diff --git a/arch/mips/Makefile b/arch/mips/Makefile index f0d196090e94..f4a4b663ebb3 100644 --- a/arch/mips/Makefile +++ b/arch/mips/Makefile | |||
@@ -93,7 +93,8 @@ all-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlinuz | |||
93 | cflags-y += -G 0 -mno-abicalls -fno-pic -pipe | 93 | cflags-y += -G 0 -mno-abicalls -fno-pic -pipe |
94 | cflags-y += -msoft-float | 94 | cflags-y += -msoft-float |
95 | LDFLAGS_vmlinux += -G 0 -static -n -nostdlib | 95 | LDFLAGS_vmlinux += -G 0 -static -n -nostdlib |
96 | MODFLAGS += -mlong-calls | 96 | KBUILD_AFLAGS_MODULE += -mlong-calls |
97 | KBUILD_CFLAGS_MODULE += -mlong-calls | ||
97 | 98 | ||
98 | cflags-y += -ffreestanding | 99 | cflags-y += -ffreestanding |
99 | 100 | ||
@@ -165,7 +166,8 @@ cflags-$(CONFIG_CPU_DADDI_WORKAROUNDS) += $(call cc-option,-mno-daddi,) | |||
165 | 166 | ||
166 | ifdef CONFIG_CPU_SB1 | 167 | ifdef CONFIG_CPU_SB1 |
167 | ifdef CONFIG_SB1_PASS_1_WORKAROUNDS | 168 | ifdef CONFIG_SB1_PASS_1_WORKAROUNDS |
168 | MODFLAGS += -msb1-pass1-workarounds | 169 | KBUILD_AFLAGS_MODULE += -msb1-pass1-workarounds |
170 | KBUILD_CFLAGS_MODULE += -msb1-pass1-workarounds | ||
169 | endif | 171 | endif |
170 | endif | 172 | endif |
171 | 173 | ||
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 77cfe7a29e25..5d42f5eae70f 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile | |||
@@ -94,7 +94,7 @@ else | |||
94 | endif | 94 | endif |
95 | endif | 95 | endif |
96 | 96 | ||
97 | LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o | 97 | KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o |
98 | 98 | ||
99 | ifeq ($(CONFIG_TUNE_CELL),y) | 99 | ifeq ($(CONFIG_TUNE_CELL),y) |
100 | KBUILD_CFLAGS += $(call cc-option,-mtune=cell) | 100 | KBUILD_CFLAGS += $(call cc-option,-mtune=cell) |
diff --git a/arch/s390/Makefile b/arch/s390/Makefile index 30c5f01f93b0..0c9e6c6d2a64 100644 --- a/arch/s390/Makefile +++ b/arch/s390/Makefile | |||
@@ -24,7 +24,8 @@ CHECKFLAGS += -D__s390__ -msize-long | |||
24 | else | 24 | else |
25 | LD_BFD := elf64-s390 | 25 | LD_BFD := elf64-s390 |
26 | LDFLAGS := -m elf64_s390 | 26 | LDFLAGS := -m elf64_s390 |
27 | MODFLAGS += -fpic -D__PIC__ | 27 | KBUILD_AFLAGS_MODULE += -fpic -D__PIC__ |
28 | KBUILD_CFLAGS_MODULE += -fpic -D__PIC__ | ||
28 | KBUILD_CFLAGS += -m64 | 29 | KBUILD_CFLAGS += -m64 |
29 | KBUILD_AFLAGS += -m64 | 30 | KBUILD_AFLAGS += -m64 |
30 | UTS_MACHINE := s390x | 31 | UTS_MACHINE := s390x |
diff --git a/arch/score/Makefile b/arch/score/Makefile index 68e0cd06d5c9..d77dc639d8e3 100644 --- a/arch/score/Makefile +++ b/arch/score/Makefile | |||
@@ -20,7 +20,8 @@ cflags-y += -G0 -pipe -mel -mnhwloop -D__SCOREEL__ \ | |||
20 | # | 20 | # |
21 | KBUILD_AFLAGS += $(cflags-y) | 21 | KBUILD_AFLAGS += $(cflags-y) |
22 | KBUILD_CFLAGS += $(cflags-y) | 22 | KBUILD_CFLAGS += $(cflags-y) |
23 | MODFLAGS += -mlong-calls | 23 | KBUILD_AFLAGS_MODULE += -mlong-calls |
24 | KBUILD_CFLAGS_MODULE += -mlong-calls | ||
24 | LDFLAGS += --oformat elf32-littlescore | 25 | LDFLAGS += --oformat elf32-littlescore |
25 | LDFLAGS_vmlinux += -G0 -static -nostdlib | 26 | LDFLAGS_vmlinux += -G0 -static -nostdlib |
26 | 27 | ||
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 154ff43aaa81..67fa774f9572 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
@@ -628,6 +628,19 @@ config DEBUG_INFO | |||
628 | 628 | ||
629 | If unsure, say N. | 629 | If unsure, say N. |
630 | 630 | ||
631 | config DEBUG_INFO_REDUCED | ||
632 | bool "Reduce debugging information" | ||
633 | depends on DEBUG_INFO | ||
634 | help | ||
635 | If you say Y here gcc is instructed to generate less debugging | ||
636 | information for structure types. This means that tools that | ||
637 | need full debugging information (like kgdb or systemtap) won't | ||
638 | be happy. But if you merely need debugging information to | ||
639 | resolve line numbers there is no loss. Advantage is that | ||
640 | build directory object sizes shrink dramatically over a full | ||
641 | DEBUG_INFO build and compile times are reduced too. | ||
642 | Only works with newer gcc versions. | ||
643 | |||
631 | config DEBUG_VM | 644 | config DEBUG_VM |
632 | bool "Debug VM" | 645 | bool "Debug VM" |
633 | depends on DEBUG_KERNEL | 646 | depends on DEBUG_KERNEL |
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index e4deb73e9a84..a1a5cf95a68d 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
@@ -115,7 +115,10 @@ endif | |||
115 | # --------------------------------------------------------------------------- | 115 | # --------------------------------------------------------------------------- |
116 | 116 | ||
117 | # Default is built-in, unless we know otherwise | 117 | # Default is built-in, unless we know otherwise |
118 | modkern_cflags = $(if $(part-of-module), $(CFLAGS_MODULE), $(CFLAGS_KERNEL)) | 118 | modkern_cflags = \ |
119 | $(if $(part-of-module), \ | ||
120 | $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \ | ||
121 | $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL)) | ||
119 | quiet_modtag := $(empty) $(empty) | 122 | quiet_modtag := $(empty) $(empty) |
120 | 123 | ||
121 | $(real-objs-m) : part-of-module := y | 124 | $(real-objs-m) : part-of-module := y |
@@ -156,14 +159,14 @@ $(obj)/%.i: $(src)/%.c FORCE | |||
156 | 159 | ||
157 | cmd_gensymtypes = \ | 160 | cmd_gensymtypes = \ |
158 | $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ | 161 | $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ |
159 | $(GENKSYMS) -T $@ -a $(ARCH) \ | 162 | $(GENKSYMS) $(if $(1), -T $(2)) -a $(ARCH) \ |
160 | $(if $(KBUILD_PRESERVE),-p) \ | 163 | $(if $(KBUILD_PRESERVE),-p) \ |
161 | $(if $(1),-r $(firstword $(wildcard $(@:.symtypes=.symref) /dev/null))) | 164 | -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) |
162 | 165 | ||
163 | quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ | 166 | quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ |
164 | cmd_cc_symtypes_c = \ | 167 | cmd_cc_symtypes_c = \ |
165 | set -e; \ | 168 | set -e; \ |
166 | $(call cmd_gensymtypes, true) >/dev/null; \ | 169 | $(call cmd_gensymtypes,true,$@) >/dev/null; \ |
167 | test -s $@ || rm -f $@ | 170 | test -s $@ || rm -f $@ |
168 | 171 | ||
169 | $(obj)/%.symtypes : $(src)/%.c FORCE | 172 | $(obj)/%.symtypes : $(src)/%.c FORCE |
@@ -192,16 +195,16 @@ else | |||
192 | # the actual value of the checksum generated by genksyms | 195 | # the actual value of the checksum generated by genksyms |
193 | 196 | ||
194 | cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< | 197 | cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< |
195 | cmd_modversions = \ | 198 | cmd_modversions = \ |
196 | if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ | 199 | if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ |
197 | $(call cmd_gensymtypes, $(KBUILD_SYMTYPES)) \ | 200 | $(call cmd_gensymtypes,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ |
198 | > $(@D)/.tmp_$(@F:.o=.ver); \ | 201 | > $(@D)/.tmp_$(@F:.o=.ver); \ |
199 | \ | 202 | \ |
200 | $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ | 203 | $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ |
201 | -T $(@D)/.tmp_$(@F:.o=.ver); \ | 204 | -T $(@D)/.tmp_$(@F:.o=.ver); \ |
202 | rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ | 205 | rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ |
203 | else \ | 206 | else \ |
204 | mv -f $(@D)/.tmp_$(@F) $@; \ | 207 | mv -f $(@D)/.tmp_$(@F) $@; \ |
205 | fi; | 208 | fi; |
206 | endif | 209 | endif |
207 | 210 | ||
@@ -248,10 +251,10 @@ $(obj)/%.lst: $(src)/%.c FORCE | |||
248 | # Compile assembler sources (.S) | 251 | # Compile assembler sources (.S) |
249 | # --------------------------------------------------------------------------- | 252 | # --------------------------------------------------------------------------- |
250 | 253 | ||
251 | modkern_aflags := $(AFLAGS_KERNEL) | 254 | modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL) |
252 | 255 | ||
253 | $(real-objs-m) : modkern_aflags := $(AFLAGS_MODULE) | 256 | $(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) |
254 | $(real-objs-m:.o=.s): modkern_aflags := $(AFLAGS_MODULE) | 257 | $(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) |
255 | 258 | ||
256 | quiet_cmd_as_s_S = CPP $(quiet_modtag) $@ | 259 | quiet_cmd_as_s_S = CPP $(quiet_modtag) $@ |
257 | cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< | 260 | cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< |
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 8f14c81abbc7..7d22056582c1 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost | |||
@@ -30,7 +30,7 @@ | |||
30 | # - See include/linux/module.h for more details | 30 | # - See include/linux/module.h for more details |
31 | 31 | ||
32 | # Step 4 is solely used to allow module versioning in external modules, | 32 | # Step 4 is solely used to allow module versioning in external modules, |
33 | # where the CRC of each module is retrieved from the Module.symers file. | 33 | # where the CRC of each module is retrieved from the Module.symvers file. |
34 | 34 | ||
35 | # KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined | 35 | # KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined |
36 | # symbols in the final module linking stage | 36 | # symbols in the final module linking stage |
@@ -107,7 +107,7 @@ $(modules:.ko=.mod.c): __modpost ; | |||
107 | modname = $(notdir $(@:.mod.o=)) | 107 | modname = $(notdir $(@:.mod.o=)) |
108 | 108 | ||
109 | quiet_cmd_cc_o_c = CC $@ | 109 | quiet_cmd_cc_o_c = CC $@ |
110 | cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \ | 110 | cmd_cc_o_c = $(CC) $(c_flags) $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE) \ |
111 | -c -o $@ $< | 111 | -c -o $@ $< |
112 | 112 | ||
113 | $(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE | 113 | $(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE |
@@ -117,8 +117,9 @@ targets += $(modules:.ko=.mod.o) | |||
117 | 117 | ||
118 | # Step 6), final link of the modules | 118 | # Step 6), final link of the modules |
119 | quiet_cmd_ld_ko_o = LD [M] $@ | 119 | quiet_cmd_ld_ko_o = LD [M] $@ |
120 | cmd_ld_ko_o = $(LD) -r $(LDFLAGS) $(LDFLAGS_MODULE) -o $@ \ | 120 | cmd_ld_ko_o = $(LD) -r $(LDFLAGS) \ |
121 | $(filter-out FORCE,$^) | 121 | $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ |
122 | -o $@ $(filter-out FORCE,$^) | ||
122 | 123 | ||
123 | $(modules): %.ko :%.o %.mod.o FORCE | 124 | $(modules): %.ko :%.o %.mod.o FORCE |
124 | $(call if_changed,ld_ko_o) | 125 | $(call if_changed,ld_ko_o) |
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 5758aab0d8bb..88f3f07205f8 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -884,16 +884,16 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, | |||
884 | char *zeros = NULL; | 884 | char *zeros = NULL; |
885 | 885 | ||
886 | /* We're looking for a section relative symbol */ | 886 | /* We're looking for a section relative symbol */ |
887 | if (!sym->st_shndx || sym->st_shndx >= info->hdr->e_shnum) | 887 | if (!sym->st_shndx || get_secindex(info, sym) >= info->num_sections) |
888 | return; | 888 | return; |
889 | 889 | ||
890 | /* Handle all-NULL symbols allocated into .bss */ | 890 | /* Handle all-NULL symbols allocated into .bss */ |
891 | if (info->sechdrs[sym->st_shndx].sh_type & SHT_NOBITS) { | 891 | if (info->sechdrs[get_secindex(info, sym)].sh_type & SHT_NOBITS) { |
892 | zeros = calloc(1, sym->st_size); | 892 | zeros = calloc(1, sym->st_size); |
893 | symval = zeros; | 893 | symval = zeros; |
894 | } else { | 894 | } else { |
895 | symval = (void *)info->hdr | 895 | symval = (void *)info->hdr |
896 | + info->sechdrs[sym->st_shndx].sh_offset | 896 | + info->sechdrs[get_secindex(info, sym)].sh_offset |
897 | + sym->st_value; | 897 | + sym->st_value; |
898 | } | 898 | } |
899 | 899 | ||
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index f6127b9f5aca..c827309c29cf 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -253,7 +253,7 @@ static enum export export_no(const char *s) | |||
253 | return export_unknown; | 253 | return export_unknown; |
254 | } | 254 | } |
255 | 255 | ||
256 | static enum export export_from_sec(struct elf_info *elf, Elf_Section sec) | 256 | static enum export export_from_sec(struct elf_info *elf, unsigned int sec) |
257 | { | 257 | { |
258 | if (sec == elf->export_sec) | 258 | if (sec == elf->export_sec) |
259 | return export_plain; | 259 | return export_plain; |
@@ -373,6 +373,8 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
373 | Elf_Ehdr *hdr; | 373 | Elf_Ehdr *hdr; |
374 | Elf_Shdr *sechdrs; | 374 | Elf_Shdr *sechdrs; |
375 | Elf_Sym *sym; | 375 | Elf_Sym *sym; |
376 | const char *secstrings; | ||
377 | unsigned int symtab_idx = ~0U, symtab_shndx_idx = ~0U; | ||
376 | 378 | ||
377 | hdr = grab_file(filename, &info->size); | 379 | hdr = grab_file(filename, &info->size); |
378 | if (!hdr) { | 380 | if (!hdr) { |
@@ -417,8 +419,27 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
417 | return 0; | 419 | return 0; |
418 | } | 420 | } |
419 | 421 | ||
422 | if (hdr->e_shnum == 0) { | ||
423 | /* | ||
424 | * There are more than 64k sections, | ||
425 | * read count from .sh_size. | ||
426 | * note: it doesn't need shndx2secindex() | ||
427 | */ | ||
428 | info->num_sections = TO_NATIVE(sechdrs[0].sh_size); | ||
429 | } | ||
430 | else { | ||
431 | info->num_sections = hdr->e_shnum; | ||
432 | } | ||
433 | if (hdr->e_shstrndx == SHN_XINDEX) { | ||
434 | info->secindex_strings = | ||
435 | shndx2secindex(TO_NATIVE(sechdrs[0].sh_link)); | ||
436 | } | ||
437 | else { | ||
438 | info->secindex_strings = hdr->e_shstrndx; | ||
439 | } | ||
440 | |||
420 | /* Fix endianness in section headers */ | 441 | /* Fix endianness in section headers */ |
421 | for (i = 0; i < hdr->e_shnum; i++) { | 442 | for (i = 0; i < info->num_sections; i++) { |
422 | sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name); | 443 | sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name); |
423 | sechdrs[i].sh_type = TO_NATIVE(sechdrs[i].sh_type); | 444 | sechdrs[i].sh_type = TO_NATIVE(sechdrs[i].sh_type); |
424 | sechdrs[i].sh_flags = TO_NATIVE(sechdrs[i].sh_flags); | 445 | sechdrs[i].sh_flags = TO_NATIVE(sechdrs[i].sh_flags); |
@@ -431,9 +452,8 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
431 | sechdrs[i].sh_entsize = TO_NATIVE(sechdrs[i].sh_entsize); | 452 | sechdrs[i].sh_entsize = TO_NATIVE(sechdrs[i].sh_entsize); |
432 | } | 453 | } |
433 | /* Find symbol table. */ | 454 | /* Find symbol table. */ |
434 | for (i = 1; i < hdr->e_shnum; i++) { | 455 | secstrings = (void *)hdr + sechdrs[info->secindex_strings].sh_offset; |
435 | const char *secstrings | 456 | for (i = 1; i < info->num_sections; i++) { |
436 | = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; | ||
437 | const char *secname; | 457 | const char *secname; |
438 | int nobits = sechdrs[i].sh_type == SHT_NOBITS; | 458 | int nobits = sechdrs[i].sh_type == SHT_NOBITS; |
439 | 459 | ||
@@ -461,14 +481,26 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
461 | else if (strcmp(secname, "__ksymtab_gpl_future") == 0) | 481 | else if (strcmp(secname, "__ksymtab_gpl_future") == 0) |
462 | info->export_gpl_future_sec = i; | 482 | info->export_gpl_future_sec = i; |
463 | 483 | ||
464 | if (sechdrs[i].sh_type != SHT_SYMTAB) | 484 | if (sechdrs[i].sh_type == SHT_SYMTAB) { |
465 | continue; | 485 | unsigned int sh_link_idx; |
486 | symtab_idx = i; | ||
487 | info->symtab_start = (void *)hdr + | ||
488 | sechdrs[i].sh_offset; | ||
489 | info->symtab_stop = (void *)hdr + | ||
490 | sechdrs[i].sh_offset + sechdrs[i].sh_size; | ||
491 | sh_link_idx = shndx2secindex(sechdrs[i].sh_link); | ||
492 | info->strtab = (void *)hdr + | ||
493 | sechdrs[sh_link_idx].sh_offset; | ||
494 | } | ||
466 | 495 | ||
467 | info->symtab_start = (void *)hdr + sechdrs[i].sh_offset; | 496 | /* 32bit section no. table? ("more than 64k sections") */ |
468 | info->symtab_stop = (void *)hdr + sechdrs[i].sh_offset | 497 | if (sechdrs[i].sh_type == SHT_SYMTAB_SHNDX) { |
469 | + sechdrs[i].sh_size; | 498 | symtab_shndx_idx = i; |
470 | info->strtab = (void *)hdr + | 499 | info->symtab_shndx_start = (void *)hdr + |
471 | sechdrs[sechdrs[i].sh_link].sh_offset; | 500 | sechdrs[i].sh_offset; |
501 | info->symtab_shndx_stop = (void *)hdr + | ||
502 | sechdrs[i].sh_offset + sechdrs[i].sh_size; | ||
503 | } | ||
472 | } | 504 | } |
473 | if (!info->symtab_start) | 505 | if (!info->symtab_start) |
474 | fatal("%s has no symtab?\n", filename); | 506 | fatal("%s has no symtab?\n", filename); |
@@ -480,6 +512,21 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
480 | sym->st_value = TO_NATIVE(sym->st_value); | 512 | sym->st_value = TO_NATIVE(sym->st_value); |
481 | sym->st_size = TO_NATIVE(sym->st_size); | 513 | sym->st_size = TO_NATIVE(sym->st_size); |
482 | } | 514 | } |
515 | |||
516 | if (symtab_shndx_idx != ~0U) { | ||
517 | Elf32_Word *p; | ||
518 | if (symtab_idx != | ||
519 | shndx2secindex(sechdrs[symtab_shndx_idx].sh_link)) | ||
520 | fatal("%s: SYMTAB_SHNDX has bad sh_link: %u!=%u\n", | ||
521 | filename, | ||
522 | shndx2secindex(sechdrs[symtab_shndx_idx].sh_link), | ||
523 | symtab_idx); | ||
524 | /* Fix endianness */ | ||
525 | for (p = info->symtab_shndx_start; p < info->symtab_shndx_stop; | ||
526 | p++) | ||
527 | *p = TO_NATIVE(*p); | ||
528 | } | ||
529 | |||
483 | return 1; | 530 | return 1; |
484 | } | 531 | } |
485 | 532 | ||
@@ -519,7 +566,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, | |||
519 | Elf_Sym *sym, const char *symname) | 566 | Elf_Sym *sym, const char *symname) |
520 | { | 567 | { |
521 | unsigned int crc; | 568 | unsigned int crc; |
522 | enum export export = export_from_sec(info, sym->st_shndx); | 569 | enum export export = export_from_sec(info, get_secindex(info, sym)); |
523 | 570 | ||
524 | switch (sym->st_shndx) { | 571 | switch (sym->st_shndx) { |
525 | case SHN_COMMON: | 572 | case SHN_COMMON: |
@@ -661,19 +708,19 @@ static const char *sym_name(struct elf_info *elf, Elf_Sym *sym) | |||
661 | return "(unknown)"; | 708 | return "(unknown)"; |
662 | } | 709 | } |
663 | 710 | ||
664 | static const char *sec_name(struct elf_info *elf, int shndx) | 711 | static const char *sec_name(struct elf_info *elf, int secindex) |
665 | { | 712 | { |
666 | Elf_Shdr *sechdrs = elf->sechdrs; | 713 | Elf_Shdr *sechdrs = elf->sechdrs; |
667 | return (void *)elf->hdr + | 714 | return (void *)elf->hdr + |
668 | elf->sechdrs[elf->hdr->e_shstrndx].sh_offset + | 715 | elf->sechdrs[elf->secindex_strings].sh_offset + |
669 | sechdrs[shndx].sh_name; | 716 | sechdrs[secindex].sh_name; |
670 | } | 717 | } |
671 | 718 | ||
672 | static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr) | 719 | static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr) |
673 | { | 720 | { |
674 | return (void *)elf->hdr + | 721 | return (void *)elf->hdr + |
675 | elf->sechdrs[elf->hdr->e_shstrndx].sh_offset + | 722 | elf->sechdrs[elf->secindex_strings].sh_offset + |
676 | sechdr->sh_name; | 723 | sechdr->sh_name; |
677 | } | 724 | } |
678 | 725 | ||
679 | /* if sym is empty or point to a string | 726 | /* if sym is empty or point to a string |
@@ -1052,11 +1099,14 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr, | |||
1052 | Elf_Sym *near = NULL; | 1099 | Elf_Sym *near = NULL; |
1053 | Elf64_Sword distance = 20; | 1100 | Elf64_Sword distance = 20; |
1054 | Elf64_Sword d; | 1101 | Elf64_Sword d; |
1102 | unsigned int relsym_secindex; | ||
1055 | 1103 | ||
1056 | if (relsym->st_name != 0) | 1104 | if (relsym->st_name != 0) |
1057 | return relsym; | 1105 | return relsym; |
1106 | |||
1107 | relsym_secindex = get_secindex(elf, relsym); | ||
1058 | for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { | 1108 | for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { |
1059 | if (sym->st_shndx != relsym->st_shndx) | 1109 | if (get_secindex(elf, sym) != relsym_secindex) |
1060 | continue; | 1110 | continue; |
1061 | if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) | 1111 | if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) |
1062 | continue; | 1112 | continue; |
@@ -1118,9 +1168,9 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr, | |||
1118 | for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { | 1168 | for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { |
1119 | const char *symsec; | 1169 | const char *symsec; |
1120 | 1170 | ||
1121 | if (sym->st_shndx >= SHN_LORESERVE) | 1171 | if (is_shndx_special(sym->st_shndx)) |
1122 | continue; | 1172 | continue; |
1123 | symsec = sec_name(elf, sym->st_shndx); | 1173 | symsec = sec_name(elf, get_secindex(elf, sym)); |
1124 | if (strcmp(symsec, sec) != 0) | 1174 | if (strcmp(symsec, sec) != 0) |
1125 | continue; | 1175 | continue; |
1126 | if (!is_valid_name(elf, sym)) | 1176 | if (!is_valid_name(elf, sym)) |
@@ -1316,7 +1366,7 @@ static void check_section_mismatch(const char *modname, struct elf_info *elf, | |||
1316 | const char *tosec; | 1366 | const char *tosec; |
1317 | const struct sectioncheck *mismatch; | 1367 | const struct sectioncheck *mismatch; |
1318 | 1368 | ||
1319 | tosec = sec_name(elf, sym->st_shndx); | 1369 | tosec = sec_name(elf, get_secindex(elf, sym)); |
1320 | mismatch = section_mismatch(fromsec, tosec); | 1370 | mismatch = section_mismatch(fromsec, tosec); |
1321 | if (mismatch) { | 1371 | if (mismatch) { |
1322 | Elf_Sym *to; | 1372 | Elf_Sym *to; |
@@ -1344,7 +1394,7 @@ static unsigned int *reloc_location(struct elf_info *elf, | |||
1344 | Elf_Shdr *sechdr, Elf_Rela *r) | 1394 | Elf_Shdr *sechdr, Elf_Rela *r) |
1345 | { | 1395 | { |
1346 | Elf_Shdr *sechdrs = elf->sechdrs; | 1396 | Elf_Shdr *sechdrs = elf->sechdrs; |
1347 | int section = sechdr->sh_info; | 1397 | int section = shndx2secindex(sechdr->sh_info); |
1348 | 1398 | ||
1349 | return (void *)elf->hdr + sechdrs[section].sh_offset + | 1399 | return (void *)elf->hdr + sechdrs[section].sh_offset + |
1350 | r->r_offset - sechdrs[section].sh_addr; | 1400 | r->r_offset - sechdrs[section].sh_addr; |
@@ -1452,7 +1502,7 @@ static void section_rela(const char *modname, struct elf_info *elf, | |||
1452 | r.r_addend = TO_NATIVE(rela->r_addend); | 1502 | r.r_addend = TO_NATIVE(rela->r_addend); |
1453 | sym = elf->symtab_start + r_sym; | 1503 | sym = elf->symtab_start + r_sym; |
1454 | /* Skip special sections */ | 1504 | /* Skip special sections */ |
1455 | if (sym->st_shndx >= SHN_LORESERVE) | 1505 | if (is_shndx_special(sym->st_shndx)) |
1456 | continue; | 1506 | continue; |
1457 | check_section_mismatch(modname, elf, &r, sym, fromsec); | 1507 | check_section_mismatch(modname, elf, &r, sym, fromsec); |
1458 | } | 1508 | } |
@@ -1510,7 +1560,7 @@ static void section_rel(const char *modname, struct elf_info *elf, | |||
1510 | } | 1560 | } |
1511 | sym = elf->symtab_start + r_sym; | 1561 | sym = elf->symtab_start + r_sym; |
1512 | /* Skip special sections */ | 1562 | /* Skip special sections */ |
1513 | if (sym->st_shndx >= SHN_LORESERVE) | 1563 | if (is_shndx_special(sym->st_shndx)) |
1514 | continue; | 1564 | continue; |
1515 | check_section_mismatch(modname, elf, &r, sym, fromsec); | 1565 | check_section_mismatch(modname, elf, &r, sym, fromsec); |
1516 | } | 1566 | } |
@@ -1535,7 +1585,7 @@ static void check_sec_ref(struct module *mod, const char *modname, | |||
1535 | Elf_Shdr *sechdrs = elf->sechdrs; | 1585 | Elf_Shdr *sechdrs = elf->sechdrs; |
1536 | 1586 | ||
1537 | /* Walk through all sections */ | 1587 | /* Walk through all sections */ |
1538 | for (i = 0; i < elf->hdr->e_shnum; i++) { | 1588 | for (i = 0; i < elf->num_sections; i++) { |
1539 | check_section(modname, elf, &elf->sechdrs[i]); | 1589 | check_section(modname, elf, &elf->sechdrs[i]); |
1540 | /* We want to process only relocation sections and not .init */ | 1590 | /* We want to process only relocation sections and not .init */ |
1541 | if (sechdrs[i].sh_type == SHT_RELA) | 1591 | if (sechdrs[i].sh_type == SHT_RELA) |
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index be987a44f250..0388cfccac8d 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h | |||
@@ -129,8 +129,51 @@ struct elf_info { | |||
129 | const char *strtab; | 129 | const char *strtab; |
130 | char *modinfo; | 130 | char *modinfo; |
131 | unsigned int modinfo_len; | 131 | unsigned int modinfo_len; |
132 | |||
133 | /* support for 32bit section numbers */ | ||
134 | |||
135 | unsigned int num_sections; /* max_secindex + 1 */ | ||
136 | unsigned int secindex_strings; | ||
137 | /* if Nth symbol table entry has .st_shndx = SHN_XINDEX, | ||
138 | * take shndx from symtab_shndx_start[N] instead */ | ||
139 | Elf32_Word *symtab_shndx_start; | ||
140 | Elf32_Word *symtab_shndx_stop; | ||
132 | }; | 141 | }; |
133 | 142 | ||
143 | static inline int is_shndx_special(unsigned int i) | ||
144 | { | ||
145 | return i != SHN_XINDEX && i >= SHN_LORESERVE && i <= SHN_HIRESERVE; | ||
146 | } | ||
147 | |||
148 | /* shndx is in [0..SHN_LORESERVE) U (SHN_HIRESERVE, 0xfffffff], thus: | ||
149 | * shndx == 0 <=> sechdrs[0] | ||
150 | * ...... | ||
151 | * shndx == SHN_LORESERVE-1 <=> sechdrs[SHN_LORESERVE-1] | ||
152 | * shndx == SHN_HIRESERVE+1 <=> sechdrs[SHN_LORESERVE] | ||
153 | * shndx == SHN_HIRESERVE+2 <=> sechdrs[SHN_LORESERVE+1] | ||
154 | * ...... | ||
155 | * fyi: sym->st_shndx is uint16, SHN_LORESERVE = ff00, SHN_HIRESERVE = ffff, | ||
156 | * so basically we map 0000..feff -> 0000..feff | ||
157 | * ff00..ffff -> (you are a bad boy, dont do it) | ||
158 | * 10000..xxxx -> ff00..(xxxx-0x100) | ||
159 | */ | ||
160 | static inline unsigned int shndx2secindex(unsigned int i) | ||
161 | { | ||
162 | if (i <= SHN_HIRESERVE) | ||
163 | return i; | ||
164 | return i - (SHN_HIRESERVE + 1 - SHN_LORESERVE); | ||
165 | } | ||
166 | |||
167 | /* Accessor for sym->st_shndx, hides ugliness of "64k sections" */ | ||
168 | static inline unsigned int get_secindex(const struct elf_info *info, | ||
169 | const Elf_Sym *sym) | ||
170 | { | ||
171 | if (sym->st_shndx != SHN_XINDEX) | ||
172 | return sym->st_shndx; | ||
173 | return shndx2secindex(info->symtab_shndx_start[sym - | ||
174 | info->symtab_start]); | ||
175 | } | ||
176 | |||
134 | /* file2alias.c */ | 177 | /* file2alias.c */ |
135 | extern unsigned int cross_build; | 178 | extern unsigned int cross_build; |
136 | void handle_moddevtable(struct module *mod, struct elf_info *info, | 179 | void handle_moddevtable(struct module *mod, struct elf_info *info, |