diff options
author | Sam Ravnborg <sam@ravnborg.org> | 2008-01-18 21:04:34 +0100 |
---|---|---|
committer | Sam Ravnborg <sam@ravnborg.org> | 2008-01-28 23:14:40 +0100 |
commit | 9ad21c3f3ecffeb56be7b35030d7ec2f30b6fe11 (patch) | |
tree | b13cef078ebe25ddfca57f64404a664440713672 /scripts | |
parent | d1f25e6658943569f2713dfde1b9d74e2f6c7243 (diff) |
kbuild: try harder to find symbol names in modpost
The relocation record sometimes contained an address
which was not an exactly match for a symbol.
Implment some simple logic such that if there
is a symbol within 20 bytes of the address contained
in the relocation record then print the name of this
symbol.
With this change modpost could find symbol names
for the remaining .init.text symbols in my
allyesconfig build for x86_64.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/mod/modpost.c | 19 | ||||
-rw-r--r-- | scripts/mod/modpost.h | 2 |
2 files changed, 19 insertions, 2 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 46660a4f9e22..902ee55f327f 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -776,10 +776,13 @@ static int secref_whitelist(const char *modname, const char *tosec, * In other cases the symbol needs to be looked up in the symbol table * based on section and address. * **/ -static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf_Addr addr, +static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr, Elf_Sym *relsym) { Elf_Sym *sym; + Elf_Sym *near = NULL; + Elf64_Sword distance = 20; + Elf64_Sword d; if (relsym->st_name != 0) return relsym; @@ -790,8 +793,20 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf_Addr addr, continue; if (sym->st_value == addr) return sym; + /* Find a symbol nearby - addr are maybe negative */ + d = sym->st_value - addr; + if (d < 0) + d = addr - sym->st_value; + if (d < distance) { + distance = d; + near = sym; + } } - return NULL; + /* We need a close match */ + if (distance < 20) + return near; + else + return NULL; } static inline int is_arm_mapping_symbol(const char *str) diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 0ffed17ec20c..999f15e0e008 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -17,6 +17,7 @@ #define Elf_Shdr Elf32_Shdr #define Elf_Sym Elf32_Sym #define Elf_Addr Elf32_Addr +#define Elf_Sword Elf64_Sword #define Elf_Section Elf32_Half #define ELF_ST_BIND ELF32_ST_BIND #define ELF_ST_TYPE ELF32_ST_TYPE @@ -31,6 +32,7 @@ #define Elf_Shdr Elf64_Shdr #define Elf_Sym Elf64_Sym #define Elf_Addr Elf64_Addr +#define Elf_Sword Elf64_Sxword #define Elf_Section Elf64_Half #define ELF_ST_BIND ELF64_ST_BIND #define ELF_ST_TYPE ELF64_ST_TYPE |