diff options
author | Filippo Arcidiacono <filippo.arcidiacono@st.com> | 2010-07-30 09:17:58 +0200 |
---|---|---|
committer | Carmelo Amoroso <carmelo.amoroso@st.com> | 2010-09-17 16:11:27 +0200 |
commit | 4136ca46e391faf1a6ce58b9a1a709b248213fb4 (patch) | |
tree | 2c36d609ff2110027d637f68db8c4af47bd38333 /ldso/ldso/dl-debug.c | |
parent | 94cc6edb78a12655c0602a246fa1cbdc8c6d0ad9 (diff) |
ldso: Add support for LD_WARN and LD_TRACE_PRELINKING
Added support for the following tracing capabilities:
- LD_WARN to warn about undefined symbols during the lookup stage.
- LD_TRACE_PRELINKING to trace the needed libraries of the object
that we are prelinking.
Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com>
Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Diffstat (limited to 'ldso/ldso/dl-debug.c')
-rw-r--r-- | ldso/ldso/dl-debug.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/ldso/ldso/dl-debug.c b/ldso/ldso/dl-debug.c index 7ce8bfbce..47b32316e 100644 --- a/ldso/ldso/dl-debug.c +++ b/ldso/ldso/dl-debug.c @@ -104,3 +104,60 @@ static void debug_reloc(ElfW(Sym) *symtab, char *strtab, ELF_RELOC *rpnt) #define debug_reloc(symtab, strtab, rpnt) #endif /* __SUPPORT_LD_DEBUG__ */ + +#ifdef __LDSO_PRELINK_SUPPORT__ +static void +internal_function +_dl_debug_lookup (const char *undef_name, struct elf_resolve *undef_map, + const ElfW(Sym) *ref, struct sym_val *value, int type_class) +{ +#ifdef SHARED + unsigned long symbol_addr; + + if (_dl_trace_prelink) + { + int conflict = 0; + struct elf_resolve *tls_tpnt = NULL; + struct sym_val val = { NULL, NULL }; + + if ((_dl_trace_prelink_map == NULL + || _dl_trace_prelink_map == _dl_loaded_modules) + && undef_map != _dl_loaded_modules) + { + symbol_addr = (unsigned long) + _dl_find_hash(undef_name, &undef_map->symbol_scope, + undef_map, &val, type_class, &tls_tpnt); + + if (val.s != value->s || val.m != value->m) + conflict = 1; + } + + if (value->s + && (__builtin_expect (ELF_ST_TYPE(value->s->st_info) + == STT_TLS, 0))) + type_class = 4; + + if (conflict + || _dl_trace_prelink_map == undef_map + || _dl_trace_prelink_map == NULL + || type_class == 4) + { + _dl_dprintf (1, "%s %x %x -> %x %x ", + conflict ? "conflict" : "lookup", + (size_t) undef_map->mapaddr, + (size_t) (((ElfW(Addr)) ref) - undef_map->mapaddr), + (size_t) (value->m ? value->m->mapaddr : 0), + (size_t) (value->s ? value->s->st_value : 0)); + if (conflict) + _dl_dprintf (1, "x %x %x ", + (size_t) (val.m ? val.m->mapaddr : 0), + (size_t) (val.s ? val.s->st_value : 0)); + _dl_dprintf (1, "/%x %s\n", type_class, undef_name); + } +} +#endif +} + +#else +#define _dl_debug_lookup(undef_name, undef_map, ref, value, type_class) +#endif |