public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Philip Kranz <philip.kranz@googlemail.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: Philip Kranz <philip.kranz@googlemail.com>,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	Sebastian Wankerl <sisewank@cip.cs.fau.de>,
	linux-kernel@vger.kernel.org,
	i4passt@lists.informatik.uni-erlangen.de,
	linux-parisc@vger.kernel.org
Subject: Re: [PATCH] Add non-zero module sections to sysfs
Date: Thu, 11 Apr 2013 16:11:55 +0200	[thread overview]
Message-ID: <20130411141155.GA21480@yoda.lan> (raw)
In-Reply-To: <878v4tbqve.fsf@rustcorp.com.au>

On Mon, Apr 08, 2013 at 01:44:45PM +0930, Rusty Russell wrote:
> Philip Kranz <philip.kranz@googlemail.com> writes:
> > Hello.
> >
> > On Fri, Apr 05, 2013 at 12:07:15PM +0200, James Bottomley wrote:
> >> Just so you know: this isn't a parisc specific problem.  Gcc produces
> >> duplicate section names under various circumstances, but the one that
> >> bites us is -ffunction-sections.  Note that there are proposals to use
> >> -ffunction-sections on all architectures (so we can garbage collect
> >> unused functions) in which case you'll induce the bug identified in
> >> 35dead4235e2b67da7275b4122fed37099c2f462 on every architecture
> >
> > I am not able to produce an object file with duplicate section names
> > using gcc on x86. Even with -ffunction-sections, every section gets a
> > unique name. Is this architecture-specific behaviour of gcc?
> 
> Good point.  ld -r will collapse them into the same section (since gcc
> produces them they have to have the same section attributes).
> 
> You can do it with --unique, but no arch uses that.  PARISC has a
> platform-specific toolchain hack which does that for .text sections.
> (Thanks to Alan Modra for that clue...)

Just for clarification, as we are currently preparing a patch set that
depends on this: Would the patch below be an acceptable solution for
this?

Thanks,
Philip



diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
index 2a625fb..1fd4411 100644
--- a/arch/parisc/kernel/module.c
+++ b/arch/parisc/kernel/module.c
@@ -341,6 +341,11 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
                ".PARISC.unwind", 14) == 0)
            me->arch.unwind_section = i;
 
+       /* we produce multiple, empty .text sections, and kallsyms
+       * gets upset.  make non-alloc so it doesn't see them. */
+       if (sechdrs[i].sh_size == 0)
+           sechdrs[i].sh_flags &= ~SHF_ALLOC;
+
        if (sechdrs[i].sh_type != SHT_RELA)
            continue;
 
diff --git a/kernel/module.c b/kernel/module.c
index 3c2c72d..42e0d5a 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1316,7 +1316,7 @@ resolve_symbol_wait(struct module *mod,
 #ifdef CONFIG_KALLSYMS
 static inline bool sect_empty(const Elf_Shdr *sect)
 {
-   return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
+   return !(sect->sh_flags & SHF_ALLOC);
 }
 
 struct module_sect_attr


  parent reply	other threads:[~2013-04-11 14:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-03 13:08 [PATCH] Add non-zero module sections to sysfs Sebastian Wankerl
2013-04-04  1:00 ` Rusty Russell
2013-04-04  9:40   ` Sebastian Wankerl
2013-04-05  4:00     ` Rusty Russell
2013-04-05  9:40       ` Sebastian Wankerl
2013-04-05 10:07       ` James Bottomley
2013-04-06  4:52         ` Rusty Russell
2013-04-06 10:52           ` James Bottomley
2013-04-06 15:16             ` John David Anglin
2013-04-07  1:22               ` James Bottomley
2013-04-07  1:45                 ` John David Anglin
2013-04-06 10:40         ` Philip Kranz
2013-04-08  4:14           ` Rusty Russell
2013-04-08 11:55             ` Philip Kranz
2013-04-11 14:11             ` Philip Kranz [this message]
2013-04-05 14:56       ` Sebastian Wankerl
2013-04-06  4:31         ` Rusty Russell

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=20130411141155.GA21480@yoda.lan \
    --to=philip.kranz@googlemail.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=i4passt@lists.informatik.uni-erlangen.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=sisewank@cip.cs.fau.de \
    /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