summaryrefslogtreecommitdiffstats
path: root/sys/kern/link_elf.c
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2002-08-24 05:01:33 +0000
committermarcel <marcel@FreeBSD.org>2002-08-24 05:01:33 +0000
commitc558abdba79c9fbb9dbb77e9b5d0f6c3f97f7888 (patch)
treecffd74fad644797530826418a675c0c02e376ca6 /sys/kern/link_elf.c
parenta37394066bdd8b2619163284b14eb9cceca8d096 (diff)
downloadFreeBSD-src-c558abdba79c9fbb9dbb77e9b5d0f6c3f97f7888.zip
FreeBSD-src-c558abdba79c9fbb9dbb77e9b5d0f6c3f97f7888.tar.gz
Work around a GCC optimization bug on ia64: In link_elf_symbol_values(),
a pointer to a symbol is given and we have to find the containing symbol table. We do this by bounds checking. For some strange reason (ie I haven't found the root cause) the first test succeeded for said symbol, implying that the symbol came from the .dynsym table. In reality however the symbol actually resided in the .symtab table. Needless to say that all that was returned was junk. The upper bounds check was: (symptr - baseptr) < symtab_size This has been rewritten to: symptr < (baseptr + symtab_size) As a side-effect, slightly more optimal (and still correct :-) code can be generated on ia64.
Diffstat (limited to 'sys/kern/link_elf.c')
-rw-r--r--sys/kern/link_elf.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c
index 0d48c20..7459150 100644
--- a/sys/kern/link_elf.c
+++ b/sys/kern/link_elf.c
@@ -1051,7 +1051,7 @@ link_elf_symbol_values(linker_file_t lf, c_linker_sym_t sym, linker_symval_t* sy
elf_file_t ef = (elf_file_t) lf;
const Elf_Sym* es = (const Elf_Sym*) sym;
- if (es >= ef->symtab && ((es - ef->symtab) < ef->nchains)) {
+ if (es >= ef->symtab && es < (ef->symtab + ef->nchains)) {
symval->name = ef->strtab + es->st_name;
symval->value = (caddr_t) ef->address + es->st_value;
symval->size = es->st_size;
@@ -1059,7 +1059,7 @@ link_elf_symbol_values(linker_file_t lf, c_linker_sym_t sym, linker_symval_t* sy
}
if (ef->symtab == ef->ddbsymtab)
return ENOENT;
- if (es >= ef->ddbsymtab && ((es - ef->ddbsymtab) < ef->ddbsymcnt)) {
+ if (es >= ef->ddbsymtab && es < (ef->ddbsymtab + ef->ddbsymcnt)) {
symval->name = ef->ddbstrtab + es->st_name;
symval->value = (caddr_t) ef->address + es->st_value;
symval->size = es->st_size;
OpenPOWER on IntegriCloud