lkml.org 
[lkml]   [2006]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: kbuild: Section mismatch warnings
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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-02-18 22:31    [W:0.343 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site