Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 Apr 2004 19:12:19 -0800 (PST)
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 50161 for review
Message-ID:  <200404020312.i323CJXR037048@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=50161

Change 50161 by peter@peter_hammer on 2004/04/01 19:12:15

	checkpoint. beginnings of actually implementing real
	elf object linkage.  oops.  ld -shared made things easy
	for us and a bunch of relocation modes are missing.

Affected files ...

.. //depot/projects/hammer/sys/kern/link_elf_obj.c#20 edit

Differences ...

==== //depot/projects/hammer/sys/kern/link_elf_obj.c#20 (text+ko) ====

@@ -881,7 +881,7 @@
 	elf_file_t ef = (elf_file_t)lf;
 	const Elf_Sym *sym;
 	const char *symbol;
-	int error;
+	Elf_addr ret;
 
 printf("elf_obj_lookup: symidx %ld (< %ld?)\n", symidx, ef->ddbsymcnt);
 
@@ -892,36 +892,35 @@
 	sym = ef->ddbsymtab + symidx;
 printf("sym: %p (base %p)\n", sym, ef->ddbsymtab);
 
-	/*
-	 * Don't do a full lookup when the symbol is local. It may even
-	 * fail because it may not be found through the hash table.
-	 */
-	if (ELF_ST_BIND(sym->st_info) == STB_LOCAL) {
-		/* Force lookup failure when we have an insanity. */
-		if (sym->st_shndx == SHN_UNDEF)
-			return (0);
-		return ((Elf_Addr)ef->address + sym->st_value);
+#if 0
+	/* Theoretically we can avoid a lookup for some locals */
+	switch (ELF64_ST_BIND(sym->st_info)) {
+	case STB_LOCAL:
+	case STB_GLOBAL:
+	case STB_WEAK:
 	}
-
-	/*
-	 * XXX we can avoid doing a hash table based lookup for global
-	 * symbols as well. This however is not always valid, so we'll
-	 * just do it the hard way for now. Performance tweaks can
-	 * always be added.
-	 */
-
-	symbol = ef->ddbstrtab + sym->st_name;
+#endif
+	switch (ELF64_ST_TYPE(sym->st_info)) {
+	case STT_OBJECT:
+	case STT_FUNC:
+		/* Relative to Data or Function name */
+		symbol = ef->ddbstrtab + sym->st_name;
 printf("strtab %p, st_name %d\n", ef->ddbstrtab, sym->st_name);
 printf("symbol = %p (%s)\n", symbol, symbol);
 
-	/* Force a lookup failure if the symbol name is bogus. */
-	if (*symbol == 0)
-		return (0);
+		/* Force a lookup failure if the symbol name is bogus. */
+		if (*symbol == 0)
+			return (0);
 
 printf("calling linker_file_lookup_symbol, deps %d\n", deps);
-	error = ((Elf_Addr)linker_file_lookup_symbol(lf, symbol, deps));
-printf("linker_file_lookup_symbol returns %d\n", error);
-	return error;
+		ret = ((Elf_Addr)linker_file_lookup_symbol(lf, symbol, deps));
+printf("linker_file_lookup_symbol returns %p\n", ret);
+		return ret;
+
+	case STT_SECTION:
+		/* Relative to section number */
+		XXX
+	}
 }
 
 static void



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200404020312.i323CJXR037048>