Re: kbuild: Section mismatch warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux