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 / +79 lines)
Lines 100-107 Link Here
100
static void init_rtld(caddr_t, Elf_Auxinfo **);
100
static void init_rtld(caddr_t, Elf_Auxinfo **);
101
static void initlist_add_neededs(Needed_Entry *, Objlist *);
101
static void initlist_add_neededs(Needed_Entry *, Objlist *);
102
static void initlist_add_objects(Obj_Entry *, Obj_Entry **, Objlist *);
102
static void initlist_add_objects(Obj_Entry *, Obj_Entry **, Objlist *);
103
static void linkmap_add(Obj_Entry *);
103
static void linkmap_add_obj(Obj_Entry *);
104
static void linkmap_delete(Obj_Entry *);
104
static void linkmap_add_map(struct link_map *);
105
static void linkmap_delete_obj(Obj_Entry *);
106
static void linkmap_delete_map(struct link_map *);
105
static void load_filtees(Obj_Entry *, int flags, RtldLockState *);
107
static void load_filtees(Obj_Entry *, int flags, RtldLockState *);
106
static void unload_filtees(Obj_Entry *);
108
static void unload_filtees(Obj_Entry *);
107
static int load_needed_objects(Obj_Entry *, int);
109
static int load_needed_objects(Obj_Entry *, int);
Lines 513-520 Link Here
513
	obj_main->path, obj_main->valid_hash_sysv, obj_main->valid_hash_gnu,
515
	obj_main->path, obj_main->valid_hash_sysv, obj_main->valid_hash_gnu,
514
	obj_main->dynsymcount);
516
	obj_main->dynsymcount);
515
517
516
    linkmap_add(obj_main);
518
    linkmap_add_obj(obj_main);
517
    linkmap_add(&obj_rtld);
519
    linkmap_add_obj(&obj_rtld);
518
520
519
    /* Link the main program into the list of objects. */
521
    /* Link the main program into the list of objects. */
520
    *obj_tail = obj_main;
522
    *obj_tail = obj_main;
Lines 2155-2161 Link Here
2155
    obj_tail = &obj->next;
2157
    obj_tail = &obj->next;
2156
    obj_count++;
2158
    obj_count++;
2157
    obj_loads++;
2159
    obj_loads++;
2158
    linkmap_add(obj);	/* for GDB & dlinfo() */
2160
    linkmap_add_obj(obj);	/* for GDB & dlinfo() */
2159
    max_stack_flags |= obj->stack_flags;
2161
    max_stack_flags |= obj->stack_flags;
2160
2162
2161
    dbg("  %p .. %p: %s", obj->mapbase,
2163
    dbg("  %p .. %p: %s", obj->mapbase,
Lines 3428-3446 Link Here
3428
}
3430
}
3429
3431
3430
static void
3432
static void
3431
linkmap_add(Obj_Entry *obj)
3433
linkmap_add_obj(Obj_Entry *obj)
3432
{
3434
{
3433
    struct link_map *l = &obj->linkmap;
3435
    struct link_map *l = &obj->linkmap;
3434
    struct link_map *prev;
3435
3436
3436
    obj->linkmap.l_name = obj->path;
3437
    l->l_name = obj->path;
3437
    obj->linkmap.l_addr = obj->mapbase;
3438
    l->l_addr = obj->mapbase;
3438
    obj->linkmap.l_ld = obj->dynamic;
3439
    l->l_ld = obj->dynamic;
3439
#ifdef __mips__
3440
#ifdef __mips__
3440
    /* GDB needs load offset on MIPS to use the symbols */
3441
    /* GDB needs load offset on MIPS to use the symbols */
3441
    obj->linkmap.l_offs = obj->relocbase;
3442
    l->l_offs = obj->relocbase;
3442
#endif
3443
#endif
3443
3444
3445
    linkmap_add_map(l);
3446
}
3447
3448
static void
3449
linkmap_add_map(struct link_map *l)
3450
{
3451
    struct link_map *prev;
3452
3444
    if (r_debug.r_map == NULL) {
3453
    if (r_debug.r_map == NULL) {
3445
	r_debug.r_map = l;
3454
	r_debug.r_map = l;
3446
	return;
3455
	return;
Lines 3464-3473 Link Here
3464
}
3473
}
3465
3474
3466
static void
3475
static void
3467
linkmap_delete(Obj_Entry *obj)
3476
linkmap_delete_obj(Obj_Entry *obj)
3468
{
3477
{
3469
    struct link_map *l = &obj->linkmap;
3478
    linkmap_delete_map(&obj->linkmap);
3479
}
3470
3480
3481
static void
3482
linkmap_delete_map(struct link_map *l)
3483
{
3471
    if (l->l_prev == NULL) {
3484
    if (l->l_prev == NULL) {
3472
	if ((r_debug.r_map = l->l_next) != NULL)
3485
	if ((r_debug.r_map = l->l_next) != NULL)
3473
	    l->l_next->l_prev = NULL;
3486
	    l->l_next->l_prev = NULL;
Lines 4092-4098 Link Here
4092
	    dbg("unloading \"%s\"", obj->path);
4105
	    dbg("unloading \"%s\"", obj->path);
4093
	    unload_filtees(root);
4106
	    unload_filtees(root);
4094
	    munmap(obj->mapbase, obj->mapsize);
4107
	    munmap(obj->mapbase, obj->mapsize);
4095
	    linkmap_delete(obj);
4108
	    linkmap_delete_obj(obj);
4096
	    *linkp = obj->next;
4109
	    *linkp = obj->next;
4097
	    obj_count--;
4110
	    obj_count--;
4098
	    obj_free(obj);
4111
	    obj_free(obj);
Lines 4809-4814 Link Here
4809
int _thread_autoinit_dummy_decl = 1;
4822
int _thread_autoinit_dummy_decl = 1;
4810
4823
4811
/*
4824
/*
4825
 * Support for an alternative loader
4826
 */
4827
4828
void
4829
r_debug_add(struct link_map *m)
4830
{
4831
	RtldLockState lockstate;
4832
	wlock_acquire(rtld_bind_lock, &lockstate);
4833
	GDB_STATE(RT_ADD,NULL);
4834
	linkmap_add_map(m);
4835
	GDB_STATE(RT_CONSISTENT, m)
4836
	lock_release(rtld_bind_lock, &lockstate);
4837
}
4838
4839
void
4840
r_debug_delete(struct link_map *m)
4841
{
4842
	RtldLockState lockstate;
4843
	wlock_acquire(rtld_bind_lock, &lockstate);
4844
	GDB_STATE(RT_DELETE, m);
4845
	linkmap_delete_map(m);
4846
	GDB_STATE(RT_CONSISTENT, NULL);
4847
	lock_release(rtld_bind_lock, &lockstate);
4848
}
4849
4850
int
4851
r_debug_iterate(int wr, int (*callback)(struct link_map *, void *), void *param)
4852
{
4853
	struct link_map *m;
4854
	int error = 0;
4855
	RtldLockState lockstate;
4856
4857
	if (wr) {
4858
		wlock_acquire(rtld_bind_lock, &lockstate);
4859
	} else {
4860
		rlock_acquire(rtld_bind_lock, &lockstate);
4861
	}
4862
4863
	/*
4864
	 * Iterate while callback returns zero
4865
	 */
4866
	for (m = r_debug.r_map;
4867
	     m != NULL && (error = callback(m, param)) == 0;
4868
	     m = m->l_next)
4869
	     ;
4870
4871
	lock_release(rtld_bind_lock, &lockstate);
4872
4873
	return error;
4874
}
4875
4876
/*
4812
 * No unresolved symbols for rtld.
4877
 * No unresolved symbols for rtld.
4813
 */
4878
 */
4814
void
4879
void
(-)sys/sys/link_elf.h (+3 lines)
Lines 94-99 Link Here
94
extern int dl_iterate_phdr(__dl_iterate_hdr_callback, void *);
94
extern int dl_iterate_phdr(__dl_iterate_hdr_callback, void *);
95
int _rtld_addr_phdr(const void *, struct dl_phdr_info *);
95
int _rtld_addr_phdr(const void *, struct dl_phdr_info *);
96
int _rtld_get_stack_prot(void);
96
int _rtld_get_stack_prot(void);
97
void r_debug_add(struct link_map *);
98
void r_debug_delete(struct link_map *);
99
int r_debug_iterate(int, int (*callback)(struct link_map *, void *), void *);
97
100
98
__END_DECLS
101
__END_DECLS
99
102

Return to bug 186435