This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 2/4] Add a signal-safe malloc replacement
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Thomas Schwinge <thomas at codesourcery dot com>
- Cc: Paul Pluzhnikov <ppluzhnikov at google dot com>, Andrew Hunter <ahh at google dot com>, GNU C Library <libc-alpha at sourceware dot org>, Carlos O'Donell <carlos at redhat dot com>, Roland McGrath <roland at hack dot frob dot com>
- Date: Fri, 20 Dec 2013 14:03:35 +0100
- Subject: Re: [PATCH 2/4] Add a signal-safe malloc replacement
- Authentication-results: sourceware.org; auth=none
- References: <1386273671-13010-1-git-send-email-ahh at google dot com> <1386722143-10513-1-git-send-email-ahh at google dot com> <1386722143-10513-2-git-send-email-ahh at google dot com> <20131211100309 dot GA24512 at domone dot podge> <CALoOobMKYyD7G7fbYHq2aqx32S_QMs19DZY2YhJ-JA4_d4717A at mail dot gmail dot com> <CADroS=7LJ4uKGB30jsNn2xV5Dxr7eZ24H3NScHUCYWORUnMTfQ at mail dot gmail dot com> <CALoOobP0xGCB_6Vf9uTizqctJP1r9aW2eRoBFNeaHHASWd75mg at mail dot gmail dot com> <CALoOobOT_os7AuCB+_+fy+u9LOaRajBLoQKgf20vKeqYTxRJhg at mail dot gmail dot com> <87ioujn0eq dot fsf at kepler dot schwinge dot homeip dot net>
On Fri, Dec 20, 2013 at 01:59:25PM +0100, Thomas Schwinge wrote:
> Hi!
>
...
> This causes a link failure on Hurd, because to resolve the mmap and
> munmap symbols it tries to pull in object files that are not meant to be
> pulled in:
>
> gcc-4.7 -nostdlib -nostartfiles -r -o [...]/elf/librtld.map.o '-Wl,-(' [...]/elf/dl-allobjs.os [...]/libc_pic.a [...]/mach/libmachuser_pic.a [...]/hurd/libhurduser_pic.a -lgcc '-Wl,-)' -Wl,-Map,[...]/elf/librtld.mapT
> [...]/libc_pic.a(init-first.os):(.data+0x0): multiple definition of `__libc_multiple_libcs'
> [...]/elf/dl-allobjs.os:[...]/elf/rtld.c:797: first defined here
> [...]/libc_pic.a(_itoa.os): In function `_itoa':
> [...]/stdio-common/_itoa.c:199: multiple definition of `_itoa'
> [...]/elf/dl-allobjs.os:[...]/elf/dl-minimal.c:317: first defined here
> collect2: error: ld returned 1 exit status
> make[2]: *** [[...]/elf/librtld.map] Error 1
>
> OK to fix as follows?
>
OK for me.
> * elf/dl-misc.c (__signal_safe_memalign, __signal_safe_free): Use
> internal symbols for mmap and munmap.
>
> diff --git elf/dl-misc.c elf/dl-misc.c
> index b529af3..0ea4329 100644
> --- elf/dl-misc.c
> +++ elf/dl-misc.c
> @@ -418,8 +418,8 @@ __signal_safe_memalign (size_t boundary, size_t size)
>
>
> size_t actual_size = roundup (padded_size, pg);
> - void *actual = mmap (NULL, actual_size, PROT_READ | PROT_WRITE,
> - MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
> + void *actual = __mmap (NULL, actual_size, PROT_READ | PROT_WRITE,
> + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
> if (actual == MAP_FAILED)
> return NULL;
>
> @@ -435,7 +435,7 @@ __signal_safe_memalign (size_t boundary, size_t size)
> start_pg -= start_pg % boundary_pg;
> if (start_pg > (actual_pg + 1))
> {
> - int ret = munmap (actual, (start_pg - actual_pg - 1) * pg);
> + int ret = __munmap (actual, (start_pg - actual_pg - 1) * pg);
> assert (ret == 0);
> actual = (void *) ((start_pg - 1) * pg);
> }
> @@ -466,7 +466,7 @@ __signal_safe_free (void *ptr)
>
> struct __signal_safe_a