mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-11-22 17:01:40 +03:00
binutils: build objcopy.
git-svn-id: svn://kolibrios.org@5217 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
c89ace2cf3
commit
c0ef1058c9
@ -15,7 +15,7 @@ CFLAGS = -c $(CFLAGS_OPT)
|
|||||||
LDFLAGS = -nostdlib -shared -s --image-base 0 -T ../newlib/dll.lds -e _DllStartup
|
LDFLAGS = -nostdlib -shared -s --image-base 0 -T ../newlib/dll.lds -e _DllStartup
|
||||||
LDFLAGS+= --out-implib
|
LDFLAGS+= --out-implib
|
||||||
|
|
||||||
SUBDIRS = libiberty bfd ld
|
SUBDIRS = libiberty bfd binutils ld
|
||||||
|
|
||||||
# targets
|
# targets
|
||||||
|
|
||||||
|
43
contrib/toolchain/binutils/binutils/Makefile
Normal file
43
contrib/toolchain/binutils/binutils/Makefile
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
NAME= objcopy-new
|
||||||
|
|
||||||
|
LIB_DIR:= $(SDK_DIR)/lib
|
||||||
|
|
||||||
|
CFLAGS_OPT = -U_Win32 -U_WIN32 -U__MINGW32__ -UWIN32 -U_MSC_VER -O2
|
||||||
|
CFLAGS_OPT+= -fomit-frame-pointer -fno-ident -mno-ms-bitfields
|
||||||
|
CFLAGS_OPT+= -W -Wall -Wmissing-prototypes -Wno-format
|
||||||
|
CFLAGS = -c $(CFLAGS_OPT)
|
||||||
|
|
||||||
|
INCLUDES= -I. -I../bfd -I../include -I$(SDK_DIR)/sources/newlib/libc/include
|
||||||
|
|
||||||
|
DEFINES= -DHAVE_CONFIG_H -DLOCALEDIR='"/home/autobuild/tools/win32/share/locale"'
|
||||||
|
DEFINES+= -Dbin_dummy_emulation=bin_vanilla_emulation
|
||||||
|
|
||||||
|
LIBS= -lbfd -liberty -lz -lgcc -lc.dll -lapp
|
||||||
|
|
||||||
|
LIBPATH:= -L$(LIB_DIR) -L/home/autobuild/tools/win32/mingw32/lib
|
||||||
|
|
||||||
|
LDFLAGS = -static -nostdlib --stack 12582912 -T$(SDK_DIR)/sources/newlib/app.lds --image-base 0
|
||||||
|
|
||||||
|
|
||||||
|
SRCS = \
|
||||||
|
objcopy.c not-strip.c rename.c \
|
||||||
|
rddbg.c debug.c stabs.c ieee.c \
|
||||||
|
rdcoff.c wrstabs.c bucomm.c \
|
||||||
|
version.c filemode.c
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
OBJS = $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS)))
|
||||||
|
|
||||||
|
# targets
|
||||||
|
|
||||||
|
all: $(NAME)
|
||||||
|
|
||||||
|
$(NAME): $(OBJS) Makefile
|
||||||
|
$(LD) $(LDFLAGS) $(LIBPATH) -o $@ $(OBJS) $(LIBS)
|
||||||
|
kos32-objcopy $@ kos32-objcopy -O binary
|
||||||
|
|
||||||
|
%.o : %.c Makefile
|
||||||
|
$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $<
|
||||||
|
|
||||||
|
|
629
contrib/toolchain/binutils/binutils/bucomm.c
Normal file
629
contrib/toolchain/binutils/binutils/bucomm.c
Normal file
@ -0,0 +1,629 @@
|
|||||||
|
/* bucomm.c -- Bin Utils COMmon code.
|
||||||
|
Copyright 1991, 1992, 1993, 1994, 1995, 1997, 1998, 2000, 2001, 2002,
|
||||||
|
2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GNU Binutils.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR 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, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
|
||||||
|
02110-1301, USA. */
|
||||||
|
|
||||||
|
/* We might put this in a library someday so it could be dynamically
|
||||||
|
loaded, but for now it's not necessary. */
|
||||||
|
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "libiberty.h"
|
||||||
|
#include "filenames.h"
|
||||||
|
#include "libbfd.h"
|
||||||
|
|
||||||
|
#include <time.h> /* ctime, maybe time_t */
|
||||||
|
#include <assert.h>
|
||||||
|
#include "bucomm.h"
|
||||||
|
|
||||||
|
#ifndef HAVE_TIME_T_IN_TIME_H
|
||||||
|
#ifndef HAVE_TIME_T_IN_TYPES_H
|
||||||
|
typedef long time_t;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static const char * endian_string (enum bfd_endian);
|
||||||
|
static int display_target_list (void);
|
||||||
|
static int display_info_table (int, int);
|
||||||
|
static int display_target_tables (void);
|
||||||
|
|
||||||
|
/* Error reporting. */
|
||||||
|
|
||||||
|
char *program_name;
|
||||||
|
|
||||||
|
void
|
||||||
|
bfd_nonfatal (const char *string)
|
||||||
|
{
|
||||||
|
const char *errmsg;
|
||||||
|
|
||||||
|
errmsg = bfd_errmsg (bfd_get_error ());
|
||||||
|
fflush (stdout);
|
||||||
|
if (string)
|
||||||
|
fprintf (stderr, "%s: %s: %s\n", program_name, string, errmsg);
|
||||||
|
else
|
||||||
|
fprintf (stderr, "%s: %s\n", program_name, errmsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Issue a non fatal error message. FILENAME, or if NULL then BFD,
|
||||||
|
are used to indicate the problematic file. SECTION, if non NULL,
|
||||||
|
is used to provide a section name. If FORMAT is non-null, then it
|
||||||
|
is used to print additional information via vfprintf. Finally the
|
||||||
|
bfd error message is printed. In summary, error messages are of
|
||||||
|
one of the following forms:
|
||||||
|
|
||||||
|
PROGRAM:file: bfd-error-message
|
||||||
|
PROGRAM:file[section]: bfd-error-message
|
||||||
|
PROGRAM:file: printf-message: bfd-error-message
|
||||||
|
PROGRAM:file[section]: printf-message: bfd-error-message. */
|
||||||
|
|
||||||
|
void
|
||||||
|
bfd_nonfatal_message (const char *filename,
|
||||||
|
const bfd *abfd,
|
||||||
|
const asection *section,
|
||||||
|
const char *format, ...)
|
||||||
|
{
|
||||||
|
const char *errmsg;
|
||||||
|
const char *section_name;
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
errmsg = bfd_errmsg (bfd_get_error ());
|
||||||
|
fflush (stdout);
|
||||||
|
section_name = NULL;
|
||||||
|
va_start (args, format);
|
||||||
|
fprintf (stderr, "%s", program_name);
|
||||||
|
|
||||||
|
if (abfd)
|
||||||
|
{
|
||||||
|
if (!filename)
|
||||||
|
filename = bfd_get_archive_filename (abfd);
|
||||||
|
if (section)
|
||||||
|
section_name = bfd_get_section_name (abfd, section);
|
||||||
|
}
|
||||||
|
if (section_name)
|
||||||
|
fprintf (stderr, ":%s[%s]", filename, section_name);
|
||||||
|
else
|
||||||
|
fprintf (stderr, ":%s", filename);
|
||||||
|
|
||||||
|
if (format)
|
||||||
|
{
|
||||||
|
fprintf (stderr, ": ");
|
||||||
|
vfprintf (stderr, format, args);
|
||||||
|
}
|
||||||
|
fprintf (stderr, ": %s\n", errmsg);
|
||||||
|
va_end (args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
bfd_fatal (const char *string)
|
||||||
|
{
|
||||||
|
bfd_nonfatal (string);
|
||||||
|
xexit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
report (const char * format, va_list args)
|
||||||
|
{
|
||||||
|
fflush (stdout);
|
||||||
|
fprintf (stderr, "%s: ", program_name);
|
||||||
|
vfprintf (stderr, format, args);
|
||||||
|
putc ('\n', stderr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
fatal VPARAMS ((const char *format, ...))
|
||||||
|
{
|
||||||
|
VA_OPEN (args, format);
|
||||||
|
VA_FIXEDARG (args, const char *, format);
|
||||||
|
|
||||||
|
report (format, args);
|
||||||
|
VA_CLOSE (args);
|
||||||
|
xexit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
non_fatal VPARAMS ((const char *format, ...))
|
||||||
|
{
|
||||||
|
VA_OPEN (args, format);
|
||||||
|
VA_FIXEDARG (args, const char *, format);
|
||||||
|
|
||||||
|
report (format, args);
|
||||||
|
VA_CLOSE (args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the default BFD target based on the configured target. Doing
|
||||||
|
this permits the binutils to be configured for a particular target,
|
||||||
|
and linked against a shared BFD library which was configured for a
|
||||||
|
different target. */
|
||||||
|
|
||||||
|
void
|
||||||
|
set_default_bfd_target (void)
|
||||||
|
{
|
||||||
|
/* The macro TARGET is defined by Makefile. */
|
||||||
|
const char *target = TARGET;
|
||||||
|
|
||||||
|
if (! bfd_set_default_target (target))
|
||||||
|
fatal (_("can't set BFD default target to `%s': %s"),
|
||||||
|
target, bfd_errmsg (bfd_get_error ()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* After a FALSE return from bfd_check_format_matches with
|
||||||
|
bfd_get_error () == bfd_error_file_ambiguously_recognized, print
|
||||||
|
the possible matching targets. */
|
||||||
|
|
||||||
|
void
|
||||||
|
list_matching_formats (char **p)
|
||||||
|
{
|
||||||
|
fflush (stdout);
|
||||||
|
fprintf (stderr, _("%s: Matching formats:"), program_name);
|
||||||
|
while (*p)
|
||||||
|
fprintf (stderr, " %s", *p++);
|
||||||
|
fputc ('\n', stderr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* List the supported targets. */
|
||||||
|
|
||||||
|
void
|
||||||
|
list_supported_targets (const char *name, FILE *f)
|
||||||
|
{
|
||||||
|
int t;
|
||||||
|
const char **targ_names;
|
||||||
|
|
||||||
|
if (name == NULL)
|
||||||
|
fprintf (f, _("Supported targets:"));
|
||||||
|
else
|
||||||
|
fprintf (f, _("%s: supported targets:"), name);
|
||||||
|
|
||||||
|
targ_names = bfd_target_list ();
|
||||||
|
for (t = 0; targ_names[t] != NULL; t++)
|
||||||
|
fprintf (f, " %s", targ_names[t]);
|
||||||
|
fprintf (f, "\n");
|
||||||
|
free (targ_names);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* List the supported architectures. */
|
||||||
|
|
||||||
|
void
|
||||||
|
list_supported_architectures (const char *name, FILE *f)
|
||||||
|
{
|
||||||
|
const char ** arch;
|
||||||
|
const char ** arches;
|
||||||
|
|
||||||
|
if (name == NULL)
|
||||||
|
fprintf (f, _("Supported architectures:"));
|
||||||
|
else
|
||||||
|
fprintf (f, _("%s: supported architectures:"), name);
|
||||||
|
|
||||||
|
for (arch = arches = bfd_arch_list (); *arch; arch++)
|
||||||
|
fprintf (f, " %s", *arch);
|
||||||
|
fprintf (f, "\n");
|
||||||
|
free (arches);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The length of the longest architecture name + 1. */
|
||||||
|
#define LONGEST_ARCH sizeof ("powerpc:common")
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
endian_string (enum bfd_endian endian)
|
||||||
|
{
|
||||||
|
switch (endian)
|
||||||
|
{
|
||||||
|
case BFD_ENDIAN_BIG: return _("big endian");
|
||||||
|
case BFD_ENDIAN_LITTLE: return _("little endian");
|
||||||
|
default: return _("endianness unknown");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* List the targets that BFD is configured to support, each followed
|
||||||
|
by its endianness and the architectures it supports. */
|
||||||
|
|
||||||
|
static int
|
||||||
|
display_target_list (void)
|
||||||
|
{
|
||||||
|
char *dummy_name;
|
||||||
|
int t;
|
||||||
|
int ret = 1;
|
||||||
|
|
||||||
|
dummy_name = make_temp_file (NULL);
|
||||||
|
for (t = 0; bfd_target_vector[t]; t++)
|
||||||
|
{
|
||||||
|
const bfd_target *p = bfd_target_vector[t];
|
||||||
|
bfd *abfd = bfd_openw (dummy_name, p->name);
|
||||||
|
int a;
|
||||||
|
|
||||||
|
printf (_("%s\n (header %s, data %s)\n"), p->name,
|
||||||
|
endian_string (p->header_byteorder),
|
||||||
|
endian_string (p->byteorder));
|
||||||
|
|
||||||
|
if (abfd == NULL)
|
||||||
|
{
|
||||||
|
bfd_nonfatal (dummy_name);
|
||||||
|
ret = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! bfd_set_format (abfd, bfd_object))
|
||||||
|
{
|
||||||
|
if (bfd_get_error () != bfd_error_invalid_operation)
|
||||||
|
{
|
||||||
|
bfd_nonfatal (p->name);
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
bfd_close_all_done (abfd);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (a = bfd_arch_obscure + 1; a < bfd_arch_last; a++)
|
||||||
|
if (bfd_set_arch_mach (abfd, (enum bfd_architecture) a, 0))
|
||||||
|
printf (" %s\n",
|
||||||
|
bfd_printable_arch_mach ((enum bfd_architecture) a, 0));
|
||||||
|
bfd_close_all_done (abfd);
|
||||||
|
}
|
||||||
|
unlink (dummy_name);
|
||||||
|
free (dummy_name);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print a table showing which architectures are supported for entries
|
||||||
|
FIRST through LAST-1 of bfd_target_vector (targets across,
|
||||||
|
architectures down). */
|
||||||
|
|
||||||
|
static int
|
||||||
|
display_info_table (int first, int last)
|
||||||
|
{
|
||||||
|
int t;
|
||||||
|
int ret = 1;
|
||||||
|
char *dummy_name;
|
||||||
|
int a;
|
||||||
|
|
||||||
|
/* Print heading of target names. */
|
||||||
|
printf ("\n%*s", (int) LONGEST_ARCH, " ");
|
||||||
|
for (t = first; t < last && bfd_target_vector[t]; t++)
|
||||||
|
printf ("%s ", bfd_target_vector[t]->name);
|
||||||
|
putchar ('\n');
|
||||||
|
|
||||||
|
dummy_name = make_temp_file (NULL);
|
||||||
|
for (a = bfd_arch_obscure + 1; a < bfd_arch_last; a++)
|
||||||
|
if (strcmp (bfd_printable_arch_mach ((enum bfd_architecture) a, 0),
|
||||||
|
"UNKNOWN!") != 0)
|
||||||
|
{
|
||||||
|
printf ("%*s ", (int) LONGEST_ARCH - 1,
|
||||||
|
bfd_printable_arch_mach ((enum bfd_architecture) a, 0));
|
||||||
|
for (t = first; t < last && bfd_target_vector[t]; t++)
|
||||||
|
{
|
||||||
|
const bfd_target *p = bfd_target_vector[t];
|
||||||
|
bfd_boolean ok = TRUE;
|
||||||
|
bfd *abfd = bfd_openw (dummy_name, p->name);
|
||||||
|
|
||||||
|
if (abfd == NULL)
|
||||||
|
{
|
||||||
|
bfd_nonfatal (p->name);
|
||||||
|
ret = 0;
|
||||||
|
ok = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
if (! bfd_set_format (abfd, bfd_object))
|
||||||
|
{
|
||||||
|
if (bfd_get_error () != bfd_error_invalid_operation)
|
||||||
|
{
|
||||||
|
bfd_nonfatal (p->name);
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
ok = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
if (! bfd_set_arch_mach (abfd, (enum bfd_architecture) a, 0))
|
||||||
|
ok = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ok)
|
||||||
|
printf ("%s ", p->name);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int l = strlen (p->name);
|
||||||
|
while (l--)
|
||||||
|
putchar ('-');
|
||||||
|
putchar (' ');
|
||||||
|
}
|
||||||
|
if (abfd != NULL)
|
||||||
|
bfd_close_all_done (abfd);
|
||||||
|
}
|
||||||
|
putchar ('\n');
|
||||||
|
}
|
||||||
|
unlink (dummy_name);
|
||||||
|
free (dummy_name);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print tables of all the target-architecture combinations that
|
||||||
|
BFD has been configured to support. */
|
||||||
|
|
||||||
|
static int
|
||||||
|
display_target_tables (void)
|
||||||
|
{
|
||||||
|
int t;
|
||||||
|
int columns;
|
||||||
|
int ret = 1;
|
||||||
|
char *colum;
|
||||||
|
|
||||||
|
columns = 0;
|
||||||
|
colum = getenv ("COLUMNS");
|
||||||
|
if (colum != NULL)
|
||||||
|
columns = atoi (colum);
|
||||||
|
if (columns == 0)
|
||||||
|
columns = 80;
|
||||||
|
|
||||||
|
t = 0;
|
||||||
|
while (bfd_target_vector[t] != NULL)
|
||||||
|
{
|
||||||
|
int oldt = t, wid;
|
||||||
|
|
||||||
|
wid = LONGEST_ARCH + strlen (bfd_target_vector[t]->name) + 1;
|
||||||
|
++t;
|
||||||
|
while (wid < columns && bfd_target_vector[t] != NULL)
|
||||||
|
{
|
||||||
|
int newwid;
|
||||||
|
|
||||||
|
newwid = wid + strlen (bfd_target_vector[t]->name) + 1;
|
||||||
|
if (newwid >= columns)
|
||||||
|
break;
|
||||||
|
wid = newwid;
|
||||||
|
++t;
|
||||||
|
}
|
||||||
|
if (! display_info_table (oldt, t))
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
display_info (void)
|
||||||
|
{
|
||||||
|
printf (_("BFD header file version %s\n"), BFD_VERSION_STRING);
|
||||||
|
if (! display_target_list () || ! display_target_tables ())
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Display the archive header for an element as if it were an ls -l listing:
|
||||||
|
|
||||||
|
Mode User\tGroup\tSize\tDate Name */
|
||||||
|
|
||||||
|
void
|
||||||
|
print_arelt_descr (FILE *file, bfd *abfd, bfd_boolean verbose)
|
||||||
|
{
|
||||||
|
struct stat buf;
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
if (bfd_stat_arch_elt (abfd, &buf) == 0)
|
||||||
|
{
|
||||||
|
char modebuf[11];
|
||||||
|
char timebuf[40];
|
||||||
|
time_t when = buf.st_mtime;
|
||||||
|
const char *ctime_result = (const char *) ctime (&when);
|
||||||
|
bfd_size_type size;
|
||||||
|
|
||||||
|
/* POSIX format: skip weekday and seconds from ctime output. */
|
||||||
|
sprintf (timebuf, "%.12s %.4s", ctime_result + 4, ctime_result + 20);
|
||||||
|
|
||||||
|
mode_string (buf.st_mode, modebuf);
|
||||||
|
modebuf[10] = '\0';
|
||||||
|
size = buf.st_size;
|
||||||
|
/* POSIX 1003.2/D11 says to skip first character (entry type). */
|
||||||
|
fprintf (file, "%s %ld/%ld %6" BFD_VMA_FMT "u %s ", modebuf + 1,
|
||||||
|
(long) buf.st_uid, (long) buf.st_gid,
|
||||||
|
size, timebuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (file, "%s\n", bfd_get_filename (abfd));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return a path for a new temporary file in the same directory
|
||||||
|
as file PATH. */
|
||||||
|
|
||||||
|
static char *
|
||||||
|
template_in_dir (const char *path)
|
||||||
|
{
|
||||||
|
#define template "stXXXXXX"
|
||||||
|
const char *slash = strrchr (path, '/');
|
||||||
|
char *tmpname;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
|
||||||
|
{
|
||||||
|
/* We could have foo/bar\\baz, or foo\\bar, or d:bar. */
|
||||||
|
char *bslash = strrchr (path, '\\');
|
||||||
|
|
||||||
|
if (slash == NULL || (bslash != NULL && bslash > slash))
|
||||||
|
slash = bslash;
|
||||||
|
if (slash == NULL && path[0] != '\0' && path[1] == ':')
|
||||||
|
slash = path + 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (slash != (char *) NULL)
|
||||||
|
{
|
||||||
|
len = slash - path;
|
||||||
|
tmpname = (char *) xmalloc (len + sizeof (template) + 2);
|
||||||
|
memcpy (tmpname, path, len);
|
||||||
|
|
||||||
|
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
|
||||||
|
/* If tmpname is "X:", appending a slash will make it a root
|
||||||
|
directory on drive X, which is NOT the same as the current
|
||||||
|
directory on drive X. */
|
||||||
|
if (len == 2 && tmpname[1] == ':')
|
||||||
|
tmpname[len++] = '.';
|
||||||
|
#endif
|
||||||
|
tmpname[len++] = '/';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmpname = (char *) xmalloc (sizeof (template));
|
||||||
|
len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy (tmpname + len, template, sizeof (template));
|
||||||
|
return tmpname;
|
||||||
|
#undef template
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the name of a created temporary file in the same directory
|
||||||
|
as FILENAME. */
|
||||||
|
|
||||||
|
char *
|
||||||
|
make_tempname (char *filename)
|
||||||
|
{
|
||||||
|
char *tmpname = template_in_dir (filename);
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
#ifdef HAVE_MKSTEMP
|
||||||
|
fd = mkstemp (tmpname);
|
||||||
|
#else
|
||||||
|
tmpname = mktemp (tmpname);
|
||||||
|
if (tmpname == NULL)
|
||||||
|
return NULL;
|
||||||
|
fd = open (tmpname, O_RDWR | O_CREAT | O_EXCL, 0600);
|
||||||
|
#endif
|
||||||
|
if (fd == -1)
|
||||||
|
{
|
||||||
|
free (tmpname);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
close (fd);
|
||||||
|
return tmpname;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the name of a created temporary directory inside the
|
||||||
|
directory containing FILENAME. */
|
||||||
|
|
||||||
|
char *
|
||||||
|
make_tempdir (char *filename)
|
||||||
|
{
|
||||||
|
char *tmpname = template_in_dir (filename);
|
||||||
|
|
||||||
|
/*
|
||||||
|
#ifdef HAVE_MKDTEMP
|
||||||
|
return mkdtemp (tmpname);
|
||||||
|
#else
|
||||||
|
tmpname = mktemp (tmpname);
|
||||||
|
if (tmpname == NULL)
|
||||||
|
return NULL;
|
||||||
|
#if defined (_WIN32) && !defined (__CYGWIN32__)
|
||||||
|
if (mkdir (tmpname) != 0)
|
||||||
|
return NULL;
|
||||||
|
#else
|
||||||
|
if (mkdir (tmpname, 0700) != 0)
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
return tmpname;
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Parse a string into a VMA, with a fatal error if it can't be
|
||||||
|
parsed. */
|
||||||
|
|
||||||
|
bfd_vma
|
||||||
|
parse_vma (const char *s, const char *arg)
|
||||||
|
{
|
||||||
|
bfd_vma ret;
|
||||||
|
const char *end;
|
||||||
|
|
||||||
|
ret = bfd_scan_vma (s, &end, 0);
|
||||||
|
|
||||||
|
if (*end != '\0')
|
||||||
|
fatal (_("%s: bad number: %s"), arg, s);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns the size of the named file. If the file does not
|
||||||
|
exist, or if it is not a real file, then a suitable non-fatal
|
||||||
|
error message is printed and (off_t) -1 is returned. */
|
||||||
|
|
||||||
|
off_t
|
||||||
|
get_file_size (const char * file_name)
|
||||||
|
{
|
||||||
|
struct stat statbuf;
|
||||||
|
|
||||||
|
if (stat (file_name, &statbuf) < 0)
|
||||||
|
{
|
||||||
|
if (errno == ENOENT)
|
||||||
|
non_fatal (_("'%s': No such file"), file_name);
|
||||||
|
else
|
||||||
|
non_fatal (_("Warning: could not locate '%s'. reason: %s"),
|
||||||
|
file_name, strerror (errno));
|
||||||
|
}
|
||||||
|
else if (! S_ISREG (statbuf.st_mode))
|
||||||
|
non_fatal (_("Warning: '%s' is not an ordinary file"), file_name);
|
||||||
|
else if (statbuf.st_size < 0)
|
||||||
|
non_fatal (_("Warning: '%s' has negative size, probably it is too large"),
|
||||||
|
file_name);
|
||||||
|
else
|
||||||
|
return statbuf.st_size;
|
||||||
|
|
||||||
|
return (off_t) -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the filename in a static buffer. */
|
||||||
|
|
||||||
|
const char *
|
||||||
|
bfd_get_archive_filename (const bfd *abfd)
|
||||||
|
{
|
||||||
|
static size_t curr = 0;
|
||||||
|
static char *buf;
|
||||||
|
size_t needed;
|
||||||
|
|
||||||
|
assert (abfd != NULL);
|
||||||
|
|
||||||
|
if (!abfd->my_archive)
|
||||||
|
return bfd_get_filename (abfd);
|
||||||
|
|
||||||
|
needed = (strlen (bfd_get_filename (abfd->my_archive))
|
||||||
|
+ strlen (bfd_get_filename (abfd)) + 3);
|
||||||
|
if (needed > curr)
|
||||||
|
{
|
||||||
|
if (curr)
|
||||||
|
free (buf);
|
||||||
|
curr = needed + (needed >> 1);
|
||||||
|
buf = (char *) bfd_malloc (curr);
|
||||||
|
/* If we can't malloc, fail safe by returning just the file name.
|
||||||
|
This function is only used when building error messages. */
|
||||||
|
if (!buf)
|
||||||
|
{
|
||||||
|
curr = 0;
|
||||||
|
return bfd_get_filename (abfd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sprintf (buf, "%s(%s)", bfd_get_filename (abfd->my_archive),
|
||||||
|
bfd_get_filename (abfd));
|
||||||
|
return buf;
|
||||||
|
}
|
79
contrib/toolchain/binutils/binutils/bucomm.h
Normal file
79
contrib/toolchain/binutils/binutils/bucomm.h
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
/* bucomm.h -- binutils common include file.
|
||||||
|
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
|
||||||
|
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GNU Binutils.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR 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, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
||||||
|
MA 02110-1301, USA. */
|
||||||
|
|
||||||
|
#ifndef _BUCOMM_H
|
||||||
|
#define _BUCOMM_H
|
||||||
|
|
||||||
|
/* Return the filename in a static buffer. */
|
||||||
|
const char *bfd_get_archive_filename (const bfd *);
|
||||||
|
|
||||||
|
void bfd_nonfatal (const char *);
|
||||||
|
|
||||||
|
void bfd_nonfatal_message (const char *, const bfd *, const asection *,
|
||||||
|
const char *, ...);
|
||||||
|
|
||||||
|
void bfd_fatal (const char *) ATTRIBUTE_NORETURN;
|
||||||
|
|
||||||
|
void report (const char *, va_list) ATTRIBUTE_PRINTF(1,0);
|
||||||
|
|
||||||
|
void fatal (const char *, ...) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
|
||||||
|
|
||||||
|
void non_fatal (const char *, ...) ATTRIBUTE_PRINTF_1;
|
||||||
|
|
||||||
|
void set_default_bfd_target (void);
|
||||||
|
|
||||||
|
void list_matching_formats (char **);
|
||||||
|
|
||||||
|
void list_supported_targets (const char *, FILE *);
|
||||||
|
|
||||||
|
void list_supported_architectures (const char *, FILE *);
|
||||||
|
|
||||||
|
int display_info (void);
|
||||||
|
|
||||||
|
void print_arelt_descr (FILE *, bfd *, bfd_boolean);
|
||||||
|
|
||||||
|
char *make_tempname (char *);
|
||||||
|
char *make_tempdir (char *);
|
||||||
|
|
||||||
|
bfd_vma parse_vma (const char *, const char *);
|
||||||
|
|
||||||
|
off_t get_file_size (const char *);
|
||||||
|
|
||||||
|
extern char *program_name;
|
||||||
|
|
||||||
|
/* filemode.c */
|
||||||
|
void mode_string (unsigned long, char *);
|
||||||
|
|
||||||
|
/* version.c */
|
||||||
|
extern void print_version (const char *);
|
||||||
|
|
||||||
|
/* rename.c */
|
||||||
|
extern void set_times (const char *, const struct stat *);
|
||||||
|
|
||||||
|
extern int smart_rename (const char *, const char *, int);
|
||||||
|
|
||||||
|
/* libiberty. */
|
||||||
|
void *xmalloc (size_t);
|
||||||
|
|
||||||
|
void *xrealloc (void *, size_t);
|
||||||
|
|
||||||
|
#endif /* _BUCOMM_H */
|
57
contrib/toolchain/binutils/binutils/budbg.h
Normal file
57
contrib/toolchain/binutils/binutils/budbg.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/* budbg.c -- Interfaces to the generic debugging information routines.
|
||||||
|
Copyright 1995, 1996, 2002, 2003, 2005, 2007, 2008, 2012
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor <ian@cygnus.com>.
|
||||||
|
|
||||||
|
This file is part of GNU Binutils.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR 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, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
|
||||||
|
02110-1301, USA. */
|
||||||
|
|
||||||
|
#ifndef BUDBG_H
|
||||||
|
#define BUDBG_H
|
||||||
|
|
||||||
|
/* Routine used to read generic debugging information. */
|
||||||
|
|
||||||
|
extern void *read_debugging_info (bfd *, asymbol **, long, bfd_boolean);
|
||||||
|
|
||||||
|
/* Routine used to print generic debugging information. */
|
||||||
|
|
||||||
|
extern bfd_boolean print_debugging_info
|
||||||
|
(FILE *, void *, bfd *, asymbol **, void *, bfd_boolean);
|
||||||
|
|
||||||
|
/* Routines used to read and write stabs information. */
|
||||||
|
|
||||||
|
extern void *start_stab (void *, bfd *, bfd_boolean, asymbol **, long);
|
||||||
|
|
||||||
|
extern bfd_boolean finish_stab (void *, void *);
|
||||||
|
|
||||||
|
extern bfd_boolean parse_stab
|
||||||
|
(void *, void *, int, int, bfd_vma, const char *);
|
||||||
|
|
||||||
|
extern bfd_boolean write_stabs_in_sections_debugging_info
|
||||||
|
(bfd *, void *, bfd_byte **, bfd_size_type *, bfd_byte **, bfd_size_type *);
|
||||||
|
|
||||||
|
/* Routines used to read and write IEEE debugging information. */
|
||||||
|
|
||||||
|
extern bfd_boolean parse_ieee (void *, bfd *, const bfd_byte *, bfd_size_type);
|
||||||
|
|
||||||
|
extern bfd_boolean write_ieee_debugging_info (bfd *, void *);
|
||||||
|
|
||||||
|
/* Routine used to read COFF debugging information. */
|
||||||
|
|
||||||
|
extern bfd_boolean parse_coff (bfd *, asymbol **, long, void *);
|
||||||
|
|
||||||
|
#endif
|
273
contrib/toolchain/binutils/binutils/config.h
Normal file
273
contrib/toolchain/binutils/binutils/config.h
Normal file
@ -0,0 +1,273 @@
|
|||||||
|
/* config.h. Generated from config.in by configure. */
|
||||||
|
/* config.in. Generated from configure.in by autoheader. */
|
||||||
|
|
||||||
|
/* Check that config.h is #included before system headers
|
||||||
|
(this works only for glibc, but that should be enough). */
|
||||||
|
#if defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__CONFIG_H__)
|
||||||
|
# error config.h must be #included before system headers
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define __CONFIG_H__ 1
|
||||||
|
|
||||||
|
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
|
||||||
|
systems. This function is required for `alloca.c' support on those systems.
|
||||||
|
*/
|
||||||
|
/* #undef CRAY_STACKSEG_END */
|
||||||
|
|
||||||
|
/* Define to 1 if using `alloca.c'. */
|
||||||
|
/* #undef C_ALLOCA */
|
||||||
|
|
||||||
|
/* Should ar and ranlib use -D behavior by default? */
|
||||||
|
#define DEFAULT_AR_DETERMINISTIC 0
|
||||||
|
|
||||||
|
/* Define to 1 if translation of program messages to the user's native
|
||||||
|
language is requested. */
|
||||||
|
/* #undef ENABLE_NLS */
|
||||||
|
|
||||||
|
/* Suffix used for executables, if any. */
|
||||||
|
#define EXECUTABLE_SUFFIX ".exe"
|
||||||
|
|
||||||
|
/* Define to 1 if you have `alloca', as a function or macro. */
|
||||||
|
#define HAVE_ALLOCA 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
|
||||||
|
*/
|
||||||
|
/* #undef HAVE_ALLOCA_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `environ', and to 0 if you
|
||||||
|
don't. */
|
||||||
|
#define HAVE_DECL_ENVIRON 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `fprintf', and to 0 if you
|
||||||
|
don't. */
|
||||||
|
#define HAVE_DECL_FPRINTF 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `getc_unlocked', and to 0 if you
|
||||||
|
don't. */
|
||||||
|
#define HAVE_DECL_GETC_UNLOCKED 0
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `getenv', and to 0 if you don't.
|
||||||
|
*/
|
||||||
|
#define HAVE_DECL_GETENV 1
|
||||||
|
|
||||||
|
/* Is the prototype for getopt in <unistd.h> in the expected format? */
|
||||||
|
#define HAVE_DECL_GETOPT 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `sbrk', and to 0 if you don't.
|
||||||
|
*/
|
||||||
|
#define HAVE_DECL_SBRK 0
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `snprintf', and to 0 if you
|
||||||
|
don't. */
|
||||||
|
#define HAVE_DECL_SNPRINTF 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `stpcpy', and to 0 if you don't.
|
||||||
|
*/
|
||||||
|
#define HAVE_DECL_STPCPY 0
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `strnlen', and to 0 if you
|
||||||
|
don't. */
|
||||||
|
#define HAVE_DECL_STRNLEN 0
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `strstr', and to 0 if you don't.
|
||||||
|
*/
|
||||||
|
#define HAVE_DECL_STRSTR 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you
|
||||||
|
don't. */
|
||||||
|
#define HAVE_DECL_VSNPRINTF 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||||
|
/* #undef HAVE_DLFCN_H */
|
||||||
|
|
||||||
|
/* Does the platform use an executable suffix? */
|
||||||
|
#define HAVE_EXECUTABLE_SUFFIX 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||||
|
#define HAVE_FCNTL_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `getc_unlocked' function. */
|
||||||
|
/* #undef HAVE_GETC_UNLOCKED */
|
||||||
|
|
||||||
|
/* Does <utime.h> define struct utimbuf? */
|
||||||
|
#define HAVE_GOOD_UTIME_H 1
|
||||||
|
|
||||||
|
/* Define if you have the iconv() function. */
|
||||||
|
#define HAVE_ICONV 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
|
#define HAVE_INTTYPES_H 1
|
||||||
|
|
||||||
|
/* Define if your <locale.h> file defines LC_MESSAGES. */
|
||||||
|
/* #undef HAVE_LC_MESSAGES */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <limits.h> header file. */
|
||||||
|
#define HAVE_LIMITS_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <locale.h> header file. */
|
||||||
|
#define HAVE_LOCALE_H 1
|
||||||
|
|
||||||
|
/* Define if mbstate_t exists in wchar.h. */
|
||||||
|
#define HAVE_MBSTATE_T 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
|
#define HAVE_MEMORY_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `mkdtemp' function. */
|
||||||
|
/* #undef HAVE_MKDTEMP */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `mkstemp' function. */
|
||||||
|
#define HAVE_MKSTEMP 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `sbrk' function. */
|
||||||
|
/* #undef HAVE_SBRK */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `setlocale' function. */
|
||||||
|
#define HAVE_SETLOCALE 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `setmode' function. */
|
||||||
|
#define HAVE_SETMODE 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdint.h> header file. */
|
||||||
|
#define HAVE_STDINT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||||
|
#define HAVE_STDLIB_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strcoll' function. */
|
||||||
|
#define HAVE_STRCOLL 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <strings.h> header file. */
|
||||||
|
#define HAVE_STRINGS_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <string.h> header file. */
|
||||||
|
#define HAVE_STRING_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/file.h> header file. */
|
||||||
|
#define HAVE_SYS_FILE_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||||
|
#define HAVE_SYS_PARAM_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||||
|
#define HAVE_SYS_STAT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||||
|
#define HAVE_SYS_TYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
|
||||||
|
/* #undef HAVE_SYS_WAIT_H */
|
||||||
|
|
||||||
|
/* Is the type time_t defined in <time.h>? */
|
||||||
|
#define HAVE_TIME_T_IN_TIME_H 1
|
||||||
|
|
||||||
|
/* Is the type time_t defined in <sys/types.h>? */
|
||||||
|
#define HAVE_TIME_T_IN_TYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
|
#define HAVE_UNISTD_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `utimes' function. */
|
||||||
|
/* #undef HAVE_UTIMES */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <wchar.h> header file. */
|
||||||
|
//#define HAVE_WCHAR_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <zlib.h> header file. */
|
||||||
|
#define HAVE_ZLIB_H 1
|
||||||
|
|
||||||
|
/* Define as const if the declaration of iconv() needs const. */
|
||||||
|
#define ICONV_CONST
|
||||||
|
|
||||||
|
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||||
|
*/
|
||||||
|
#define LT_OBJDIR ".libs/"
|
||||||
|
|
||||||
|
/* Name of package */
|
||||||
|
#define PACKAGE "binutils"
|
||||||
|
|
||||||
|
/* Define to the address where bug reports for this package should be sent. */
|
||||||
|
#define PACKAGE_BUGREPORT ""
|
||||||
|
|
||||||
|
/* Define to the full name of this package. */
|
||||||
|
#define PACKAGE_NAME ""
|
||||||
|
|
||||||
|
/* Define to the full name and version of this package. */
|
||||||
|
#define PACKAGE_STRING ""
|
||||||
|
|
||||||
|
/* Define to the one symbol short name of this package. */
|
||||||
|
#define PACKAGE_TARNAME ""
|
||||||
|
|
||||||
|
/* Define to the home page for this package. */
|
||||||
|
#define PACKAGE_URL ""
|
||||||
|
|
||||||
|
/* Define to the version of this package. */
|
||||||
|
#define PACKAGE_VERSION ""
|
||||||
|
|
||||||
|
/* If using the C implementation of alloca, define if you know the
|
||||||
|
direction of stack growth for your system; otherwise it will be
|
||||||
|
automatically deduced at runtime.
|
||||||
|
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||||
|
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||||
|
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||||
|
/* #undef STACK_DIRECTION */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the ANSI C header files. */
|
||||||
|
#define STDC_HEADERS 1
|
||||||
|
|
||||||
|
/* Define if you can safely include both <string.h> and <strings.h>. */
|
||||||
|
#define STRING_WITH_STRINGS 1
|
||||||
|
|
||||||
|
/* Configured target name. */
|
||||||
|
#define TARGET "i686-pc-mingw32"
|
||||||
|
|
||||||
|
/* Define to 1 if user symbol names have a leading underscore, 0 if not. */
|
||||||
|
#define TARGET_PREPENDS_UNDERSCORE 1
|
||||||
|
|
||||||
|
/* Use b modifier when opening binary files? */
|
||||||
|
#define USE_BINARY_FOPEN 1
|
||||||
|
|
||||||
|
/* Enable extensions on AIX 3, Interix. */
|
||||||
|
#ifndef _ALL_SOURCE
|
||||||
|
# define _ALL_SOURCE 1
|
||||||
|
#endif
|
||||||
|
/* Enable GNU extensions on systems that have them. */
|
||||||
|
#ifndef _GNU_SOURCE
|
||||||
|
# define _GNU_SOURCE 1
|
||||||
|
#endif
|
||||||
|
/* Enable threading extensions on Solaris. */
|
||||||
|
#ifndef _POSIX_PTHREAD_SEMANTICS
|
||||||
|
# define _POSIX_PTHREAD_SEMANTICS 1
|
||||||
|
#endif
|
||||||
|
/* Enable extensions on HP NonStop. */
|
||||||
|
#ifndef _TANDEM_SOURCE
|
||||||
|
# define _TANDEM_SOURCE 1
|
||||||
|
#endif
|
||||||
|
/* Enable general extensions on Solaris. */
|
||||||
|
#ifndef __EXTENSIONS__
|
||||||
|
# define __EXTENSIONS__ 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Version number of package */
|
||||||
|
#define VERSION "2.24"
|
||||||
|
|
||||||
|
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
|
||||||
|
`char[]'. */
|
||||||
|
/* #undef YYTEXT_POINTER */
|
||||||
|
|
||||||
|
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||||
|
/* #undef _FILE_OFFSET_BITS */
|
||||||
|
|
||||||
|
/* Define for large files, on AIX-style hosts. */
|
||||||
|
/* #undef _LARGE_FILES */
|
||||||
|
|
||||||
|
/* Define to 1 if on MINIX. */
|
||||||
|
/* #undef _MINIX */
|
||||||
|
|
||||||
|
/* Define to 2 if the system does not provide POSIX.1 features except with
|
||||||
|
this defined. */
|
||||||
|
/* #undef _POSIX_1_SOURCE */
|
||||||
|
|
||||||
|
/* Define to 1 if you need to in order for `stat' and other things to work. */
|
||||||
|
/* #undef _POSIX_SOURCE */
|
3371
contrib/toolchain/binutils/binutils/debug.c
Normal file
3371
contrib/toolchain/binutils/binutils/debug.c
Normal file
File diff suppressed because it is too large
Load Diff
793
contrib/toolchain/binutils/binutils/debug.h
Normal file
793
contrib/toolchain/binutils/binutils/debug.h
Normal file
@ -0,0 +1,793 @@
|
|||||||
|
/* debug.h -- Describe generic debugging information.
|
||||||
|
Copyright 1995, 1996, 2002, 2003, 2005, 2007, 2009
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor <ian@cygnus.com>.
|
||||||
|
|
||||||
|
This file is part of GNU Binutils.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR 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, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
|
||||||
|
02110-1301, USA. */
|
||||||
|
|
||||||
|
#ifndef DEBUG_H
|
||||||
|
#define DEBUG_H
|
||||||
|
|
||||||
|
/* This header file describes a generic debugging information format.
|
||||||
|
We may eventually have readers which convert different formats into
|
||||||
|
this generic format, and writers which write it out. The initial
|
||||||
|
impetus for this was writing a converter from stabs to HP IEEE-695
|
||||||
|
debugging format. */
|
||||||
|
|
||||||
|
/* Different kinds of types. */
|
||||||
|
|
||||||
|
enum debug_type_kind
|
||||||
|
{
|
||||||
|
/* Not used. */
|
||||||
|
DEBUG_KIND_ILLEGAL,
|
||||||
|
/* Indirect via a pointer. */
|
||||||
|
DEBUG_KIND_INDIRECT,
|
||||||
|
/* Void. */
|
||||||
|
DEBUG_KIND_VOID,
|
||||||
|
/* Integer. */
|
||||||
|
DEBUG_KIND_INT,
|
||||||
|
/* Floating point. */
|
||||||
|
DEBUG_KIND_FLOAT,
|
||||||
|
/* Complex. */
|
||||||
|
DEBUG_KIND_COMPLEX,
|
||||||
|
/* Boolean. */
|
||||||
|
DEBUG_KIND_BOOL,
|
||||||
|
/* Struct. */
|
||||||
|
DEBUG_KIND_STRUCT,
|
||||||
|
/* Union. */
|
||||||
|
DEBUG_KIND_UNION,
|
||||||
|
/* Class. */
|
||||||
|
DEBUG_KIND_CLASS,
|
||||||
|
/* Union class (can this really happen?). */
|
||||||
|
DEBUG_KIND_UNION_CLASS,
|
||||||
|
/* Enumeration type. */
|
||||||
|
DEBUG_KIND_ENUM,
|
||||||
|
/* Pointer. */
|
||||||
|
DEBUG_KIND_POINTER,
|
||||||
|
/* Function. */
|
||||||
|
DEBUG_KIND_FUNCTION,
|
||||||
|
/* Reference. */
|
||||||
|
DEBUG_KIND_REFERENCE,
|
||||||
|
/* Range. */
|
||||||
|
DEBUG_KIND_RANGE,
|
||||||
|
/* Array. */
|
||||||
|
DEBUG_KIND_ARRAY,
|
||||||
|
/* Set. */
|
||||||
|
DEBUG_KIND_SET,
|
||||||
|
/* Based pointer. */
|
||||||
|
DEBUG_KIND_OFFSET,
|
||||||
|
/* Method. */
|
||||||
|
DEBUG_KIND_METHOD,
|
||||||
|
/* Const qualified type. */
|
||||||
|
DEBUG_KIND_CONST,
|
||||||
|
/* Volatile qualified type. */
|
||||||
|
DEBUG_KIND_VOLATILE,
|
||||||
|
/* Named type. */
|
||||||
|
DEBUG_KIND_NAMED,
|
||||||
|
/* Tagged type. */
|
||||||
|
DEBUG_KIND_TAGGED
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Different kinds of variables. */
|
||||||
|
|
||||||
|
enum debug_var_kind
|
||||||
|
{
|
||||||
|
/* Not used. */
|
||||||
|
DEBUG_VAR_ILLEGAL,
|
||||||
|
/* A global variable. */
|
||||||
|
DEBUG_GLOBAL,
|
||||||
|
/* A static variable. */
|
||||||
|
DEBUG_STATIC,
|
||||||
|
/* A local static variable. */
|
||||||
|
DEBUG_LOCAL_STATIC,
|
||||||
|
/* A local variable. */
|
||||||
|
DEBUG_LOCAL,
|
||||||
|
/* A register variable. */
|
||||||
|
DEBUG_REGISTER
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Different kinds of function parameters. */
|
||||||
|
|
||||||
|
enum debug_parm_kind
|
||||||
|
{
|
||||||
|
/* Not used. */
|
||||||
|
DEBUG_PARM_ILLEGAL,
|
||||||
|
/* A stack based parameter. */
|
||||||
|
DEBUG_PARM_STACK,
|
||||||
|
/* A register parameter. */
|
||||||
|
DEBUG_PARM_REG,
|
||||||
|
/* A stack based reference parameter. */
|
||||||
|
DEBUG_PARM_REFERENCE,
|
||||||
|
/* A register reference parameter. */
|
||||||
|
DEBUG_PARM_REF_REG
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Different kinds of visibility. */
|
||||||
|
|
||||||
|
enum debug_visibility
|
||||||
|
{
|
||||||
|
/* A public field (e.g., a field in a C struct). */
|
||||||
|
DEBUG_VISIBILITY_PUBLIC,
|
||||||
|
/* A protected field. */
|
||||||
|
DEBUG_VISIBILITY_PROTECTED,
|
||||||
|
/* A private field. */
|
||||||
|
DEBUG_VISIBILITY_PRIVATE,
|
||||||
|
/* A field which should be ignored. */
|
||||||
|
DEBUG_VISIBILITY_IGNORE
|
||||||
|
};
|
||||||
|
|
||||||
|
/* A type. */
|
||||||
|
|
||||||
|
typedef struct debug_type_s *debug_type;
|
||||||
|
|
||||||
|
#define DEBUG_TYPE_NULL ((debug_type) NULL)
|
||||||
|
|
||||||
|
/* A field in a struct or union. */
|
||||||
|
|
||||||
|
typedef struct debug_field_s *debug_field;
|
||||||
|
|
||||||
|
#define DEBUG_FIELD_NULL ((debug_field) NULL)
|
||||||
|
|
||||||
|
/* A base class for an object. */
|
||||||
|
|
||||||
|
typedef struct debug_baseclass_s *debug_baseclass;
|
||||||
|
|
||||||
|
#define DEBUG_BASECLASS_NULL ((debug_baseclass) NULL)
|
||||||
|
|
||||||
|
/* A method of an object. */
|
||||||
|
|
||||||
|
typedef struct debug_method_s *debug_method;
|
||||||
|
|
||||||
|
#define DEBUG_METHOD_NULL ((debug_method) NULL)
|
||||||
|
|
||||||
|
/* The arguments to a method function of an object. These indicate
|
||||||
|
which method to run. */
|
||||||
|
|
||||||
|
typedef struct debug_method_variant_s *debug_method_variant;
|
||||||
|
|
||||||
|
#define DEBUG_METHOD_VARIANT_NULL ((debug_method_variant) NULL)
|
||||||
|
|
||||||
|
/* This structure is passed to debug_write. It holds function
|
||||||
|
pointers that debug_write will call based on the accumulated
|
||||||
|
debugging information. */
|
||||||
|
|
||||||
|
struct debug_write_fns
|
||||||
|
{
|
||||||
|
/* This is called at the start of each new compilation unit with the
|
||||||
|
name of the main file in the new unit. */
|
||||||
|
bfd_boolean (*start_compilation_unit) (void *, const char *);
|
||||||
|
|
||||||
|
/* This is called at the start of each source file within a
|
||||||
|
compilation unit, before outputting any global information for
|
||||||
|
that file. The argument is the name of the file. */
|
||||||
|
bfd_boolean (*start_source) (void *, const char *);
|
||||||
|
|
||||||
|
/* Each writer must keep a stack of types. */
|
||||||
|
|
||||||
|
/* Push an empty type onto the type stack. This type can appear if
|
||||||
|
there is a reference to a type which is never defined. */
|
||||||
|
bfd_boolean (*empty_type) (void *);
|
||||||
|
|
||||||
|
/* Push a void type onto the type stack. */
|
||||||
|
bfd_boolean (*void_type) (void *);
|
||||||
|
|
||||||
|
/* Push an integer type onto the type stack, given the size and
|
||||||
|
whether it is unsigned. */
|
||||||
|
bfd_boolean (*int_type) (void *, unsigned int, bfd_boolean);
|
||||||
|
|
||||||
|
/* Push a floating type onto the type stack, given the size. */
|
||||||
|
bfd_boolean (*float_type) (void *, unsigned int);
|
||||||
|
|
||||||
|
/* Push a complex type onto the type stack, given the size. */
|
||||||
|
bfd_boolean (*complex_type) (void *, unsigned int);
|
||||||
|
|
||||||
|
/* Push a bfd_boolean type onto the type stack, given the size. */
|
||||||
|
bfd_boolean (*bool_type) (void *, unsigned int);
|
||||||
|
|
||||||
|
/* Push an enum type onto the type stack, given the tag, a NULL
|
||||||
|
terminated array of names and the associated values. If there is
|
||||||
|
no tag, the tag argument will be NULL. If this is an undefined
|
||||||
|
enum, the names and values arguments will be NULL. */
|
||||||
|
bfd_boolean (*enum_type)
|
||||||
|
(void *, const char *, const char **, bfd_signed_vma *);
|
||||||
|
|
||||||
|
/* Pop the top type on the type stack, and push a pointer to that
|
||||||
|
type onto the type stack. */
|
||||||
|
bfd_boolean (*pointer_type) (void *);
|
||||||
|
|
||||||
|
/* Push a function type onto the type stack. The second argument
|
||||||
|
indicates the number of argument types that have been pushed onto
|
||||||
|
the stack. If the number of argument types is passed as -1, then
|
||||||
|
the argument types of the function are unknown, and no types have
|
||||||
|
been pushed onto the stack. The third argument is TRUE if the
|
||||||
|
function takes a variable number of arguments. The return type
|
||||||
|
of the function is pushed onto the type stack below the argument
|
||||||
|
types, if any. */
|
||||||
|
bfd_boolean (*function_type) (void *, int, bfd_boolean);
|
||||||
|
|
||||||
|
/* Pop the top type on the type stack, and push a reference to that
|
||||||
|
type onto the type stack. */
|
||||||
|
bfd_boolean (*reference_type) (void *);
|
||||||
|
|
||||||
|
/* Pop the top type on the type stack, and push a range of that type
|
||||||
|
with the given lower and upper bounds onto the type stack. */
|
||||||
|
bfd_boolean (*range_type) (void *, bfd_signed_vma, bfd_signed_vma);
|
||||||
|
|
||||||
|
/* Push an array type onto the type stack. The top type on the type
|
||||||
|
stack is the range, and the next type on the type stack is the
|
||||||
|
element type. These should be popped before the array type is
|
||||||
|
pushed. The arguments are the lower bound, the upper bound, and
|
||||||
|
whether the array is a string. */
|
||||||
|
bfd_boolean (*array_type)
|
||||||
|
(void *, bfd_signed_vma, bfd_signed_vma, bfd_boolean);
|
||||||
|
|
||||||
|
/* Pop the top type on the type stack, and push a set of that type
|
||||||
|
onto the type stack. The argument indicates whether this set is
|
||||||
|
a bitstring. */
|
||||||
|
bfd_boolean (*set_type) (void *, bfd_boolean);
|
||||||
|
|
||||||
|
/* Push an offset type onto the type stack. The top type on the
|
||||||
|
type stack is the target type, and the next type on the type
|
||||||
|
stack is the base type. These should be popped before the offset
|
||||||
|
type is pushed. */
|
||||||
|
bfd_boolean (*offset_type) (void *);
|
||||||
|
|
||||||
|
/* Push a method type onto the type stack. If the second argument
|
||||||
|
is TRUE, the top type on the stack is the class to which the
|
||||||
|
method belongs; otherwise, the class must be determined by the
|
||||||
|
class to which the method is attached. The third argument is the
|
||||||
|
number of argument types; these are pushed onto the type stack in
|
||||||
|
reverse order (the first type popped is the last argument to the
|
||||||
|
method). A value of -1 for the third argument means that no
|
||||||
|
argument information is available. The fourth argument is TRUE
|
||||||
|
if the function takes a variable number of arguments. The next
|
||||||
|
type on the type stack below the domain and the argument types is
|
||||||
|
the return type of the method. All these types must be popped,
|
||||||
|
and then the method type must be pushed. */
|
||||||
|
bfd_boolean (*method_type) (void *, bfd_boolean, int, bfd_boolean);
|
||||||
|
|
||||||
|
/* Pop the top type off the type stack, and push a const qualified
|
||||||
|
version of that type onto the type stack. */
|
||||||
|
bfd_boolean (*const_type) (void *);
|
||||||
|
|
||||||
|
/* Pop the top type off the type stack, and push a volatile
|
||||||
|
qualified version of that type onto the type stack. */
|
||||||
|
bfd_boolean (*volatile_type) (void *);
|
||||||
|
|
||||||
|
/* Start building a struct. This is followed by calls to the
|
||||||
|
struct_field function, and finished by a call to the
|
||||||
|
end_struct_type function. The second argument is the tag; this
|
||||||
|
will be NULL if there isn't one. If the second argument is NULL,
|
||||||
|
the third argument is a constant identifying this struct for use
|
||||||
|
with tag_type. The fourth argument is TRUE for a struct, FALSE
|
||||||
|
for a union. The fifth argument is the size. If this is an
|
||||||
|
undefined struct or union, the size will be 0 and struct_field
|
||||||
|
will not be called before end_struct_type is called. */
|
||||||
|
bfd_boolean (*start_struct_type)
|
||||||
|
(void *, const char *, unsigned int, bfd_boolean, unsigned int);
|
||||||
|
|
||||||
|
/* Add a field to the struct type currently being built. The type
|
||||||
|
of the field should be popped off the type stack. The arguments
|
||||||
|
are the name, the bit position, the bit size (may be zero if the
|
||||||
|
field is not packed), and the visibility. */
|
||||||
|
bfd_boolean (*struct_field)
|
||||||
|
(void *, const char *, bfd_vma, bfd_vma, enum debug_visibility);
|
||||||
|
|
||||||
|
/* Finish building a struct, and push it onto the type stack. */
|
||||||
|
bfd_boolean (*end_struct_type) (void *);
|
||||||
|
|
||||||
|
/* Start building a class. This is followed by calls to several
|
||||||
|
functions: struct_field, class_static_member, class_baseclass,
|
||||||
|
class_start_method, class_method_variant,
|
||||||
|
class_static_method_variant, and class_end_method. The class is
|
||||||
|
finished by a call to end_class_type. The first five arguments
|
||||||
|
are the same as for start_struct_type. The sixth argument is
|
||||||
|
TRUE if there is a virtual function table; if there is, the
|
||||||
|
seventh argument is TRUE if the virtual function table can be
|
||||||
|
found in the type itself, and is FALSE if the type of the object
|
||||||
|
holding the virtual function table should be popped from the type
|
||||||
|
stack. */
|
||||||
|
bfd_boolean (*start_class_type)
|
||||||
|
(void *, const char *, unsigned int, bfd_boolean, unsigned int,
|
||||||
|
bfd_boolean, bfd_boolean);
|
||||||
|
|
||||||
|
/* Add a static member to the class currently being built. The
|
||||||
|
arguments are the field name, the physical name, and the
|
||||||
|
visibility. The type must be popped off the type stack. */
|
||||||
|
bfd_boolean (*class_static_member)
|
||||||
|
(void *, const char *, const char *, enum debug_visibility);
|
||||||
|
|
||||||
|
/* Add a baseclass to the class currently being built. The type of
|
||||||
|
the baseclass must be popped off the type stack. The arguments
|
||||||
|
are the bit position, whether the class is virtual, and the
|
||||||
|
visibility. */
|
||||||
|
bfd_boolean (*class_baseclass)
|
||||||
|
(void *, bfd_vma, bfd_boolean, enum debug_visibility);
|
||||||
|
|
||||||
|
/* Start adding a method to the class currently being built. This
|
||||||
|
is followed by calls to class_method_variant and
|
||||||
|
class_static_method_variant to describe different variants of the
|
||||||
|
method which take different arguments. The method is finished
|
||||||
|
with a call to class_end_method. The argument is the method
|
||||||
|
name. */
|
||||||
|
bfd_boolean (*class_start_method) (void *, const char *);
|
||||||
|
|
||||||
|
/* Describe a variant to the class method currently being built.
|
||||||
|
The type of the variant must be popped off the type stack. The
|
||||||
|
second argument is the physical name of the function. The
|
||||||
|
following arguments are the visibility, whether the variant is
|
||||||
|
const, whether the variant is volatile, the offset in the virtual
|
||||||
|
function table, and whether the context is on the type stack
|
||||||
|
(below the variant type). */
|
||||||
|
bfd_boolean (*class_method_variant)
|
||||||
|
(void *, const char *, enum debug_visibility, bfd_boolean,
|
||||||
|
bfd_boolean, bfd_vma, bfd_boolean);
|
||||||
|
|
||||||
|
/* Describe a static variant to the class method currently being
|
||||||
|
built. The arguments are the same as for class_method_variant,
|
||||||
|
except that the last two arguments are omitted. The type of the
|
||||||
|
variant must be popped off the type stack. */
|
||||||
|
bfd_boolean (*class_static_method_variant)
|
||||||
|
(void *, const char *, enum debug_visibility, bfd_boolean,
|
||||||
|
bfd_boolean);
|
||||||
|
|
||||||
|
/* Finish describing a class method. */
|
||||||
|
bfd_boolean (*class_end_method) (void *);
|
||||||
|
|
||||||
|
/* Finish describing a class, and push it onto the type stack. */
|
||||||
|
bfd_boolean (*end_class_type) (void *);
|
||||||
|
|
||||||
|
/* Push a type on the stack which was given a name by an earlier
|
||||||
|
call to typdef. */
|
||||||
|
bfd_boolean (*typedef_type) (void *, const char *);
|
||||||
|
|
||||||
|
/* Push a tagged type on the stack which was defined earlier. If
|
||||||
|
the second argument is not NULL, the type was defined by a call
|
||||||
|
to tag. If the second argument is NULL, the type was defined by
|
||||||
|
a call to start_struct_type or start_class_type with a tag of
|
||||||
|
NULL and the number of the third argument. Either way, the
|
||||||
|
fourth argument is the tag kind. Note that this may be called
|
||||||
|
for a struct (class) being defined, in between the call to
|
||||||
|
start_struct_type (start_class_type) and the call to
|
||||||
|
end_struct_type (end_class_type). */
|
||||||
|
bfd_boolean (*tag_type)
|
||||||
|
(void *, const char *, unsigned int, enum debug_type_kind);
|
||||||
|
|
||||||
|
/* Pop the type stack, and typedef it to the given name. */
|
||||||
|
bfd_boolean (*typdef) (void *, const char *);
|
||||||
|
|
||||||
|
/* Pop the type stack, and declare it as a tagged struct or union or
|
||||||
|
enum or whatever. The tag passed down here is redundant, since
|
||||||
|
was also passed when enum_type, start_struct_type, or
|
||||||
|
start_class_type was called. */
|
||||||
|
bfd_boolean (*tag) (void *, const char *);
|
||||||
|
|
||||||
|
/* This is called to record a named integer constant. */
|
||||||
|
bfd_boolean (*int_constant) (void *, const char *, bfd_vma);
|
||||||
|
|
||||||
|
/* This is called to record a named floating point constant. */
|
||||||
|
bfd_boolean (*float_constant) (void *, const char *, double);
|
||||||
|
|
||||||
|
/* This is called to record a typed integer constant. The type is
|
||||||
|
popped off the type stack. */
|
||||||
|
bfd_boolean (*typed_constant) (void *, const char *, bfd_vma);
|
||||||
|
|
||||||
|
/* This is called to record a variable. The type is popped off the
|
||||||
|
type stack. */
|
||||||
|
bfd_boolean (*variable)
|
||||||
|
(void *, const char *, enum debug_var_kind, bfd_vma);
|
||||||
|
|
||||||
|
/* Start writing out a function. The return type must be popped off
|
||||||
|
the stack. The bfd_boolean is TRUE if the function is global. This
|
||||||
|
is followed by calls to function_parameter, followed by block
|
||||||
|
information. */
|
||||||
|
bfd_boolean (*start_function) (void *, const char *, bfd_boolean);
|
||||||
|
|
||||||
|
/* Record a function parameter for the current function. The type
|
||||||
|
must be popped off the stack. */
|
||||||
|
bfd_boolean (*function_parameter)
|
||||||
|
(void *, const char *, enum debug_parm_kind, bfd_vma);
|
||||||
|
|
||||||
|
/* Start writing out a block. There is at least one top level block
|
||||||
|
per function. Blocks may be nested. The argument is the
|
||||||
|
starting address of the block. */
|
||||||
|
bfd_boolean (*start_block) (void *, bfd_vma);
|
||||||
|
|
||||||
|
/* Finish writing out a block. The argument is the ending address
|
||||||
|
of the block. */
|
||||||
|
bfd_boolean (*end_block) (void *, bfd_vma);
|
||||||
|
|
||||||
|
/* Finish writing out a function. */
|
||||||
|
bfd_boolean (*end_function) (void *);
|
||||||
|
|
||||||
|
/* Record line number information for the current compilation unit. */
|
||||||
|
bfd_boolean (*lineno) (void *, const char *, unsigned long, bfd_vma);
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Exported functions. */
|
||||||
|
|
||||||
|
/* The first argument to most of these functions is a handle. This
|
||||||
|
handle is returned by the debug_init function. The purpose of the
|
||||||
|
handle is to permit the debugging routines to not use static
|
||||||
|
variables, and hence to be reentrant. This would be useful for a
|
||||||
|
program which wanted to handle two executables simultaneously. */
|
||||||
|
|
||||||
|
/* Return a debugging handle. */
|
||||||
|
|
||||||
|
extern void *debug_init (void);
|
||||||
|
|
||||||
|
/* Set the source filename. This implicitly starts a new compilation
|
||||||
|
unit. */
|
||||||
|
|
||||||
|
extern bfd_boolean debug_set_filename (void *, const char *);
|
||||||
|
|
||||||
|
/* Change source files to the given file name. This is used for
|
||||||
|
include files in a single compilation unit. */
|
||||||
|
|
||||||
|
extern bfd_boolean debug_start_source (void *, const char *);
|
||||||
|
|
||||||
|
/* Record a function definition. This implicitly starts a function
|
||||||
|
block. The debug_type argument is the type of the return value.
|
||||||
|
The bfd_boolean indicates whether the function is globally visible.
|
||||||
|
The bfd_vma is the address of the start of the function. Currently
|
||||||
|
the parameter types are specified by calls to
|
||||||
|
debug_record_parameter. */
|
||||||
|
|
||||||
|
extern bfd_boolean debug_record_function
|
||||||
|
(void *, const char *, debug_type, bfd_boolean, bfd_vma);
|
||||||
|
|
||||||
|
/* Record a parameter for the current function. */
|
||||||
|
|
||||||
|
extern bfd_boolean debug_record_parameter
|
||||||
|
(void *, const char *, debug_type, enum debug_parm_kind, bfd_vma);
|
||||||
|
|
||||||
|
/* End a function definition. The argument is the address where the
|
||||||
|
function ends. */
|
||||||
|
|
||||||
|
extern bfd_boolean debug_end_function (void *, bfd_vma);
|
||||||
|
|
||||||
|
/* Start a block in a function. All local information will be
|
||||||
|
recorded in this block, until the matching call to debug_end_block.
|
||||||
|
debug_start_block and debug_end_block may be nested. The argument
|
||||||
|
is the address at which this block starts. */
|
||||||
|
|
||||||
|
extern bfd_boolean debug_start_block (void *, bfd_vma);
|
||||||
|
|
||||||
|
/* Finish a block in a function. This matches the call to
|
||||||
|
debug_start_block. The argument is the address at which this block
|
||||||
|
ends. */
|
||||||
|
|
||||||
|
extern bfd_boolean debug_end_block (void *, bfd_vma);
|
||||||
|
|
||||||
|
/* Associate a line number in the current source file with a given
|
||||||
|
address. */
|
||||||
|
|
||||||
|
extern bfd_boolean debug_record_line (void *, unsigned long, bfd_vma);
|
||||||
|
|
||||||
|
/* Start a named common block. This is a block of variables that may
|
||||||
|
move in memory. */
|
||||||
|
|
||||||
|
extern bfd_boolean debug_start_common_block (void *, const char *);
|
||||||
|
|
||||||
|
/* End a named common block. */
|
||||||
|
|
||||||
|
extern bfd_boolean debug_end_common_block (void *, const char *);
|
||||||
|
|
||||||
|
/* Record a named integer constant. */
|
||||||
|
|
||||||
|
extern bfd_boolean debug_record_int_const (void *, const char *, bfd_vma);
|
||||||
|
|
||||||
|
/* Record a named floating point constant. */
|
||||||
|
|
||||||
|
extern bfd_boolean debug_record_float_const (void *, const char *, double);
|
||||||
|
|
||||||
|
/* Record a typed constant with an integral value. */
|
||||||
|
|
||||||
|
extern bfd_boolean debug_record_typed_const
|
||||||
|
(void *, const char *, debug_type, bfd_vma);
|
||||||
|
|
||||||
|
/* Record a label. */
|
||||||
|
|
||||||
|
extern bfd_boolean debug_record_label
|
||||||
|
(void *, const char *, debug_type, bfd_vma);
|
||||||
|
|
||||||
|
/* Record a variable. */
|
||||||
|
|
||||||
|
extern bfd_boolean debug_record_variable
|
||||||
|
(void *, const char *, debug_type, enum debug_var_kind, bfd_vma);
|
||||||
|
|
||||||
|
/* Make an indirect type. The first argument is a pointer to the
|
||||||
|
location where the real type will be placed. The second argument
|
||||||
|
is the type tag, if there is one; this may be NULL; the only
|
||||||
|
purpose of this argument is so that debug_get_type_name can return
|
||||||
|
something useful. This function may be used when a type is
|
||||||
|
referenced before it is defined. */
|
||||||
|
|
||||||
|
extern debug_type debug_make_indirect_type
|
||||||
|
(void *, debug_type *, const char *);
|
||||||
|
|
||||||
|
/* Make a void type. */
|
||||||
|
|
||||||
|
extern debug_type debug_make_void_type (void *);
|
||||||
|
|
||||||
|
/* Make an integer type of a given size. The bfd_boolean argument is TRUE
|
||||||
|
if the integer is unsigned. */
|
||||||
|
|
||||||
|
extern debug_type debug_make_int_type (void *, unsigned int, bfd_boolean);
|
||||||
|
|
||||||
|
/* Make a floating point type of a given size. FIXME: On some
|
||||||
|
platforms, like an Alpha, you probably need to be able to specify
|
||||||
|
the format. */
|
||||||
|
|
||||||
|
extern debug_type debug_make_float_type (void *, unsigned int);
|
||||||
|
|
||||||
|
/* Make a boolean type of a given size. */
|
||||||
|
|
||||||
|
extern debug_type debug_make_bool_type (void *, unsigned int);
|
||||||
|
|
||||||
|
/* Make a complex type of a given size. */
|
||||||
|
|
||||||
|
extern debug_type debug_make_complex_type (void *, unsigned int);
|
||||||
|
|
||||||
|
/* Make a structure type. The second argument is TRUE for a struct,
|
||||||
|
FALSE for a union. The third argument is the size of the struct.
|
||||||
|
The fourth argument is a NULL terminated array of fields. */
|
||||||
|
|
||||||
|
extern debug_type debug_make_struct_type
|
||||||
|
(void *, bfd_boolean, bfd_vma, debug_field *);
|
||||||
|
|
||||||
|
/* Make an object type. The first three arguments after the handle
|
||||||
|
are the same as for debug_make_struct_type. The next arguments are
|
||||||
|
a NULL terminated array of base classes, a NULL terminated array of
|
||||||
|
methods, the type of the object holding the virtual function table
|
||||||
|
if it is not this object, and a bfd_boolean which is TRUE if this
|
||||||
|
object has its own virtual function table. */
|
||||||
|
|
||||||
|
extern debug_type debug_make_object_type
|
||||||
|
(void *, bfd_boolean, bfd_vma, debug_field *, debug_baseclass *,
|
||||||
|
debug_method *, debug_type, bfd_boolean);
|
||||||
|
|
||||||
|
/* Make an enumeration type. The arguments are a null terminated
|
||||||
|
array of strings, and an array of corresponding values. */
|
||||||
|
|
||||||
|
extern debug_type debug_make_enum_type
|
||||||
|
(void *, const char **, bfd_signed_vma *);
|
||||||
|
|
||||||
|
/* Make a pointer to a given type. */
|
||||||
|
|
||||||
|
extern debug_type debug_make_pointer_type (void *, debug_type);
|
||||||
|
|
||||||
|
/* Make a function type. The second argument is the return type. The
|
||||||
|
third argument is a NULL terminated array of argument types. The
|
||||||
|
fourth argument is TRUE if the function takes a variable number of
|
||||||
|
arguments. If the third argument is NULL, then the argument types
|
||||||
|
are unknown. */
|
||||||
|
|
||||||
|
extern debug_type debug_make_function_type
|
||||||
|
(void *, debug_type, debug_type *, bfd_boolean);
|
||||||
|
|
||||||
|
/* Make a reference to a given type. */
|
||||||
|
|
||||||
|
extern debug_type debug_make_reference_type (void *, debug_type);
|
||||||
|
|
||||||
|
/* Make a range of a given type from a lower to an upper bound. */
|
||||||
|
|
||||||
|
extern debug_type debug_make_range_type
|
||||||
|
(void *, debug_type, bfd_signed_vma, bfd_signed_vma);
|
||||||
|
|
||||||
|
/* Make an array type. The second argument is the type of an element
|
||||||
|
of the array. The third argument is the type of a range of the
|
||||||
|
array. The fourth and fifth argument are the lower and upper
|
||||||
|
bounds, respectively (if the bounds are not known, lower should be
|
||||||
|
0 and upper should be -1). The sixth argument is TRUE if this
|
||||||
|
array is actually a string, as in C. */
|
||||||
|
|
||||||
|
extern debug_type debug_make_array_type
|
||||||
|
(void *, debug_type, debug_type, bfd_signed_vma, bfd_signed_vma,
|
||||||
|
bfd_boolean);
|
||||||
|
|
||||||
|
/* Make a set of a given type. For example, a Pascal set type. The
|
||||||
|
bfd_boolean argument is TRUE if this set is actually a bitstring, as in
|
||||||
|
CHILL. */
|
||||||
|
|
||||||
|
extern debug_type debug_make_set_type (void *, debug_type, bfd_boolean);
|
||||||
|
|
||||||
|
/* Make a type for a pointer which is relative to an object. The
|
||||||
|
second argument is the type of the object to which the pointer is
|
||||||
|
relative. The third argument is the type that the pointer points
|
||||||
|
to. */
|
||||||
|
|
||||||
|
extern debug_type debug_make_offset_type (void *, debug_type, debug_type);
|
||||||
|
|
||||||
|
/* Make a type for a method function. The second argument is the
|
||||||
|
return type. The third argument is the domain. The fourth
|
||||||
|
argument is a NULL terminated array of argument types. The fifth
|
||||||
|
argument is TRUE if the function takes a variable number of
|
||||||
|
arguments, in which case the array of argument types indicates the
|
||||||
|
types of the first arguments. The domain and the argument array
|
||||||
|
may be NULL, in which case this is a stub method and that
|
||||||
|
information is not available. Stabs debugging uses this, and gets
|
||||||
|
the argument types from the mangled name. */
|
||||||
|
|
||||||
|
extern debug_type debug_make_method_type
|
||||||
|
(void *, debug_type, debug_type, debug_type *, bfd_boolean);
|
||||||
|
|
||||||
|
/* Make a const qualified version of a given type. */
|
||||||
|
|
||||||
|
extern debug_type debug_make_const_type (void *, debug_type);
|
||||||
|
|
||||||
|
/* Make a volatile qualified version of a given type. */
|
||||||
|
|
||||||
|
extern debug_type debug_make_volatile_type (void *, debug_type);
|
||||||
|
|
||||||
|
/* Make an undefined tagged type. For example, a struct which has
|
||||||
|
been mentioned, but not defined. */
|
||||||
|
|
||||||
|
extern debug_type debug_make_undefined_tagged_type
|
||||||
|
(void *, const char *, enum debug_type_kind);
|
||||||
|
|
||||||
|
/* Make a base class for an object. The second argument is the base
|
||||||
|
class type. The third argument is the bit position of this base
|
||||||
|
class in the object. The fourth argument is whether this is a
|
||||||
|
virtual class. The fifth argument is the visibility of the base
|
||||||
|
class. */
|
||||||
|
|
||||||
|
extern debug_baseclass debug_make_baseclass
|
||||||
|
(void *, debug_type, bfd_vma, bfd_boolean, enum debug_visibility);
|
||||||
|
|
||||||
|
/* Make a field for a struct. The second argument is the name. The
|
||||||
|
third argument is the type of the field. The fourth argument is
|
||||||
|
the bit position of the field. The fifth argument is the size of
|
||||||
|
the field (it may be zero). The sixth argument is the visibility
|
||||||
|
of the field. */
|
||||||
|
|
||||||
|
extern debug_field debug_make_field
|
||||||
|
(void *, const char *, debug_type, bfd_vma, bfd_vma, enum debug_visibility);
|
||||||
|
|
||||||
|
/* Make a static member of an object. The second argument is the
|
||||||
|
name. The third argument is the type of the member. The fourth
|
||||||
|
argument is the physical name of the member (i.e., the name as a
|
||||||
|
global variable). The fifth argument is the visibility of the
|
||||||
|
member. */
|
||||||
|
|
||||||
|
extern debug_field debug_make_static_member
|
||||||
|
(void *, const char *, debug_type, const char *, enum debug_visibility);
|
||||||
|
|
||||||
|
/* Make a method. The second argument is the name, and the third
|
||||||
|
argument is a NULL terminated array of method variants. Each
|
||||||
|
method variant is a method with this name but with different
|
||||||
|
argument types. */
|
||||||
|
|
||||||
|
extern debug_method debug_make_method
|
||||||
|
(void *, const char *, debug_method_variant *);
|
||||||
|
|
||||||
|
/* Make a method variant. The second argument is the physical name of
|
||||||
|
the function. The third argument is the type of the function,
|
||||||
|
probably constructed by debug_make_method_type. The fourth
|
||||||
|
argument is the visibility. The fifth argument is whether this is
|
||||||
|
a const function. The sixth argument is whether this is a volatile
|
||||||
|
function. The seventh argument is the index in the virtual
|
||||||
|
function table, if any. The eighth argument is the virtual
|
||||||
|
function context. */
|
||||||
|
|
||||||
|
extern debug_method_variant debug_make_method_variant
|
||||||
|
(void *, const char *, debug_type, enum debug_visibility, bfd_boolean,
|
||||||
|
bfd_boolean, bfd_vma, debug_type);
|
||||||
|
|
||||||
|
/* Make a static method argument. The arguments are the same as for
|
||||||
|
debug_make_method_variant, except that the last two are omitted
|
||||||
|
since a static method can not also be virtual. */
|
||||||
|
|
||||||
|
extern debug_method_variant debug_make_static_method_variant
|
||||||
|
(void *, const char *, debug_type, enum debug_visibility, bfd_boolean,
|
||||||
|
bfd_boolean);
|
||||||
|
|
||||||
|
/* Name a type. This returns a new type with an attached name. */
|
||||||
|
|
||||||
|
extern debug_type debug_name_type (void *, const char *, debug_type);
|
||||||
|
|
||||||
|
/* Give a tag to a type, such as a struct or union. This returns a
|
||||||
|
new type with an attached tag. */
|
||||||
|
|
||||||
|
extern debug_type debug_tag_type (void *, const char *, debug_type);
|
||||||
|
|
||||||
|
/* Record the size of a given type. */
|
||||||
|
|
||||||
|
extern bfd_boolean debug_record_type_size (void *, debug_type, unsigned int);
|
||||||
|
|
||||||
|
/* Find a named type. */
|
||||||
|
|
||||||
|
extern debug_type debug_find_named_type (void *, const char *);
|
||||||
|
|
||||||
|
/* Find a tagged type. */
|
||||||
|
|
||||||
|
extern debug_type debug_find_tagged_type
|
||||||
|
(void *, const char *, enum debug_type_kind);
|
||||||
|
|
||||||
|
/* Get the kind of a type. */
|
||||||
|
|
||||||
|
extern enum debug_type_kind debug_get_type_kind (void *, debug_type);
|
||||||
|
|
||||||
|
/* Get the name of a type. */
|
||||||
|
|
||||||
|
extern const char *debug_get_type_name (void *, debug_type);
|
||||||
|
|
||||||
|
/* Get the size of a type. */
|
||||||
|
|
||||||
|
extern bfd_vma debug_get_type_size (void *, debug_type);
|
||||||
|
|
||||||
|
/* Get the return type of a function or method type. */
|
||||||
|
|
||||||
|
extern debug_type debug_get_return_type (void *, debug_type);
|
||||||
|
|
||||||
|
/* Get the NULL terminated array of parameter types for a function or
|
||||||
|
method type (actually, parameter types are not currently stored for
|
||||||
|
function types). This may be used to determine whether a method
|
||||||
|
type is a stub method or not. The last argument points to a
|
||||||
|
bfd_boolean which is set to TRUE if the function takes a variable
|
||||||
|
number of arguments. */
|
||||||
|
|
||||||
|
extern const debug_type *debug_get_parameter_types
|
||||||
|
(void *, debug_type, bfd_boolean *);
|
||||||
|
|
||||||
|
/* Get the target type of a pointer or reference or const or volatile
|
||||||
|
type. */
|
||||||
|
|
||||||
|
extern debug_type debug_get_target_type (void *, debug_type);
|
||||||
|
|
||||||
|
/* Get the NULL terminated array of fields for a struct, union, or
|
||||||
|
class. */
|
||||||
|
|
||||||
|
extern const debug_field *debug_get_fields (void *, debug_type);
|
||||||
|
|
||||||
|
/* Get the type of a field. */
|
||||||
|
|
||||||
|
extern debug_type debug_get_field_type (void *, debug_field);
|
||||||
|
|
||||||
|
/* Get the name of a field. */
|
||||||
|
|
||||||
|
extern const char *debug_get_field_name (void *, debug_field);
|
||||||
|
|
||||||
|
/* Get the bit position of a field within the containing structure.
|
||||||
|
If the field is a static member, this will return (bfd_vma) -1. */
|
||||||
|
|
||||||
|
extern bfd_vma debug_get_field_bitpos (void *, debug_field);
|
||||||
|
|
||||||
|
/* Get the bit size of a field. If the field is a static member, this
|
||||||
|
will return (bfd_vma) -1. */
|
||||||
|
|
||||||
|
extern bfd_vma debug_get_field_bitsize (void *, debug_field);
|
||||||
|
|
||||||
|
/* Get the visibility of a field. */
|
||||||
|
|
||||||
|
extern enum debug_visibility debug_get_field_visibility (void *, debug_field);
|
||||||
|
|
||||||
|
/* Get the physical name of a field, if it is a static member. If the
|
||||||
|
field is not a static member, this will return NULL. */
|
||||||
|
|
||||||
|
extern const char *debug_get_field_physname (void *, debug_field);
|
||||||
|
|
||||||
|
/* Write out the recorded debugging information. This takes a set of
|
||||||
|
function pointers which are called to do the actual writing. The
|
||||||
|
first void * is the debugging handle. The second void * is a handle
|
||||||
|
which is passed to the functions. */
|
||||||
|
|
||||||
|
extern bfd_boolean debug_write
|
||||||
|
(void *, const struct debug_write_fns *, void *);
|
||||||
|
|
||||||
|
#endif /* DEBUG_H */
|
249
contrib/toolchain/binutils/binutils/filemode.c
Normal file
249
contrib/toolchain/binutils/binutils/filemode.c
Normal file
@ -0,0 +1,249 @@
|
|||||||
|
/* filemode.c -- make a string describing file modes
|
||||||
|
Copyright 1985, 1990, 1991, 1994, 1995, 1997, 1999, 2002, 2003, 2005,
|
||||||
|
2007 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR 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, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
|
||||||
|
02110-1301, USA. */
|
||||||
|
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "bucomm.h"
|
||||||
|
|
||||||
|
static char ftypelet (unsigned long);
|
||||||
|
static void setst (unsigned long, char *);
|
||||||
|
|
||||||
|
/* filemodestring - fill in string STR with an ls-style ASCII
|
||||||
|
representation of the st_mode field of file stats block STATP.
|
||||||
|
10 characters are stored in STR; no terminating null is added.
|
||||||
|
The characters stored in STR are:
|
||||||
|
|
||||||
|
0 File type. 'd' for directory, 'c' for character
|
||||||
|
special, 'b' for block special, 'm' for multiplex,
|
||||||
|
'l' for symbolic link, 's' for socket, 'p' for fifo,
|
||||||
|
'-' for any other file type
|
||||||
|
|
||||||
|
1 'r' if the owner may read, '-' otherwise.
|
||||||
|
|
||||||
|
2 'w' if the owner may write, '-' otherwise.
|
||||||
|
|
||||||
|
3 'x' if the owner may execute, 's' if the file is
|
||||||
|
set-user-id, '-' otherwise.
|
||||||
|
'S' if the file is set-user-id, but the execute
|
||||||
|
bit isn't set.
|
||||||
|
|
||||||
|
4 'r' if group members may read, '-' otherwise.
|
||||||
|
|
||||||
|
5 'w' if group members may write, '-' otherwise.
|
||||||
|
|
||||||
|
6 'x' if group members may execute, 's' if the file is
|
||||||
|
set-group-id, '-' otherwise.
|
||||||
|
'S' if it is set-group-id but not executable.
|
||||||
|
|
||||||
|
7 'r' if any user may read, '-' otherwise.
|
||||||
|
|
||||||
|
8 'w' if any user may write, '-' otherwise.
|
||||||
|
|
||||||
|
9 'x' if any user may execute, 't' if the file is "sticky"
|
||||||
|
(will be retained in swap space after execution), '-'
|
||||||
|
otherwise.
|
||||||
|
'T' if the file is sticky but not executable. */
|
||||||
|
|
||||||
|
/* Get definitions for the file permission bits. */
|
||||||
|
|
||||||
|
#ifndef S_IRWXU
|
||||||
|
#define S_IRWXU 0700
|
||||||
|
#endif
|
||||||
|
#ifndef S_IRUSR
|
||||||
|
#define S_IRUSR 0400
|
||||||
|
#endif
|
||||||
|
#ifndef S_IWUSR
|
||||||
|
#define S_IWUSR 0200
|
||||||
|
#endif
|
||||||
|
#ifndef S_IXUSR
|
||||||
|
#define S_IXUSR 0100
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef S_IRWXG
|
||||||
|
#define S_IRWXG 0070
|
||||||
|
#endif
|
||||||
|
#ifndef S_IRGRP
|
||||||
|
#define S_IRGRP 0040
|
||||||
|
#endif
|
||||||
|
#ifndef S_IWGRP
|
||||||
|
#define S_IWGRP 0020
|
||||||
|
#endif
|
||||||
|
#ifndef S_IXGRP
|
||||||
|
#define S_IXGRP 0010
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef S_IRWXO
|
||||||
|
#define S_IRWXO 0007
|
||||||
|
#endif
|
||||||
|
#ifndef S_IROTH
|
||||||
|
#define S_IROTH 0004
|
||||||
|
#endif
|
||||||
|
#ifndef S_IWOTH
|
||||||
|
#define S_IWOTH 0002
|
||||||
|
#endif
|
||||||
|
#ifndef S_IXOTH
|
||||||
|
#define S_IXOTH 0001
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Like filemodestring, but only the relevant part of the `struct stat'
|
||||||
|
is given as an argument. */
|
||||||
|
|
||||||
|
void
|
||||||
|
mode_string (unsigned long mode, char *str)
|
||||||
|
{
|
||||||
|
str[0] = ftypelet ((unsigned long) mode);
|
||||||
|
str[1] = (mode & S_IRUSR) != 0 ? 'r' : '-';
|
||||||
|
str[2] = (mode & S_IWUSR) != 0 ? 'w' : '-';
|
||||||
|
str[3] = (mode & S_IXUSR) != 0 ? 'x' : '-';
|
||||||
|
str[4] = (mode & S_IRGRP) != 0 ? 'r' : '-';
|
||||||
|
str[5] = (mode & S_IWGRP) != 0 ? 'w' : '-';
|
||||||
|
str[6] = (mode & S_IXGRP) != 0 ? 'x' : '-';
|
||||||
|
str[7] = (mode & S_IROTH) != 0 ? 'r' : '-';
|
||||||
|
str[8] = (mode & S_IWOTH) != 0 ? 'w' : '-';
|
||||||
|
str[9] = (mode & S_IXOTH) != 0 ? 'x' : '-';
|
||||||
|
setst ((unsigned long) mode, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return a character indicating the type of file described by
|
||||||
|
file mode BITS:
|
||||||
|
'd' for directories
|
||||||
|
'b' for block special files
|
||||||
|
'c' for character special files
|
||||||
|
'm' for multiplexer files
|
||||||
|
'l' for symbolic links
|
||||||
|
's' for sockets
|
||||||
|
'p' for fifos
|
||||||
|
'-' for any other file type. */
|
||||||
|
|
||||||
|
#ifndef S_ISDIR
|
||||||
|
#ifdef S_IFDIR
|
||||||
|
#define S_ISDIR(i) (((i) & S_IFMT) == S_IFDIR)
|
||||||
|
#else /* ! defined (S_IFDIR) */
|
||||||
|
#define S_ISDIR(i) (((i) & 0170000) == 040000)
|
||||||
|
#endif /* ! defined (S_IFDIR) */
|
||||||
|
#endif /* ! defined (S_ISDIR) */
|
||||||
|
|
||||||
|
#ifndef S_ISBLK
|
||||||
|
#ifdef S_IFBLK
|
||||||
|
#define S_ISBLK(i) (((i) & S_IFMT) == S_IFBLK)
|
||||||
|
#else /* ! defined (S_IFBLK) */
|
||||||
|
#define S_ISBLK(i) 0
|
||||||
|
#endif /* ! defined (S_IFBLK) */
|
||||||
|
#endif /* ! defined (S_ISBLK) */
|
||||||
|
|
||||||
|
#ifndef S_ISCHR
|
||||||
|
#ifdef S_IFCHR
|
||||||
|
#define S_ISCHR(i) (((i) & S_IFMT) == S_IFCHR)
|
||||||
|
#else /* ! defined (S_IFCHR) */
|
||||||
|
#define S_ISCHR(i) 0
|
||||||
|
#endif /* ! defined (S_IFCHR) */
|
||||||
|
#endif /* ! defined (S_ISCHR) */
|
||||||
|
|
||||||
|
#ifndef S_ISFIFO
|
||||||
|
#ifdef S_IFIFO
|
||||||
|
#define S_ISFIFO(i) (((i) & S_IFMT) == S_IFIFO)
|
||||||
|
#else /* ! defined (S_IFIFO) */
|
||||||
|
#define S_ISFIFO(i) 0
|
||||||
|
#endif /* ! defined (S_IFIFO) */
|
||||||
|
#endif /* ! defined (S_ISFIFO) */
|
||||||
|
|
||||||
|
#ifndef S_ISSOCK
|
||||||
|
#ifdef S_IFSOCK
|
||||||
|
#define S_ISSOCK(i) (((i) & S_IFMT) == S_IFSOCK)
|
||||||
|
#else /* ! defined (S_IFSOCK) */
|
||||||
|
#define S_ISSOCK(i) 0
|
||||||
|
#endif /* ! defined (S_IFSOCK) */
|
||||||
|
#endif /* ! defined (S_ISSOCK) */
|
||||||
|
|
||||||
|
#ifndef S_ISLNK
|
||||||
|
#ifdef S_IFLNK
|
||||||
|
#define S_ISLNK(i) (((i) & S_IFMT) == S_IFLNK)
|
||||||
|
#else /* ! defined (S_IFLNK) */
|
||||||
|
#define S_ISLNK(i) 0
|
||||||
|
#endif /* ! defined (S_IFLNK) */
|
||||||
|
#endif /* ! defined (S_ISLNK) */
|
||||||
|
|
||||||
|
static char
|
||||||
|
ftypelet (unsigned long bits)
|
||||||
|
{
|
||||||
|
if (S_ISDIR (bits))
|
||||||
|
return 'd';
|
||||||
|
if (S_ISLNK (bits))
|
||||||
|
return 'l';
|
||||||
|
if (S_ISBLK (bits))
|
||||||
|
return 'b';
|
||||||
|
if (S_ISCHR (bits))
|
||||||
|
return 'c';
|
||||||
|
if (S_ISSOCK (bits))
|
||||||
|
return 's';
|
||||||
|
if (S_ISFIFO (bits))
|
||||||
|
return 'p';
|
||||||
|
|
||||||
|
#ifdef S_IFMT
|
||||||
|
#ifdef S_IFMPC
|
||||||
|
if ((bits & S_IFMT) == S_IFMPC
|
||||||
|
|| (bits & S_IFMT) == S_IFMPB)
|
||||||
|
return 'm';
|
||||||
|
#endif
|
||||||
|
#ifdef S_IFNWK
|
||||||
|
if ((bits & S_IFMT) == S_IFNWK)
|
||||||
|
return 'n';
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the 's' and 't' flags in file attributes string CHARS,
|
||||||
|
according to the file mode BITS. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
setst (unsigned long bits ATTRIBUTE_UNUSED, char *chars ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
#ifdef S_ISUID
|
||||||
|
if (bits & S_ISUID)
|
||||||
|
{
|
||||||
|
if (chars[3] != 'x')
|
||||||
|
/* Set-uid, but not executable by owner. */
|
||||||
|
chars[3] = 'S';
|
||||||
|
else
|
||||||
|
chars[3] = 's';
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef S_ISGID
|
||||||
|
if (bits & S_ISGID)
|
||||||
|
{
|
||||||
|
if (chars[6] != 'x')
|
||||||
|
/* Set-gid, but not executable by group. */
|
||||||
|
chars[6] = 'S';
|
||||||
|
else
|
||||||
|
chars[6] = 's';
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef S_ISVTX
|
||||||
|
if (bits & S_ISVTX)
|
||||||
|
{
|
||||||
|
if (chars[9] != 'x')
|
||||||
|
/* Sticky, but not executable by others. */
|
||||||
|
chars[9] = 'T';
|
||||||
|
else
|
||||||
|
chars[9] = 't';
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
7411
contrib/toolchain/binutils/binutils/ieee.c
Normal file
7411
contrib/toolchain/binutils/binutils/ieee.c
Normal file
File diff suppressed because it is too large
Load Diff
23
contrib/toolchain/binutils/binutils/not-strip.c
Normal file
23
contrib/toolchain/binutils/binutils/not-strip.c
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/* Copyright 2007 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GNU Binutils.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR 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, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
|
||||||
|
02110-1301, USA. */
|
||||||
|
|
||||||
|
/* Linked with objcopy.o to flag that this program is 'objcopy' (not
|
||||||
|
'strip'). */
|
||||||
|
|
||||||
|
int is_strip = 0;
|
4293
contrib/toolchain/binutils/binutils/objcopy.c
Normal file
4293
contrib/toolchain/binutils/binutils/objcopy.c
Normal file
File diff suppressed because it is too large
Load Diff
876
contrib/toolchain/binutils/binutils/rdcoff.c
Normal file
876
contrib/toolchain/binutils/binutils/rdcoff.c
Normal file
@ -0,0 +1,876 @@
|
|||||||
|
/* stabs.c -- Parse COFF debugging information
|
||||||
|
Copyright 1996, 1999, 2000, 2002, 2003, 2005, 2007
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor <ian@cygnus.com>.
|
||||||
|
|
||||||
|
This file is part of GNU Binutils.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR 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, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
|
||||||
|
02110-1301, USA. */
|
||||||
|
|
||||||
|
/* This file contains code which parses COFF debugging information. */
|
||||||
|
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "coff/internal.h"
|
||||||
|
#include "libiberty.h"
|
||||||
|
#include "bucomm.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include "budbg.h"
|
||||||
|
|
||||||
|
/* FIXME: We should not need this BFD internal file. We need it for
|
||||||
|
the N_BTMASK, etc., values. */
|
||||||
|
#include "libcoff.h"
|
||||||
|
|
||||||
|
/* These macros extract the right mask and shifts for this BFD. They
|
||||||
|
assume that there is a local variable named ABFD. This is so that
|
||||||
|
macros like ISFCN and DECREF, from coff/internal.h, will work
|
||||||
|
without modification. */
|
||||||
|
#define N_BTMASK (coff_data (abfd)->local_n_btmask)
|
||||||
|
#define N_BTSHFT (coff_data (abfd)->local_n_btshft)
|
||||||
|
#define N_TMASK (coff_data (abfd)->local_n_tmask)
|
||||||
|
#define N_TSHIFT (coff_data (abfd)->local_n_tshift)
|
||||||
|
|
||||||
|
/* This structure is used to hold the symbols, as well as the current
|
||||||
|
location within the symbols. */
|
||||||
|
|
||||||
|
struct coff_symbols
|
||||||
|
{
|
||||||
|
/* The symbols. */
|
||||||
|
asymbol **syms;
|
||||||
|
/* The number of symbols. */
|
||||||
|
long symcount;
|
||||||
|
/* The index of the current symbol. */
|
||||||
|
long symno;
|
||||||
|
/* The index of the current symbol in the COFF symbol table (where
|
||||||
|
each auxent counts as a symbol). */
|
||||||
|
long coff_symno;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The largest basic type we are prepared to handle. */
|
||||||
|
|
||||||
|
#define T_MAX (T_LNGDBL)
|
||||||
|
|
||||||
|
/* This structure is used to hold slots. */
|
||||||
|
|
||||||
|
struct coff_slots
|
||||||
|
{
|
||||||
|
/* Next set of slots. */
|
||||||
|
struct coff_slots *next;
|
||||||
|
/* Slots. */
|
||||||
|
#define COFF_SLOTS (16)
|
||||||
|
debug_type slots[COFF_SLOTS];
|
||||||
|
};
|
||||||
|
|
||||||
|
/* This structure is used to map symbol indices to types. */
|
||||||
|
|
||||||
|
struct coff_types
|
||||||
|
{
|
||||||
|
/* Slots. */
|
||||||
|
struct coff_slots *slots;
|
||||||
|
/* Basic types. */
|
||||||
|
debug_type basic[T_MAX + 1];
|
||||||
|
};
|
||||||
|
|
||||||
|
static debug_type *coff_get_slot (struct coff_types *, int);
|
||||||
|
static debug_type parse_coff_type
|
||||||
|
(bfd *, struct coff_symbols *, struct coff_types *, long, int,
|
||||||
|
union internal_auxent *, bfd_boolean, void *);
|
||||||
|
static debug_type parse_coff_base_type
|
||||||
|
(bfd *, struct coff_symbols *, struct coff_types *, long, int,
|
||||||
|
union internal_auxent *, void *);
|
||||||
|
static debug_type parse_coff_struct_type
|
||||||
|
(bfd *, struct coff_symbols *, struct coff_types *, int,
|
||||||
|
union internal_auxent *, void *);
|
||||||
|
static debug_type parse_coff_enum_type
|
||||||
|
(bfd *, struct coff_symbols *, struct coff_types *,
|
||||||
|
union internal_auxent *, void *);
|
||||||
|
static bfd_boolean parse_coff_symbol
|
||||||
|
(bfd *, struct coff_types *, asymbol *, long, struct internal_syment *,
|
||||||
|
void *, debug_type, bfd_boolean);
|
||||||
|
static bfd_boolean external_coff_symbol_p (int sym_class);
|
||||||
|
|
||||||
|
/* Return the slot for a type. */
|
||||||
|
|
||||||
|
static debug_type *
|
||||||
|
coff_get_slot (struct coff_types *types, int indx)
|
||||||
|
{
|
||||||
|
struct coff_slots **pps;
|
||||||
|
|
||||||
|
pps = &types->slots;
|
||||||
|
|
||||||
|
while (indx >= COFF_SLOTS)
|
||||||
|
{
|
||||||
|
if (*pps == NULL)
|
||||||
|
{
|
||||||
|
*pps = (struct coff_slots *) xmalloc (sizeof **pps);
|
||||||
|
memset (*pps, 0, sizeof **pps);
|
||||||
|
}
|
||||||
|
pps = &(*pps)->next;
|
||||||
|
indx -= COFF_SLOTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*pps == NULL)
|
||||||
|
{
|
||||||
|
*pps = (struct coff_slots *) xmalloc (sizeof **pps);
|
||||||
|
memset (*pps, 0, sizeof **pps);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (*pps)->slots + indx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Parse a COFF type code in NTYPE. */
|
||||||
|
|
||||||
|
static debug_type
|
||||||
|
parse_coff_type (bfd *abfd, struct coff_symbols *symbols,
|
||||||
|
struct coff_types *types, long coff_symno, int ntype,
|
||||||
|
union internal_auxent *pauxent, bfd_boolean useaux,
|
||||||
|
void *dhandle)
|
||||||
|
{
|
||||||
|
debug_type type;
|
||||||
|
|
||||||
|
if ((ntype & ~N_BTMASK) != 0)
|
||||||
|
{
|
||||||
|
int newtype;
|
||||||
|
|
||||||
|
newtype = DECREF (ntype);
|
||||||
|
|
||||||
|
if (ISPTR (ntype))
|
||||||
|
{
|
||||||
|
type = parse_coff_type (abfd, symbols, types, coff_symno, newtype,
|
||||||
|
pauxent, useaux, dhandle);
|
||||||
|
type = debug_make_pointer_type (dhandle, type);
|
||||||
|
}
|
||||||
|
else if (ISFCN (ntype))
|
||||||
|
{
|
||||||
|
type = parse_coff_type (abfd, symbols, types, coff_symno, newtype,
|
||||||
|
pauxent, useaux, dhandle);
|
||||||
|
type = debug_make_function_type (dhandle, type, (debug_type *) NULL,
|
||||||
|
FALSE);
|
||||||
|
}
|
||||||
|
else if (ISARY (ntype))
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
|
||||||
|
if (pauxent == NULL)
|
||||||
|
n = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned short *dim;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* FIXME: If pauxent->x_sym.x_tagndx.l == 0, gdb sets
|
||||||
|
the c_naux field of the syment to 0. */
|
||||||
|
|
||||||
|
/* Move the dimensions down, so that the next array
|
||||||
|
picks up the next one. */
|
||||||
|
dim = pauxent->x_sym.x_fcnary.x_ary.x_dimen;
|
||||||
|
n = dim[0];
|
||||||
|
for (i = 0; *dim != 0 && i < DIMNUM - 1; i++, dim++)
|
||||||
|
*dim = *(dim + 1);
|
||||||
|
*dim = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
type = parse_coff_type (abfd, symbols, types, coff_symno, newtype,
|
||||||
|
pauxent, FALSE, dhandle);
|
||||||
|
type = debug_make_array_type (dhandle, type,
|
||||||
|
parse_coff_base_type (abfd, symbols,
|
||||||
|
types,
|
||||||
|
coff_symno,
|
||||||
|
T_INT,
|
||||||
|
NULL, dhandle),
|
||||||
|
0, n - 1, FALSE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
non_fatal (_("parse_coff_type: Bad type code 0x%x"), ntype);
|
||||||
|
return DEBUG_TYPE_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pauxent != NULL && pauxent->x_sym.x_tagndx.l > 0)
|
||||||
|
{
|
||||||
|
debug_type *slot;
|
||||||
|
|
||||||
|
/* This is a reference to an existing type. FIXME: gdb checks
|
||||||
|
that the class is not C_STRTAG, nor C_UNTAG, nor C_ENTAG. */
|
||||||
|
slot = coff_get_slot (types, pauxent->x_sym.x_tagndx.l);
|
||||||
|
if (*slot != DEBUG_TYPE_NULL)
|
||||||
|
return *slot;
|
||||||
|
else
|
||||||
|
return debug_make_indirect_type (dhandle, slot, (const char *) NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the aux entry has already been used for something, useaux will
|
||||||
|
have been set to false, indicating that parse_coff_base_type
|
||||||
|
should not use it. We need to do it this way, rather than simply
|
||||||
|
passing pauxent as NULL, because we need to be able handle
|
||||||
|
multiple array dimensions while still discarding pauxent after
|
||||||
|
having handled all of them. */
|
||||||
|
if (! useaux)
|
||||||
|
pauxent = NULL;
|
||||||
|
|
||||||
|
return parse_coff_base_type (abfd, symbols, types, coff_symno, ntype,
|
||||||
|
pauxent, dhandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Parse a basic COFF type in NTYPE. */
|
||||||
|
|
||||||
|
static debug_type
|
||||||
|
parse_coff_base_type (bfd *abfd, struct coff_symbols *symbols,
|
||||||
|
struct coff_types *types, long coff_symno, int ntype,
|
||||||
|
union internal_auxent *pauxent, void *dhandle)
|
||||||
|
{
|
||||||
|
debug_type ret;
|
||||||
|
bfd_boolean set_basic;
|
||||||
|
const char *name;
|
||||||
|
debug_type *slot;
|
||||||
|
|
||||||
|
if (ntype >= 0
|
||||||
|
&& ntype <= T_MAX
|
||||||
|
&& types->basic[ntype] != DEBUG_TYPE_NULL)
|
||||||
|
return types->basic[ntype];
|
||||||
|
|
||||||
|
set_basic = TRUE;
|
||||||
|
name = NULL;
|
||||||
|
|
||||||
|
switch (ntype)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
ret = debug_make_void_type (dhandle);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_NULL:
|
||||||
|
case T_VOID:
|
||||||
|
ret = debug_make_void_type (dhandle);
|
||||||
|
name = "void";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_CHAR:
|
||||||
|
ret = debug_make_int_type (dhandle, 1, FALSE);
|
||||||
|
name = "char";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_SHORT:
|
||||||
|
ret = debug_make_int_type (dhandle, 2, FALSE);
|
||||||
|
name = "short";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_INT:
|
||||||
|
/* FIXME: Perhaps the size should depend upon the architecture. */
|
||||||
|
ret = debug_make_int_type (dhandle, 4, FALSE);
|
||||||
|
name = "int";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_LONG:
|
||||||
|
ret = debug_make_int_type (dhandle, 4, FALSE);
|
||||||
|
name = "long";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_FLOAT:
|
||||||
|
ret = debug_make_float_type (dhandle, 4);
|
||||||
|
name = "float";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_DOUBLE:
|
||||||
|
ret = debug_make_float_type (dhandle, 8);
|
||||||
|
name = "double";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_LNGDBL:
|
||||||
|
ret = debug_make_float_type (dhandle, 12);
|
||||||
|
name = "long double";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_UCHAR:
|
||||||
|
ret = debug_make_int_type (dhandle, 1, TRUE);
|
||||||
|
name = "unsigned char";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_USHORT:
|
||||||
|
ret = debug_make_int_type (dhandle, 2, TRUE);
|
||||||
|
name = "unsigned short";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_UINT:
|
||||||
|
ret = debug_make_int_type (dhandle, 4, TRUE);
|
||||||
|
name = "unsigned int";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_ULONG:
|
||||||
|
ret = debug_make_int_type (dhandle, 4, TRUE);
|
||||||
|
name = "unsigned long";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_STRUCT:
|
||||||
|
if (pauxent == NULL)
|
||||||
|
ret = debug_make_struct_type (dhandle, TRUE, 0,
|
||||||
|
(debug_field *) NULL);
|
||||||
|
else
|
||||||
|
ret = parse_coff_struct_type (abfd, symbols, types, ntype, pauxent,
|
||||||
|
dhandle);
|
||||||
|
|
||||||
|
slot = coff_get_slot (types, coff_symno);
|
||||||
|
*slot = ret;
|
||||||
|
|
||||||
|
set_basic = FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_UNION:
|
||||||
|
if (pauxent == NULL)
|
||||||
|
ret = debug_make_struct_type (dhandle, FALSE, 0, (debug_field *) NULL);
|
||||||
|
else
|
||||||
|
ret = parse_coff_struct_type (abfd, symbols, types, ntype, pauxent,
|
||||||
|
dhandle);
|
||||||
|
|
||||||
|
slot = coff_get_slot (types, coff_symno);
|
||||||
|
*slot = ret;
|
||||||
|
|
||||||
|
set_basic = FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_ENUM:
|
||||||
|
if (pauxent == NULL)
|
||||||
|
ret = debug_make_enum_type (dhandle, (const char **) NULL,
|
||||||
|
(bfd_signed_vma *) NULL);
|
||||||
|
else
|
||||||
|
ret = parse_coff_enum_type (abfd, symbols, types, pauxent, dhandle);
|
||||||
|
|
||||||
|
slot = coff_get_slot (types, coff_symno);
|
||||||
|
*slot = ret;
|
||||||
|
|
||||||
|
set_basic = FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name != NULL)
|
||||||
|
ret = debug_name_type (dhandle, name, ret);
|
||||||
|
|
||||||
|
if (set_basic
|
||||||
|
&& ntype >= 0
|
||||||
|
&& ntype <= T_MAX)
|
||||||
|
types->basic[ntype] = ret;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Parse a struct type. */
|
||||||
|
|
||||||
|
static debug_type
|
||||||
|
parse_coff_struct_type (bfd *abfd, struct coff_symbols *symbols,
|
||||||
|
struct coff_types *types, int ntype,
|
||||||
|
union internal_auxent *pauxent, void *dhandle)
|
||||||
|
{
|
||||||
|
long symend;
|
||||||
|
int alloc;
|
||||||
|
debug_field *fields;
|
||||||
|
int count;
|
||||||
|
bfd_boolean done;
|
||||||
|
|
||||||
|
symend = pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l;
|
||||||
|
|
||||||
|
alloc = 10;
|
||||||
|
fields = (debug_field *) xmalloc (alloc * sizeof *fields);
|
||||||
|
count = 0;
|
||||||
|
|
||||||
|
done = FALSE;
|
||||||
|
while (! done
|
||||||
|
&& symbols->coff_symno < symend
|
||||||
|
&& symbols->symno < symbols->symcount)
|
||||||
|
{
|
||||||
|
asymbol *sym;
|
||||||
|
long this_coff_symno;
|
||||||
|
struct internal_syment syment;
|
||||||
|
union internal_auxent auxent;
|
||||||
|
union internal_auxent *psubaux;
|
||||||
|
bfd_vma bitpos = 0, bitsize = 0;
|
||||||
|
|
||||||
|
sym = symbols->syms[symbols->symno];
|
||||||
|
|
||||||
|
if (! bfd_coff_get_syment (abfd, sym, &syment))
|
||||||
|
{
|
||||||
|
non_fatal (_("bfd_coff_get_syment failed: %s"),
|
||||||
|
bfd_errmsg (bfd_get_error ()));
|
||||||
|
return DEBUG_TYPE_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
this_coff_symno = symbols->coff_symno;
|
||||||
|
|
||||||
|
++symbols->symno;
|
||||||
|
symbols->coff_symno += 1 + syment.n_numaux;
|
||||||
|
|
||||||
|
if (syment.n_numaux == 0)
|
||||||
|
psubaux = NULL;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (! bfd_coff_get_auxent (abfd, sym, 0, &auxent))
|
||||||
|
{
|
||||||
|
non_fatal (_("bfd_coff_get_auxent failed: %s"),
|
||||||
|
bfd_errmsg (bfd_get_error ()));
|
||||||
|
return DEBUG_TYPE_NULL;
|
||||||
|
}
|
||||||
|
psubaux = &auxent;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (syment.n_sclass)
|
||||||
|
{
|
||||||
|
case C_MOS:
|
||||||
|
case C_MOU:
|
||||||
|
bitpos = 8 * bfd_asymbol_value (sym);
|
||||||
|
bitsize = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case C_FIELD:
|
||||||
|
bitpos = bfd_asymbol_value (sym);
|
||||||
|
bitsize = auxent.x_sym.x_misc.x_lnsz.x_size;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case C_EOS:
|
||||||
|
done = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! done)
|
||||||
|
{
|
||||||
|
debug_type ftype;
|
||||||
|
debug_field f;
|
||||||
|
|
||||||
|
ftype = parse_coff_type (abfd, symbols, types, this_coff_symno,
|
||||||
|
syment.n_type, psubaux, TRUE, dhandle);
|
||||||
|
f = debug_make_field (dhandle, bfd_asymbol_name (sym), ftype,
|
||||||
|
bitpos, bitsize, DEBUG_VISIBILITY_PUBLIC);
|
||||||
|
if (f == DEBUG_FIELD_NULL)
|
||||||
|
return DEBUG_TYPE_NULL;
|
||||||
|
|
||||||
|
if (count + 1 >= alloc)
|
||||||
|
{
|
||||||
|
alloc += 10;
|
||||||
|
fields = ((debug_field *)
|
||||||
|
xrealloc (fields, alloc * sizeof *fields));
|
||||||
|
}
|
||||||
|
|
||||||
|
fields[count] = f;
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fields[count] = DEBUG_FIELD_NULL;
|
||||||
|
|
||||||
|
return debug_make_struct_type (dhandle, ntype == T_STRUCT,
|
||||||
|
pauxent->x_sym.x_misc.x_lnsz.x_size,
|
||||||
|
fields);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Parse an enum type. */
|
||||||
|
|
||||||
|
static debug_type
|
||||||
|
parse_coff_enum_type (bfd *abfd, struct coff_symbols *symbols,
|
||||||
|
struct coff_types *types ATTRIBUTE_UNUSED,
|
||||||
|
union internal_auxent *pauxent, void *dhandle)
|
||||||
|
{
|
||||||
|
long symend;
|
||||||
|
int alloc;
|
||||||
|
const char **names;
|
||||||
|
bfd_signed_vma *vals;
|
||||||
|
int count;
|
||||||
|
bfd_boolean done;
|
||||||
|
|
||||||
|
symend = pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l;
|
||||||
|
|
||||||
|
alloc = 10;
|
||||||
|
names = (const char **) xmalloc (alloc * sizeof *names);
|
||||||
|
vals = (bfd_signed_vma *) xmalloc (alloc * sizeof *vals);
|
||||||
|
count = 0;
|
||||||
|
|
||||||
|
done = FALSE;
|
||||||
|
while (! done
|
||||||
|
&& symbols->coff_symno < symend
|
||||||
|
&& symbols->symno < symbols->symcount)
|
||||||
|
{
|
||||||
|
asymbol *sym;
|
||||||
|
struct internal_syment syment;
|
||||||
|
|
||||||
|
sym = symbols->syms[symbols->symno];
|
||||||
|
|
||||||
|
if (! bfd_coff_get_syment (abfd, sym, &syment))
|
||||||
|
{
|
||||||
|
non_fatal (_("bfd_coff_get_syment failed: %s"),
|
||||||
|
bfd_errmsg (bfd_get_error ()));
|
||||||
|
return DEBUG_TYPE_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
++symbols->symno;
|
||||||
|
symbols->coff_symno += 1 + syment.n_numaux;
|
||||||
|
|
||||||
|
switch (syment.n_sclass)
|
||||||
|
{
|
||||||
|
case C_MOE:
|
||||||
|
if (count + 1 >= alloc)
|
||||||
|
{
|
||||||
|
alloc += 10;
|
||||||
|
names = ((const char **)
|
||||||
|
xrealloc (names, alloc * sizeof *names));
|
||||||
|
vals = ((bfd_signed_vma *)
|
||||||
|
xrealloc (vals, alloc * sizeof *vals));
|
||||||
|
}
|
||||||
|
|
||||||
|
names[count] = bfd_asymbol_name (sym);
|
||||||
|
vals[count] = bfd_asymbol_value (sym);
|
||||||
|
++count;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case C_EOS:
|
||||||
|
done = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
names[count] = NULL;
|
||||||
|
|
||||||
|
return debug_make_enum_type (dhandle, names, vals);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Handle a single COFF symbol. */
|
||||||
|
|
||||||
|
static bfd_boolean
|
||||||
|
parse_coff_symbol (bfd *abfd ATTRIBUTE_UNUSED, struct coff_types *types,
|
||||||
|
asymbol *sym, long coff_symno,
|
||||||
|
struct internal_syment *psyment, void *dhandle,
|
||||||
|
debug_type type, bfd_boolean within_function)
|
||||||
|
{
|
||||||
|
switch (psyment->n_sclass)
|
||||||
|
{
|
||||||
|
case C_NULL:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case C_AUTO:
|
||||||
|
if (! debug_record_variable (dhandle, bfd_asymbol_name (sym), type,
|
||||||
|
DEBUG_LOCAL, bfd_asymbol_value (sym)))
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case C_WEAKEXT:
|
||||||
|
case C_EXT:
|
||||||
|
if (! debug_record_variable (dhandle, bfd_asymbol_name (sym), type,
|
||||||
|
DEBUG_GLOBAL, bfd_asymbol_value (sym)))
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case C_STAT:
|
||||||
|
if (! debug_record_variable (dhandle, bfd_asymbol_name (sym), type,
|
||||||
|
(within_function
|
||||||
|
? DEBUG_LOCAL_STATIC
|
||||||
|
: DEBUG_STATIC),
|
||||||
|
bfd_asymbol_value (sym)))
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case C_REG:
|
||||||
|
/* FIXME: We may need to convert the register number. */
|
||||||
|
if (! debug_record_variable (dhandle, bfd_asymbol_name (sym), type,
|
||||||
|
DEBUG_REGISTER, bfd_asymbol_value (sym)))
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case C_LABEL:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case C_ARG:
|
||||||
|
if (! debug_record_parameter (dhandle, bfd_asymbol_name (sym), type,
|
||||||
|
DEBUG_PARM_STACK, bfd_asymbol_value (sym)))
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case C_REGPARM:
|
||||||
|
/* FIXME: We may need to convert the register number. */
|
||||||
|
if (! debug_record_parameter (dhandle, bfd_asymbol_name (sym), type,
|
||||||
|
DEBUG_PARM_REG, bfd_asymbol_value (sym)))
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case C_TPDEF:
|
||||||
|
type = debug_name_type (dhandle, bfd_asymbol_name (sym), type);
|
||||||
|
if (type == DEBUG_TYPE_NULL)
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case C_STRTAG:
|
||||||
|
case C_UNTAG:
|
||||||
|
case C_ENTAG:
|
||||||
|
{
|
||||||
|
debug_type *slot;
|
||||||
|
|
||||||
|
type = debug_tag_type (dhandle, bfd_asymbol_name (sym), type);
|
||||||
|
if (type == DEBUG_TYPE_NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* Store the named type into the slot, so that references get
|
||||||
|
the name. */
|
||||||
|
slot = coff_get_slot (types, coff_symno);
|
||||||
|
*slot = type;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Determine if a symbol has external visibility. */
|
||||||
|
|
||||||
|
static bfd_boolean
|
||||||
|
external_coff_symbol_p (int sym_class)
|
||||||
|
{
|
||||||
|
switch (sym_class)
|
||||||
|
{
|
||||||
|
case C_EXT:
|
||||||
|
case C_WEAKEXT:
|
||||||
|
return TRUE;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This is the main routine. It looks through all the symbols and
|
||||||
|
handles them. */
|
||||||
|
|
||||||
|
bfd_boolean
|
||||||
|
parse_coff (bfd *abfd, asymbol **syms, long symcount, void *dhandle)
|
||||||
|
{
|
||||||
|
struct coff_symbols symbols;
|
||||||
|
struct coff_types types;
|
||||||
|
int i;
|
||||||
|
long next_c_file;
|
||||||
|
const char *fnname;
|
||||||
|
int fnclass;
|
||||||
|
int fntype;
|
||||||
|
bfd_vma fnend;
|
||||||
|
alent *linenos;
|
||||||
|
bfd_boolean within_function;
|
||||||
|
long this_coff_symno;
|
||||||
|
|
||||||
|
symbols.syms = syms;
|
||||||
|
symbols.symcount = symcount;
|
||||||
|
symbols.symno = 0;
|
||||||
|
symbols.coff_symno = 0;
|
||||||
|
|
||||||
|
types.slots = NULL;
|
||||||
|
for (i = 0; i <= T_MAX; i++)
|
||||||
|
types.basic[i] = DEBUG_TYPE_NULL;
|
||||||
|
|
||||||
|
next_c_file = -1;
|
||||||
|
fnname = NULL;
|
||||||
|
fnclass = 0;
|
||||||
|
fntype = 0;
|
||||||
|
fnend = 0;
|
||||||
|
linenos = NULL;
|
||||||
|
within_function = FALSE;
|
||||||
|
|
||||||
|
while (symbols.symno < symcount)
|
||||||
|
{
|
||||||
|
asymbol *sym;
|
||||||
|
const char *name;
|
||||||
|
struct internal_syment syment;
|
||||||
|
union internal_auxent auxent;
|
||||||
|
union internal_auxent *paux;
|
||||||
|
debug_type type;
|
||||||
|
|
||||||
|
sym = syms[symbols.symno];
|
||||||
|
|
||||||
|
if (! bfd_coff_get_syment (abfd, sym, &syment))
|
||||||
|
{
|
||||||
|
non_fatal (_("bfd_coff_get_syment failed: %s"),
|
||||||
|
bfd_errmsg (bfd_get_error ()));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
name = bfd_asymbol_name (sym);
|
||||||
|
|
||||||
|
this_coff_symno = symbols.coff_symno;
|
||||||
|
|
||||||
|
++symbols.symno;
|
||||||
|
symbols.coff_symno += 1 + syment.n_numaux;
|
||||||
|
|
||||||
|
/* We only worry about the first auxent, because that is the
|
||||||
|
only one which is relevant for debugging information. */
|
||||||
|
if (syment.n_numaux == 0)
|
||||||
|
paux = NULL;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (! bfd_coff_get_auxent (abfd, sym, 0, &auxent))
|
||||||
|
{
|
||||||
|
non_fatal (_("bfd_coff_get_auxent failed: %s"),
|
||||||
|
bfd_errmsg (bfd_get_error ()));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
paux = &auxent;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this_coff_symno == next_c_file && syment.n_sclass != C_FILE)
|
||||||
|
{
|
||||||
|
/* The last C_FILE symbol points to the first external
|
||||||
|
symbol. */
|
||||||
|
if (! debug_set_filename (dhandle, "*globals*"))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (syment.n_sclass)
|
||||||
|
{
|
||||||
|
case C_EFCN:
|
||||||
|
case C_EXTDEF:
|
||||||
|
case C_ULABEL:
|
||||||
|
case C_USTATIC:
|
||||||
|
case C_LINE:
|
||||||
|
case C_ALIAS:
|
||||||
|
case C_HIDDEN:
|
||||||
|
/* Just ignore these classes. */
|
||||||
|
break;
|
||||||
|
|
||||||
|
case C_FILE:
|
||||||
|
next_c_file = syment.n_value;
|
||||||
|
if (! debug_set_filename (dhandle, name))
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case C_STAT:
|
||||||
|
/* Ignore static symbols with a type of T_NULL. These
|
||||||
|
represent section entries. */
|
||||||
|
if (syment.n_type == T_NULL)
|
||||||
|
break;
|
||||||
|
/* Fall through. */
|
||||||
|
case C_WEAKEXT:
|
||||||
|
case C_EXT:
|
||||||
|
if (ISFCN (syment.n_type))
|
||||||
|
{
|
||||||
|
fnname = name;
|
||||||
|
fnclass = syment.n_sclass;
|
||||||
|
fntype = syment.n_type;
|
||||||
|
if (syment.n_numaux > 0)
|
||||||
|
fnend = bfd_asymbol_value (sym) + auxent.x_sym.x_misc.x_fsize;
|
||||||
|
else
|
||||||
|
fnend = 0;
|
||||||
|
linenos = BFD_SEND (abfd, _get_lineno, (abfd, sym));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
type = parse_coff_type (abfd, &symbols, &types, this_coff_symno,
|
||||||
|
syment.n_type, paux, TRUE, dhandle);
|
||||||
|
if (type == DEBUG_TYPE_NULL)
|
||||||
|
return FALSE;
|
||||||
|
if (! parse_coff_symbol (abfd, &types, sym, this_coff_symno, &syment,
|
||||||
|
dhandle, type, within_function))
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case C_FCN:
|
||||||
|
if (strcmp (name, ".bf") == 0)
|
||||||
|
{
|
||||||
|
if (fnname == NULL)
|
||||||
|
{
|
||||||
|
non_fatal (_("%ld: .bf without preceding function"),
|
||||||
|
this_coff_symno);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
type = parse_coff_type (abfd, &symbols, &types, this_coff_symno,
|
||||||
|
DECREF (fntype), paux, FALSE, dhandle);
|
||||||
|
if (type == DEBUG_TYPE_NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (! debug_record_function (dhandle, fnname, type,
|
||||||
|
external_coff_symbol_p (fnclass),
|
||||||
|
bfd_asymbol_value (sym)))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (linenos != NULL)
|
||||||
|
{
|
||||||
|
int base;
|
||||||
|
bfd_vma addr;
|
||||||
|
|
||||||
|
if (syment.n_numaux == 0)
|
||||||
|
base = 0;
|
||||||
|
else
|
||||||
|
base = auxent.x_sym.x_misc.x_lnsz.x_lnno - 1;
|
||||||
|
|
||||||
|
addr = bfd_get_section_vma (abfd, bfd_get_section (sym));
|
||||||
|
|
||||||
|
++linenos;
|
||||||
|
|
||||||
|
while (linenos->line_number != 0)
|
||||||
|
{
|
||||||
|
if (! debug_record_line (dhandle,
|
||||||
|
linenos->line_number + base,
|
||||||
|
linenos->u.offset + addr))
|
||||||
|
return FALSE;
|
||||||
|
++linenos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fnname = NULL;
|
||||||
|
linenos = NULL;
|
||||||
|
fnclass = 0;
|
||||||
|
fntype = 0;
|
||||||
|
|
||||||
|
within_function = TRUE;
|
||||||
|
}
|
||||||
|
else if (strcmp (name, ".ef") == 0)
|
||||||
|
{
|
||||||
|
if (! within_function)
|
||||||
|
{
|
||||||
|
non_fatal (_("%ld: unexpected .ef\n"), this_coff_symno);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bfd_asymbol_value (sym) > fnend)
|
||||||
|
fnend = bfd_asymbol_value (sym);
|
||||||
|
if (! debug_end_function (dhandle, fnend))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
fnend = 0;
|
||||||
|
within_function = FALSE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case C_BLOCK:
|
||||||
|
if (strcmp (name, ".bb") == 0)
|
||||||
|
{
|
||||||
|
if (! debug_start_block (dhandle, bfd_asymbol_value (sym)))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else if (strcmp (name, ".eb") == 0)
|
||||||
|
{
|
||||||
|
if (! debug_end_block (dhandle, bfd_asymbol_value (sym)))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
type = parse_coff_type (abfd, &symbols, &types, this_coff_symno,
|
||||||
|
syment.n_type, paux, TRUE, dhandle);
|
||||||
|
if (type == DEBUG_TYPE_NULL)
|
||||||
|
return FALSE;
|
||||||
|
if (! parse_coff_symbol (abfd, &types, sym, this_coff_symno, &syment,
|
||||||
|
dhandle, type, within_function))
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
450
contrib/toolchain/binutils/binutils/rddbg.c
Normal file
450
contrib/toolchain/binutils/binutils/rddbg.c
Normal file
@ -0,0 +1,450 @@
|
|||||||
|
/* rddbg.c -- Read debugging information into a generic form.
|
||||||
|
Copyright 1995, 1996, 1997, 2000, 2002, 2003, 2005, 2007, 2008,
|
||||||
|
2010 Free Software Foundation, Inc.
|
||||||
|
Written by Ian Lance Taylor <ian@cygnus.com>.
|
||||||
|
|
||||||
|
This file is part of GNU Binutils.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR 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, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
|
||||||
|
02110-1301, USA. */
|
||||||
|
|
||||||
|
|
||||||
|
/* This file reads debugging information into a generic form. This
|
||||||
|
file knows how to dig the debugging information out of an object
|
||||||
|
file. */
|
||||||
|
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "libiberty.h"
|
||||||
|
#include "bucomm.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include "budbg.h"
|
||||||
|
|
||||||
|
static bfd_boolean read_section_stabs_debugging_info
|
||||||
|
(bfd *, asymbol **, long, void *, bfd_boolean *);
|
||||||
|
static bfd_boolean read_symbol_stabs_debugging_info
|
||||||
|
(bfd *, asymbol **, long, void *, bfd_boolean *);
|
||||||
|
static bfd_boolean read_ieee_debugging_info (bfd *, void *, bfd_boolean *);
|
||||||
|
static void save_stab (int, int, bfd_vma, const char *);
|
||||||
|
static void stab_context (void);
|
||||||
|
static void free_saved_stabs (void);
|
||||||
|
|
||||||
|
/* Read debugging information from a BFD. Returns a generic debugging
|
||||||
|
pointer. */
|
||||||
|
|
||||||
|
void *
|
||||||
|
read_debugging_info (bfd *abfd, asymbol **syms, long symcount, bfd_boolean no_messages)
|
||||||
|
{
|
||||||
|
void *dhandle;
|
||||||
|
bfd_boolean found;
|
||||||
|
|
||||||
|
dhandle = debug_init ();
|
||||||
|
if (dhandle == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (! read_section_stabs_debugging_info (abfd, syms, symcount, dhandle,
|
||||||
|
&found))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (bfd_get_flavour (abfd) == bfd_target_aout_flavour)
|
||||||
|
{
|
||||||
|
if (! read_symbol_stabs_debugging_info (abfd, syms, symcount, dhandle,
|
||||||
|
&found))
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bfd_get_flavour (abfd) == bfd_target_ieee_flavour)
|
||||||
|
{
|
||||||
|
if (! read_ieee_debugging_info (abfd, dhandle, &found))
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try reading the COFF symbols if we didn't find any stabs in COFF
|
||||||
|
sections. */
|
||||||
|
if (! found
|
||||||
|
&& bfd_get_flavour (abfd) == bfd_target_coff_flavour
|
||||||
|
&& symcount > 0)
|
||||||
|
{
|
||||||
|
if (! parse_coff (abfd, syms, symcount, dhandle))
|
||||||
|
return NULL;
|
||||||
|
found = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! found)
|
||||||
|
{
|
||||||
|
if (! no_messages)
|
||||||
|
non_fatal (_("%s: no recognized debugging information"),
|
||||||
|
bfd_get_filename (abfd));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dhandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read stabs in sections debugging information from a BFD. */
|
||||||
|
|
||||||
|
static bfd_boolean
|
||||||
|
read_section_stabs_debugging_info (bfd *abfd, asymbol **syms, long symcount,
|
||||||
|
void *dhandle, bfd_boolean *pfound)
|
||||||
|
{
|
||||||
|
static struct
|
||||||
|
{
|
||||||
|
const char *secname;
|
||||||
|
const char *strsecname;
|
||||||
|
}
|
||||||
|
names[] =
|
||||||
|
{
|
||||||
|
{ ".stab", ".stabstr" },
|
||||||
|
{ "LC_SYMTAB.stabs", "LC_SYMTAB.stabstr" },
|
||||||
|
{ "$GDB_SYMBOLS$", "$GDB_STRINGS$" }
|
||||||
|
};
|
||||||
|
unsigned int i;
|
||||||
|
void *shandle;
|
||||||
|
|
||||||
|
*pfound = FALSE;
|
||||||
|
shandle = NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof names / sizeof names[0]; i++)
|
||||||
|
{
|
||||||
|
asection *sec, *strsec;
|
||||||
|
|
||||||
|
sec = bfd_get_section_by_name (abfd, names[i].secname);
|
||||||
|
strsec = bfd_get_section_by_name (abfd, names[i].strsecname);
|
||||||
|
if (sec != NULL && strsec != NULL)
|
||||||
|
{
|
||||||
|
bfd_size_type stabsize, strsize;
|
||||||
|
bfd_byte *stabs, *strings;
|
||||||
|
bfd_byte *stab;
|
||||||
|
bfd_size_type stroff, next_stroff;
|
||||||
|
|
||||||
|
stabsize = bfd_section_size (abfd, sec);
|
||||||
|
stabs = (bfd_byte *) xmalloc (stabsize);
|
||||||
|
if (! bfd_get_section_contents (abfd, sec, stabs, 0, stabsize))
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s: %s: %s\n",
|
||||||
|
bfd_get_filename (abfd), names[i].secname,
|
||||||
|
bfd_errmsg (bfd_get_error ()));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
strsize = bfd_section_size (abfd, strsec);
|
||||||
|
strings = (bfd_byte *) xmalloc (strsize);
|
||||||
|
if (! bfd_get_section_contents (abfd, strsec, strings, 0, strsize))
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s: %s: %s\n",
|
||||||
|
bfd_get_filename (abfd), names[i].strsecname,
|
||||||
|
bfd_errmsg (bfd_get_error ()));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shandle == NULL)
|
||||||
|
{
|
||||||
|
shandle = start_stab (dhandle, abfd, TRUE, syms, symcount);
|
||||||
|
if (shandle == NULL)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pfound = TRUE;
|
||||||
|
|
||||||
|
stroff = 0;
|
||||||
|
next_stroff = 0;
|
||||||
|
for (stab = stabs; stab < stabs + stabsize; stab += 12)
|
||||||
|
{
|
||||||
|
unsigned int strx;
|
||||||
|
int type;
|
||||||
|
int other ATTRIBUTE_UNUSED;
|
||||||
|
int desc;
|
||||||
|
bfd_vma value;
|
||||||
|
|
||||||
|
/* This code presumes 32 bit values. */
|
||||||
|
|
||||||
|
strx = bfd_get_32 (abfd, stab);
|
||||||
|
type = bfd_get_8 (abfd, stab + 4);
|
||||||
|
other = bfd_get_8 (abfd, stab + 5);
|
||||||
|
desc = bfd_get_16 (abfd, stab + 6);
|
||||||
|
value = bfd_get_32 (abfd, stab + 8);
|
||||||
|
|
||||||
|
if (type == 0)
|
||||||
|
{
|
||||||
|
/* Special type 0 stabs indicate the offset to the
|
||||||
|
next string table. */
|
||||||
|
stroff = next_stroff;
|
||||||
|
next_stroff += value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char *f, *s;
|
||||||
|
|
||||||
|
f = NULL;
|
||||||
|
|
||||||
|
if (stroff + strx > strsize)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s: %s: stab entry %ld is corrupt, strx = 0x%x, type = %d\n",
|
||||||
|
bfd_get_filename (abfd), names[i].secname,
|
||||||
|
(long) (stab - stabs) / 12, strx, type);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
s = (char *) strings + stroff + strx;
|
||||||
|
|
||||||
|
while (s[strlen (s) - 1] == '\\'
|
||||||
|
&& stab + 12 < stabs + stabsize)
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
stab += 12;
|
||||||
|
p = s + strlen (s) - 1;
|
||||||
|
*p = '\0';
|
||||||
|
s = concat (s,
|
||||||
|
((char *) strings
|
||||||
|
+ stroff
|
||||||
|
+ bfd_get_32 (abfd, stab)),
|
||||||
|
(const char *) NULL);
|
||||||
|
|
||||||
|
/* We have to restore the backslash, because, if
|
||||||
|
the linker is hashing stabs strings, we may
|
||||||
|
see the same string more than once. */
|
||||||
|
*p = '\\';
|
||||||
|
|
||||||
|
if (f != NULL)
|
||||||
|
free (f);
|
||||||
|
f = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
save_stab (type, desc, value, s);
|
||||||
|
|
||||||
|
if (! parse_stab (dhandle, shandle, type, desc, value, s))
|
||||||
|
{
|
||||||
|
stab_context ();
|
||||||
|
free_saved_stabs ();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Don't free f, since I think the stabs code
|
||||||
|
expects strings to hang around. This should be
|
||||||
|
straightened out. FIXME. */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free_saved_stabs ();
|
||||||
|
free (stabs);
|
||||||
|
|
||||||
|
/* Don't free strings, since I think the stabs code expects
|
||||||
|
the strings to hang around. This should be straightened
|
||||||
|
out. FIXME. */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shandle != NULL)
|
||||||
|
{
|
||||||
|
if (! finish_stab (dhandle, shandle))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read stabs in the symbol table. */
|
||||||
|
|
||||||
|
static bfd_boolean
|
||||||
|
read_symbol_stabs_debugging_info (bfd *abfd, asymbol **syms, long symcount,
|
||||||
|
void *dhandle, bfd_boolean *pfound)
|
||||||
|
{
|
||||||
|
void *shandle;
|
||||||
|
asymbol **ps, **symend;
|
||||||
|
|
||||||
|
shandle = NULL;
|
||||||
|
symend = syms + symcount;
|
||||||
|
for (ps = syms; ps < symend; ps++)
|
||||||
|
{
|
||||||
|
symbol_info i;
|
||||||
|
|
||||||
|
bfd_get_symbol_info (abfd, *ps, &i);
|
||||||
|
|
||||||
|
if (i.type == '-')
|
||||||
|
{
|
||||||
|
const char *s;
|
||||||
|
char *f;
|
||||||
|
|
||||||
|
if (shandle == NULL)
|
||||||
|
{
|
||||||
|
shandle = start_stab (dhandle, abfd, FALSE, syms, symcount);
|
||||||
|
if (shandle == NULL)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pfound = TRUE;
|
||||||
|
|
||||||
|
s = i.name;
|
||||||
|
f = NULL;
|
||||||
|
while (s[strlen (s) - 1] == '\\'
|
||||||
|
&& ps + 1 < symend)
|
||||||
|
{
|
||||||
|
char *sc, *n;
|
||||||
|
|
||||||
|
++ps;
|
||||||
|
sc = xstrdup (s);
|
||||||
|
sc[strlen (sc) - 1] = '\0';
|
||||||
|
n = concat (sc, bfd_asymbol_name (*ps), (const char *) NULL);
|
||||||
|
free (sc);
|
||||||
|
if (f != NULL)
|
||||||
|
free (f);
|
||||||
|
f = n;
|
||||||
|
s = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
save_stab (i.stab_type, i.stab_desc, i.value, s);
|
||||||
|
|
||||||
|
if (! parse_stab (dhandle, shandle, i.stab_type, i.stab_desc,
|
||||||
|
i.value, s))
|
||||||
|
{
|
||||||
|
stab_context ();
|
||||||
|
free_saved_stabs ();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Don't free f, since I think the stabs code expects
|
||||||
|
strings to hang around. This should be straightened out.
|
||||||
|
FIXME. */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free_saved_stabs ();
|
||||||
|
|
||||||
|
if (shandle != NULL)
|
||||||
|
{
|
||||||
|
if (! finish_stab (dhandle, shandle))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read IEEE debugging information. */
|
||||||
|
|
||||||
|
static bfd_boolean
|
||||||
|
read_ieee_debugging_info (bfd *abfd, void *dhandle, bfd_boolean *pfound)
|
||||||
|
{
|
||||||
|
asection *dsec;
|
||||||
|
bfd_size_type size;
|
||||||
|
bfd_byte *contents;
|
||||||
|
|
||||||
|
/* The BFD backend puts the debugging information into a section
|
||||||
|
named .debug. */
|
||||||
|
|
||||||
|
dsec = bfd_get_section_by_name (abfd, ".debug");
|
||||||
|
if (dsec == NULL)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
size = bfd_section_size (abfd, dsec);
|
||||||
|
contents = (bfd_byte *) xmalloc (size);
|
||||||
|
if (! bfd_get_section_contents (abfd, dsec, contents, 0, size))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (! parse_ieee (dhandle, abfd, contents, size))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
free (contents);
|
||||||
|
|
||||||
|
*pfound = TRUE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Record stabs strings, so that we can give some context for errors. */
|
||||||
|
|
||||||
|
#define SAVE_STABS_COUNT (16)
|
||||||
|
|
||||||
|
struct saved_stab
|
||||||
|
{
|
||||||
|
int type;
|
||||||
|
int desc;
|
||||||
|
bfd_vma value;
|
||||||
|
char *string;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct saved_stab saved_stabs[SAVE_STABS_COUNT];
|
||||||
|
static int saved_stabs_index;
|
||||||
|
|
||||||
|
/* Save a stabs string. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
save_stab (int type, int desc, bfd_vma value, const char *string)
|
||||||
|
{
|
||||||
|
if (saved_stabs[saved_stabs_index].string != NULL)
|
||||||
|
free (saved_stabs[saved_stabs_index].string);
|
||||||
|
saved_stabs[saved_stabs_index].type = type;
|
||||||
|
saved_stabs[saved_stabs_index].desc = desc;
|
||||||
|
saved_stabs[saved_stabs_index].value = value;
|
||||||
|
saved_stabs[saved_stabs_index].string = xstrdup (string);
|
||||||
|
saved_stabs_index = (saved_stabs_index + 1) % SAVE_STABS_COUNT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Provide context for an error. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
stab_context (void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
fprintf (stderr, _("Last stabs entries before error:\n"));
|
||||||
|
fprintf (stderr, "n_type n_desc n_value string\n");
|
||||||
|
|
||||||
|
i = saved_stabs_index;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
struct saved_stab *stabp;
|
||||||
|
|
||||||
|
stabp = saved_stabs + i;
|
||||||
|
if (stabp->string != NULL)
|
||||||
|
{
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
s = bfd_get_stab_name (stabp->type);
|
||||||
|
if (s != NULL)
|
||||||
|
fprintf (stderr, "%-6s", s);
|
||||||
|
else if (stabp->type == 0)
|
||||||
|
fprintf (stderr, "HdrSym");
|
||||||
|
else
|
||||||
|
fprintf (stderr, "%-6d", stabp->type);
|
||||||
|
fprintf (stderr, " %-6d ", stabp->desc);
|
||||||
|
fprintf_vma (stderr, stabp->value);
|
||||||
|
if (stabp->type != 0)
|
||||||
|
fprintf (stderr, " %s", stabp->string);
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
}
|
||||||
|
i = (i + 1) % SAVE_STABS_COUNT;
|
||||||
|
}
|
||||||
|
while (i != saved_stabs_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free the saved stab strings. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
free_saved_stabs (void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < SAVE_STABS_COUNT; i++)
|
||||||
|
{
|
||||||
|
if (saved_stabs[i].string != NULL)
|
||||||
|
{
|
||||||
|
free (saved_stabs[i].string);
|
||||||
|
saved_stabs[i].string = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
saved_stabs_index = 0;
|
||||||
|
}
|
212
contrib/toolchain/binutils/binutils/rename.c
Normal file
212
contrib/toolchain/binutils/binutils/rename.c
Normal file
@ -0,0 +1,212 @@
|
|||||||
|
/* rename.c -- rename a file, preserving symlinks.
|
||||||
|
Copyright 1999, 2002, 2003, 2005, 2007, 2008 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GNU Binutils.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR 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, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
|
||||||
|
02110-1301, USA. */
|
||||||
|
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "bucomm.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_GOOD_UTIME_H
|
||||||
|
#include <utime.h>
|
||||||
|
#else /* ! HAVE_GOOD_UTIME_H */
|
||||||
|
#ifdef HAVE_UTIMES
|
||||||
|
#include <sys/time.h>
|
||||||
|
#endif /* HAVE_UTIMES */
|
||||||
|
#endif /* ! HAVE_GOOD_UTIME_H */
|
||||||
|
|
||||||
|
#if ! defined (_WIN32) || defined (__CYGWIN32__)
|
||||||
|
static int simple_copy (const char *, const char *);
|
||||||
|
|
||||||
|
/* The number of bytes to copy at once. */
|
||||||
|
#define COPY_BUF 8192
|
||||||
|
|
||||||
|
/* Copy file FROM to file TO, performing no translations.
|
||||||
|
Return 0 if ok, -1 if error. */
|
||||||
|
|
||||||
|
static int
|
||||||
|
simple_copy (const char *from, const char *to)
|
||||||
|
{
|
||||||
|
int fromfd, tofd, nread;
|
||||||
|
int saved;
|
||||||
|
char buf[COPY_BUF];
|
||||||
|
|
||||||
|
fromfd = open (from, O_RDONLY | O_BINARY);
|
||||||
|
if (fromfd < 0)
|
||||||
|
return -1;
|
||||||
|
#ifdef O_CREAT
|
||||||
|
tofd = open (to, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, 0777);
|
||||||
|
#else
|
||||||
|
tofd = creat (to, 0777);
|
||||||
|
#endif
|
||||||
|
if (tofd < 0)
|
||||||
|
{
|
||||||
|
saved = errno;
|
||||||
|
close (fromfd);
|
||||||
|
errno = saved;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
while ((nread = read (fromfd, buf, sizeof buf)) > 0)
|
||||||
|
{
|
||||||
|
if (write (tofd, buf, nread) != nread)
|
||||||
|
{
|
||||||
|
saved = errno;
|
||||||
|
close (fromfd);
|
||||||
|
close (tofd);
|
||||||
|
errno = saved;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
saved = errno;
|
||||||
|
close (fromfd);
|
||||||
|
close (tofd);
|
||||||
|
if (nread < 0)
|
||||||
|
{
|
||||||
|
errno = saved;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif /* __CYGWIN32__ or not _WIN32 */
|
||||||
|
|
||||||
|
/* Set the times of the file DESTINATION to be the same as those in
|
||||||
|
STATBUF. */
|
||||||
|
|
||||||
|
void
|
||||||
|
set_times (const char *destination, const struct stat *statbuf)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
|
||||||
|
{
|
||||||
|
#ifdef HAVE_GOOD_UTIME_H
|
||||||
|
struct utimbuf tb;
|
||||||
|
|
||||||
|
tb.actime = statbuf->st_atime;
|
||||||
|
tb.modtime = statbuf->st_mtime;
|
||||||
|
// result = utime (destination, &tb);
|
||||||
|
#else /* ! HAVE_GOOD_UTIME_H */
|
||||||
|
#ifndef HAVE_UTIMES
|
||||||
|
long tb[2];
|
||||||
|
|
||||||
|
tb[0] = statbuf->st_atime;
|
||||||
|
tb[1] = statbuf->st_mtime;
|
||||||
|
result = utime (destination, tb);
|
||||||
|
#else /* HAVE_UTIMES */
|
||||||
|
struct timeval tv[2];
|
||||||
|
|
||||||
|
tv[0].tv_sec = statbuf->st_atime;
|
||||||
|
tv[0].tv_usec = 0;
|
||||||
|
tv[1].tv_sec = statbuf->st_mtime;
|
||||||
|
tv[1].tv_usec = 0;
|
||||||
|
result = utimes (destination, tv);
|
||||||
|
#endif /* HAVE_UTIMES */
|
||||||
|
#endif /* ! HAVE_GOOD_UTIME_H */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result != 0)
|
||||||
|
non_fatal (_("%s: cannot set time: %s"), destination, strerror (errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef S_ISLNK
|
||||||
|
#ifdef S_IFLNK
|
||||||
|
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
|
||||||
|
#else
|
||||||
|
#define S_ISLNK(m) 0
|
||||||
|
#define lstat stat
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Rename FROM to TO, copying if TO is a link.
|
||||||
|
Return 0 if ok, -1 if error. */
|
||||||
|
|
||||||
|
int
|
||||||
|
smart_rename (const char *from, const char *to, int preserve_dates ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
bfd_boolean exists;
|
||||||
|
struct stat s;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
exists = lstat (to, &s) == 0;
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
/* Win32, unlike unix, will not erase `to' in `rename(from, to)' but
|
||||||
|
fail instead. Also, chown is not present. */
|
||||||
|
|
||||||
|
if (exists)
|
||||||
|
remove (to);
|
||||||
|
|
||||||
|
ret = rename (from, to);
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
/* We have to clean up here. */
|
||||||
|
non_fatal (_("unable to rename '%s'; reason: %s"), to, strerror (errno));
|
||||||
|
unlink (from);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/* Use rename only if TO is not a symbolic link and has
|
||||||
|
only one hard link, and we have permission to write to it. */
|
||||||
|
if (! exists
|
||||||
|
|| (!S_ISLNK (s.st_mode)
|
||||||
|
&& S_ISREG (s.st_mode)
|
||||||
|
&& (s.st_mode & S_IWUSR)
|
||||||
|
&& s.st_nlink == 1)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ret = rename (from, to);
|
||||||
|
if (ret == 0)
|
||||||
|
{
|
||||||
|
if (exists)
|
||||||
|
{
|
||||||
|
/* Try to preserve the permission bits and ownership of
|
||||||
|
TO. First get the mode right except for the setuid
|
||||||
|
bit. Then change the ownership. Then fix the setuid
|
||||||
|
bit. We do the chmod before the chown because if the
|
||||||
|
chown succeeds, and we are a normal user, we won't be
|
||||||
|
able to do the chmod afterward. We don't bother to
|
||||||
|
fix the setuid bit first because that might introduce
|
||||||
|
a fleeting security problem, and because the chown
|
||||||
|
will clear the setuid bit anyhow. We only fix the
|
||||||
|
setuid bit if the chown succeeds, because we don't
|
||||||
|
want to introduce an unexpected setuid file owned by
|
||||||
|
the user running objcopy. */
|
||||||
|
// chmod (to, s.st_mode & 0777);
|
||||||
|
// if (chown (to, s.st_uid, s.st_gid) >= 0)
|
||||||
|
// chmod (to, s.st_mode & 07777);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* We have to clean up here. */
|
||||||
|
non_fatal (_("unable to rename '%s'; reason: %s"), to, strerror (errno));
|
||||||
|
unlink (from);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = simple_copy (from, to);
|
||||||
|
if (ret != 0)
|
||||||
|
non_fatal (_("unable to copy file '%s'; reason: %s"), to, strerror (errno));
|
||||||
|
|
||||||
|
if (preserve_dates)
|
||||||
|
set_times (to, &s);
|
||||||
|
unlink (from);
|
||||||
|
}
|
||||||
|
#endif /* _WIN32 && !__CYGWIN32__ */
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
5433
contrib/toolchain/binutils/binutils/stabs.c
Normal file
5433
contrib/toolchain/binutils/binutils/stabs.c
Normal file
File diff suppressed because it is too large
Load Diff
188
contrib/toolchain/binutils/binutils/sysdep.h
Normal file
188
contrib/toolchain/binutils/binutils/sysdep.h
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
/* sysdep.h -- handle host dependencies for binutils
|
||||||
|
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
|
||||||
|
2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2012
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GNU Binutils.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR 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, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||||
|
|
||||||
|
#ifndef _BIN_SYSDEP_H
|
||||||
|
#define _BIN_SYSDEP_H
|
||||||
|
|
||||||
|
#include "alloca-conf.h"
|
||||||
|
#include "ansidecl.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "bfdver.h"
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#ifdef USE_BINARY_FOPEN
|
||||||
|
#include "fopen-bin.h"
|
||||||
|
#else
|
||||||
|
#include "fopen-same.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#ifndef errno
|
||||||
|
extern int errno;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef STRING_WITH_STRINGS
|
||||||
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#else
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
#include <string.h>
|
||||||
|
#else
|
||||||
|
#ifdef HAVE_STRINGS_H
|
||||||
|
#include <strings.h>
|
||||||
|
#else
|
||||||
|
extern char *strchr ();
|
||||||
|
extern char *strrchr ();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_STDLIB_H
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_FCNTL_H
|
||||||
|
#include <fcntl.h>
|
||||||
|
#else
|
||||||
|
#ifdef HAVE_SYS_FILE_H
|
||||||
|
#include <sys/file.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_STAT_H
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "binary-io.h"
|
||||||
|
|
||||||
|
#if !HAVE_DECL_STPCPY
|
||||||
|
extern char *stpcpy (char *, const char *);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !HAVE_DECL_STRSTR
|
||||||
|
extern char *strstr ();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SBRK
|
||||||
|
#if !HAVE_DECL_SBRK
|
||||||
|
extern char *sbrk ();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !HAVE_DECL_GETENV
|
||||||
|
extern char *getenv ();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !HAVE_DECL_ENVIRON
|
||||||
|
extern char **environ;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !HAVE_DECL_FPRINTF
|
||||||
|
extern int fprintf (FILE *, const char *, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !HAVE_DECL_SNPRINTF
|
||||||
|
extern int snprintf(char *, size_t, const char *, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !HAVE_DECL_VSNPRINTF
|
||||||
|
extern int vsnprintf(char *, size_t, const char *, va_list);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_RDONLY
|
||||||
|
#define O_RDONLY 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_RDWR
|
||||||
|
#define O_RDWR 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SEEK_SET
|
||||||
|
#define SEEK_SET 0
|
||||||
|
#endif
|
||||||
|
#ifndef SEEK_CUR
|
||||||
|
#define SEEK_CUR 1
|
||||||
|
#endif
|
||||||
|
#ifndef SEEK_END
|
||||||
|
#define SEEK_END 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LOCALE_H
|
||||||
|
# ifndef ENABLE_NLS
|
||||||
|
/* The Solaris version of locale.h always includes libintl.h. If we have
|
||||||
|
been configured with --disable-nls then ENABLE_NLS will not be defined
|
||||||
|
and the dummy definitions of bindtextdomain (et al) below will conflict
|
||||||
|
with the defintions in libintl.h. So we define these values to prevent
|
||||||
|
the bogus inclusion of libintl.h. */
|
||||||
|
# define _LIBINTL_H
|
||||||
|
# define _LIBGETTEXT_H
|
||||||
|
# endif
|
||||||
|
# include <locale.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_NLS
|
||||||
|
# include <libintl.h>
|
||||||
|
# define _(String) gettext (String)
|
||||||
|
# ifdef gettext_noop
|
||||||
|
# define N_(String) gettext_noop (String)
|
||||||
|
# else
|
||||||
|
# define N_(String) (String)
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define gettext(Msgid) (Msgid)
|
||||||
|
# define dgettext(Domainname, Msgid) (Msgid)
|
||||||
|
# define dcgettext(Domainname, Msgid, Category) (Msgid)
|
||||||
|
# define textdomain(Domainname) while (0) /* nothing */
|
||||||
|
# define bindtextdomain(Domainname, Dirname) while (0) /* nothing */
|
||||||
|
# define _(String) (String)
|
||||||
|
# define N_(String) (String)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Used by ar.c and objcopy.c. */
|
||||||
|
#define BUFSIZE 8192
|
||||||
|
|
||||||
|
/* For PATH_MAX. */
|
||||||
|
#ifdef HAVE_LIMITS_H
|
||||||
|
#include <limits.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PATH_MAX
|
||||||
|
/* For MAXPATHLEN. */
|
||||||
|
# ifdef HAVE_SYS_PARAM_H
|
||||||
|
# include <sys/param.h>
|
||||||
|
# endif
|
||||||
|
# ifndef PATH_MAX
|
||||||
|
# ifdef MAXPATHLEN
|
||||||
|
# define PATH_MAX MAXPATHLEN
|
||||||
|
# else
|
||||||
|
# define PATH_MAX 1024
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _BIN_SYSDEP_H */
|
42
contrib/toolchain/binutils/binutils/version.c
Normal file
42
contrib/toolchain/binutils/binutils/version.c
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/* version.c -- binutils version information
|
||||||
|
Copyright 1991, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||||
|
2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
|
||||||
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GNU Binutils.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR 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, write to the Free Software
|
||||||
|
Foundation, 51 Franklin Street - Fifth Floor, Boston,
|
||||||
|
MA 02110-1301, USA. */
|
||||||
|
|
||||||
|
#include "sysdep.h"
|
||||||
|
#include "bfd.h"
|
||||||
|
#include "bucomm.h"
|
||||||
|
|
||||||
|
/* Print the version number and copyright information, and exit.
|
||||||
|
This implements the --version option for the various programs. */
|
||||||
|
|
||||||
|
void
|
||||||
|
print_version (const char *name)
|
||||||
|
{
|
||||||
|
/* This output is intended to follow the GNU standards document. */
|
||||||
|
/* xgettext:c-format */
|
||||||
|
printf ("GNU %s %s\n", name, BFD_VERSION_STRING);
|
||||||
|
printf (_("Copyright 2013 Free Software Foundation, Inc.\n"));
|
||||||
|
printf (_("\
|
||||||
|
This program is free software; you may redistribute it under the terms of\n\
|
||||||
|
the GNU General Public License version 3 or (at your option) any later version.\n\
|
||||||
|
This program has absolutely no warranty.\n"));
|
||||||
|
exit (0);
|
||||||
|
}
|
2272
contrib/toolchain/binutils/binutils/wrstabs.c
Normal file
2272
contrib/toolchain/binutils/binutils/wrstabs.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -4275,8 +4275,8 @@ yy_input (char *buf, int max_size)
|
|||||||
if (yyin)
|
if (yyin)
|
||||||
{
|
{
|
||||||
result = fread (buf, 1, max_size, yyin);
|
result = fread (buf, 1, max_size, yyin);
|
||||||
// if (result < max_size && ferror (yyin))
|
if (result < max_size && ferror (yyin))
|
||||||
// einfo ("%F%P: read in flex scanner failed\n");
|
einfo ("%F%P: read in flex scanner failed\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -16,7 +16,7 @@ SRCS = \
|
|||||||
fopen_unlocked.c getopt.c getopt1.c getpwd.c \
|
fopen_unlocked.c getopt.c getopt1.c getpwd.c \
|
||||||
getruntime.c hashtab.c hex.c index.c insque.c \
|
getruntime.c hashtab.c hex.c index.c insque.c \
|
||||||
lbasename.c lrealpath.c make-relative-prefix.c \
|
lbasename.c lrealpath.c make-relative-prefix.c \
|
||||||
make-temp-file.c md5.c memmem.c mempcpy.c mkstemps.c \
|
make-temp-file.c md5.c memmem.c mempcpy.c \
|
||||||
objalloc.c obstack.c partition.c physmem.c random.c \
|
objalloc.c obstack.c partition.c physmem.c random.c \
|
||||||
regex.c rindex.c safe-ctype.c setenv.c setproctitle.c \
|
regex.c rindex.c safe-ctype.c setenv.c setproctitle.c \
|
||||||
sha1.c sigsetmask.c simple-object.c simple-object-coff.c\
|
sha1.c sigsetmask.c simple-object.c simple-object-coff.c\
|
||||||
|
@ -165,7 +165,7 @@
|
|||||||
#define HAVE_MEMSET 1
|
#define HAVE_MEMSET 1
|
||||||
|
|
||||||
/* Define to 1 if you have the `mkstemps' function. */
|
/* Define to 1 if you have the `mkstemps' function. */
|
||||||
/* #undef HAVE_MKSTEMPS */
|
#define HAVE_MKSTEMPS 1
|
||||||
|
|
||||||
/* Define to 1 if you have a working `mmap' system call. */
|
/* Define to 1 if you have a working `mmap' system call. */
|
||||||
/* #undef HAVE_MMAP */
|
/* #undef HAVE_MMAP */
|
||||||
|
@ -89,7 +89,7 @@ static const char vartmp[] =
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char *memoized_tmpdir;
|
//static char *memoized_tmpdir;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@ -105,68 +105,7 @@ files in.
|
|||||||
char *
|
char *
|
||||||
choose_tmpdir (void)
|
choose_tmpdir (void)
|
||||||
{
|
{
|
||||||
if (!memoized_tmpdir)
|
return "/tmp0/1/";
|
||||||
{
|
|
||||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
|
||||||
const char *base = 0;
|
|
||||||
char *tmpdir;
|
|
||||||
unsigned int len;
|
|
||||||
|
|
||||||
#ifdef VMS
|
|
||||||
/* Try VMS standard temp logical. */
|
|
||||||
base = try_dir ("/sys$scratch", base);
|
|
||||||
#else
|
|
||||||
base = try_dir (getenv ("TMPDIR"), base);
|
|
||||||
base = try_dir (getenv ("TMP"), base);
|
|
||||||
base = try_dir (getenv ("TEMP"), base);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef P_tmpdir
|
|
||||||
/* We really want a directory name here as if concatenated with say \dir
|
|
||||||
we do not end up with a double \\ which defines an UNC path. */
|
|
||||||
if (strcmp (P_tmpdir, "\\") == 0)
|
|
||||||
base = try_dir ("\\.", base);
|
|
||||||
else
|
|
||||||
base = try_dir (P_tmpdir, base);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Try /var/tmp, /usr/tmp, then /tmp. */
|
|
||||||
base = try_dir (vartmp, base);
|
|
||||||
base = try_dir (usrtmp, base);
|
|
||||||
base = try_dir (tmp, base);
|
|
||||||
|
|
||||||
/* If all else fails, use the current directory! */
|
|
||||||
if (base == 0)
|
|
||||||
base = ".";
|
|
||||||
/* Append DIR_SEPARATOR to the directory we've chosen
|
|
||||||
and return it. */
|
|
||||||
len = strlen (base);
|
|
||||||
tmpdir = XNEWVEC (char, len + 2);
|
|
||||||
strcpy (tmpdir, base);
|
|
||||||
tmpdir[len] = DIR_SEPARATOR;
|
|
||||||
tmpdir[len+1] = '\0';
|
|
||||||
memoized_tmpdir = tmpdir;
|
|
||||||
#else /* defined(_WIN32) && !defined(__CYGWIN__) */
|
|
||||||
DWORD len;
|
|
||||||
|
|
||||||
/* Figure out how much space we need. */
|
|
||||||
len = GetTempPath(0, NULL);
|
|
||||||
if (len)
|
|
||||||
{
|
|
||||||
memoized_tmpdir = XNEWVEC (char, len);
|
|
||||||
if (!GetTempPath(len, memoized_tmpdir))
|
|
||||||
{
|
|
||||||
XDELETEVEC (memoized_tmpdir);
|
|
||||||
memoized_tmpdir = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!memoized_tmpdir)
|
|
||||||
/* If all else fails, use the current directory. */
|
|
||||||
memoized_tmpdir = xstrdup (".\\");
|
|
||||||
#endif /* defined(_WIN32) && !defined(__CYGWIN__) */
|
|
||||||
}
|
|
||||||
|
|
||||||
return memoized_tmpdir;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -100,9 +100,9 @@ mkstemps (char *pattern, int suffix_len)
|
|||||||
#ifdef HAVE_GETTIMEOFDAY
|
#ifdef HAVE_GETTIMEOFDAY
|
||||||
/* Get some more or less random data. */
|
/* Get some more or less random data. */
|
||||||
gettimeofday (&tv, NULL);
|
gettimeofday (&tv, NULL);
|
||||||
value += ((gcc_uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid ();
|
value += ((gcc_uint64_t) tv.tv_usec << 16) ^ tv.tv_sec; // ^ getpid ();
|
||||||
#else
|
#else
|
||||||
value += getpid ();
|
value += 1;//getpid ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (count = 0; count < TMP_MAX; ++count)
|
for (count = 0; count < TMP_MAX; ++count)
|
||||||
|
@ -64,9 +64,9 @@ unlink_if_ordinary (const char *name)
|
|||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
// if (lstat (name, &st) == 0
|
if (lstat (name, &st) == 0
|
||||||
// && (S_ISREG (st.st_mode) || S_ISLNK (st.st_mode)))
|
&& (S_ISREG (st.st_mode) || S_ISLNK (st.st_mode)))
|
||||||
// return unlink (name);
|
return unlink (name);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user