linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: Nicholas Miell <nmiell@comcast.net>
Cc: Adrian Bunk <bunk@stusta.de>, LKML <linux-kernel@vger.kernel.org>,
	len.brown@intel.com, Paul Bristow <paul@paulbristow.net>,
	mpm@selenic.com, B.Zolnierkiewicz@elka.pw.edu.pl,
	dtor_core@ameritech.net, kkeil@suse.de,
	linux-dvb-maintainer@linuxtv.org, philb@gnu.org, gregkh@suse.de,
	dwmw2@infradead.org
Subject: Re: kbuild: Section mismatch warnings
Date: Sat, 18 Feb 2006 22:25:49 +0100	[thread overview]
Message-ID: <20060218212549.GA8936@mars.ravnborg.org> (raw)
In-Reply-To: <1140221699.2907.5.camel@entropy>

On Fri, Feb 17, 2006 at 04:14:59PM -0800, Nicholas Miell wrote:
> > Correct.
> > What I wanted was modpost to tell that the symbol being referenced in
> > the .data section was 'asus_hotk_add' and not just an offset after
> > asus_hotk_driver.
> > 
> > What is needed is a link from the RELOCATION RECORD to the symbol table.
> 
> The r_info field of Elf{32,64}_Rel{,a} contains an index into the symbol
> table which can be extracted using the ELF{32,64}_R_SYM() macro.

What I found here is that the symbol pointed out by ELF_R_SYM(r_info)
only contain one valid entry, namely the section where the symbol that
requires relocation is present. At least for amd64 all RELOCATION
RECORDS are of type RELA so they had an r_addent that pointed out
the offset within that section. So traversing the symbol table I could
find the symbol by looking up the symbol where shndx equals the section
in the symbol table and st_value equal the value of r_addent in the
relocation record.

I cooked up the following:
static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf_Addr addr,
				Elf_Section sec)
{
        Elf_Sym *sym;

        for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) {
                if (sym->st_shndx != sec)
                        continue;
                if (sym->st_value == addr)
			return sym;
	}
	return NULL;
}

This was with binutils version: 2.16.1 and gcc 3.4.4

So far I have only support for RELA records, not REL records.
That may prove required for other platforms.

	Sam

  reply	other threads:[~2006-02-18 21:26 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-17 21:48 kbuild: Sam Ravnborg
2006-02-17 22:47 ` kbuild: Section mismatch warnings Sam Ravnborg
2006-02-17 23:32   ` Adrian Bunk
2006-02-17 23:38     ` Sam Ravnborg
2006-02-17 23:56       ` Adrian Bunk
2006-02-18  0:14       ` Nicholas Miell
2006-02-18 21:25         ` Sam Ravnborg [this message]
2006-02-18  0:09   ` Greg KH
2006-02-18  0:48     ` David Brownell
2006-02-18  0:57       ` Greg KH
2006-02-18 20:32         ` David Brownell
2006-02-19  0:21     ` Sam Ravnborg
2006-02-22  5:09       ` Greg KH
2006-02-18  0:49   ` Dmitry Torokhov
2006-02-18 12:14     ` Sam Ravnborg
2006-02-18 13:34       ` Russell King
2006-02-19 11:36   ` Sam Ravnborg
2006-02-19 12:59     ` [v4l-dvb-maintainer] " Johannes Stezenbach
2006-02-19 13:19       ` Sam Ravnborg
2006-02-19 13:30         ` Johannes Stezenbach
2006-02-25 15:31           ` Adrian Bunk
2006-02-19 14:18     ` Sam Ravnborg
2006-02-19 22:38     ` Rusty Russell
2006-02-19 22:44       ` Sam Ravnborg
2006-02-18 22:12 ` kbuild: Andi Kleen
2006-02-18 22:38   ` kbuild: Sam Ravnborg
2006-02-18 23:41     ` kbuild: Sam Ravnborg

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=20060218212549.GA8936@mars.ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=B.Zolnierkiewicz@elka.pw.edu.pl \
    --cc=bunk@stusta.de \
    --cc=dtor_core@ameritech.net \
    --cc=dwmw2@infradead.org \
    --cc=gregkh@suse.de \
    --cc=kkeil@suse.de \
    --cc=len.brown@intel.com \
    --cc=linux-dvb-maintainer@linuxtv.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpm@selenic.com \
    --cc=nmiell@comcast.net \
    --cc=paul@paulbristow.net \
    --cc=philb@gnu.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).