diff mbox series

[bpf,v1,2/3] bpf: prevent .BTF section elimination

Message ID a635b5d3e2da044e7b51ec1315e8910fbce0083f.1600417359.git.Tony.Ambardar@gmail.com
State Accepted
Delegated to: BPF Maintainers
Headers show
Series fix BTF usage on embedded systems | expand

Commit Message

Tony Ambardar Sept. 20, 2020, 5:01 a.m. UTC
Systems with memory or disk constraints often reduce the kernel footprint
by configuring LD_DEAD_CODE_DATA_ELIMINATION. However, this can result in
removal of any BTF information.

Use the KEEP() macro to preserve the BTF data as done with other important
sections, while still allowing for smaller kernels.

Fixes: 90ceddcb4950 ("bpf: Support llvm-objcopy for vmlinux BTF")

Signed-off-by: Tony Ambardar <Tony.Ambardar@gmail.com>
---
 include/asm-generic/vmlinux.lds.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

John Fastabend Sept. 21, 2020, 3:45 p.m. UTC | #1
Tony Ambardar wrote:
> Systems with memory or disk constraints often reduce the kernel footprint
> by configuring LD_DEAD_CODE_DATA_ELIMINATION. However, this can result in
> removal of any BTF information.
> 
> Use the KEEP() macro to preserve the BTF data as done with other important
> sections, while still allowing for smaller kernels.
> 
> Fixes: 90ceddcb4950 ("bpf: Support llvm-objcopy for vmlinux BTF")
> 
> Signed-off-by: Tony Ambardar <Tony.Ambardar@gmail.com>
> ---
>  include/asm-generic/vmlinux.lds.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> index 5430febd34be..7636bc71c71f 100644
> --- a/include/asm-generic/vmlinux.lds.h
> +++ b/include/asm-generic/vmlinux.lds.h
> @@ -661,7 +661,7 @@
>  #define BTF								\
>  	.BTF : AT(ADDR(.BTF) - LOAD_OFFSET) {				\
>  		__start_BTF = .;					\
> -		*(.BTF)							\
> +		KEEP(*(.BTF))						\
>  		__stop_BTF = .;						\
>  	}								\
>  	. = ALIGN(4);							\
> -- 
> 2.25.1
> 

Acked-by: John Fastabend <john.fastabend@gmail.com>
diff mbox series

Patch

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 5430febd34be..7636bc71c71f 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -661,7 +661,7 @@ 
 #define BTF								\
 	.BTF : AT(ADDR(.BTF) - LOAD_OFFSET) {				\
 		__start_BTF = .;					\
-		*(.BTF)							\
+		KEEP(*(.BTF))						\
 		__stop_BTF = .;						\
 	}								\
 	. = ALIGN(4);							\