aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/mod/modpost.c19
-rw-r--r--scripts/mod/modpost.h2
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,
776 * In other cases the symbol needs to be looked up in the symbol table 776 * In other cases the symbol needs to be looked up in the symbol table
777 * based on section and address. 777 * based on section and address.
778 * **/ 778 * **/
779static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf_Addr addr, 779static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
780 Elf_Sym *relsym) 780 Elf_Sym *relsym)
781{ 781{
782 Elf_Sym *sym; 782 Elf_Sym *sym;
783 Elf_Sym *near = NULL;
784 Elf64_Sword distance = 20;
785 Elf64_Sword d;
783 786
784 if (relsym->st_name != 0) 787 if (relsym->st_name != 0)
785 return relsym; 788 return relsym;
@@ -790,8 +793,20 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf_Addr addr,
790 continue; 793 continue;
791 if (sym->st_value == addr) 794 if (sym->st_value == addr)
792 return sym; 795 return sym;
796 /* Find a symbol nearby - addr are maybe negative */
797 d = sym->st_value - addr;
798 if (d < 0)
799 d = addr - sym->st_value;
800 if (d < distance) {
801 distance = d;
802 near = sym;
803 }
793 } 804 }
794 return NULL; 805 /* We need a close match */
806 if (distance < 20)
807 return near;
808 else
809 return NULL;
795} 810}
796 811
797static inline int is_arm_mapping_symbol(const char *str) 812static 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 @@
17#define Elf_Shdr Elf32_Shdr 17#define Elf_Shdr Elf32_Shdr
18#define Elf_Sym Elf32_Sym 18#define Elf_Sym Elf32_Sym
19#define Elf_Addr Elf32_Addr 19#define Elf_Addr Elf32_Addr
20#define Elf_Sword Elf64_Sword
20#define Elf_Section Elf32_Half 21#define Elf_Section Elf32_Half
21#define ELF_ST_BIND ELF32_ST_BIND 22#define ELF_ST_BIND ELF32_ST_BIND
22#define ELF_ST_TYPE ELF32_ST_TYPE 23#define ELF_ST_TYPE ELF32_ST_TYPE
@@ -31,6 +32,7 @@
31#define Elf_Shdr Elf64_Shdr 32#define Elf_Shdr Elf64_Shdr
32#define Elf_Sym Elf64_Sym 33#define Elf_Sym Elf64_Sym
33#define Elf_Addr Elf64_Addr 34#define Elf_Addr Elf64_Addr
35#define Elf_Sword Elf64_Sxword
34#define Elf_Section Elf64_Half 36#define Elf_Section Elf64_Half
35#define ELF_ST_BIND ELF64_ST_BIND 37#define ELF_ST_BIND ELF64_ST_BIND
36#define ELF_ST_TYPE ELF64_ST_TYPE 38#define ELF_ST_TYPE ELF64_ST_TYPE