[uClibc-cvs] uClibc/ldso/ldso ldso.c, 1.78, 1.79 readelflib1.c, 1.54, 1.55
Erik Andersen
andersen at uclibc.org
Thu Jan 29 10:44:52 UTC 2004
Update of /var/cvs/uClibc/ldso/ldso
In directory nail:/tmp/cvs-serv12637/ldso
Modified Files:
ldso.c readelflib1.c
Log Message:
Eliminate separate passes for _dl_copy_fixups() and _dl_fixup(), and
do both operations in a single pass.
Index: readelflib1.c
===================================================================
RCS file: /var/cvs/uClibc/ldso/ldso/readelflib1.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- readelflib1.c 17 Dec 2003 18:34:15 -0000 1.54
+++ readelflib1.c 29 Jan 2004 10:44:49 -0000 1.55
@@ -735,47 +735,6 @@
return tpnt;
}
-/* Ugly, ugly. Some versions of the SVr4 linker fail to generate COPY
- relocations for global variables that are present both in the image and
- the shared library. Go through and do it manually. If the images
- are guaranteed to be generated by a trustworthy linker, then this
- step can be skipped. */
-
-int _dl_copy_fixups(struct dyn_elf *rpnt)
-{
- int goof = 0;
- struct elf_resolve *tpnt;
-
- if (rpnt->next)
- goof += _dl_copy_fixups(rpnt->next);
- else
- return 0;
-
- tpnt = rpnt->dyn;
-
- if (tpnt->init_flag & COPY_RELOCS_DONE)
- return goof;
- tpnt->init_flag |= COPY_RELOCS_DONE;
-
-#if defined (__SUPPORT_LD_DEBUG__)
- if(_dl_debug) _dl_dprintf(_dl_debug_file,"\nrelocation copy fixups: %s", tpnt->libname);
-#endif
-
-#ifdef ELF_USES_RELOCA
- goof += _dl_parse_copy_information(rpnt,
- tpnt->dynamic_info[DT_RELA], tpnt->dynamic_info[DT_RELASZ], 0);
-
-#else
- goof += _dl_parse_copy_information(rpnt, tpnt->dynamic_info[DT_REL],
- tpnt->dynamic_info[DT_RELSZ], 0);
-
-#endif
-#if defined (__SUPPORT_LD_DEBUG__)
- if(_dl_debug) _dl_dprintf(_dl_debug_file,"\nrelocation copy fixups: %s; finished\n\n", tpnt->libname);
-#endif
- return goof;
-}
-
/* Minimal printf which handles only %s, %d, and %x */
void _dl_dprintf(int fd, const char *fmt, ...)
{
@@ -905,12 +864,15 @@
return retval;
}
-int _dl_fixup(struct elf_resolve *tpnt, int flag)
+int _dl_fixup(struct dyn_elf *rpnt, int flag)
{
int goof = 0;
+ struct elf_resolve *tpnt;
+
+ if (rpnt->next)
+ goof += _dl_fixup(rpnt->next, flag);
+ tpnt = rpnt->dyn;
- if (tpnt->next)
- goof += _dl_fixup(tpnt->next, flag);
#if defined (__SUPPORT_LD_DEBUG__)
if(_dl_debug) _dl_dprintf(_dl_debug_file,"\nrelocation processing: %s", tpnt->libname);
#endif
@@ -961,6 +923,19 @@
tpnt->dynamic_info[DT_PLTRELSZ], 0);
}
}
+ if (tpnt->init_flag & COPY_RELOCS_DONE)
+ return goof;
+ tpnt->init_flag |= COPY_RELOCS_DONE;
+#ifdef ELF_USES_RELOCA
+ goof += _dl_parse_copy_information(rpnt,
+ tpnt->dynamic_info[DT_RELA], tpnt->dynamic_info[DT_RELASZ], 0);
+
+#else
+ goof += _dl_parse_copy_information(rpnt, tpnt->dynamic_info[DT_REL],
+ tpnt->dynamic_info[DT_RELSZ], 0);
+
+#endif
+
#if defined (__SUPPORT_LD_DEBUG__)
if(_dl_debug) {
_dl_dprintf(_dl_debug_file,"\nrelocation processing: %s", tpnt->libname);
@@ -970,4 +945,3 @@
return goof;
}
-
Index: ldso.c
===================================================================
RCS file: /var/cvs/uClibc/ldso/ldso/ldso.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- ldso.c 2 Jan 2004 23:34:12 -0000 1.78
+++ ldso.c 29 Jan 2004 10:44:49 -0000 1.79
@@ -145,7 +145,7 @@
struct r_debug *_dl_debug_addr = NULL;
unsigned long *_dl_brkp;
unsigned long *_dl_envp;
-int _dl_fixup(struct elf_resolve *tpnt, int lazy);
+int _dl_fixup(struct dyn_elf *rpnt, int flag);
void _dl_debug_state(void);
char *_dl_get_last_path_component(char *path);
static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *app_tpnt,
@@ -1185,18 +1185,9 @@
* Now we go through and look for REL and RELA records that indicate fixups
* to the GOT tables. We need to do this in reverse order so that COPY
* directives work correctly */
- goof = _dl_loaded_modules ? _dl_fixup(_dl_loaded_modules, _dl_be_lazy) : 0;
-
-
- /* Some flavors of SVr4 do not generate the R_*_COPY directive,
- and we have to manually search for entries that require fixups.
- Solaris gets this one right, from what I understand. */
-
-#ifdef __SUPPORT_LD_DEBUG_EARLY__
- _dl_dprintf(_dl_debug_file, "Beginning copy fixups\n");
-#endif
if (_dl_symbol_tables)
- goof += _dl_copy_fixups(_dl_symbol_tables);
+ goof += _dl_fixup(_dl_symbol_tables, _dl_be_lazy);
+
/* OK, at this point things are pretty much ready to run. Now we
need to touch up a few items that are required, and then
More information about the uClibc-cvs
mailing list