lkml.org 
[lkml]   [2021]   [Jan]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 19/20] dyndbg: try conditional linker expression in KEEP - RFC
Date
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
\
 
 \ /
  Last update: 2021-01-27 07:42    [W:0.026 / U:0.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site