Create ELF aliases for identical symbols

This change greatly reduces the number of modules that need to be
compiled. The only issue right now is that sometimes when viewing
symbol table entries, the aliased symbol is chosen.
This commit is contained in:
Justine Tunney 2023-06-06 03:30:37 -07:00
parent e1b83399bd
commit b8a6a989c0
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
191 changed files with 414 additions and 2190 deletions

View file

@ -193,7 +193,7 @@ ar_glob_match (int desc UNUSED, const char *mem, int truncated UNUSED,
if (fnmatch (state->pattern, mem, FNM_PATHNAME|FNM_PERIOD) == 0)
{
/* We have a match. Add it to the chain. */
struct nameseq *new = xcalloc (state->size);
struct nameseq *new = xcalloc (1, state->size);
new->name = strcache_add(concat(4, state->arname, "(", mem, ")"));
new->next = state->chain;
state->chain = new;

View file

@ -15,6 +15,7 @@ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
#include "libc/x/x.h"
/* Structure used in chains of names, for parsing and globbing. */
@ -98,7 +99,7 @@ struct nameseq *ar_glob (const char *arname, const char *member_pattern, size_t
#define dep_name(d) ((d)->name ? (d)->name : (d)->file->name)
#define alloc_seq_elt(_t) xcalloc (sizeof (_t))
#define alloc_seq_elt(_t) xcalloc (1, sizeof (_t))
void free_ns_chain (struct nameseq *n);
#if defined(MAKE_MAINTAINER_MODE) && defined(__GNUC__) && !defined(__STRICT_ANSI__)

View file

@ -17,6 +17,7 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#include "third_party/make/makeint.inc"
/**/
#include "libc/calls/struct/dirent.h"
#include "libc/x/x.h"
#include "third_party/make/dep.h"
#include "third_party/make/filedef.h"
#include "third_party/make/hash.h"
@ -584,7 +585,7 @@ void file_impossible(const char *filename) {
if (dir->contents == 0)
/* The directory could not be stat'd. We allocate a contents
structure for it, but leave it out of the contents hash table. */
dir->contents = xcalloc(sizeof(struct directory_contents));
dir->contents = xcalloc(1, sizeof(struct directory_contents));
if (dir->contents->dirfiles.ht_vec == 0) {
hash_init(&dir->contents->dirfiles, DIRFILE_BUCKETS, dirfile_hash_1,

View file

@ -21,6 +21,7 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#include "third_party/make/job.h"
#include "third_party/make/commands.h"
#include "third_party/make/variable.h"
#include "libc/x/x.h"
#include "third_party/make/rule.h"
/* Initially, any errors reported when expanding strings will be reported

View file

@ -130,7 +130,7 @@ enter_file (const char *name)
return f;
}
new = xcalloc (sizeof (struct file));
new = xcalloc (1, sizeof (struct file));
new->name = new->hname = name;
new->update_status = us_none;

View file

@ -21,10 +21,11 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#include "libc/intrin/bsr.h"
#include "libc/intrin/likely.h"
#include "libc/log/check.h"
#include "libc/x/x.h"
#include "third_party/make/hash.h"
/* clang-format off */
#define CALLOC(t, n) ((t *) xcalloc (sizeof (t) * (n)))
#define CALLOC(t, n) ((t *) xcalloc (1, sizeof (t) * (n)))
#define MALLOC(t, n) ((t *) xmalloc (sizeof (t) * (n)))
#define REALLOC(o, t, n) ((t *) xrealloc ((o), sizeof (t) * (n)))
#define CLONE(o, t, n) ((t *) memcpy (MALLOC (t, (n)), (o), sizeof (t) * (n)))

View file

@ -1315,7 +1315,7 @@ new_job (struct file *file)
/* Start the command sequence, record it in a new
'struct child', and add that to the chain. */
c = xcalloc (sizeof (struct child));
c = xcalloc (1, sizeof (struct child));
output_init (&c->output);
c->file = file;

View file

@ -50,7 +50,6 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#include "libc/sysv/consts/w.h"
#include "libc/time/struct/tm.h"
#include "libc/time/time.h"
#include "libc/x/x.h"
#include "third_party/gdtoa/gdtoa.h"
#include "third_party/musl/glob.h"
/* clang-format off */
@ -395,8 +394,6 @@ void pfatal_with_name (const char *) NORETURN;
void perror_with_name (const char *, const char *);
#define xstrlen(_s) ((_s)==NULL ? 0 : strlen (_s))
void *xmalloc (size_t);
// void *xcalloc (size_t);
#define xcalloc(size) ((xcalloc)(1, (size)))
void *xrealloc (void *, size_t);
char *xstrdup (const char *);
char *xstrndup (const char *, size_t);

View file

@ -3121,7 +3121,7 @@ parse_file_seq (char **stringp, size_t size, int stopmap,
struct nameseq **newp = &new;
#define NEWELT(_n) do { \
const char *__n = (_n); \
*newp = xcalloc (size); \
*newp = xcalloc (1, size); \
(*newp)->name = (cachep ? strcache_add (__n) : xstrdup (__n)); \
newp = &(*newp)->next; \
} while(0)

View file

@ -47,7 +47,7 @@ struct pattern_var *
create_pattern_var (const char *target, const char *suffix)
{
size_t len = strlen (target);
struct pattern_var *p = xcalloc (sizeof (struct pattern_var));
struct pattern_var *p = xcalloc (1, sizeof (struct pattern_var));
if (pattern_vars != 0)
{
@ -235,7 +235,7 @@ define_variable_in_set (const char *name, size_t length,
/* Create a new variable definition and add it to the hash table. */
v = xcalloc (sizeof (struct variable));
v = xcalloc (1, sizeof (struct variable));
v->name = xstrndup (name, length);
v->length = (unsigned int) length;
hash_insert_at (&set->table, v, var_slot);

View file

@ -164,7 +164,7 @@ compile(void)
fixuplabel(prog, NULL);
uselabel();
if (appendnum > 0)
appends = xmalloc(sizeof(struct s_appends) * appendnum);
appends_ = xmalloc(sizeof(struct s_appends) * appendnum);
g_match = xmalloc((maxnsub + 1) * sizeof(regmatch_t));
}

View file

@ -9,7 +9,7 @@ COSMOPOLITAN_C_START_
// clang-format off
extern struct s_command *prog;
extern struct s_appends *appends;
extern struct s_appends *appends_;
extern regmatch_t *g_match;
extern size_t maxnsub;
extern u_long linenum;

View file

@ -33,7 +33,6 @@
#include "libc/thread/thread.h"
#include "libc/calls/typedef/u.h"
#include "libc/calls/weirdtypes.h"
#include "libc/intrin/newbie.h"
#include "libc/sock/select.h"
#include "libc/sysv/consts/endian.h"
#include "libc/calls/calls.h"

View file

@ -702,7 +702,6 @@ char *d; /* directory to delete */
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__386BSD__) || \
defined(__OpenBSD__) || defined(__bsdi__)
#include "libc/intrin/newbie.h"
#include "libc/calls/calls.h"
#include "libc/calls/struct/rlimit.h"
#include "libc/calls/struct/rusage.h"