dyndbg: try conditional linker expression in KEEP - RFC
PATCH 19/20 dyndbg: try conditional linker expression in KEEP - RFC
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.
--- include/asm-generic/vmlinux.lds.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/asm-generic/vmlinux.lds.h +2 -2
@@ -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 ()
Signature · 1 line
2.29.2