summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authorjdp <jdp@FreeBSD.org>1998-09-02 02:00:20 +0000
committerjdp <jdp@FreeBSD.org>1998-09-02 02:00:20 +0000
commit6bd2d046080d19e9b93daec5325c4480fcde0b55 (patch)
treeb15d70f6ed899af58a19c1666fa13ebc12069eaa /libexec
parent387abc60ff4c3740948b3add9bcec42c70114f2f (diff)
downloadFreeBSD-src-6bd2d046080d19e9b93daec5325c4480fcde0b55.zip
FreeBSD-src-6bd2d046080d19e9b93daec5325c4480fcde0b55.tar.gz
Style fixes. If it seems like a lot of lines of changes, it's
because I moved some functions. Mr. Tidy likes them to be in alphabetical order.
Diffstat (limited to 'libexec')
-rw-r--r--libexec/rtld-elf/rtld.c154
1 files changed, 79 insertions, 75 deletions
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index eb5b605..1456ad9 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -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.3 1998/05/01 08:39:27 dfr Exp $
+ * $Id: rtld.c,v 1.4 1998/09/02 01:09:34 jdp Exp $
*/
/*
@@ -81,6 +81,8 @@ static const Elf32_Sym *find_symdef(unsigned long, const Obj_Entry *,
const Obj_Entry **, bool);
static void init_rtld(caddr_t);
static bool is_exported(const Elf32_Sym *);
+static void linkmap_add(Obj_Entry *);
+static void linkmap_delete(Obj_Entry *);
static int load_needed_objects(Obj_Entry *);
static Obj_Entry *load_object(char *);
static Obj_Entry *obj_from_addr(const void *);
@@ -90,11 +92,9 @@ static char *search_library_path(const char *, const char *);
static const Elf32_Sym *symlook_obj(const char *, unsigned long,
const Obj_Entry *, bool);
static void unref_object_dag(Obj_Entry *);
-void r_debug_state(void);
-static void linkmap_add(Obj_Entry *);
-static void linkmap_delete(Obj_Entry *);
static void trace_loaded_objects(Obj_Entry *obj);
+void r_debug_state(void);
void xprintf(const char *, ...);
#ifdef DEBUG
@@ -1284,75 +1284,6 @@ dlsym(void *handle, const char *name)
return NULL;
}
-
-/*
- * Search the symbol table of a single shared object for a symbol of
- * the given name. Returns a pointer to the symbol, or NULL if no
- * definition was found.
- *
- * The symbol's hash value is passed in for efficiency reasons; that
- * eliminates many recomputations of the hash value.
- */
-static const Elf32_Sym *
-symlook_obj(const char *name, unsigned long hash, const Obj_Entry *obj,
- bool in_plt)
-{
- unsigned long symnum = obj->buckets[hash % obj->nbuckets];
-
- while (symnum != STN_UNDEF) {
- const Elf32_Sym *symp;
- const char *strp;
-
- assert(symnum < obj->nchains);
- symp = obj->symtab + symnum;
- assert(symp->st_name != 0);
- strp = obj->strtab + symp->st_name;
-
- if (strcmp(name, strp) == 0)
- return symp->st_shndx != SHN_UNDEF ||
- (!in_plt && symp->st_value != 0 &&
- ELF32_ST_TYPE(symp->st_info) == STT_FUNC) ? symp : NULL;
-
- symnum = obj->chains[symnum];
- }
-
- return NULL;
-}
-
-static void
-unref_object_dag(Obj_Entry *root)
-{
- assert(root->refcount != 0);
- root->refcount--;
- if (root->refcount == 0) {
- const Needed_Entry *needed;
-
- for (needed = root->needed; needed != NULL; needed = needed->next)
- unref_object_dag(needed->obj);
- }
-}
-
-/*
- * Non-mallocing printf, for use by malloc itself.
- * XXX - This doesn't belong in this module.
- */
-void
-xprintf(const char *fmt, ...)
-{
- char buf[256];
- va_list ap;
-
- va_start(ap, fmt);
- vsprintf(buf, fmt, ap);
- (void)write(1, buf, strlen(buf));
- va_end(ap);
-}
-
-void
-r_debug_state(void)
-{
-}
-
static void
linkmap_add(Obj_Entry *obj)
{
@@ -1379,7 +1310,8 @@ linkmap_add(Obj_Entry *obj)
l->l_next = NULL;
}
-void linkmap_delete(Obj_Entry *obj)
+static void
+linkmap_delete(Obj_Entry *obj)
{
struct link_map *l = &obj->linkmap;
@@ -1393,7 +1325,50 @@ void linkmap_delete(Obj_Entry *obj)
l->l_next->l_prev = l->l_prev;
}
-void trace_loaded_objects(Obj_Entry *obj)
+/*
+ * Function for the debugger to set a breakpoint on to gain control.
+ */
+void
+r_debug_state(void)
+{
+}
+
+/*
+ * Search the symbol table of a single shared object for a symbol of
+ * the given name. Returns a pointer to the symbol, or NULL if no
+ * definition was found.
+ *
+ * The symbol's hash value is passed in for efficiency reasons; that
+ * eliminates many recomputations of the hash value.
+ */
+static const Elf32_Sym *
+symlook_obj(const char *name, unsigned long hash, const Obj_Entry *obj,
+ bool in_plt)
+{
+ unsigned long symnum = obj->buckets[hash % obj->nbuckets];
+
+ while (symnum != STN_UNDEF) {
+ const Elf32_Sym *symp;
+ const char *strp;
+
+ assert(symnum < obj->nchains);
+ symp = obj->symtab + symnum;
+ assert(symp->st_name != 0);
+ strp = obj->strtab + symp->st_name;
+
+ if (strcmp(name, strp) == 0)
+ return symp->st_shndx != SHN_UNDEF ||
+ (!in_plt && symp->st_value != 0 &&
+ ELF32_ST_TYPE(symp->st_info) == STT_FUNC) ? symp : NULL;
+
+ symnum = obj->chains[symnum];
+ }
+
+ return NULL;
+}
+
+static void
+trace_loaded_objects(Obj_Entry *obj)
{
char *fmt1, *fmt2, *fmt, *main_local;
int c;
@@ -1482,3 +1457,32 @@ void trace_loaded_objects(Obj_Entry *obj)
}
}
}
+
+static void
+unref_object_dag(Obj_Entry *root)
+{
+ assert(root->refcount != 0);
+ root->refcount--;
+ if (root->refcount == 0) {
+ const Needed_Entry *needed;
+
+ for (needed = root->needed; needed != NULL; needed = needed->next)
+ unref_object_dag(needed->obj);
+ }
+}
+
+/*
+ * Non-mallocing printf, for use by malloc itself.
+ * XXX - This doesn't belong in this module.
+ */
+void
+xprintf(const char *fmt, ...)
+{
+ char buf[256];
+ va_list ap;
+
+ va_start(ap, fmt);
+ vsprintf(buf, fmt, ap);
+ (void)write(1, buf, strlen(buf));
+ va_end(ap);
+}
OpenPOWER on IntegriCloud