/* Handle DSBT initialization */
{
struct elf_resolve *t, *ref;
- int idx = tpnt->loadaddr.map->dsbt_index;
- unsigned *dsbt = tpnt->loadaddr.map->dsbt_table;
+ int idx = tpnt->dsbt_index;
+ void **dsbt = tpnt->dsbt_table;
- if (idx == 0) {
+ /*
+ * It is okay (required actually) to have zero idx for an executable.
+ * This is the case when running ldso standalone and the program
+ * is being mapped in via _dl_load_shared_library().
+ */
+ if (idx == 0 && tpnt->libtype != elf_executable) {
if (!dynamic_info[DT_TEXTREL]) {
/* This DSO has not been assigned an index. */
_dl_dprintf(2, "%s: '%s' is missing a dsbt index assignment!\n",
break;
}
}
- idx = tpnt->loadaddr.map->dsbt_size;
+ idx = tpnt->dsbt_size;
while (idx-- > 0)
- if (!ref || ref->loadaddr.map->dsbt_table[idx] == NULL)
+ if (!ref || ref->dsbt_table[idx] == NULL)
break;
if (idx <= 0) {
_dl_dprintf(2, "%s: '%s' caused DSBT table overflow!\n",
}
_dl_if_debug_dprint("\n\tfile='%s'; assigned index %d\n",
libname, idx);
- tpnt->loadaddr.map->dsbt_index = idx;
+ tpnt->dsbt_index = idx;
+ }
+ /* make sure index is not already used */
+ if (_dl_ldso_dsbt[idx]) {
+ struct elf_resolve *dup;
+ const char *dup_name;
+
+ for (dup = _dl_loaded_modules; dup; dup = dup->next)
+ if (dup != tpnt && dup->dsbt_index == idx)
+ break;
+ if (dup)
+ dup_name = dup->libname;
+ else if (idx == 1)
+ dup_name = "runtime linker";
+ else
+ dup_name = "unknown library";
+ _dl_dprintf(2, "%s: '%s' dsbt index %d already used by %s!\n",
+ _dl_progname, libname, idx, dup_name);
+ _dl_exit(1);
}
/*
* Setup dsbt slot for this module in dsbt of all modules.
*/
- ref = NULL;
- for (t = _dl_loaded_modules; t; t = t->next) {
- /* find a dsbt table from another module */
- if (ref == NULL && t != tpnt) {
- ref = t;
-
- /* make sure index is not already used */
- if (t->loadaddr.map->dsbt_table[idx]) {
- struct elf_resolve *dup;
- char *dup_name;
-
- for (dup = _dl_loaded_modules; dup; dup = dup->next)
- if (dup != tpnt && dup->loadaddr.map->dsbt_index == idx)
- break;
- if (dup)
- dup_name = dup->libname;
- else if (idx == 1)
- dup_name = "runtime linker";
- else
- dup_name = "unknown library";
- _dl_dprintf(2, "%s: '%s' dsbt index %d already used by %s!\n",
- _dl_progname, libname, idx, dup_name);
- _dl_exit(1);
- }
- }
- t->loadaddr.map->dsbt_table[idx] = (unsigned)dsbt;
- }
- if (ref)
- _dl_memcpy(dsbt, ref->loadaddr.map->dsbt_table,
- tpnt->loadaddr.map->dsbt_size * sizeof(unsigned *));
+ for (t = _dl_loaded_modules; t; t = t->next)
+ t->dsbt_table[idx] = dsbt;
+ _dl_ldso_dsbt[idx] = dsbt;
+ _dl_memcpy(dsbt, _dl_ldso_dsbt,
+ tpnt->dsbt_size * sizeof(tpnt->dsbt_table[0]));
}
#endif
_dl_if_debug_dprint("\n\tfile='%s'; generating link map\n", libname);
int _dl_debug_file = 2;
#endif
+#ifdef __DSBT__
+void **_dl_ldso_dsbt = NULL;
+#endif
+
unsigned long attribute_hidden _dl_skip_args = 0;
const char *_dl_progname = UCLIBC_LDSO; /* The name of the executable being run */
_dl_progname = argv[0];
}
+#ifdef __DSBT__
+ _dl_ldso_dsbt = (void *)tpnt->dynamic_info[DT_DSBT_BASE_IDX];
+ _dl_ldso_dsbt[tpnt->dynamic_info[DT_DSBT_INDEX_IDX]] = _dl_ldso_dsbt;
+#endif
+
#ifndef __LDSO_STANDALONE_SUPPORT__
if (_start == (void *) auxvt[AT_ENTRY].a_un.a_val) {
_dl_dprintf(_dl_debug_file, "Standalone execution is not enabled\n");
app_tpnt->mapaddr = app_mapaddr;
app_tpnt->rtld_flags = unlazy | RTLD_GLOBAL;
app_tpnt->usage_count++;
+#ifdef __DSBT__
+ _dl_ldso_dsbt[0] = app_tpnt->dsbt_table;
+ _dl_memcpy(app_tpnt->dsbt_table, _dl_ldso_dsbt,
+ app_tpnt->dsbt_size * sizeof(tpnt->dsbt_table[0]));
+#endif
lpnt = (unsigned long *) (app_tpnt->dynamic_info[DT_PLTGOT]);
#ifdef ALLOW_ZERO_PLTGOT
if (lpnt)