[PATCH v1 01/14] DCE/DSE: allow keep unique bounded sections

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Zhangjin Wu <falcon@xxxxxxxxxxx>

The bounded sections may break the elimination of some dead code.

Some unused syscalls have been wrongly kept by `__ex_table`, we will
unique `__ex_table` for every inserting and then remove the unused ones
explicitly and eventually, the unused syscalls will be eliminated.

In the future, we should find better methods to solve such issue:

  Some code may use '.pushsection/.popsection' to insert data
  to a bounded section, use `sys_sendfile` as an example:

      sys_sendfile:

        ".pushsection __ex_table,\"\"\n"
        ...
	".long		((" insn ") - .)\n"
        ...
        ".popsection"

  `insn` is an address in `sys_sendfile`, even if no real user uses
  sys_sendfile, the keeping of __ex_table will become a 'user' and
  break the elimination of `sys_sendfile`.

All of the bounded sections should be uniqued, and we should check if
they are the last users of the code, if so, those sections should be
removed and the code should be eliminated.

Signed-off-by: Zhangjin Wu <falcon@xxxxxxxxxxx>
---
 include/asm-generic/vmlinux.lds.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 9c59409104f6..ea8170e11ab1 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -103,6 +103,7 @@
 #define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* .rodata..L*
 #define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..compoundliteral*
 #define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]*
+#define BSEC_MAIN(sec) sec sec##.[0-9a-zA-Z_]*
 #else
 #define TEXT_MAIN .text
 #define DATA_MAIN .data
@@ -110,6 +111,7 @@
 #define RODATA_MAIN .rodata
 #define BSS_MAIN .bss
 #define SBSS_MAIN .sbss
+#define BSEC_MAIN(sec) sec
 #endif
 
 /*
@@ -201,12 +203,12 @@
 
 #define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)	\
 	_BEGIN_##_label_ = .;						\
-	KEEP(*(_sec_))							\
+	KEEP(*(BSEC_MAIN(_sec_)))					\
 	_END_##_label_ = .;
 
 #define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)	\
 	_label_##_BEGIN_ = .;						\
-	KEEP(*(_sec_))							\
+	KEEP(*(BSEC_MAIN(_sec_)))					\
 	_label_##_END_ = .;
 
 #define BOUNDED_SECTION_BY(_sec_, _label_)				\
-- 
2.34.1





[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux