mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-07 06:43:00 +03:00
Update.
* elf/link.h (struct link_map): New field l_phdr_allocated. * elf/dl-load.c (_dl_map_object_from_fd): Don't depend on having the program header being part of any loaded segment. If it is not allocate memory and set l_phdr_allocated flag. * elf/dl-close.c (_dl_close): Free l_phdr if necessary.
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
1999-05-06 Ulrich Drepper <drepper@cygnus.com>
|
1999-05-06 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
|
* elf/link.h (struct link_map): New field l_phdr_allocated.
|
||||||
|
* elf/dl-load.c (_dl_map_object_from_fd): Don't depend on having
|
||||||
|
the program header being part of any loaded segment. If it is not
|
||||||
|
allocate memory and set l_phdr_allocated flag.
|
||||||
|
* elf/dl-close.c (_dl_close): Free l_phdr if necessary.
|
||||||
|
|
||||||
* nss/digits_dots.c: Correct return value interpretation of
|
* nss/digits_dots.c: Correct return value interpretation of
|
||||||
inet_ntoa. Fix PR libc/1109.
|
inet_ntoa. Fix PR libc/1109.
|
||||||
|
|
||||||
|
@@ -165,6 +165,9 @@ _dl_close (struct link_map *map)
|
|||||||
if (imap != map && imap->l_searchlist.r_list != NULL)
|
if (imap != map && imap->l_searchlist.r_list != NULL)
|
||||||
free (imap->l_searchlist.r_list);
|
free (imap->l_searchlist.r_list);
|
||||||
|
|
||||||
|
if (imap->l_phdr_allocated)
|
||||||
|
free (imap->l_phdr);
|
||||||
|
|
||||||
free (imap);
|
free (imap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -917,6 +917,13 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname,
|
|||||||
c->prot, MAP_FIXED, c->mapoff);
|
c->prot, MAP_FIXED, c->mapoff);
|
||||||
|
|
||||||
postmap:
|
postmap:
|
||||||
|
if (l->l_phdr == 0
|
||||||
|
&& c->mapoff <= header->e_phoff
|
||||||
|
&& (c->mapend - c->mapstart + c->mapoff
|
||||||
|
>= header->e_phoff + header->e_phnum * sizeof (ElfW(Phdr))))
|
||||||
|
/* Found the program header in this segment. */
|
||||||
|
l->l_phdr = (void *) (c->mapstart + header->e_phoff - c->mapoff);
|
||||||
|
|
||||||
if (c->allocend > c->dataend)
|
if (c->allocend > c->dataend)
|
||||||
{
|
{
|
||||||
/* Extra zero pages should appear at the end of this segment,
|
/* Extra zero pages should appear at the end of this segment,
|
||||||
@@ -963,22 +970,19 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname,
|
|||||||
++c;
|
++c;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l->l_phdr == 0)
|
if (l->l_phdr == NULL)
|
||||||
{
|
{
|
||||||
/* There was no PT_PHDR specified. We need to find the phdr in the
|
/* The program header is not contained in any of the segmenst.
|
||||||
load image ourselves. We assume it is in fact in the load image
|
We have to allocate memory ourself and copy it over from
|
||||||
somewhere. */
|
out temporary place. */
|
||||||
for (c = loadcmds; c < &loadcmds[nloadcmds]; c++)
|
ElfW(Phdr) *newp = (ElfW(Phdr) *) malloc (header->e_phnum
|
||||||
if (c->mapoff <= header->e_phoff
|
* sizeof (ElfW(Phdr)));
|
||||||
&& (c->mapend - c->mapstart + c->mapoff
|
if (newp == NULL)
|
||||||
>= header->e_phoff + header->e_phnum * sizeof (ElfW(Phdr))))
|
LOSE (ENOMEM, "cannot allocate memory for program header");
|
||||||
{
|
|
||||||
ElfW(Addr) bof = l->l_addr + c->mapstart;
|
l->l_phdr = memcpy (newp, phdr,
|
||||||
l->l_phdr = (void *) (bof + header->e_phoff - c->mapoff);
|
(header->e_phnum * sizeof (ElfW(Phdr))));
|
||||||
break;
|
l->l_phdr_allocated = 1;
|
||||||
}
|
|
||||||
if (l->l_phdr == 0)
|
|
||||||
LOSE (0, "program headers not contained in any loaded segment");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* Adjust the PT_PHDR value by the runtime load address. */
|
/* Adjust the PT_PHDR value by the runtime load address. */
|
||||||
|
@@ -199,6 +199,9 @@ struct link_map
|
|||||||
object is the same as one already loaded. */
|
object is the same as one already loaded. */
|
||||||
dev_t l_dev;
|
dev_t l_dev;
|
||||||
ino_t l_ino;
|
ino_t l_ino;
|
||||||
|
|
||||||
|
/* Nonzero if the data structure pointed to by `l_phdr' is allocated. */
|
||||||
|
int l_phdr_allocated;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* link.h */
|
#endif /* link.h */
|
||||||
|
Reference in New Issue
Block a user