All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 19/20] dyndbg: try conditional linker expression in KEEP - RFC
@ 2021-01-27  6:17 Jim Cromie
  0 siblings, 0 replies; only message in thread
From: Jim Cromie @ 2021-01-27  6:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jim Cromie, Arnd Bergmann, linux-arch

This is the last patch in v3 of patchest Ive sent previously:
v2: https://lore.kernel.org/lkml/?q=Cromie+v2+00%2F19+2020-12-25+-Re

It isolates my only issue now, Id appreciate advice, and dont want to
distract you with the 18 previous commits.

Im trying to use ? : inside a KEEP(*(expression)) to only include
A_header when A has content.

IE:
  KEEP(*( A ? A_header : ))

It fails with inscrutable linker error.
  GEN     modules.builtin
  LD      .tmp_vmlinux.kallsyms1
ld:./arch/x86/kernel/vmlinux.lds:46: syntax error

Is this possible by other modes of expression ?

I tried inserting {} 1st, that failed, appearing to foreclose any
foreach-like construct.  I also tried () around each term, and a
preceding, embedded "_loc=.;" statement to test the parser.

I didnt try doing this with 2 separate KEEPs; while it would be
simple, it defeats the adjacency guaranteed by *(.text .rdata), which
is the point of this.

If this were to be possible, it opens up interesting options to
statically construct table headers, and possibly even tree structures
in the linker script.  Id use it to add 1 header for each module, and
strip a column out of the table.

Ive pulled binutils to take a look at the source; having never done
anything bison-ish, I anticipate a long study without some focused
primer knowledge.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 include/asm-generic/vmlinux.lds.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 87868c5a980a..6198cc850f9b 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -329,10 +329,10 @@
 #define DYNAMIC_DEBUG_DATA()						\
 	. = ALIGN(8);							\
 	__start___dyndbg_sites = .;					\
-	KEEP(*(__dyndbg_sites .gnu.linkonce.*.dyndbg_site))			\
+	KEEP(*(__dyndbg_sites ? .gnu.linkonce.*.dyndbg_site : ))	\
 	__stop___dyndbg_sites = .;					\
 	__start___dyndbg = .;						\
-	KEEP(*(__dyndbg .gnu.linkonce.*.dyndbg))				\
+	KEEP(*(__dyndbg ? .gnu.linkonce.*.dyndbg : ))			\
 	__stop___dyndbg = .;
 #else
 #define DYNAMIC_DEBUG_DATA()
-- 
2.29.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-27  6:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-27  6:17 [PATCH 19/20] dyndbg: try conditional linker expression in KEEP - RFC Jim Cromie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.