binutils-gdb/libiberty/simple-object-common.h
Nick Clifton 533da48302 Update libiberty sources with changes in the gcc mainline.
+2020-01-01  Jakub Jelinek  <jakub@redhat.com>
+
+	Update copyright years.
+
+2019-12-06  Tim Ruehsen  <tim.ruehsen@gmx.de>
+
+	* make-relative-prefix.c (split_directories):
+	Return early on empty 'name'
+
+2019-11-16  Tim Ruehsen  <tim.ruehsen@gmx.de>
+
+	* cp-demangle.c (d_print_init): Remove const from 4th param.
+	(cplus_demangle_fill_name): Initialize d->d_counting.
+	(cplus_demangle_fill_extended_operator): Likewise.
+	(cplus_demangle_fill_ctor): Likewise.
+	(cplus_demangle_fill_dtor): Likewise.
+	(d_make_empty): Likewise.
+	(d_count_templates_scopes): Remobe const from 3rd param,
+	Return on dc->d_counting > 1,
+	Increment dc->d_counting.
+        * cp-demint.c (cplus_demangle_fill_component): Initialize d->d_counting.
+	(cplus_demangle_fill_builtin_type): Likewise.
+	(cplus_demangle_fill_operator): Likewise.
+
+2019-11-16  Eduard-Mihai Burtescu  <eddyb@lyken.rs>
+
+	* cplus-dem.c (cplus_demangle): Use rust_demangle directly.
+	(rust_demangle): Remove.
+	* rust-demangle.c (is_prefixed_hash): Rename to is_legacy_prefixed_hash.
+	(parse_lower_hex_nibble): Rename to decode_lower_hex_nibble.
+	(parse_legacy_escape): Rename to decode_legacy_escape.
+	(rust_is_mangled): Remove.
+	(struct rust_demangler): Add.
+	(peek): Add.
+	(next): Add.
+	(struct rust_mangled_ident): Add.
+	(parse_ident): Add.
+	(rust_demangle_sym): Remove.
+	(print_str): Add.
+	(PRINT): Add.
+	(print_ident): Add.
+	(rust_demangle_callback): Add.
+	(struct str_buf): Add.
+	(str_buf_reserve): Add.
+	(str_buf_append): Add.
+	(str_buf_demangle_callback): Add.
+	(rust_demangle): Add.
+	* rust-demangle.h: Remove.
+
+2019-11-15  Miguel Saldivar  <saldivarcher@gmail.com>
+
+	* testsuite/demangle-expected: Fix test.
+
+2019-11-04  Kamlesh Kumar  <kamleshbhalui@gmail.com>
+
+	* cp-demangle.c (d_expr_primary): Handle
+	nullptr demangling.
+	* testsuite/demangle-expected: Added test.
+
+2019-10-29 Paul Pluzhnikov  <ppluzhnikov@google.com>
+
+	* cp-demangle.c (d_number): Avoid signed int overflow.
+
+2019-10-28  Miguel Saldivar  <saldivarcher@gmail.com>
+
+	* cp-demangle.c (d_print_mod): Add a space before printing `complex`
+	and `imaginary`, as opposed to after.
+	* testsuite/demangle-expected: Adjust test.
+
+2019-10-03  Eduard-Mihai Burtescu  <eddyb@lyken.rs>
+
+	* rust-demangle.c (looks_like_rust): Remove.
+	(rust_is_mangled): Don't check escapes.
+	(is_prefixed_hash): Allow 0-9a-f permutations.
+	(rust_demangle_sym): Don't bail on unknown escapes.
+	* testsuite/rust-demangle-expected: Update 'main::$99$' test.
+
+2019-09-03  Eduard-Mihai Burtescu  <eddyb@lyken.rs>
+
+	* rust-demangle.c (unescape): Remove.
+	(parse_lower_hex_nibble): New function.
+	(parse_legacy_escape): New function.
+	(is_prefixed_hash): Use parse_lower_hex_nibble.
+	(looks_like_rust): Use parse_legacy_escape.
+	(rust_demangle_sym): Use parse_legacy_escape.
+	* testsuite/rust-demangle-expected: Add 'llv$u6d$' test.
+
+2019-08-27  Martin Liska  <mliska@suse.cz>
+
+	PR lto/91478
+	* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
+	First find a WEAK HIDDEN symbol in symbol table that will be
+	preserved.  Later, use the symbol name for all removed symbols.
+
+2019-08-12  Martin Liska  <mliska@suse.cz>
+
+	* Makefile.in: Add filedescriptor.c.
+	* filedescriptor.c: New file.
+	* lrealpath.c (is_valid_fd): Remove.

diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index 0be45b4ae8..fe738d0db4 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -1,7 +1,7 @@
 # Makefile for the libiberty library.
 # Originally written by K. Richard Pixley <rich@cygnus.com>.
 #
-# Copyright (C) 1990-2019 Free Software Foundation, Inc.
+# Copyright (C) 1990-2020 Free Software Foundation, Inc.
 #
 # This file is part of the libiberty library.
 # Libiberty is free software; you can redistribute it and/or
@@ -127,7 +127,7 @@ CFILES = alloca.c argv.c asprintf.c atexit.c				\
 	calloc.c choose-temp.c clock.c concat.c cp-demangle.c		\
 	 cp-demint.c cplus-dem.c crc32.c				\
 	d-demangle.c dwarfnames.c dyn-string.c				\
-	fdmatch.c ffs.c fibheap.c filename_cmp.c floatformat.c		\
+	fdmatch.c ffs.c fibheap.c filedescriptor.c filename_cmp.c floatformat.c		\
 	fnmatch.c fopen_unlocked.c					\
 	getcwd.c getopt.c getopt1.c getpagesize.c getpwd.c getruntime.c	\
          gettimeofday.c                                                 \
@@ -171,6 +171,7 @@ REQUIRED_OFILES =							\
 	./cp-demint.$(objext) ./crc32.$(objext) ./d-demangle.$(objext)	\
 	./dwarfnames.$(objext) ./dyn-string.$(objext)			\
 	./fdmatch.$(objext) ./fibheap.$(objext)				\
+	./filedescriptor.$(objext)	\
 	./filename_cmp.$(objext) ./floatformat.$(objext)		\
 	./fnmatch.$(objext) ./fopen_unlocked.$(objext)			\
 	./getopt.$(objext) ./getopt1.$(objext) ./getpwd.$(objext)	\
@@ -756,6 +757,17 @@ $(CONFIGURED_OFILES): stamp-picdir stamp-noasandir
 	else true; fi
 	$(COMPILE.c) $(srcdir)/fibheap.c $(OUTPUT_OPTION)

+./filedescriptor.$(objext): $(srcdir)/filedescriptor.c config.h $(INCDIR)/ansidecl.h \
+	$(INCDIR)/libiberty.h
+	if [ x"$(PICFLAG)" != x ]; then \
+	  $(COMPILE.c) $(PICFLAG) $(srcdir)/filedescriptor.c -o pic/$@; \
+	else true; fi
+	if [ x"$(NOASANFLAG)" != x ]; then \
+	  $(COMPILE.c) $(PICFLAG) $(NOASANFLAG) $(srcdir)/filedescriptor.c -o noasan/$@; \
+	else true; fi
+	$(COMPILE.c) $(srcdir)/filedescriptor.c $(OUTPUT_OPTION)
+
+
 ./filename_cmp.$(objext): $(srcdir)/filename_cmp.c config.h $(INCDIR)/ansidecl.h \
 	$(INCDIR)/filenames.h $(INCDIR)/hashtab.h \
 	$(INCDIR)/safe-ctype.h
diff --git a/libiberty/_doprnt.c b/libiberty/_doprnt.c
index d44dc415ed..a739f4304f 100644
--- a/libiberty/_doprnt.c
+++ b/libiberty/_doprnt.c
@@ -1,5 +1,5 @@
 /* Provide a version of _doprnt in terms of fprintf.
-   Copyright (C) 1998-2019 Free Software Foundation, Inc.
+   Copyright (C) 1998-2020 Free Software Foundation, Inc.
    Contributed by Kaveh Ghazi  (ghazi@caip.rutgers.edu)  3/29/98

 This program is free software; you can redistribute it and/or modify it
diff --git a/libiberty/argv.c b/libiberty/argv.c
index 6444896f99..8c9794db6a 100644
--- a/libiberty/argv.c
+++ b/libiberty/argv.c
@@ -1,5 +1,5 @@
 /* Create and destroy argument vectors (argv's)
-   Copyright (C) 1992-2019 Free Software Foundation, Inc.
+   Copyright (C) 1992-2020 Free Software Foundation, Inc.
    Written by Fred Fish @ Cygnus Support

 This file is part of the libiberty library.
diff --git a/libiberty/asprintf.c b/libiberty/asprintf.c
index 5718682f69..6e38e2234d 100644
--- a/libiberty/asprintf.c
+++ b/libiberty/asprintf.c
@@ -1,6 +1,6 @@
 /* Like sprintf but provides a pointer to malloc'd storage, which must
    be freed by the caller.
-   Copyright (C) 1997-2019 Free Software Foundation, Inc.
+   Copyright (C) 1997-2020 Free Software Foundation, Inc.
    Contributed by Cygnus Solutions.

 This file is part of the libiberty library.
diff --git a/libiberty/choose-temp.c b/libiberty/choose-temp.c
index 72c1b710bd..49a2faaa51 100644
--- a/libiberty/choose-temp.c
+++ b/libiberty/choose-temp.c
@@ -1,5 +1,5 @@
 /* Utility to pick a temporary filename prefix.
-   Copyright (C) 1996-2019 Free Software Foundation, Inc.
+   Copyright (C) 1996-2020 Free Software Foundation, Inc.

 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/clock.c b/libiberty/clock.c
index a3730714bd..0de74657d0 100644
--- a/libiberty/clock.c
+++ b/libiberty/clock.c
@@ -1,5 +1,5 @@
 /* ANSI-compatible clock function.
-   Copyright (C) 1994-2019 Free Software Foundation, Inc.
+   Copyright (C) 1994-2020 Free Software Foundation, Inc.

 This file is part of the libiberty library.  This library is free
 software; you can redistribute it and/or modify it under the
diff --git
2020-01-17 14:13:22 +00:00

363 lines
10 KiB
C

/* simple-object-common.h -- common structs for object file manipulation.
Copyright (C) 2010-2020 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
Libiberty 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with libiberty; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
Boston, MA 02110-1301, USA. */
/* Forward reference. */
struct simple_object_functions;
/* An object file opened for reading. */
struct simple_object_read_struct
{
/* The file descriptor. */
int descriptor;
/* The offset within the file. */
off_t offset;
/* The functions which do the actual work. */
const struct simple_object_functions *functions;
/* Private data for the object file format. */
void *data;
};
/* Object file attributes. */
struct simple_object_attributes_struct
{
/* The functions which do the actual work. */
const struct simple_object_functions *functions;
/* Private data for the object file format. */
void *data;
};
/* An object file being created. */
struct simple_object_write_struct
{
/* The functions which do the actual work. */
const struct simple_object_functions *functions;
/* The segment_name argument from the user. */
char *segment_name;
/* The start of the list of sections. */
simple_object_write_section *sections;
/* The last entry in the list of sections. */
simple_object_write_section *last_section;
/* Private data for the object file format. */
void *data;
};
/* A section in an object file being created. */
struct simple_object_write_section_struct
{
/* Next in the list of sections attached to an
simple_object_write. */
simple_object_write_section *next;
/* The name of this section. */
char *name;
/* The required alignment. */
unsigned int align;
/* The first data attached to this section. */
struct simple_object_write_section_buffer *buffers;
/* The last data attached to this section. */
struct simple_object_write_section_buffer *last_buffer;
};
/* Data attached to a section. */
struct simple_object_write_section_buffer
{
/* The next data for this section. */
struct simple_object_write_section_buffer *next;
/* The size of the buffer. */
size_t size;
/* The actual bytes. */
const void *buffer;
/* A buffer to free, or NULL. */
void *free_buffer;
};
/* The number of bytes we read from the start of the file to pass to
the match function. */
#define SIMPLE_OBJECT_MATCH_HEADER_LEN (16)
/* Format-specific object file functions. */
struct simple_object_functions
{
/* If this file matches these functions, return a new value for the
private data for an simple_object_read. HEADER is the first 16
bytes of the file. DESCRIPTOR, OFFSET, SEGMENT_NAME, ERRMSG, and
ERR are as for simple_object_open_read. If this file does not
match, this function should return NULL with *ERRMSG set to
NULL. */
void *(*match) (unsigned char header[SIMPLE_OBJECT_MATCH_HEADER_LEN],
int descriptor, off_t offset, const char *segment_name,
const char **errmsg, int *err);
/* Implement simple_object_find_sections. */
const char *(*find_sections) (simple_object_read *,
int (*pfn) (void *, const char *,
off_t offset, off_t length),
void *data,
int *err);
/* Return the private data for the attributes for SOBJ. */
void *(*fetch_attributes) (simple_object_read *sobj, const char **errmsg,
int *err);
/* Release the private data for an simple_object_read. */
void (*release_read) (void *);
/* Merge the private data for the attributes of two files. If they
could be linked together, return NULL. Otherwise return an error
message. */
const char *(*attributes_merge) (void *, void *, int *err);
/* Release the private data for an simple_object_attributes. */
void (*release_attributes) (void *);
/* Start creating an object file. */
void *(*start_write) (void *attributes_data, const char **errmsg,
int *err);
/* Write the complete object file. */
const char *(*write_to_file) (simple_object_write *sobj, int descriptor,
int *err);
/* Release the private data for an simple_object_write. */
void (*release_write) (void *);
/* Copy LTO debug sections. */
const char *(*copy_lto_debug_sections) (simple_object_read *sobj,
simple_object_write *dobj,
char *(*pfn) (const char *),
int *err);
};
/* The known object file formats. */
extern const struct simple_object_functions simple_object_coff_functions;
extern const struct simple_object_functions simple_object_elf_functions;
extern const struct simple_object_functions simple_object_mach_o_functions;
extern const struct simple_object_functions simple_object_xcoff_functions;
/* Read SIZE bytes from DESCRIPTOR at file offset OFFSET into BUFFER.
Return non-zero on success. On failure return 0 and set *ERRMSG
and *ERR. */
extern int
simple_object_internal_read (int descriptor, off_t offset,
unsigned char *buffer, size_t size,
const char **errmsg, int *err);
/* Write SIZE bytes from BUFFER to DESCRIPTOR at file offset OFFSET.
Return non-zero on success. On failure return 0 and set *ERRMSG
and *ERR. */
extern int
simple_object_internal_write (int descriptor, off_t offset,
const unsigned char *buffer, size_t size,
const char **errmsg, int *err);
/* Define ulong_type as an unsigned 64-bit type if available.
Otherwise just make it unsigned long. */
#ifdef UNSIGNED_64BIT_TYPE
__extension__ typedef UNSIGNED_64BIT_TYPE ulong_type;
#else
typedef unsigned long ulong_type;
#endif
/* Fetch a big-endian 16-bit value. */
static inline unsigned short
simple_object_fetch_big_16 (const unsigned char *buf)
{
return ((unsigned short) buf[0] << 8) | (unsigned short) buf[1];
}
/* Fetch a little-endian 16-bit value. */
static inline unsigned short
simple_object_fetch_little_16 (const unsigned char *buf)
{
return ((unsigned short) buf[1] << 8) | (unsigned short) buf[0];
}
/* Fetch a big-endian 32-bit value. */
static inline unsigned int
simple_object_fetch_big_32 (const unsigned char *buf)
{
return (((unsigned int) buf[0] << 24)
| ((unsigned int) buf[1] << 16)
| ((unsigned int) buf[2] << 8)
| (unsigned int) buf[3]);
}
/* Fetch a little-endian 32-bit value. */
static inline unsigned int
simple_object_fetch_little_32 (const unsigned char *buf)
{
return (((unsigned int) buf[3] << 24)
| ((unsigned int) buf[2] << 16)
| ((unsigned int) buf[1] << 8)
| (unsigned int) buf[0]);
}
/* Fetch a big-endian 32-bit value as a ulong_type. */
static inline ulong_type
simple_object_fetch_big_32_ulong (const unsigned char *buf)
{
return (ulong_type) simple_object_fetch_big_32 (buf);
}
/* Fetch a little-endian 32-bit value as a ulong_type. */
static inline ulong_type
simple_object_fetch_little_32_ulong (const unsigned char *buf)
{
return (ulong_type) simple_object_fetch_little_32 (buf);
}
#ifdef UNSIGNED_64BIT_TYPE
/* Fetch a big-endian 64-bit value. */
static inline ulong_type
simple_object_fetch_big_64 (const unsigned char *buf)
{
return (((ulong_type) buf[0] << 56)
| ((ulong_type) buf[1] << 48)
| ((ulong_type) buf[2] << 40)
| ((ulong_type) buf[3] << 32)
| ((ulong_type) buf[4] << 24)
| ((ulong_type) buf[5] << 16)
| ((ulong_type) buf[6] << 8)
| (ulong_type) buf[7]);
}
/* Fetch a little-endian 64-bit value. */
static inline ulong_type
simple_object_fetch_little_64 (const unsigned char *buf)
{
return (((ulong_type) buf[7] << 56)
| ((ulong_type) buf[6] << 48)
| ((ulong_type) buf[5] << 40)
| ((ulong_type) buf[4] << 32)
| ((ulong_type) buf[3] << 24)
| ((ulong_type) buf[2] << 16)
| ((ulong_type) buf[1] << 8)
| (ulong_type) buf[0]);
}
#endif
/* Store a big-endian 16-bit value. */
static inline void
simple_object_set_big_16 (unsigned char *buf, unsigned short val)
{
buf[0] = (val >> 8) & 0xff;
buf[1] = val & 0xff;
}
/* Store a little-endian 16-bit value. */
static inline void
simple_object_set_little_16 (unsigned char *buf, unsigned short val)
{
buf[1] = (val >> 8) & 0xff;
buf[0] = val & 0xff;
}
/* Store a big-endian 32-bit value. */
static inline void
simple_object_set_big_32 (unsigned char *buf, unsigned int val)
{
buf[0] = (val >> 24) & 0xff;
buf[1] = (val >> 16) & 0xff;
buf[2] = (val >> 8) & 0xff;
buf[3] = val & 0xff;
}
/* Store a little-endian 32-bit value. */
static inline void
simple_object_set_little_32 (unsigned char *buf, unsigned int val)
{
buf[3] = (val >> 24) & 0xff;
buf[2] = (val >> 16) & 0xff;
buf[1] = (val >> 8) & 0xff;
buf[0] = val & 0xff;
}
/* Store a big-endian 32-bit value coming in as a ulong_type. */
static inline void
simple_object_set_big_32_ulong (unsigned char *buf, ulong_type val)
{
simple_object_set_big_32 (buf, val);
}
/* Store a little-endian 32-bit value coming in as a ulong_type. */
static inline void
simple_object_set_little_32_ulong (unsigned char *buf, ulong_type val)
{
simple_object_set_little_32 (buf, val);
}
#ifdef UNSIGNED_64BIT_TYPE
/* Store a big-endian 64-bit value. */
static inline void
simple_object_set_big_64 (unsigned char *buf, ulong_type val)
{
buf[0] = (val >> 56) & 0xff;
buf[1] = (val >> 48) & 0xff;
buf[2] = (val >> 40) & 0xff;
buf[3] = (val >> 32) & 0xff;
buf[4] = (val >> 24) & 0xff;
buf[5] = (val >> 16) & 0xff;
buf[6] = (val >> 8) & 0xff;
buf[7] = val & 0xff;
}
/* Store a little-endian 64-bit value. */
static inline void
simple_object_set_little_64 (unsigned char *buf, ulong_type val)
{
buf[7] = (val >> 56) & 0xff;
buf[6] = (val >> 48) & 0xff;
buf[5] = (val >> 40) & 0xff;
buf[4] = (val >> 32) & 0xff;
buf[3] = (val >> 24) & 0xff;
buf[2] = (val >> 16) & 0xff;
buf[1] = (val >> 8) & 0xff;
buf[0] = val & 0xff;
}
#endif