Resolve undefined weak references to a value of 0. This solves the

"__deregister_frame_info" problem that was seen when combining a
program linked using the old gcc with shared libraries that were
built using egcs.
This commit is contained in:
John Polstra 1999-04-05 02:36:40 +00:00
parent 9854208acb
commit 5e4636f2b0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=45320

View File

@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: rtld.c,v 1.15 1999/03/24 23:47:29 nate Exp $
* $Id: rtld.c,v 1.16 1999/04/04 06:01:09 peter Exp $
*/
/*
@ -133,10 +133,13 @@ static Obj_Entry **obj_tail; /* Link field of last object in list */
static Obj_Entry *obj_main; /* The main program shared object */
static Obj_Entry obj_rtld; /* The dynamic linker shared object */
static Elf_Sym sym_zero; /* For resolving undefined weak refs. */
#define GDB_STATE(s) r_debug.r_state = s; r_debug_state();
extern Elf_Dyn _DYNAMIC;
/*
* These are the functions the dynamic linker exports to application
* programs. They are the only symbols the dynamic linker is willing
@ -272,6 +275,10 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
obj_tail = &obj_main->next;
obj_main->refcount++;
/* Initialize a fake symbol for resolving undefined weak references. */
sym_zero.st_info = ELF_ST_INFO(STB_GLOBAL, STT_NOTYPE);
sym_zero.st_shndx = SHN_ABS;
dbg("loading LD_PRELOAD libraries");
if (load_preload_objects() == -1)
die();
@ -759,6 +766,11 @@ find_symdef(unsigned long symnum, const Obj_Entry *refobj,
return weakdef;
}
if (ELF_ST_BIND(ref->st_info) == STB_WEAK) {
*defobj_out = obj_main;
return &sym_zero;
}
_rtld_error("%s: Undefined symbol \"%s\"", refobj->path, name);
return NULL;
}