* [PATCH] Optimize some free_mem handlers, save 4K from .bss
@ 2002-10-25 22:41 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2002-10-25 22:41 UTC (permalink / raw)
To: Roland McGrath, Ulrich Drepper; +Cc: Glibc hackers
Hi!
This is what I managed tonight, the rest will have to wait.
It passed make check and I have even checked in debugger that
__libc_freeres frees all ptrs from __libc_freeres_ptrs section.
Don't have exact numbers how much it saved, because I can only compare ~ 1
day old libc.so with today's libc.so with this patch, but it has 36
fewer RELATIVE relocs, 1472 fewer bytes in .text section, 148 fewer bytes
in __libc_subfreeres, 4064 fewer bytes in .bss (this is still
without Roland's sigvec patch).
2002-10-25 Jakub Jelinek <jakub@redhat.com>
* include/libc-symbols.h (libc_freeres_ptr): Define.
* malloc/set-freeres.c (__libc_freeres_ptrs): Define using
symbol_set_define.
(__libc_freeres): Free all pointers in that section.
* Makerules (build-shlib): Add $(LDSEDCMD-$(@F:lib%.so=%).so) to sed
commands when creating .lds script.
(LDSEDCMD-c.so): Define.
* inet/rcmd.c (ahostbuf): Change into char *. Add libc_freeres_ptr.
(rcmd_af): Use strdup to allocate ahostbuf.
* inet/rexec.c (ahostbuf): Change into char *. Add libc_freeres_ptr.
(rexec_af): Use strdup to allocate ahostbuf.
* stdio-common/reg-printf.c (printf_funcs): Remove.
(__printf_arginfo_table): Change into printf_arginfo_function **.
Add libc_freeres_ptr.
(__register_printf_function): Allocate __printf_arginfo_table
and __printf_function_table the first time it is called.
* stdio-common/printf-parse.h (__printf_arginfo_table): Change into
printf_arginfo_function **.
(parse_one_spec): Add __builtin_expect.
* grp/fgetgrent.c (buffer): Add libc_freeres_ptr.
(free_mem): Remove.
* inet/getnetgrent.c (buffer): Add libc_freeres_ptr.
(free_mem): Remove.
* intl/localealias.c (libc_freeres_ptr): Define if !_LIBC.
(string_space, map): Add libc_freeres_ptr.
(free_mem): Remove.
* misc/efgcvt.c (FCVT_BUFPTR): Add libc_freeres_ptr.
(free_mem): Remove.
* misc/mntent.c (getmntent_buffer): Add libc_freeres_ptr.
(free_mem): Remove.
* crypt/md5-crypt.c (libc_freeres_ptr): Define if !_LIBC.
(buffer): Add libc_freeres_ptr.
(free_mem): Remove for _LIBC.
* nss/getXXbyYY.c (buffer): Add libc_freeres_ptr.
(free_mem): Remove.
* nss/getXXent.c (buffer): Add libc_freeres_ptr.
(free_mem): Remove.
* pwd/fgetpwent.c (buffer): Add libc_freeres_ptr.
(free_mem): Remove.
* resolv/res_hconf.c (ifaddrs): Add libc_freeres_ptr.
(free_mem): Remove.
* shadow/fgetspent.c (buffer): Add libc_freeres_ptr.
(free_mem): Remove.
* sysdeps/posix/ttyname.c (getttyname_name): Add libc_freeres_ptr.
(free_mem): Remove.
* sysdeps/unix/sysv/linux/getsysstats.c (mount_proc): Add
libc_freeres_ptr.
(free_mem): Remove.
* sysdeps/unix/sysv/linux/ttyname.c (getttyname_name, ttyname_buf): Add
libc_freeres_ptr.
(free_mem): Remove.
--- libc/include/libc-symbols.h.jj 2002-10-16 23:21:24.000000000 +0200
+++ libc/include/libc-symbols.h 2002-10-25 23:49:37.000000000 +0200
@@ -253,17 +253,18 @@
/* Tacking on "\n\t#" to the section name makes gcc put it's bogus
section attributes on what looks like a comment to the assembler. */
# ifdef HAVE_SECTION_QUOTES
-# define link_warning(symbol, msg) \
- __make_section_unallocated (".gnu.warning." #symbol) \
- static const char __evoke_link_warning_##symbol[] \
- __attribute__ ((unused, section (".gnu.warning." #symbol "\"\n\t#\""))) \
- = msg;
+# define __sec_comment "\"\n\t#\""
# else
-# define link_warning(symbol, msg) \
+# define __sec_comment "\n\t#"
+# endif
+# define link_warning(symbol, msg) \
__make_section_unallocated (".gnu.warning." #symbol) \
static const char __evoke_link_warning_##symbol[] \
- __attribute__ ((unused, section (".gnu.warning." #symbol "\n\t#"))) = msg;
-# endif
+ __attribute__ ((unused, section (".gnu.warning." #symbol __sec_comment))) \
+ = msg;
+# define libc_freeres_ptr(decl) \
+ __make_section_unallocated ("__libc_freeres_ptrs, \"aw\", @nobits") \
+ decl __attribute__ ((section ("__libc_freeres_ptrs" __sec_comment)))
# else /* Not ELF: a.out */
# ifdef HAVE_XCOFF
/* XCOFF does not support .stabs.
@@ -276,10 +277,12 @@
asm (".stabs \"" msg "\",30,0,0,0\n\t" \
".stabs \"" __SYMBOL_PREFIX #symbol "\",1,0,0,0\n");
# endif /* XCOFF */
+# define libc_freeres_ptr(decl) decl
# endif
#else
/* We will never be heard; they will all die horribly. */
# define link_warning(symbol, msg)
+# define libc_freeres_ptr(decl) decl
#endif
/* A canned warning for sysdeps/stub functions. */
--- libc/grp/fgetgrent.c.jj 2001-08-23 18:47:11.000000000 +0200
+++ libc/grp/fgetgrent.c 2002-10-25 23:52:05.000000000 +0200
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991,1996,1997,1999,2000,2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -26,7 +26,7 @@
/* We need to protect the dynamic buffer handling. */
__libc_lock_define_initialized (static, lock);
-static char *buffer;
+libc_freeres_ptr (static char *buffer);
/* Read one entry from the given stream. */
struct group *
@@ -83,13 +83,3 @@ fgetgrent (FILE *stream)
return result;
}
-
-
-/* Free all resources if necessary. */
-static void __attribute__ ((unused))
-free_mem (void)
-{
- free (buffer);
-}
-
-text_set_element (__libc_subfreeres, free_mem);
--- libc/inet/rcmd.c.jj 2002-08-06 10:15:14.000000000 +0200
+++ libc/inet/rcmd.c 2002-10-26 00:03:01.000000000 +0200
@@ -101,7 +101,7 @@ int iruserok (u_int32_t raddr, int super
libc_hidden_proto (iruserok_af)
-static char ahostbuf[NI_MAXHOST];
+libc_freeres_ptr(static char *ahostbuf);
int
rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
@@ -153,11 +153,21 @@ rcmd_af(ahost, rport, locuser, remuser,
pfd[1].events = POLLIN;
if (res->ai_canonname){
- strncpy(ahostbuf, res->ai_canonname, sizeof(ahostbuf));
- ahostbuf[sizeof(ahostbuf)-1] = '\0';
+ free (ahostbuf);
+ ahostbuf = strdup (res->ai_canonname);
+ if (ahostbuf == NULL) {
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf(stderr, L"%s",
+ _("rcmd: Cannot allocate memory\n"));
+ else
+#endif
+ fputs(_("rcmd: Cannot allocate memory\n"),
+ stderr);
+ return (-1);
+ }
*ahost = ahostbuf;
- }
- else
+ } else
*ahost = NULL;
ai = res;
refused = 0;
--- libc/inet/rexec.c.jj 2002-08-12 15:27:47.000000000 +0200
+++ libc/inet/rexec.c 2002-10-26 00:04:57.000000000 +0200
@@ -45,7 +45,7 @@ static char sccsid[] = "@(#)rexec.c 8.1
#include <unistd.h>
int rexecoptions;
-static char ahostbuf[NI_MAXHOST];
+libc_freeres_ptr (static char *ahostbuf);
int
rexec_af(ahost, rport, name, pass, cmd, fd2p, af)
@@ -79,13 +79,15 @@ rexec_af(ahost, rport, name, pass, cmd,
}
if (res0->ai_canonname){
- strncpy(ahostbuf, res0->ai_canonname, sizeof(ahostbuf));
- ahostbuf[sizeof(ahostbuf)-1] = '\0';
+ free (ahostbuf);
+ ahostbuf = strdup (res0->ai_canonname);
+ if (ahostbuf == NULL) {
+ perror ("rexec: strdup");
+ return (-1);
+ }
*ahost = ahostbuf;
- }
- else{
+ } else
*ahost = NULL;
- }
ruserpass(res0->ai_canonname, &name, &pass);
retry:
s = __socket(res0->ai_family, res0->ai_socktype, 0);
--- libc/inet/getnetgrent.c.jj 2001-08-23 18:47:43.000000000 +0200
+++ libc/inet/getnetgrent.c 2002-10-26 00:08:54.000000000 +0200
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 2000, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,8 +21,8 @@
#include <stdlib.h>
#include <bits/libc-lock.h>
-/* Statis buffer for return value. We allocate it when needed. */
-static char *buffer;
+/* Static buffer for return value. We allocate it when needed. */
+libc_freeres_ptr (static char *buffer);
/* All three strings should fit in a block of 1kB size. */
#define BUFSIZE 1024
@@ -48,15 +48,3 @@ getnetgrent (char **hostp, char **userp,
return __getnetgrent_r (hostp, userp, domainp, buffer, BUFSIZE);
}
-
-
-/* Make sure the memory is freed if the programs ends while in
- memory-debugging mode and something actually was allocated. */
-static void
-__attribute__ ((unused))
-free_mem (void)
-{
- free (buffer);
-}
-
-text_set_element (__libc_subfreeres, free_mem);
--- libc/intl/localealias.c.jj 2002-09-01 15:33:18.000000000 +0200
+++ libc/intl/localealias.c 2002-10-26 00:11:00.000000000 +0200
@@ -117,10 +117,14 @@ struct alias_map
};
-static char *string_space;
+#ifndef _LIBC
+# define libc_freeres_ptr(decl) decl
+#endif
+
+libc_freeres_ptr (static char *string_space);
static size_t string_space_act;
static size_t string_space_max;
-static struct alias_map *map;
+libc_freeres_ptr (static struct alias_map *map);
static size_t nmap;
static size_t maxmap;
@@ -371,19 +375,6 @@ extend_alias_table ()
}
-#ifdef _LIBC
-static void __attribute__ ((unused))
-free_mem (void)
-{
- if (string_space != NULL)
- free (string_space);
- if (map != NULL)
- free (map);
-}
-text_set_element (__libc_subfreeres, free_mem);
-#endif
-
-
static int
alias_compare (map1, map2)
const struct alias_map *map1;
--- libc/malloc/set-freeres.c.jj 2002-08-03 11:09:31.000000000 +0200
+++ libc/malloc/set-freeres.c 2002-10-26 01:11:29.000000000 +0200
@@ -27,6 +27,8 @@
DEFINE_HOOK (__libc_subfreeres, (void));
+symbol_set_define (__libc_freeres_ptrs);
+
void
__libc_freeres (void)
{
@@ -36,11 +38,17 @@ __libc_freeres (void)
if (compare_and_swap (&already_called, 0, 1))
{
+ void * const *p;
+
#ifdef USE_IN_LIBIO
_IO_cleanup ();
#endif
RUN_HOOK (__libc_subfreeres, ());
+
+ for (p = symbol_set_first_element (__libc_freeres_ptrs);
+ ! symbol_set_end_p (__libc_freeres_ptrs, p); ++p)
+ free (*p);
}
}
libc_hidden_def (__libc_freeres)
--- libc/misc/efgcvt.c.jj 2001-08-23 18:48:30.000000000 +0200
+++ libc/misc/efgcvt.c 2002-10-26 00:13:58.000000000 +0200
@@ -1,5 +1,5 @@
/* Compatibility functions for floating point formatting.
- Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1999, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -57,7 +57,7 @@
static char FCVT_BUFFER[MAXDIG];
static char ECVT_BUFFER[MAXDIG];
-static char *FCVT_BUFPTR;
+libc_freeres_ptr (static char *FCVT_BUFPTR);
char *
APPEND (FUNC_PREFIX, fcvt) (value, ndigit, decpt, sign)
@@ -102,13 +102,3 @@ APPEND (FUNC_PREFIX, gcvt) (value, ndigi
sprintf (buf, "%.*" FLOAT_FMT_FLAG "g", MIN (ndigit, NDIGIT_MAX), value);
return buf;
}
-
-/* Free all resources if necessary. */
-static void __attribute__ ((unused))
-free_mem (void)
-{
- if (FCVT_BUFPTR != NULL)
- free (FCVT_BUFPTR);
-}
-
-text_set_element (__libc_subfreeres, free_mem);
--- libc/misc/mntent.c.jj 2001-08-23 18:48:30.000000000 +0200
+++ libc/misc/mntent.c 2002-10-26 00:14:43.000000000 +0200
@@ -1,5 +1,5 @@
/* Utilities for reading/writing fstab, mtab, etc.
- Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 2000, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -24,7 +24,7 @@
/* We don't want to allocate the static buffer all the time since it
is not always used (in fact, rather infrequently). Accept the
extra cost of a `malloc'. */
-static char *getmntent_buffer;
+libc_freeres_ptr (static char *getmntent_buffer);
/* This is the size of the buffer. This is really big. */
#define BUFFER_SIZE 4096
@@ -52,15 +52,3 @@ getmntent (FILE *stream)
return __getmntent_r (stream, &m, getmntent_buffer, BUFFER_SIZE);
}
-
-
-/* Make sure the memory is freed if the programs ends while in
- memory-debugging mode and something actually was allocated. */
-static void
-__attribute__ ((unused))
-free_mem (void)
-{
- free (getmntent_buffer);
-}
-
-text_set_element (__libc_subfreeres, free_mem);
--- libc/crypt/md5-crypt.c.jj 2002-01-30 18:00:15.000000000 +0100
+++ libc/crypt/md5-crypt.c 2002-10-26 00:17:12.000000000 +0200
@@ -1,5 +1,5 @@
/* One way encryption based on MD5 sum.
- Copyright (C) 1996, 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1996,1997,1999,2000,2001,2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -233,8 +233,10 @@ __md5_crypt_r (key, salt, buffer, buflen
return buffer;
}
-
-static char *buffer;
+#ifndef _LIBC
+# define libc_freeres_ptr(decl) decl
+#endif
+libc_freeres_ptr (static char *buffer);
char *
__md5_crypt (const char *key, const char *salt)
@@ -261,10 +263,11 @@ __md5_crypt (const char *key, const char
return __md5_crypt_r (key, salt, buffer, buflen);
}
-
+#ifndef _LIBC
static void
__attribute__ ((__destructor__))
free_mem (void)
{
free (buffer);
}
+#endif
--- libc/nss/getXXbyYY.c.jj 2001-08-23 18:48:43.000000000 +0200
+++ libc/nss/getXXbyYY.c 2002-10-26 00:17:58.000000000 +0200
@@ -86,7 +86,7 @@ extern int INTERNAL (REENTRANT_NAME) (AD
__libc_lock_define_initialized (static, lock);
/* This points to the static buffer used. */
-static char *buffer;
+libc_freeres_ptr (static char *buffer);
LOOKUP_TYPE *
@@ -162,13 +162,3 @@ done:
return result;
}
-
-
-/* Free all resources if necessary. */
-static void __attribute__ ((unused))
-free_mem (void)
-{
- free (buffer);
-}
-
-text_set_element (__libc_subfreeres, free_mem);
--- libc/nss/getXXent.c.jj 2001-08-23 18:48:43.000000000 +0200
+++ libc/nss/getXXent.c 2002-10-26 00:18:37.000000000 +0200
@@ -63,7 +63,7 @@ extern int INTERNAL (REENTRANT_GETNAME)
__libc_lock_define_initialized (static, lock);
/* This points to the static buffer used. */
-static char *buffer;
+libc_freeres_ptr (static char *buffer);
LOOKUP_TYPE *
@@ -87,13 +87,3 @@ GETFUNC_NAME (void)
__set_errno (save);
return result;
}
-
-
-/* Free all resources if necessary. */
-static void __attribute__ ((unused))
-free_mem (void)
-{
- free (buffer);
-}
-
-text_set_element (__libc_subfreeres, free_mem);
--- libc/pwd/fgetpwent.c.jj 2001-08-23 18:49:01.000000000 +0200
+++ libc/pwd/fgetpwent.c 2002-10-26 00:19:34.000000000 +0200
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991,1996,1997,1999,2000,2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -26,7 +26,7 @@
/* We need to protect the dynamic buffer handling. */
__libc_lock_define_initialized (static, lock);
-static char *buffer;
+libc_freeres_ptr (static char *buffer);
/* Read one entry from the given stream. */
struct passwd *
@@ -83,13 +83,3 @@ fgetpwent (FILE *stream)
return result;
}
-
-
-/* Free all resources if necessary. */
-static void __attribute__ ((unused))
-free_mem (void)
-{
- free (buffer);
-}
-
-text_set_element (__libc_subfreeres, free_mem);
--- libc/resolv/res_hconf.c.jj 2002-09-24 13:00:09.000000000 +0200
+++ libc/resolv/res_hconf.c 2002-10-26 00:20:39.000000000 +0200
@@ -489,6 +489,7 @@ _res_hconf_init (void)
/* List of known interfaces. */
+libc_freeres_ptr (
static struct netaddr
{
int addrtype;
@@ -500,7 +501,7 @@ static struct netaddr
u_int32_t mask;
} ipv4;
} u;
-} *ifaddrs;
+} *ifaddrs);
/* We need to protect the dynamic buffer handling. */
__libc_lock_define_initialized (static, lock);
@@ -657,13 +658,3 @@ _res_hconf_trim_domains (struct hostent
for (i = 0; hp->h_aliases[i]; ++i)
_res_hconf_trim_domain (hp->h_aliases[i]);
}
-
-
-/* Free all resources if necessary. */
-static void __attribute__ ((unused))
-free_mem (void)
-{
- free (ifaddrs);
-}
-
-text_set_element (__libc_subfreeres, free_mem);
--- libc/shadow/fgetspent.c.jj 2001-08-23 18:49:01.000000000 +0200
+++ libc/shadow/fgetspent.c 2002-10-26 00:21:13.000000000 +0200
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -29,7 +29,7 @@
/* We need to protect the dynamic buffer handling. */
__libc_lock_define_initialized (static, lock);
-static char *buffer;
+libc_freeres_ptr (static char *buffer);
/* Read one shadow entry from the given stream. */
struct spwd *
@@ -86,13 +86,3 @@ fgetspent (FILE *stream)
return result;
}
-
-
-/* Free all resources if necessary. */
-static void __attribute__ ((unused))
-free_mem (void)
-{
- free (buffer);
-}
-
-text_set_element (__libc_subfreeres, free_mem);
--- libc/stdio-common/reg-printf.c.jj 2002-03-23 11:50:55.000000000 +0100
+++ libc/stdio-common/reg-printf.c 2002-10-26 00:31:44.000000000 +0200
@@ -21,10 +21,8 @@
#include <printf.h>
/* Array of functions indexed by format character. */
-static printf_function *printf_funcs[UCHAR_MAX + 1];
-printf_arginfo_function *__printf_arginfo_table[UCHAR_MAX + 1]
- attribute_hidden;
-
+libc_freeres_ptr (printf_arginfo_function **__printf_arginfo_table)
+ attribute_hidden;
printf_function **__printf_function_table attribute_hidden;
int __register_printf_function __P ((int, printf_function,
@@ -43,9 +41,18 @@ __register_printf_function (spec, conver
return -1;
}
- __printf_function_table = printf_funcs;
+ if (__printf_function_table == NULL)
+ {
+ __printf_arginfo_table = (printf_arginfo_function **)
+ malloc ((UCHAR_MAX + 1) * sizeof (void *) * 2);
+ if (__printf_arginfo_table == NULL)
+ return -1;
+ __printf_function_table = (printf_function **)
+ (__printf_arginfo_table + UCHAR_MAX + 1);
+ }
+
+ __printf_function_table[spec] = converter;
__printf_arginfo_table[spec] = arginfo;
- printf_funcs[spec] = converter;
return 0;
}
--- libc/stdio-common/printf-parse.h.jj 2002-03-23 11:50:55.000000000 +0100
+++ libc/stdio-common/printf-parse.h 2002-10-25 17:19:29.000000000 +0200
@@ -117,7 +117,7 @@ find_spec (const UCHAR_T *format, mbstat
/* These are defined in reg-printf.c. */
-extern printf_arginfo_function *__printf_arginfo_table[] attribute_hidden;
+extern printf_arginfo_function **__printf_arginfo_table attribute_hidden;
extern printf_function **__printf_function_table attribute_hidden;
@@ -354,7 +354,7 @@ parse_one_spec (const UCHAR_T *format, s
/* Get the format specification. */
spec->info.spec = (wchar_t) *format++;
- if (__printf_function_table != NULL
+ if (__builtin_expect (__printf_function_table != NULL, 0)
&& spec->info.spec <= UCHAR_MAX
&& __printf_arginfo_table[spec->info.spec] != NULL)
/* We don't try to get the types for all arguments if the format
--- libc/sysdeps/posix/ttyname.c.jj 2001-08-23 18:50:12.000000000 +0200
+++ libc/sysdeps/posix/ttyname.c 2002-10-26 00:24:43.000000000 +0200
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 96, 97, 98, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,93,96,97,98,2000,2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -32,7 +32,7 @@ static char *getttyname (int fd, dev_t m
int save, int *dostat) internal_function;
-static char *getttyname_name;
+libc_freeres_ptr (static char *getttyname_name);
static char *
internal_function
@@ -134,11 +134,3 @@ ttyname (fd)
return name;
}
-
-
-static void
-free_mem (void)
-{
- free (getttyname_name);
-}
-text_set_element (__libc_subfreeres, free_mem);
--- libc/sysdeps/unix/sysv/linux/getsysstats.c.jj 2002-09-24 13:00:11.000000000 +0200
+++ libc/sysdeps/unix/sysv/linux/getsysstats.c 2002-10-26 00:25:32.000000000 +0200
@@ -38,7 +38,7 @@
static const char path_proc[] = "/proc";
/* Actual mount point of /proc filesystem. */
-static char *mount_proc;
+libc_freeres_ptr (static char *mount_proc);
/* Determine the path to the /proc filesystem if available. */
static const char *
@@ -319,11 +319,3 @@ __get_avphys_pages ()
return phys_pages_info ("MemFree: %ld kB");
}
weak_alias (__get_avphys_pages, get_avphys_pages)
-
-
-static void
-free_mem (void)
-{
- free (mount_proc);
-}
-text_set_element (__libc_subfreeres, free_mem);
--- libc/sysdeps/unix/sysv/linux/ttyname.c.jj 2002-09-24 13:00:11.000000000 +0200
+++ libc/sysdeps/unix/sysv/linux/ttyname.c 2002-10-26 00:30:15.000000000 +0200
@@ -38,7 +38,7 @@ static char *getttyname (const char *dev
internal_function;
-static char *getttyname_name;
+libc_freeres_ptr (static char *getttyname_name);
static char *
internal_function
@@ -103,7 +103,7 @@ getttyname (const char *dev, dev_t mydev
/* Static buffer in `ttyname'. */
-static char *ttyname_buf;
+libc_freeres_ptr (static char *ttyname_buf);
/* Return the pathname of the terminal FD is open on, or NULL on errors.
@@ -186,12 +186,3 @@ ttyname (int fd)
return name;
}
-
-
-static void
-free_mem (void)
-{
- free (ttyname_buf);
- free (getttyname_name);
-}
-text_set_element (__libc_subfreeres, free_mem);
--- libc/Makerules.jj 2002-10-17 13:34:18.000000000 +0200
+++ libc/Makerules 2002-10-26 01:56:52.000000000 +0200
@@ -447,7 +447,7 @@ $(build-shlib-helper) \
$(LDLIBS-$(@F:lib%.so=%).so) 2>&1 | \
sed -e '/^=========/,/^=========/!d;/^=========/d' \
-e 's/^.*\.hash[ ]*:.*$$/ .note.ABI-tag : { *(.note.ABI-tag) } &/' \
- > $@.lds
+ $(LDSEDCMD-$(@F:lib%.so=%).so) > $@.lds
rm -f $@.new
$(build-shlib-helper) -o $@ -T $@.lds \
$(csu-objpfx)abi-note.o $(build-shlib-objlist)
@@ -548,6 +548,7 @@ ifeq ($(elf),yes)
$(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a
$(LINK.o) -nostdlib -nostartfiles -r -o $@ \
$(LDFLAGS-c_pic.os) -Wl,-d -Wl,--whole-archive $^
+LDSEDCMD-c.so = -e 's/^.*\*(\.dynbss).*$$/& __start___libc_freeres_ptrs = .; *(__libc_freeres_ptrs) __stop___libc_freeres_ptrs = .;/'
# Use our own special initializer and finalizer files for libc.so.
$(common-objpfx)libc.so: $(elfobjdir)/soinit.os \
$(common-objpfx)libc_pic.os \
Jakub
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-10-26 0:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-25 22:41 [PATCH] Optimize some free_mem handlers, save 4K from .bss Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).