View | Details | Raw Unified | Return to bug 186435 | Differences between
and this patch

Collapse All | Expand All

(-)libexec/rtld-elf/Symbol.map (+3 lines)
Lines 15-20 Link Here
15
    dlinfo;
15
    dlinfo;
16
    dl_iterate_phdr;
16
    dl_iterate_phdr;
17
    r_debug_state;
17
    r_debug_state;
18
    r_debug_add;
19
    r_debug_delete;
20
    r_debug_iterate;
18
    __tls_get_addr;
21
    __tls_get_addr;
19
};
22
};
20
23
(-)libexec/rtld-elf/rtld.c (-14 / +82 lines)
Lines 96-103 Link Here
96
static void init_rtld(caddr_t, Elf_Auxinfo **);
96
static void init_rtld(caddr_t, Elf_Auxinfo **);
97
static void initlist_add_neededs(Needed_Entry *, Objlist *);
97
static void initlist_add_neededs(Needed_Entry *, Objlist *);
98
static void initlist_add_objects(Obj_Entry *, Obj_Entry *, Objlist *);
98
static void initlist_add_objects(Obj_Entry *, Obj_Entry *, Objlist *);
99
static void linkmap_add(Obj_Entry *);
99
static void linkmap_add_obj(Obj_Entry *);
100
static void linkmap_delete(Obj_Entry *);
100
static void linkmap_add_map(struct link_map *);
101
static void linkmap_delete_obj(Obj_Entry *);
102
static void linkmap_delete_map(struct link_map *);
101
static void load_filtees(Obj_Entry *, int flags, RtldLockState *);
103
static void load_filtees(Obj_Entry *, int flags, RtldLockState *);
102
static void unload_filtees(Obj_Entry *);
104
static void unload_filtees(Obj_Entry *);
103
static int load_needed_objects(Obj_Entry *, int);
105
static int load_needed_objects(Obj_Entry *, int);
Lines 159-164 Link Here
159
    const unsigned long);
161
    const unsigned long);
160
162
161
void r_debug_state(struct r_debug *, struct link_map *) __noinline __exported;
163
void r_debug_state(struct r_debug *, struct link_map *) __noinline __exported;
164
void r_debug_add(struct link_map *m) __noinline __exported;
165
void r_debug_delete(struct link_map *m) __noinline __exported;
166
int r_debug_iterate(int wr, int (*callback)(struct link_map *, void *), void *param) __noinline __exported;
162
void _r_debug_postinit(struct link_map *) __noinline __exported;
167
void _r_debug_postinit(struct link_map *) __noinline __exported;
163
168
164
/*
169
/*
Lines 533-540 Link Here
533
	obj_main->path, obj_main->valid_hash_sysv, obj_main->valid_hash_gnu,
538
	obj_main->path, obj_main->valid_hash_sysv, obj_main->valid_hash_gnu,
534
	obj_main->dynsymcount);
539
	obj_main->dynsymcount);
535
540
536
    linkmap_add(obj_main);
541
    linkmap_add_obj(obj_main);
537
    linkmap_add(&obj_rtld);
542
    linkmap_add_obj(&obj_rtld);
538
543
539
    /* Link the main program into the list of objects. */
544
    /* Link the main program into the list of objects. */
540
    TAILQ_INSERT_HEAD(&obj_list, obj_main, next);
545
    TAILQ_INSERT_HEAD(&obj_list, obj_main, next);
Lines 2282-2288 Link Here
2282
    TAILQ_INSERT_TAIL(&obj_list, obj, next);
2287
    TAILQ_INSERT_TAIL(&obj_list, obj, next);
2283
    obj_count++;
2288
    obj_count++;
2284
    obj_loads++;
2289
    obj_loads++;
2285
    linkmap_add(obj);	/* for GDB & dlinfo() */
2290
    linkmap_add_obj(obj);	/* for GDB & dlinfo() */
2286
    max_stack_flags |= obj->stack_flags;
2291
    max_stack_flags |= obj->stack_flags;
2287
2292
2288
    dbg("  %p .. %p: %s", obj->mapbase,
2293
    dbg("  %p .. %p: %s", obj->mapbase,
Lines 3622-3640 Link Here
3622
}
3627
}
3623
3628
3624
static void
3629
static void
3625
linkmap_add(Obj_Entry *obj)
3630
linkmap_add_obj(Obj_Entry *obj)
3626
{
3631
{
3627
    struct link_map *l = &obj->linkmap;
3632
    struct link_map *l = &obj->linkmap;
3628
    struct link_map *prev;
3629
3633
3630
    obj->linkmap.l_name = obj->path;
3634
    l->l_name = obj->path;
3631
    obj->linkmap.l_addr = obj->mapbase;
3635
    l->l_addr = obj->mapbase;
3632
    obj->linkmap.l_ld = obj->dynamic;
3636
    l->l_ld = obj->dynamic;
3633
#ifdef __mips__
3637
#ifdef __mips__
3634
    /* GDB needs load offset on MIPS to use the symbols */
3638
    /* GDB needs load offset on MIPS to use the symbols */
3635
    obj->linkmap.l_offs = obj->relocbase;
3639
    l->l_offs = obj->relocbase;
3636
#endif
3640
#endif
3637
3641
3642
    linkmap_add_map(l);
3643
}
3644
3645
static void
3646
linkmap_add_map(struct link_map *l)
3647
{
3648
    struct link_map *prev;
3649
3638
    if (r_debug.r_map == NULL) {
3650
    if (r_debug.r_map == NULL) {
3639
	r_debug.r_map = l;
3651
	r_debug.r_map = l;
3640
	return;
3652
	return;
Lines 3658-3667 Link Here
3658
}
3670
}
3659
3671
3660
static void
3672
static void
3661
linkmap_delete(Obj_Entry *obj)
3673
linkmap_delete_obj(Obj_Entry *obj)
3662
{
3674
{
3663
    struct link_map *l = &obj->linkmap;
3675
    linkmap_delete_map(&obj->linkmap);
3676
}
3664
3677
3678
static void
3679
linkmap_delete_map(struct link_map *l)
3680
{
3665
    if (l->l_prev == NULL) {
3681
    if (l->l_prev == NULL) {
3666
	if ((r_debug.r_map = l->l_next) != NULL)
3682
	if ((r_debug.r_map = l->l_next) != NULL)
3667
	    l->l_next->l_prev = NULL;
3683
	    l->l_next->l_prev = NULL;
Lines 4300-4306 Link Here
4300
		dbg("unloading \"%s\"", obj->path);
4316
		dbg("unloading \"%s\"", obj->path);
4301
		unload_filtees(root);
4317
		unload_filtees(root);
4302
		munmap(obj->mapbase, obj->mapsize);
4318
		munmap(obj->mapbase, obj->mapsize);
4303
		linkmap_delete(obj);
4319
		linkmap_delete_obj(obj);
4304
		TAILQ_REMOVE(&obj_list, obj, next);
4320
		TAILQ_REMOVE(&obj_list, obj, next);
4305
		obj_count--;
4321
		obj_count--;
4306
		obj_free(obj);
4322
		obj_free(obj);
Lines 5039-5044 Link Here
5039
int _thread_autoinit_dummy_decl = 1;
5055
int _thread_autoinit_dummy_decl = 1;
5040
5056
5041
/*
5057
/*
5058
 * Support for an alternative loader
5059
 */
5060
5061
void
5062
r_debug_add(struct link_map *m)
5063
{
5064
	RtldLockState lockstate;
5065
	wlock_acquire(rtld_bind_lock, &lockstate);
5066
	GDB_STATE(RT_ADD,NULL);
5067
	linkmap_add_map(m);
5068
	GDB_STATE(RT_CONSISTENT, m)
5069
	lock_release(rtld_bind_lock, &lockstate);
5070
}
5071
5072
void
5073
r_debug_delete(struct link_map *m)
5074
{
5075
	RtldLockState lockstate;
5076
	wlock_acquire(rtld_bind_lock, &lockstate);
5077
	GDB_STATE(RT_DELETE, m);
5078
	linkmap_delete_map(m);
5079
	GDB_STATE(RT_CONSISTENT, NULL);
5080
	lock_release(rtld_bind_lock, &lockstate);
5081
}
5082
5083
int
5084
r_debug_iterate(int wr, int (*callback)(struct link_map *, void *), void *param)
5085
{
5086
	struct link_map *m;
5087
	int error = 0;
5088
	RtldLockState lockstate;
5089
5090
	if (wr) {
5091
		wlock_acquire(rtld_bind_lock, &lockstate);
5092
	} else {
5093
		rlock_acquire(rtld_bind_lock, &lockstate);
5094
	}
5095
5096
	/*
5097
	 * Iterate while callback returns zero
5098
	 */
5099
	for (m = r_debug.r_map;
5100
	     m != NULL && (error = callback(m, param)) == 0;
5101
	     m = m->l_next)
5102
	     ;
5103
5104
	lock_release(rtld_bind_lock, &lockstate);
5105
5106
	return error;
5107
}
5108
5109
/*
5042
 * No unresolved symbols for rtld.
5110
 * No unresolved symbols for rtld.
5043
 */
5111
 */
5044
void
5112
void

Return to bug 186435