kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: jim.cromie@gmail.com
To: kernelnewbies <kernelnewbies@kernelnewbies.org>
Subject: help with linker script mods
Date: Tue, 16 Mar 2021 22:50:39 -0600	[thread overview]
Message-ID: <CAJfuBxxmwdksPh7LXkzbBjzVuaH1Sx2cKtJaoN6awszV7hRijw@mail.gmail.com> (raw)


[-- 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

                 reply	other threads:[~2021-03-17  4:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJfuBxxmwdksPh7LXkzbBjzVuaH1Sx2cKtJaoN6awszV7hRijw@mail.gmail.com \
    --to=jim.cromie@gmail.com \
    --cc=kernelnewbies@kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).