diff options
author | Sam Ravnborg <sam@mars.ravnborg.org> | 2006-03-05 06:02:46 -0500 |
---|---|---|
committer | Sam Ravnborg <sam@mars.ravnborg.org> | 2006-03-05 06:02:46 -0500 |
commit | 43c74d179596ba1f8eceb8c6a5c7e11afe233662 (patch) | |
tree | 09f7fcee82d8a464706b77e171956cc23661baf4 /scripts/mod | |
parent | e835a39c1c1f023ef443f735b0e98b08660ae0e4 (diff) |
kbuild: in the section mismatch check try harder to find symbols
When searching for symbols the only check performed was if
offset equals st_value. Adding an additional check to see if st_name
points t a valid name made us sort out a few more false positives and
let us report more correct names in warnings.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts/mod')
-rw-r--r-- | scripts/mod/modpost.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 3b570b18c2e4..3648683a26c5 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -558,7 +558,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf_Addr addr, | |||
558 | } | 558 | } |
559 | 559 | ||
560 | /* | 560 | /* |
561 | * Find symbols before or equal addr and after addr - in the section sec | 561 | * Find symbols before or equal addr and after addr - in the section sec. |
562 | * If we find two symbols with equal offset prefer one with a valid name. | ||
563 | * The ELF format may have a better way to detect what type of symbol | ||
564 | * it is, but this works for now. | ||
562 | **/ | 565 | **/ |
563 | static void find_symbols_between(struct elf_info *elf, Elf_Addr addr, | 566 | static void find_symbols_between(struct elf_info *elf, Elf_Addr addr, |
564 | const char *sec, | 567 | const char *sec, |
@@ -587,6 +590,12 @@ static void find_symbols_between(struct elf_info *elf, Elf_Addr addr, | |||
587 | beforediff = addr - sym->st_value; | 590 | beforediff = addr - sym->st_value; |
588 | *before = sym; | 591 | *before = sym; |
589 | } | 592 | } |
593 | else if ((addr - sym->st_value) == beforediff) { | ||
594 | /* equal offset, valid name? */ | ||
595 | const char *name = elf->strtab + sym->st_name; | ||
596 | if (name && strlen(name)) | ||
597 | *before = sym; | ||
598 | } | ||
590 | } | 599 | } |
591 | else | 600 | else |
592 | { | 601 | { |
@@ -594,6 +603,12 @@ static void find_symbols_between(struct elf_info *elf, Elf_Addr addr, | |||
594 | afterdiff = sym->st_value - addr; | 603 | afterdiff = sym->st_value - addr; |
595 | *after = sym; | 604 | *after = sym; |
596 | } | 605 | } |
606 | else if ((sym->st_value - addr) == afterdiff) { | ||
607 | /* equal offset, valid name? */ | ||
608 | const char *name = elf->strtab + sym->st_name; | ||
609 | if (name && strlen(name)) | ||
610 | *after = sym; | ||
611 | } | ||
597 | } | 612 | } |
598 | } | 613 | } |
599 | } | 614 | } |