linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: Link failures due to __bug_table in current -next
Date: Mon, 19 Sep 2011 19:40:27 +0100	[thread overview]
Message-ID: <20110919184027.GZ16381@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <20110919120954.GA20314@opensource.wolfsonmicro.com>

On Mon, Sep 19, 2011 at 01:09:54PM +0100, Mark Brown wrote:
> I'm seeing linker failures in -next as of today:
> 
> `.exit.text' referenced in section `__bug_table' of fs/built-in.o:
> defined in discarded section `.exit.text' of fs/built-in.o
> `.exit.text' referenced in section `__bug_table' of crypto/built-in.o:
> defined in discarded section `.exit.text' of crypto/built-in.o
> `.exit.text' referenced in section `__bug_table' of net/built-in.o:
> defined in discarded section `.exit.text' of net/built-in.o
> `.exit.text' referenced in section `__bug_table' of net/built-in.o:
> defined in discarded section `.exit.text' of net/built-in.o
> 
> which appears to be due to the chnage to use generic BUG() introduced in
> commit 5254a3 (ARM: 7017/1: Use generic BUG() handler), reverting that
> commit resolves the issue for me.

It's a known issue - there's been an earlier thread about it:

http://lists.arm.linux.org.uk/lurker/thread/20110808.184931.a38e1c4e.en.html

The asm-generic/vmlinux.lds.S is basically relying on undefined behaviour
from the linker, which is biting us.  There is no guaranteed ordering of
matching input sections to output sections, so listing the same section
more than once in the linker script is asking for problems.

The unfortunate thing is that the linker internally groups the /DISCARD/
sections together into one section, all grouped at the first mention of
the /DISCARD/ section.  This means if you have several /DISCARD/ sections
scattered throughout the linker script, and you rely on the order in which
they appear, you're going to be disappointed because they'll all be merged
into the same position as the first one.

Practically, and observably, this means that for this linker script:

#undef DISCARD_EXIT_TEXT
#ifdef FOO
	/DISCARD/ : {
		*(.foo)
	}
#endif

	.foo : {
		*(.foo)
	}

	.exit.text : {
#ifndef DISCARD_EXIT_TEXT
		*(.exit.text)
#endif
	}

	/DISCARD/ : {
		*(.exit.text)
	}

If FOO is set, .exit.text will be discarded along with .foo.  If FOO is
unset, both .exit.text and .foo will be kept.

Practically, this is what's happening - the DISCARD macro from the
asm-generic/vmlinux.lds.S lists input sections which _may_ be discarded
with the assumption that if they are required, they'll be mentioned
_before_ any discards.  _That_ in itself is undefined linker behaviour.

> I'm wondering if we need something like 7c8a25 (CRIS: Discard exit.text
> and .data at runtime) but figuring it out is a bit beyond my ld skills
> right now.

fatal: ambiguous argument '7c8a25': unknown revision or path not in the working
tree.

Maybe you could be more specific?

  reply	other threads:[~2011-09-19 18:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-19 12:09 Link failures due to __bug_table in current -next Mark Brown
2011-09-19 18:40 ` Russell King - ARM Linux [this message]
2011-09-19 18:42   ` Mark Brown
2011-09-19 18:58     ` Russell King - ARM Linux
2011-09-19 19:06       ` Mark Brown
2011-09-19 19:16         ` Russell King - ARM Linux
2011-09-20  7:35           ` Uwe Kleine-König
2011-09-19 19:12       ` Russell King - ARM Linux
2011-09-19 20:03 ` Russell King - ARM Linux
2011-09-20  7:06   ` Simon Glass
2011-09-20  7:59     ` Russell King - ARM Linux
2011-09-20 17:00       ` Simon Glass
2011-09-20 18:51         ` Russell King - ARM Linux
2011-09-20 19:13           ` Arnd Bergmann
2011-09-20 19:57           ` Nicolas Pitre
2011-09-21 22:58             ` Simon Glass
2011-09-21 22:45           ` Simon Glass
2011-09-20 11:02   ` Mark Brown

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=20110919184027.GZ16381@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.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).