Put back one optimization from the original patch. Use non-exported symbols. Mark translatable strings. Pretty printing.

This commit is contained in:
Ulrich Drepper 2003-05-02 08:19:41 +00:00
parent a0c8a2499e
commit e0f8662c22
1 changed files with 30 additions and 20 deletions

View File

@ -55,12 +55,12 @@ static struct local
} }
local = local =
{ {
root: &local.boot_table, .root = &local.boot_table,
npages: 2, .npages = 2,
boot_table: .boot_table =
{ {
len: sizeof (local.boot_fdescs) / sizeof (local.boot_fdescs[0]), .len = sizeof (local.boot_fdescs) / sizeof (local.boot_fdescs[0]),
first_unused: 0 .first_unused = 0
} }
}; };
@ -80,12 +80,11 @@ new_fdesc_table (struct local *l, size_t *size)
return (struct fdesc_table *) NULL; return (struct fdesc_table *) NULL;
*size = old_npages * GL(dl_pagesize); *size = old_npages * GL(dl_pagesize);
new_table = __mmap (0, *size, new_table = __mmap (NULL, *size,
PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
-1, 0);
if (new_table == MAP_FAILED) if (new_table == MAP_FAILED)
_dl_signal_error (errno, NULL, NULL, INTUSE(_dl_signal_error) (errno, NULL, NULL,
"cannot map pages for fdesc table"); N_("cannot map pages for fdesc table"));
new_table->len new_table->len
= (*size - sizeof (*new_table)) / sizeof (struct fdesc); = (*size - sizeof (*new_table)) / sizeof (struct fdesc);
@ -93,6 +92,7 @@ new_fdesc_table (struct local *l, size_t *size)
return new_table; return new_table;
} }
static ElfW(Addr) static ElfW(Addr)
make_fdesc (ElfW(Addr) ip, ElfW(Addr) gp) make_fdesc (ElfW(Addr) ip, ElfW(Addr) gp)
{ {
@ -119,7 +119,7 @@ make_fdesc (ElfW(Addr) ip, ElfW(Addr) gp)
if (l->free_list) if (l->free_list)
{ {
/* Get it from free-list */ /* Get it from free-list. */
do do
{ {
fdesc = l->free_list; fdesc = l->free_list;
@ -131,7 +131,7 @@ make_fdesc (ElfW(Addr) ip, ElfW(Addr) gp)
} }
else else
{ {
/* Create a new fdesc table */ /* Create a new fdesc table. */
size_t size; size_t size;
struct fdesc_table *new_table = new_fdesc_table (l, &size); struct fdesc_table *new_table = new_fdesc_table (l, &size);
@ -142,11 +142,16 @@ make_fdesc (ElfW(Addr) ip, ElfW(Addr) gp)
if (! COMPARE_AND_SWAP ((ElfW(Addr) *) &l->root, if (! COMPARE_AND_SWAP ((ElfW(Addr) *) &l->root,
(ElfW(Addr)) root, (ElfW(Addr)) root,
(ElfW(Addr)) new_table)) (ElfW(Addr)) new_table))
/* Someone has just installed a new table. Return NULL to {
tell the caller to use the new table. */ /* Someone has just installed a new table. Return NULL to
__munmap (new_table, size); tell the caller to use the new table. */
__munmap (new_table, size);
goto retry;
}
goto retry; /* Note that the first entry was reserved while allocating the
memory for the new page. */
fdesc = &new_table->fdesc[0];
} }
install: install:
@ -156,6 +161,7 @@ make_fdesc (ElfW(Addr) ip, ElfW(Addr) gp)
return (ElfW(Addr)) fdesc; return (ElfW(Addr)) fdesc;
} }
static inline ElfW(Addr) * static inline ElfW(Addr) *
make_fptr_table (struct link_map *map) make_fptr_table (struct link_map *map)
{ {
@ -181,8 +187,8 @@ make_fptr_table (struct link_map *map)
PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE,
-1, 0); -1, 0);
if (fptr_table == MAP_FAILED) if (fptr_table == MAP_FAILED)
_dl_signal_error (errno, NULL, NULL, INTUSE(_dl_signal)_error (errno, NULL, NULL,
"cannot map pages for fptr table"); N_("cannot map pages for fptr table"));
if (COMPARE_AND_SWAP ((ElfW(Addr) *) &map->l_mach.fptr_table, if (COMPARE_AND_SWAP ((ElfW(Addr) *) &map->l_mach.fptr_table,
(ElfW(Addr)) NULL, (ElfW(Addr)) fptr_table)) (ElfW(Addr)) NULL, (ElfW(Addr)) fptr_table))
@ -193,6 +199,7 @@ make_fptr_table (struct link_map *map)
return map->l_mach.fptr_table; return map->l_mach.fptr_table;
} }
ElfW(Addr) ElfW(Addr)
_dl_make_fptr (struct link_map *map, const ElfW(Sym) *sym, _dl_make_fptr (struct link_map *map, const ElfW(Sym) *sym,
ElfW(Addr) ip) ElfW(Addr) ip)
@ -209,8 +216,8 @@ _dl_make_fptr (struct link_map *map, const ElfW(Sym) *sym,
symidx = sym - symtab; symidx = sym - symtab;
if (symidx >= map->l_mach.fptr_table_len) if (symidx >= map->l_mach.fptr_table_len)
_dl_signal_error (0, NULL, NULL, INTUSE(_dl_signal_error) (0, NULL, NULL, N_("\
"internal error: symidx out of range of fptr table"); internal error: symidx out of range of fptr table"));
while (ftab[symidx] == NULL) while (ftab[symidx] == NULL)
{ {
@ -254,6 +261,7 @@ _dl_make_fptr (struct link_map *map, const ElfW(Sym) *sym,
return ftab[symidx]; return ftab[symidx];
} }
void void
_dl_unmap (struct link_map *map) _dl_unmap (struct link_map *map)
{ {
@ -292,6 +300,7 @@ _dl_unmap (struct link_map *map)
map->l_mach.fptr_table = NULL; map->l_mach.fptr_table = NULL;
} }
ElfW(Addr) ElfW(Addr)
_dl_lookup_address (const void *address) _dl_lookup_address (const void *address)
{ {
@ -308,5 +317,6 @@ _dl_lookup_address (const void *address)
break; break;
} }
} }
return addr; return addr;
} }