Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F152836236
D47206.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D47206.id.diff
View Options
diff --git a/lib/libkldelf/ef.c b/lib/libkldelf/ef.c
--- a/lib/libkldelf/ef.c
+++ b/lib/libkldelf/ef.c
@@ -81,7 +81,7 @@
static int ef_lookup_set(elf_file_t ef, const char *name,
GElf_Addr *startp, GElf_Addr *stopp, long *countp);
static int ef_lookup_symbol(elf_file_t ef, const char *name,
- GElf_Sym **sym);
+ GElf_Sym **sym, bool see_local);
static struct elf_file_ops ef_file_ops = {
.close = ef_close,
@@ -126,7 +126,7 @@
* next two functions copied from link_elf.c
*/
static int
-ef_lookup_symbol(elf_file_t ef, const char *name, GElf_Sym **sym)
+ef_lookup_symbol(elf_file_t ef, const char *name, GElf_Sym **sym, bool see_local)
{
unsigned long hash, symnum;
GElf_Sym *symp;
@@ -156,8 +156,11 @@
if (symp->st_shndx != SHN_UNDEF ||
(symp->st_value != 0 &&
GELF_ST_TYPE(symp->st_info) == STT_FUNC)) {
- *sym = symp;
- return (0);
+ if (see_local ||
+ GELF_ST_BIND(symp->st_info) != STB_LOCAL) {
+ *sym = symp;
+ return (0);
+ }
} else
return (ENOENT);
}
@@ -183,14 +186,14 @@
/* get address of first entry */
snprintf(setsym, len, "%s%s", "__start_set_", name);
- error = ef_lookup_symbol(ef, setsym, &sym);
+ error = ef_lookup_symbol(ef, setsym, &sym, true);
if (error != 0)
goto out;
*startp = sym->st_value;
/* get address of last entry */
snprintf(setsym, len, "%s%s", "__stop_set_", name);
- error = ef_lookup_symbol(ef, setsym, &sym);
+ error = ef_lookup_symbol(ef, setsym, &sym, true);
if (error != 0)
goto out;
*stopp = sym->st_value;
diff --git a/lib/libkldelf/ef_obj.c b/lib/libkldelf/ef_obj.c
--- a/lib/libkldelf/ef_obj.c
+++ b/lib/libkldelf/ef_obj.c
@@ -101,7 +101,7 @@
static int ef_obj_lookup_set(elf_file_t ef, const char *name,
GElf_Addr *startp, GElf_Addr *stopp, long *countp);
static int ef_obj_lookup_symbol(elf_file_t ef, const char *name,
- GElf_Sym **sym);
+ GElf_Sym **sym, bool see_local);
static struct elf_file_ops ef_obj_file_ops = {
.close = ef_obj_close,
@@ -129,7 +129,8 @@
}
static int
-ef_obj_lookup_symbol(elf_file_t ef, const char *name, GElf_Sym **sym)
+ef_obj_lookup_symbol(elf_file_t ef, const char *name, GElf_Sym **sym,
+ bool see_local)
{
GElf_Sym *symp;
const char *strp;
@@ -138,8 +139,11 @@
for (i = 0, symp = ef->ddbsymtab; i < ef->ddbsymcnt; i++, symp++) {
strp = ef->ddbstrtab + symp->st_name;
if (symp->st_shndx != SHN_UNDEF && strcmp(name, strp) == 0) {
- *sym = symp;
- return (0);
+ if (see_local ||
+ GELF_ST_BIND(symp->st_info) != STB_LOCAL) {
+ *sym = symp;
+ return (0);
+ }
}
}
return (ENOENT);
diff --git a/lib/libkldelf/elf.c b/lib/libkldelf/elf.c
--- a/lib/libkldelf/elf.c
+++ b/lib/libkldelf/elf.c
@@ -688,7 +688,8 @@
}
int
-elf_lookup_symbol(struct elf_file *efile, const char *name, GElf_Sym **sym)
+elf_lookup_symbol(struct elf_file *efile, const char *name, GElf_Sym **sym,
+ bool see_local)
{
- return (EF_LOOKUP_SYMBOL(efile, name, sym));
+ return (EF_LOOKUP_SYMBOL(efile, name, sym, see_local));
}
diff --git a/lib/libkldelf/kldelf.h b/lib/libkldelf/kldelf.h
--- a/lib/libkldelf/kldelf.h
+++ b/lib/libkldelf/kldelf.h
@@ -48,8 +48,8 @@
(ef)->ef_ops->symaddr((ef)->ef_ef, symidx)
#define EF_LOOKUP_SET(ef, name, startp, stopp, countp) \
(ef)->ef_ops->lookup_set((ef)->ef_ef, name, startp, stopp, countp)
-#define EF_LOOKUP_SYMBOL(ef, name, sym) \
- (ef)->ef_ops->lookup_symbol((ef)->ef_ef, name, sym)
+#define EF_LOOKUP_SYMBOL(ef, name, sym, see_local) \
+ (ef)->ef_ops->lookup_symbol((ef)->ef_ef, name, sym, see_local)
/* XXX, should have a different name. */
typedef struct ef_file *elf_file_t;
@@ -69,7 +69,8 @@
GElf_Addr (*symaddr)(elf_file_t ef, GElf_Size symidx);
int (*lookup_set)(elf_file_t ef, const char *name, GElf_Addr *startp,
GElf_Addr *stopp, long *countp);
- int (*lookup_symbol)(elf_file_t ef, const char *name, GElf_Sym **sym);
+ int (*lookup_symbol)(elf_file_t ef, const char *name, GElf_Sym **sym,
+ bool see_local);
};
typedef int (elf_reloc_t)(struct elf_file *ef, const void *reldata,
@@ -317,11 +318,9 @@
* Find the symbol with the specified symbol name 'name' within the given
* 'efile'. 0 is returned when such a symbol is found, otherwise ENOENT is
* returned.
- *
- * XXX: This only return the first symbol being found when traversing symtab.
*/
int elf_lookup_symbol(struct elf_file *efile, const char *name,
- GElf_Sym **sym);
+ GElf_Sym **sym, bool see_local);
__END_DECLS
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 18, 10:22 AM (20 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31713426
Default Alt Text
D47206.id.diff (4 KB)
Attached To
Mode
D47206: libkldelf: add see_local parameter to elf_lookup_symbol
Attached
Detach File
Event Timeline
Log In to Comment