diff mbox series

[v1,10/14] DCE/DSE: riscv: make every ex_table's name unique

Message ID f0ee9abfd8d7b27489a4efe3196813225ce5680f.1699025537.git.tanyuan@tinylab.org (mailing list archive)
State Handled Elsewhere
Headers show
Series DCE/DSE: Add Dead Syscalls Elimination support, part2 | expand

Commit Message

Yuan Tan Nov. 3, 2023, 4:02 p.m. UTC
gc-sections require section names to be unique.

Signed-off-by: Yuan Tan <tanyuan@tinylab.org>
Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
---
 arch/riscv/include/asm/asm-extable.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Fangrui Song Nov. 5, 2023, 9:13 p.m. UTC | #1
On Fri, Nov 3, 2023 at 9:02 AM Yuan Tan <tanyuan@tinylab.org> wrote:
>
> gc-sections require section names to be unique.

This is not precise, since a monolithic section can be garbage
collected as well.

https://maskray.me/blog/2021-02-28-linker-garbage-collection

"Without the options, the compiler tends to produce monolithic text
and data sections. The large sections make the GC coarse-grained and
they will likely be retained as a whole. ld --gc-sections can still
discard some sections, but the effect is likely very poor."


> Signed-off-by: Yuan Tan <tanyuan@tinylab.org>
> Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
> ---
>  arch/riscv/include/asm/asm-extable.h | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/include/asm/asm-extable.h b/arch/riscv/include/asm/asm-extable.h
> index 00a96e7a9664..d0be5a838242 100644
> --- a/arch/riscv/include/asm/asm-extable.h
> +++ b/arch/riscv/include/asm/asm-extable.h
> @@ -9,10 +9,12 @@
>
>  #ifdef CONFIG_MMU
>
> +#include <linux/compiler.h>
> +
>  #ifdef __ASSEMBLY__
>
>  #define __ASM_EXTABLE_RAW(insn, fixup, type, data)     \
> -       .pushsection    __ex_table, "a";                \
> +       .pushsection    __SECTION_NAME(__ex_table), "a";                \
>         .balign         4;                              \
>         .long           ((insn) - .);                   \
>         .long           ((fixup) - .);                  \
> @@ -31,7 +33,7 @@
>  #include <asm/gpr-num.h>

__SECTION_NAME is probably added by a previous patch.
An alternative is to use the .section directive's `unique` feature
(binutils>=2.35).

>  #define __ASM_EXTABLE_RAW(insn, fixup, type, data)     \
> -       ".pushsection   __ex_table, \"a\"\n"            \
> +       ".pushsection " __SECTION_NAME(__ex_table) ", \"a\"\n"          \
>         ".balign        4\n"                            \
>         ".long          ((" insn ") - .)\n"             \
>         ".long          ((" fixup ") - .)\n"            \
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/arch/riscv/include/asm/asm-extable.h b/arch/riscv/include/asm/asm-extable.h
index 00a96e7a9664..d0be5a838242 100644
--- a/arch/riscv/include/asm/asm-extable.h
+++ b/arch/riscv/include/asm/asm-extable.h
@@ -9,10 +9,12 @@ 
 
 #ifdef CONFIG_MMU
 
+#include <linux/compiler.h>
+
 #ifdef __ASSEMBLY__
 
 #define __ASM_EXTABLE_RAW(insn, fixup, type, data)	\
-	.pushsection	__ex_table, "a";		\
+	.pushsection	__SECTION_NAME(__ex_table), "a";		\
 	.balign		4;				\
 	.long		((insn) - .);			\
 	.long		((fixup) - .);			\
@@ -31,7 +33,7 @@ 
 #include <asm/gpr-num.h>
 
 #define __ASM_EXTABLE_RAW(insn, fixup, type, data)	\
-	".pushsection	__ex_table, \"a\"\n"		\
+	".pushsection "	__SECTION_NAME(__ex_table) ", \"a\"\n"		\
 	".balign	4\n"				\
 	".long		((" insn ") - .)\n"		\
 	".long		((" fixup ") - .)\n"		\