Skip to contentSkip to conversation

lkdtm: avoid link error on ARM

PATCH In review Arnd Bergmann 3 participants 3 messages Jun 17, 2016 Char and misc drivers

lore
Share & tools
lore

Arnd Bergmann

author maintainer
#0 lore raw

PATCH 1/1 lkdtm: avoid link error on ARM

The lkdtm_rodata file is built so that a function in it gets linked into the .rodata ELF section. This works fine normally, but on 32-bit ARM with really large kernels, it prevents the linker from inserting a veneer for the call to __gnu_mcount_nc in case we are building with "gcc -pg":

drivers/misc/built-in.o: In function `lkdtm_rodata_do_nothing':
panel.c:(.rodata+0x1480): relocation truncated to fit: R_ARM_CALL against symbol `__gnu_mcount_nc' defined in .text section in arch/arm/kernel/built-in.o

We probably never want the profiling code to be enabled for this file anyway, so this just removes the option here, and for the sake of consistency also in the lkdtm core module.

Fixes 9a49a528dcf3 ("lkdtm: add function for testing .rodata section")
---
 drivers/misc/Makefile | 2 ++
 1 file changed, 2 insertions(+)
drivers/misc/Makefile +2 -0
index 7d45ed4a1549..4a25eeaa30f9 100644
@@ -60,6 +60,8 @@ obj-$(CONFIG_PANEL)             += panel.o
 
 lkdtm-$(CONFIG_LKDTM)		+= lkdtm_core.o
 lkdtm-$(CONFIG_LKDTM)		+= lkdtm_rodata_objcopy.o
+CFLAGS_REMOVE_lkdtm_core.o	+= -pg
+CFLAGS_REMOVE_lkdtm_rodata.o	+= -pg
 
 OBJCOPYFLAGS :=
 OBJCOPYFLAGS_lkdtm_rodata_objcopy.o := \
Signature · 1 line
2.9.0
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Arnd Bergmann

The lkdtm_rodata file is built so that a function in it gets linked into the .rodata ELF section. This works fine normally, but on 32-bit ARM with really large kernels, it prevents the linker from inserting a veneer for the call to __gnu_mcount_nc in case we are building with "gcc -pg":

drivers/misc/built-in.o: In function `lkdtm_rodata_do_nothing':
panel.c:(.rodata+0x1480): relocation truncated to fit: R_ARM_CALL against symbol `__gnu_mcount_nc' defined in .text section in arch/arm/kernel/built-in.o

Quoted 6 lines

We probably never want the profiling code to be enabled for this file anyway, so this just removes the option here, and for the sake of consistency also in the lkdtm core module.

Fixes 9a49a528dcf3 ("lkdtm: add function for testing .rodata section")

Looks fine to me, thanks!

Greg, can you take this into your tree for -next?

Thanks!

-Kees

Quoted 20 lines
---
 drivers/misc/Makefile | 2 ++
 1 file changed, 2 insertions(+)
drivers/misc/Makefile +2 -1
index 7d45ed4a1549..4a25eeaa30f9 100644
@@ -60,6 +60,8 @@ obj-$(CONFIG_PANEL)             += panel.o
 
 lkdtm-$(CONFIG_LKDTM)          += lkdtm_core.o
 lkdtm-$(CONFIG_LKDTM)          += lkdtm_rodata_objcopy.o
+CFLAGS_REMOVE_lkdtm_core.o     += -pg
+CFLAGS_REMOVE_lkdtm_rodata.o   += -pg
 
 OBJCOPYFLAGS :=
 OBJCOPYFLAGS_lkdtm_rodata_objcopy.o := \
--

2.9.0

Signature · 2 lines
Kees Cook
Chrome OS & Brillo Security
#2 lore raw
Quoted 14 lines · Kees Cook
Quoted 13 lines · Arnd Bergmann

The lkdtm_rodata file is built so that a function in it gets linked into the .rodata ELF section. This works fine normally, but on 32-bit ARM with really large kernels, it prevents the linker from inserting a veneer for the call to __gnu_mcount_nc in case we are building with "gcc -pg":

drivers/misc/built-in.o: In function `lkdtm_rodata_do_nothing':
panel.c:(.rodata+0x1480): relocation truncated to fit: R_ARM_CALL against symbol `__gnu_mcount_nc' defined in .text section in arch/arm/kernel/built-in.o

We probably never want the profiling code to be enabled for this file anyway, so this just removes the option here, and for the sake of consistency also in the lkdtm core module.

Quoted 8 lines
Quoted 2 lines
Fixes 9a49a528dcf3 ("lkdtm: add function for testing .rodata section")

Looks fine to me, thanks!

Greg, can you take this into your tree for -next?

Yes,will do.