diff options
author | Christopher Faylor <me+cygwin@cgf.cx> | 2003-07-05 02:58:29 +0000 |
---|---|---|
committer | Christopher Faylor <me+cygwin@cgf.cx> | 2003-07-05 02:58:29 +0000 |
commit | bf7a6389e81782655f363fbeda9b5d16d5f6fdac (patch) | |
tree | 429b4b8080da6c50c7a4556d902ba102c3833f3a /binutils | |
parent | dbb9d0f3eee9d21097d4cf7ab4f3b49e53ae22ed (diff) | |
download | gdb-bf7a6389e81782655f363fbeda9b5d16d5f6fdac.zip gdb-bf7a6389e81782655f363fbeda9b5d16d5f6fdac.tar.gz gdb-bf7a6389e81782655f363fbeda9b5d16d5f6fdac.tar.bz2 |
* dlltool.c (prefix_encode): New function. Encode temp file prefix from pid.
(dlltmp): Pass address of pointer being alloced or suffer neverending mallocs.
(make_one_lib_file): Allocate enough space for new longer stub names.
(gen_lib_file): Ditto.
(main): Generate the temp file prefix from the pid if prefix was not specified
on the command line.
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/ChangeLog | 11 | ||||
-rw-r--r-- | binutils/dlltool.c | 48 |
2 files changed, 45 insertions, 14 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 897cc66..2617875 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,14 @@ +2003-07-04 Christopher Faylor <cgf@redhat.com> + + * dlltool.c (prefix_encode): New function. Encode temp file prefix + from pid. + (dlltmp): Pass address of pointer being alloced or suffer neverending + mallocs. + (make_one_lib_file): Allocate enough space for new longer stub names. + (gen_lib_file): Ditto. + (main): Generate the temp file prefix from the pid if prefix was not + specified on the command line. + 2003-07-04 Nick Clifton <nickc@redhat.com> * readelf.c (get_data): Print (unsigned) hex values for size and diff --git a/binutils/dlltool.c b/binutils/dlltool.c index 81b6b92..544602b 100644 --- a/binutils/dlltool.c +++ b/binutils/dlltool.c @@ -350,7 +350,7 @@ static iheadtype *import_list = NULL; static char *as_name = NULL; static char * as_flags = ""; -static char *tmp_prefix = "d"; +static char *tmp_prefix; static int no_idata4; static int no_idata5; @@ -440,12 +440,12 @@ char *tmp_tail_s_buf; char *tmp_tail_o_buf; char *tmp_stub_buf; -#define TMP_ASM dlltmp (tmp_asm_buf, "%sc.s") -#define TMP_HEAD_S dlltmp (tmp_head_s_buf, "%sh.s") -#define TMP_HEAD_O dlltmp (tmp_head_o_buf, "%sh.o") -#define TMP_TAIL_S dlltmp (tmp_tail_s_buf, "%st.s") -#define TMP_TAIL_O dlltmp (tmp_tail_o_buf, "%st.o") -#define TMP_STUB dlltmp (tmp_stub_buf, "%ss") +#define TMP_ASM dlltmp (&tmp_asm_buf, "%sc.s") +#define TMP_HEAD_S dlltmp (&tmp_head_s_buf, "%sh.s") +#define TMP_HEAD_O dlltmp (&tmp_head_o_buf, "%sh.o") +#define TMP_TAIL_S dlltmp (&tmp_tail_s_buf, "%st.s") +#define TMP_TAIL_O dlltmp (&tmp_tail_o_buf, "%st.o") +#define TMP_STUB dlltmp (&tmp_stub_buf, "%ss") /* This bit of assemly does jmp * .... */ static const unsigned char i386_jtab[] = @@ -751,14 +751,31 @@ static void inform PARAMS ((const char *, ...)); static char * -dlltmp PARAMS ((char *buf, const char *fmt)) -{ - if (!buf) - buf = malloc (strlen (tmp_prefix) + 17); - sprintf (buf, fmt, tmp_prefix); +prefix_encode PARAMS ((char *start, unsigned code)) +{ + static char alpha[] = "abcdefghijklmnopqrstuvwxyz"; + static char buf[32]; + char *p; + strcpy (buf, start); + p = strchr (buf, '\0'); + do + *p++ = alpha[code % sizeof (alpha)]; + while ((code /= sizeof (alpha)) != 0); + *p = '\0'; return buf; } +static char * +dlltmp PARAMS ((char **buf, const char *fmt)) +{ + if (!*buf) + { + *buf = malloc (strlen (tmp_prefix) + 64); + sprintf (*buf, fmt, tmp_prefix); + } + return *buf; +} + static void inform VPARAMS ((const char * message, ...)) { @@ -2348,7 +2365,7 @@ make_one_lib_file (exp, i) asymbol * ptrs[NSECS + 4 + EXTRA + 1]; flagword applicable; - char * outname = xmalloc (10); + char * outname = xmalloc (strlen (TMP_STUB) + 10); int oidx = 0; @@ -2925,7 +2942,7 @@ gen_lib_file () { char *name; - name = (char *) alloca (sizeof TMP_STUB + 10); + name = (char *) alloca (strlen (TMP_STUB) + 10); for (i = 0, exp = d_exports; exp; i++, exp = exp->next) { sprintf (name, "%s%05d.o", TMP_STUB, i); @@ -3421,6 +3438,9 @@ main (ac, av) } } + if (!tmp_prefix) + tmp_prefix = prefix_encode ("d", getpid ()); + for (i = 0; mtable[i].type; i++) if (strcmp (mtable[i].type, mname) == 0) break; |