Kernel Newbies Archive on lore.kernel.org
 help / color / Atom feed
* help with linker script mods
@ 2021-03-17  4:50 jim.cromie
  0 siblings, 0 replies; only message in thread
From: jim.cromie @ 2021-03-17  4:50 UTC (permalink / raw)
  To: kernelnewbies

[-- Attachment #1.1: Type: text/plain, Size: 2086 bytes --]

so Im trying to constrain the linker to put ELF section pairs
into contiguous chunks of memory.

this is on top of:
https://lore.kernel.org/lkml/20210316050801.2446401-1-jim.cromie@gmail.com/

The macro below works when used in vmlinux.lds.h,
it does pack the sections as desired.

but same macro, when reused in module.lds.h, fails.

The version below links ok, but appears to absorb the __dyndbg* sections
into the .data section, which works for vmlinux.lds.h, cuz there we use the
__start/stop ___dyndbg* symbols to use the section.

In contrast, for modules, I want to preserve the named sections
as proper elf sections in the ko, so that loader picks them up
and saves them into struct load-info

Anyone got some deep linker-fu ?


[jimc@frodo wk-next]$ git diff
diff --git a/include/asm-generic/module.lds.h
b/include/asm-generic/module.lds.h
index f210d5c1b78b..4840f01a0828 100644
--- a/include/asm-generic/module.lds.h
+++ b/include/asm-generic/module.lds.h
@@ -4,7 +4,26 @@

 /*
  * <asm/module.lds.h> can specify arch-specific sections for linking
modules.
- * Empty for the asm-generic header.
+ * DYNAMIC_DEBUG needs its header sections contiguous with its data
sections.
  */

+#if defined(CONFIG_DYNAMIC_DEBUG) ||                                    \
+        (defined(CONFIG_DYNAMIC_DEBUG_CORE)                             \
+         && defined(DYNAMIC_DEBUG_MODULE))
+#define DYNAMIC_DEBUG_DATA()                                            \
+        . = ALIGN(8);                                                   \
+        __start___dyndbg_sites = .;                                     \
+        KEEP(*(__dyndbg_sites .gnu.linkonce.dyndbg_site))               \
+        __stop___dyndbg_sites = .;                                      \
+        __start___dyndbg = .;                                           \
+        KEEP(*(__dyndbg .gnu.linkonce.dyndbg))                          \
+        __stop___dyndbg = .;
+#else
+#define DYNAMIC_DEBUG_DATA()
+#endif
+
+SECTIONS {
+       .data : { DYNAMIC_DEBUG_DATA() }
+}
+
 #endif /* __ASM_GENERIC_MODULE_LDS_H */

[-- Attachment #1.2: Type: text/html, Size: 2778 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-17  4:50 help with linker script mods jim.cromie

Kernel Newbies Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kernelnewbies/0 kernelnewbies/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kernelnewbies kernelnewbies/ https://lore.kernel.org/kernelnewbies \
		kernelnewbies@kernelnewbies.org
	public-inbox-index kernelnewbies

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernelnewbies.kernelnewbies


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git