/contrib/toolchain/binutils/bfd/bfd-in.h |
---|
File deleted |
/contrib/toolchain/binutils/bfd/bfd-in2.h |
---|
File deleted |
/contrib/toolchain/binutils/bfd/coff-bfd.c |
---|
File deleted |
/contrib/toolchain/binutils/bfd/coff-bfd.h |
---|
File deleted |
/contrib/toolchain/binutils/bfd/plugin.h |
---|
1,5 → 1,5 |
/* Plugin support for BFD. |
Copyright (C) 2009-2015 Free Software Foundation, Inc. |
Copyright 2009 Free Software Foundation, Inc. |
This file is part of BFD, the Binary File Descriptor library. |
25,9 → 25,6 |
void bfd_plugin_set_program_name (const char *); |
void bfd_plugin_set_plugin (const char *); |
bfd_boolean bfd_plugin_target_p (const bfd_target *); |
bfd_boolean bfd_plugin_specified_p (void); |
void register_ld_plugin_object_p (const bfd_target *(*object_p) (bfd *)); |
typedef struct plugin_data_struct |
{ |
/contrib/toolchain/binutils/bfd/Makefile |
---|
6,14 → 6,14 |
INCLUDES= -I. -I../include -I$(SDK_DIR)/sources/newlib/libc/include -I$(SDK_DIR)/sources/zlib |
DEFINES= -DHAVE_CONFIG_H -DHAVE_i386_pe_vec -DHAVE_i386_pei_vec -DHAVE_i386_elf32_vec |
DEFINES+= -DHAVE_elf32_le_vec -DHAVE_elf32_be_vec |
DEFINES+= -DBINDIR="/home/autobuild/tools/win32/bin" |
TDEFS= -DDEFAULT_VECTOR=i386_pe_vec "-DSELECT_VECS=&i386_pe_vec,&i386_pei_vec,&i386_elf32_vec,&elf32_le_vec,&elf32_be_vec" |
DEFINES= -DHAVE_CONFIG_H -DHAVE_i386pe_vec -DHAVE_i386pei_vec -DHAVE_bfd_elf32_i386_vec -DHAVE_bfd_elf32_little_generic_vec |
DEFINES+= -DHAVE_bfd_elf32_big_generic_vec -DBINDIR="/home/autobuild/tools/win32/bin" |
TDEFS= -DDEFAULT_VECTOR=i386pe_vec "-DSELECT_VECS=&i386pe_vec,&i386pei_vec,&bfd_elf32_i386_vec,&bfd_elf32_little_generic_vec,&bfd_elf32_big_generic_vec" |
TDEFS+= "-DSELECT_ARCHITECTURES=&bfd_i386_arch" |
SRCS = \ |
archive.c archures.c bfd.c bfdio.c \ |
binary.c cache.c coff-bfd.c coffgen.c cofflink.c \ |
binary.c cache.c coffgen.c cofflink.c \ |
compress.c corefile.c cpu-i386.c \ |
dwarf1.c dwarf2.c elf.c elf32.c \ |
elf32-gen.c elf32-i386.c elf-attrs.c \ |
/contrib/toolchain/binutils/bfd/bfdio.c |
---|
1,6 → 1,6 |
/* Low-level I/O routines for BFDs. |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990-2013 Free Software Foundation, Inc. |
Written by Cygnus Support. |
/contrib/toolchain/binutils/bfd/cache.c |
---|
1,6 → 1,7 |
/* BFD library -- caching of file descriptors. |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990, 1991, 1992, 1993, 1994, 1996, 2000, 2001, 2002, |
2003, 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc. |
Hacked by Steve Chamberlain of Cygnus Support (steve@cygnus.com). |
295,7 → 296,7 |
if (nread == (file_ptr)-1) |
{ |
bfd_set_error (bfd_error_system_call); |
return nread; |
return -1; |
} |
#else |
nread = fread (buf, 1, nbytes, f); |
305,7 → 306,7 |
if (nread < nbytes && ferror (f)) |
{ |
bfd_set_error (bfd_error_system_call); |
return nread; |
return -1; |
} |
#endif |
if (nread < nbytes) |
/contrib/toolchain/binutils/bfd/opncls.c |
---|
1,5 → 1,5 |
/* opncls.c -- open and close a BFD. |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990-2013 Free Software Foundation, Inc. |
Written by Cygnus Support. |
80,6 → 80,9 |
nbfd->arch_info = &bfd_default_arch_struct; |
nbfd->direction = no_direction; |
nbfd->iostream = NULL; |
nbfd->where = 0; |
if (!bfd_hash_table_init_n (& nbfd->section_htab, bfd_section_hash_newfunc, |
sizeof (struct section_hash_entry), 13)) |
{ |
86,6 → 89,18 |
free (nbfd); |
return NULL; |
} |
nbfd->sections = NULL; |
nbfd->section_last = NULL; |
nbfd->format = bfd_unknown; |
nbfd->my_archive = NULL; |
nbfd->origin = 0; |
nbfd->opened_once = FALSE; |
nbfd->output_has_begun = FALSE; |
nbfd->section_count = 0; |
nbfd->usrdata = NULL; |
nbfd->cacheable = FALSE; |
nbfd->flags = BFD_NO_FLAGS; |
nbfd->mtime_set = FALSE; |
return nbfd; |
} |
109,8 → 124,6 |
nbfd->my_archive = obfd; |
nbfd->direction = read_direction; |
nbfd->target_defaulted = obfd->target_defaulted; |
nbfd->lto_output = obfd->lto_output; |
nbfd->no_export = obfd->no_export; |
return nbfd; |
} |
125,8 → 138,6 |
objalloc_free ((struct objalloc *) abfd->memory); |
} |
if (abfd->filename) |
free ((char *) abfd->filename); |
free (abfd->arelt_data); |
free (abfd); |
} |
185,9 → 196,6 |
<<system_call>> error. |
On error, @var{fd} is always closed. |
A copy of the @var{filename} argument is stored in the newly created |
BFD. It can be accessed via the bfd_get_filename() macro. |
*/ |
bfd * |
227,11 → 235,8 |
} |
/* OK, put everything where it belongs. */ |
nbfd->filename = filename; |
/* PR 11983: Do not cache the original filename, but |
rather make a copy - the original might go away. */ |
nbfd->filename = xstrdup (filename); |
/* Figure out whether the user is opening the file for reading, |
writing, or both, by looking at the MODE argument. */ |
if ((mode[0] == 'r' || mode[0] == 'w' || mode[0] == 'a') |
276,9 → 281,6 |
If <<NULL>> is returned then an error has occured. Possible errors |
are <<bfd_error_no_memory>>, <<bfd_error_invalid_target>> or |
<<system_call>> error. |
A copy of the @var{filename} argument is stored in the newly created |
BFD. It can be accessed via the bfd_get_filename() macro. |
*/ |
bfd * |
320,9 → 322,6 |
<<bfd_error_invalid_target>> and <<bfd_error_system_call>>. |
On error, @var{fd} is closed. |
A copy of the @var{filename} argument is stored in the newly created |
BFD. It can be accessed via the bfd_get_filename() macro. |
*/ |
bfd * |
365,15 → 364,12 |
bfd_openstreamr |
SYNOPSIS |
bfd *bfd_openstreamr (const char * filename, const char * target, void * stream); |
bfd *bfd_openstreamr (const char *, const char *, void *); |
DESCRIPTION |
Open a BFD for read access on an existing stdio stream. When |
the BFD is passed to <<bfd_close>>, the stream will be closed. |
A copy of the @var{filename} argument is stored in the newly created |
BFD. It can be accessed via the bfd_get_filename() macro. |
*/ |
bfd * |
395,9 → 391,7 |
} |
nbfd->iostream = stream; |
/* PR 11983: Do not cache the original filename, but |
rather make a copy - the original might go away. */ |
nbfd->filename = xstrdup (filename); |
nbfd->filename = filename; |
nbfd->direction = read_direction; |
if (! bfd_cache_init (nbfd)) |
462,8 → 456,6 |
occurred. Possible errors are <<bfd_error_no_memory>>, |
<<bfd_error_invalid_target>> and <<bfd_error_system_call>>. |
A copy of the @var{filename} argument is stored in the newly created |
BFD. It can be accessed via the bfd_get_filename() macro. |
*/ |
struct opncls |
589,9 → 581,7 |
return NULL; |
} |
/* PR 11983: Do not cache the original filename, but |
rather make a copy - the original might go away. */ |
nbfd->filename = xstrdup (filename); |
nbfd->filename = filename; |
nbfd->direction = read_direction; |
/* `open_p (...)' would get expanded by an the open(2) syscall macro. */ |
632,9 → 622,6 |
Possible errors are <<bfd_error_system_call>>, <<bfd_error_no_memory>>, |
<<bfd_error_invalid_target>>. |
A copy of the @var{filename} argument is stored in the newly created |
BFD. It can be accessed via the bfd_get_filename() macro. |
*/ |
bfd * |
656,9 → 643,7 |
return NULL; |
} |
/* PR 11983: Do not cache the original filename, but |
rather make a copy - the original might go away. */ |
nbfd->filename = xstrdup (filename); |
nbfd->filename = filename; |
nbfd->direction = write_direction; |
if (bfd_open_file (nbfd) == NULL) |
797,9 → 782,6 |
Create a new BFD in the manner of <<bfd_openw>>, but without |
opening a file. The new BFD takes the target from the target |
used by @var{templ}. The format is always set to <<bfd_object>>. |
A copy of the @var{filename} argument is stored in the newly created |
BFD. It can be accessed via the bfd_get_filename() macro. |
*/ |
bfd * |
810,9 → 792,7 |
nbfd = _bfd_new_bfd (); |
if (nbfd == NULL) |
return NULL; |
/* PR 11983: Do not cache the original filename, but |
rather make a copy - the original might go away. */ |
nbfd->filename = xstrdup (filename); |
nbfd->filename = filename; |
if (templ) |
nbfd->xvec = templ->xvec; |
nbfd->direction = no_direction; |
941,23 → 921,14 |
bfd_alloc (bfd *abfd, bfd_size_type size) |
{ |
void *ret; |
unsigned long ul_size = (unsigned long) size; |
if (size != ul_size |
/* Note - although objalloc_alloc takes an unsigned long as its |
argument, internally the size is treated as a signed long. This can |
lead to problems where, for example, a request to allocate -1 bytes |
can result in just 1 byte being allocated, rather than |
((unsigned long) -1) bytes. Also memory checkers will often |
complain about attempts to allocate a negative amount of memory. |
So to stop these problems we fail if the size is negative. */ |
|| ((signed long) ul_size) < 0) |
if (size != (unsigned long) size) |
{ |
bfd_set_error (bfd_error_no_memory); |
return NULL; |
} |
ret = objalloc_alloc ((struct objalloc *) abfd->memory, ul_size); |
ret = objalloc_alloc ((struct objalloc *) abfd->memory, (unsigned long) size); |
if (ret == NULL) |
bfd_set_error (bfd_error_no_memory); |
return ret; |
978,6 → 949,8 |
void * |
bfd_alloc2 (bfd *abfd, bfd_size_type nmemb, bfd_size_type size) |
{ |
void *ret; |
if ((nmemb | size) >= HALF_BFD_SIZE_TYPE |
&& size != 0 |
&& nmemb > ~(bfd_size_type) 0 / size) |
986,9 → 959,20 |
return NULL; |
} |
return bfd_alloc (abfd, size * nmemb); |
size *= nmemb; |
if (size != (unsigned long) size) |
{ |
bfd_set_error (bfd_error_no_memory); |
return NULL; |
} |
ret = objalloc_alloc ((struct objalloc *) abfd->memory, (unsigned long) size); |
if (ret == NULL) |
bfd_set_error (bfd_error_no_memory); |
return ret; |
} |
/* |
FUNCTION |
bfd_zalloc |
1165,7 → 1149,7 |
char *bfd_get_debug_link_info (bfd *abfd, unsigned long *crc32_out); |
DESCRIPTION |
Fetch the filename and CRC32 value for any separate debuginfo |
fetch the filename and CRC32 value for any separate debuginfo |
associated with @var{abfd}. Return NULL if no such info found, |
otherwise return filename and update @var{crc32_out}. The |
returned filename is allocated with @code{malloc}; freeing it |
1178,7 → 1162,7 |
asection *sect; |
unsigned long crc32; |
bfd_byte *contents; |
unsigned int crc_offset; |
int crc_offset; |
char *name; |
BFD_ASSERT (abfd); |
1196,13 → 1180,10 |
return NULL; |
} |
/* CRC value is stored after the filename, aligned up to 4 bytes. */ |
/* Crc value is stored after the filename, aligned up to 4 bytes. */ |
name = (char *) contents; |
/* PR 17597: avoid reading off the end of the buffer. */ |
crc_offset = strnlen (name, bfd_get_section_size (sect)) + 1; |
crc_offset = strlen (name) + 1; |
crc_offset = (crc_offset + 3) & ~3; |
if (crc_offset >= bfd_get_section_size (sect)) |
return NULL; |
crc32 = bfd_get_32 (abfd, contents + crc_offset); |
1215,30 → 1196,25 |
bfd_get_alt_debug_link_info |
SYNOPSIS |
char *bfd_get_alt_debug_link_info (bfd * abfd, |
bfd_size_type *buildid_len, |
bfd_byte **buildid_out); |
char *bfd_get_alt_debug_link_info (bfd *abfd, unsigned long *crc32_out); |
DESCRIPTION |
Fetch the filename and BuildID value for any alternate debuginfo |
associated with @var{abfd}. Return NULL if no such info found, |
otherwise return filename and update @var{buildid_len} and |
@var{buildid_out}. The returned filename and build_id are |
allocated with @code{malloc}; freeing them is the |
responsibility of the caller. |
otherwise return filename and update @var{buildid_out}. The |
returned filename is allocated with @code{malloc}; freeing it |
is the responsibility of the caller. |
*/ |
char * |
bfd_get_alt_debug_link_info (bfd * abfd, bfd_size_type *buildid_len, |
bfd_byte **buildid_out) |
bfd_get_alt_debug_link_info (bfd * abfd, unsigned long * buildid_out) |
{ |
asection *sect; |
bfd_byte *contents; |
unsigned int buildid_offset; |
int buildid_offset; |
char *name; |
BFD_ASSERT (abfd); |
BFD_ASSERT (buildid_len); |
BFD_ASSERT (buildid_out); |
sect = bfd_get_section_by_name (abfd, GNU_DEBUGALTLINK); |
1253,15 → 1229,12 |
return NULL; |
} |
/* BuildID value is stored after the filename. */ |
/* BuildID value is stored after the filename, aligned up to 4 bytes. */ |
name = (char *) contents; |
buildid_offset = strnlen (name, bfd_get_section_size (sect)) + 1; |
if (buildid_offset >= bfd_get_section_size (sect)) |
return NULL; |
buildid_offset = strlen (name) + 1; |
buildid_offset = (buildid_offset + 3) & ~3; |
*buildid_len = bfd_get_section_size (sect) - buildid_offset; |
*buildid_out = bfd_malloc (*buildid_len); |
memcpy (*buildid_out, contents + buildid_offset, *buildid_len); |
* buildid_out = bfd_get_32 (abfd, contents + buildid_offset); |
return name; |
} |
1495,24 → 1468,6 |
separate_debug_file_exists); |
} |
/* Helper for bfd_follow_gnu_debugaltlink. It just pretends to return |
a CRC. .gnu_debugaltlink supplies a build-id, which is different, |
but this is ok because separate_alt_debug_file_exists ignores the |
CRC anyway. */ |
static char * |
get_alt_debug_link_info_shim (bfd * abfd, unsigned long *crc32_out) |
{ |
bfd_size_type len; |
bfd_byte *buildid = NULL; |
char *result = bfd_get_alt_debug_link_info (abfd, &len, &buildid); |
*crc32_out = 0; |
free (buildid); |
return result; |
} |
/* |
FUNCTION |
bfd_follow_gnu_debugaltlink |
1543,7 → 1498,7 |
bfd_follow_gnu_debugaltlink (bfd *abfd, const char *dir) |
{ |
return find_separate_debug_file (abfd, dir, |
get_alt_debug_link_info_shim, |
bfd_get_alt_debug_link_info, |
separate_alt_debug_file_exists); |
} |
/contrib/toolchain/binutils/bfd/pei-i386.c |
---|
1,5 → 1,6 |
/* BFD back-end for Intel 386 PE IMAGE COFF files. |
Copyright (C) 1995-2015 Free Software Foundation, Inc. |
Copyright 1995, 1996, 1999, 2002, 2004, 2005, 2006, 2007, 2009 |
Free Software Foundation, Inc. |
This file is part of BFD, the Binary File Descriptor library. |
21,7 → 22,7 |
#include "sysdep.h" |
#include "bfd.h" |
#define TARGET_SYM i386_pei_vec |
#define TARGET_SYM i386pei_vec |
#define TARGET_NAME "pei-i386" |
#define COFF_IMAGE_WITH_PE |
#define COFF_WITH_PE |
/contrib/toolchain/binutils/bfd/sysdep.h |
---|
1,5 → 1,6 |
/* sysdep.h -- handle host dependencies for the BFD library |
Copyright (C) 1995-2015 Free Software Foundation, Inc. |
Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2007, 2009 |
Free Software Foundation, Inc. |
Written by Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
26,6 → 27,8 |
#error sysdep.h must be included in lieu of config.h |
#endif |
#include <stdarg.h> |
#include "config.h" |
#include "ansidecl.h" |
34,8 → 37,6 |
#include <stddef.h> |
#endif |
#include <stdarg.h> |
#include <stdio.h> |
#include <sys/types.h> |
#include <sys/stat.h> |
172,10 → 173,6 |
#endif |
#endif |
#if !HAVE_DECL_STRNLEN |
size_t strnlen (const char *, size_t); |
#endif |
/* Define offsetof for those systems which lack it */ |
#ifndef offsetof |
/contrib/toolchain/binutils/bfd/archive.c |
---|
1,5 → 1,5 |
/* BFD back-end for archive files (libraries). |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990-2013 Free Software Foundation, Inc. |
Written by Cygnus Support. Mostly Gumby Henkel-Wallace's fault. |
This file is part of BFD, the Binary File Descriptor library. |
140,7 → 140,6 |
#include "safe-ctype.h" |
#include "hashtab.h" |
#include "filenames.h" |
#include "bfdlink.h" |
#ifndef errno |
extern int errno; |
311,11 → 310,7 |
struct ar_cache *entry = (struct ar_cache *) htab_find (hash_table, &m); |
if (!entry) |
return NULL; |
/* Unfortunately this flag is set after checking that we have |
an archive, and checking for an archive means one element has |
sneaked into the cache. */ |
entry->arbfd->no_export = arch_bfd->no_export; |
else |
return entry->arbfd; |
} |
else |
379,28 → 374,11 |
} |
static bfd * |
open_nested_file (const char *filename, bfd *archive) |
_bfd_find_nested_archive (bfd *arch_bfd, const char *filename) |
{ |
bfd *abfd; |
const char *target; |
bfd *n_bfd; |
target = NULL; |
if (!archive->target_defaulted) |
target = archive->xvec->name; |
n_bfd = bfd_openr (filename, target); |
if (n_bfd != NULL) |
{ |
n_bfd->lto_output = archive->lto_output; |
n_bfd->no_export = archive->no_export; |
} |
return n_bfd; |
} |
static bfd * |
find_nested_archive (const char *filename, bfd *arch_bfd) |
{ |
bfd *abfd; |
/* PR 15140: Don't allow a nested archive pointing to itself. */ |
if (filename_cmp (filename, arch_bfd->filename) == 0) |
{ |
415,7 → 393,10 |
if (filename_cmp (filename, abfd->filename) == 0) |
return abfd; |
} |
abfd = open_nested_file (filename, arch_bfd); |
target = NULL; |
if (!arch_bfd->target_defaulted) |
target = arch_bfd->xvec->name; |
abfd = bfd_openr (filename, target); |
if (abfd) |
{ |
abfd->archive_next = arch_bfd->nested_archives; |
644,12 → 625,12 |
_bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos) |
{ |
struct areltdata *new_areldata; |
bfd *n_bfd; |
bfd *n_nfd; |
char *filename; |
n_bfd = _bfd_look_for_bfd_in_cache (archive, filepos); |
if (n_bfd) |
return n_bfd; |
n_nfd = _bfd_look_for_bfd_in_cache (archive, filepos); |
if (n_nfd) |
return n_nfd; |
if (0 > bfd_seek (archive, filepos, SEEK_SET)) |
return NULL; |
661,6 → 642,8 |
if (bfd_is_thin_archive (archive)) |
{ |
const char *target; |
/* This is a proxy entry for an external file. */ |
if (! IS_ABSOLUTE_PATH (filename)) |
{ |
676,7 → 659,7 |
{ |
/* This proxy entry refers to an element of a nested archive. |
Locate the member of that archive and return a bfd for it. */ |
bfd *ext_arch = find_nested_archive (filename, archive); |
bfd *ext_arch = _bfd_find_nested_archive (archive, filename); |
if (ext_arch == NULL |
|| ! bfd_check_format (ext_arch, bfd_archive)) |
684,60 → 667,57 |
free (new_areldata); |
return NULL; |
} |
n_bfd = _bfd_get_elt_at_filepos (ext_arch, new_areldata->origin); |
if (n_bfd == NULL) |
n_nfd = _bfd_get_elt_at_filepos (ext_arch, new_areldata->origin); |
if (n_nfd == NULL) |
{ |
free (new_areldata); |
return NULL; |
} |
n_bfd->proxy_origin = bfd_tell (archive); |
return n_bfd; |
n_nfd->proxy_origin = bfd_tell (archive); |
return n_nfd; |
} |
/* It's not an element of a nested archive; |
open the external file as a bfd. */ |
n_bfd = open_nested_file (filename, archive); |
if (n_bfd == NULL) |
target = NULL; |
if (!archive->target_defaulted) |
target = archive->xvec->name; |
n_nfd = bfd_openr (filename, target); |
if (n_nfd == NULL) |
bfd_set_error (bfd_error_malformed_archive); |
} |
else |
{ |
n_bfd = _bfd_create_empty_archive_element_shell (archive); |
n_nfd = _bfd_create_empty_archive_element_shell (archive); |
} |
if (n_bfd == NULL) |
if (n_nfd == NULL) |
{ |
free (new_areldata); |
return NULL; |
} |
n_bfd->proxy_origin = bfd_tell (archive); |
n_nfd->proxy_origin = bfd_tell (archive); |
if (bfd_is_thin_archive (archive)) |
{ |
n_bfd->origin = 0; |
n_nfd->origin = 0; |
} |
else |
{ |
n_bfd->origin = n_bfd->proxy_origin; |
n_bfd->filename = xstrdup (filename); |
n_nfd->origin = n_nfd->proxy_origin; |
n_nfd->filename = filename; |
} |
n_bfd->arelt_data = new_areldata; |
n_nfd->arelt_data = new_areldata; |
/* Copy BFD_COMPRESS, BFD_DECOMPRESS and BFD_COMPRESS_GABI flags. */ |
n_bfd->flags |= archive->flags & (BFD_COMPRESS |
| BFD_DECOMPRESS |
| BFD_COMPRESS_GABI); |
/* Copy BFD_COMPRESS and BFD_DECOMPRESS flags. */ |
n_nfd->flags |= archive->flags & (BFD_COMPRESS | BFD_DECOMPRESS); |
/* Copy is_linker_input. */ |
n_bfd->is_linker_input = archive->is_linker_input; |
if (_bfd_add_bfd_to_archive_cache (archive, filepos, n_nfd)) |
return n_nfd; |
if (_bfd_add_bfd_to_archive_cache (archive, filepos, n_bfd)) |
return n_bfd; |
free (new_areldata); |
n_bfd->arelt_data = NULL; |
n_nfd->arelt_data = NULL; |
return NULL; |
} |
786,30 → 766,22 |
bfd * |
bfd_generic_openr_next_archived_file (bfd *archive, bfd *last_file) |
{ |
ufile_ptr filestart; |
file_ptr filestart; |
if (!last_file) |
filestart = bfd_ardata (archive)->first_file_filepos; |
else |
{ |
bfd_size_type size = arelt_size (last_file); |
filestart = last_file->proxy_origin; |
if (! bfd_is_thin_archive (archive)) |
{ |
bfd_size_type size = arelt_size (last_file); |
filestart += size; |
/* Pad to an even boundary... |
Note that last_file->origin can be odd in the case of |
BSD-4.4-style element with a long odd size. */ |
filestart += filestart % 2; |
if (filestart <= last_file->proxy_origin) |
{ |
/* Prevent looping. See PR19256. */ |
bfd_set_error (bfd_error_malformed_archive); |
return NULL; |
} |
} |
} |
return _bfd_get_elt_at_filepos (archive, filestart); |
} |
929,10 → 901,6 |
return FALSE; |
parsed_size = mapdata->parsed_size; |
free (mapdata); |
/* PR 17512: file: 883ff754. */ |
/* PR 17512: file: 0458885f. */ |
if (parsed_size < 4) |
return FALSE; |
raw_armap = (bfd_byte *) bfd_zalloc (abfd, parsed_size); |
if (raw_armap == NULL) |
948,6 → 916,7 |
} |
ardata->symdef_count = H_GET_32 (abfd, raw_armap) / BSD_SYMDEF_SIZE; |
if (ardata->symdef_count * BSD_SYMDEF_SIZE > |
parsed_size - BSD_SYMDEF_COUNT_SIZE) |
{ |
1068,19 → 1037,12 |
} |
/* OK, build the carsyms. */ |
for (i = 0; i < nsymz && stringsize > 0; i++) |
for (i = 0; i < nsymz; i++) |
{ |
bfd_size_type len; |
rawptr = raw_armap + i; |
carsyms->file_offset = swap ((bfd_byte *) rawptr); |
carsyms->name = stringbase; |
/* PR 17512: file: 4a1d50c1. */ |
len = strnlen (stringbase, stringsize); |
if (len < stringsize) |
len ++; |
stringbase += len; |
stringsize -= len; |
stringbase += strlen (stringbase) + 1; |
carsyms++; |
} |
*stringbase = 0; |
1168,7 → 1130,6 |
return FALSE; |
if (bfd_seek (abfd, -(file_ptr) (sizeof (hdr) + 20), SEEK_CUR) != 0) |
return FALSE; |
extname[20] = 0; |
if (CONST_STRNEQ (extname, "__.SYMDEF SORTED") |
|| CONST_STRNEQ (extname, "__.SYMDEF")) |
return do_slurp_bsd_armap (abfd); |
1338,8 → 1299,6 |
{ |
byebye: |
free (namedata); |
bfd_ardata (abfd)->extended_names = NULL; |
bfd_ardata (abfd)->extended_names_size = 0; |
return FALSE; |
} |
1356,12 → 1315,11 |
text, the entries in the list are newline-padded, not null |
padded. In SVR4-style archives, the names also have a |
trailing '/'. DOS/NT created archive often have \ in them |
We'll fix all problems here. */ |
We'll fix all problems here.. */ |
{ |
char *ext_names = bfd_ardata (abfd)->extended_names; |
char *temp = ext_names; |
char *limit = temp + namedata->parsed_size; |
for (; temp < limit; ++temp) |
{ |
if (*temp == ARFMAG[1]) |
2002,9 → 1960,7 |
} |
hdr = arch_hdr (abfd); |
/* PR 17512: file: 3d9e9fe9. */ |
if (hdr == NULL) |
return -1; |
#define foo(arelt, stelt, size) \ |
buf->stelt = strtol (hdr->arelt, &aloser, size); \ |
if (aloser == hdr->arelt) \ |
2400,10 → 2356,6 |
map = new_map; |
} |
if (strcmp (syms[src_count]->name, "__gnu_lto_slim") == 0) |
(*_bfd_error_handler) |
(_("%s: plugin needed to handle lto object"), |
bfd_get_filename (current)); |
namelen = strlen (syms[src_count]->name); |
amt = sizeof (char *); |
map[orl_count].name = (char **) bfd_alloc (arch, amt); |
2799,8 → 2751,5 |
} |
} |
} |
if (abfd->is_linker_output) |
(*abfd->link.hash->hash_table_free) (abfd); |
return TRUE; |
} |
/contrib/toolchain/binutils/bfd/archures.c |
---|
1,5 → 1,5 |
/* BFD library support routines for architectures. |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990-2013 Free Software Foundation, Inc. |
Hacked by John Gilmore and Steve Chamberlain of Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
121,9 → 121,7 |
.#define bfd_mach_i960_jx 7 |
.#define bfd_mach_i960_hx 8 |
. |
. bfd_arch_or1k, {* OpenRISC 1000 *} |
.#define bfd_mach_or1k 1 |
.#define bfd_mach_or1knd 2 |
. bfd_arch_or32, {* OpenRISC 32 *} |
. |
. bfd_arch_sparc, {* SPARC *} |
.#define bfd_mach_sparc 1 |
179,18 → 177,11 |
.#define bfd_mach_mips_octeon 6501 |
.#define bfd_mach_mips_octeonp 6601 |
.#define bfd_mach_mips_octeon2 6502 |
.#define bfd_mach_mips_octeon3 6503 |
.#define bfd_mach_mips_xlr 887682 {* decimal 'XLR' *} |
.#define bfd_mach_mipsisa32 32 |
.#define bfd_mach_mipsisa32r2 33 |
.#define bfd_mach_mipsisa32r3 34 |
.#define bfd_mach_mipsisa32r5 36 |
.#define bfd_mach_mipsisa32r6 37 |
.#define bfd_mach_mipsisa64 64 |
.#define bfd_mach_mipsisa64r2 65 |
.#define bfd_mach_mipsisa64r3 66 |
.#define bfd_mach_mipsisa64r5 68 |
.#define bfd_mach_mipsisa64r6 69 |
.#define bfd_mach_mips_micromips 96 |
. bfd_arch_i386, {* Intel 386 *} |
.#define bfd_mach_i386_intel_syntax (1 << 0) |
211,10 → 202,6 |
.#define bfd_mach_i386_i386_nacl (bfd_mach_i386_i386 | bfd_mach_i386_nacl) |
.#define bfd_mach_x86_64_nacl (bfd_mach_x86_64 | bfd_mach_i386_nacl) |
.#define bfd_mach_x64_32_nacl (bfd_mach_x64_32 | bfd_mach_i386_nacl) |
. bfd_arch_iamcu, {* Intel MCU *} |
.#define bfd_mach_iamcu (1 << 8) |
.#define bfd_mach_i386_iamcu (bfd_mach_i386_i386 | bfd_mach_iamcu) |
.#define bfd_mach_i386_iamcu_intel_syntax (bfd_mach_i386_iamcu | bfd_mach_i386_intel_syntax) |
. bfd_arch_we32k, {* AT&T WE32xxx *} |
. bfd_arch_tahoe, {* CCI/Harris Tahoe *} |
. bfd_arch_i860, {* Intel 860 *} |
329,12 → 316,6 |
.#define bfd_mach_arm_ep9312 11 |
.#define bfd_mach_arm_iWMMXt 12 |
.#define bfd_mach_arm_iWMMXt2 13 |
. bfd_arch_nds32, {* Andes NDS32 *} |
.#define bfd_mach_n1 1 |
.#define bfd_mach_n1h 2 |
.#define bfd_mach_n1h_v2 3 |
.#define bfd_mach_n1h_v3 4 |
.#define bfd_mach_n1h_v3m 5 |
. bfd_arch_ns32k, {* National Semiconductors ns32000 *} |
. bfd_arch_w65, {* WDC 65816 *} |
. bfd_arch_tic30, {* Texas Instruments TMS320C30 *} |
353,12 → 334,10 |
.#define bfd_mach_v850e2v3 0x45325633 |
.#define bfd_mach_v850e3v5 0x45335635 {* ('E'|'3'|'V'|'5') *} |
. bfd_arch_arc, {* ARC Cores *} |
.#define bfd_mach_arc_a4 0 |
.#define bfd_mach_arc_a5 1 |
.#define bfd_mach_arc_arc600 2 |
.#define bfd_mach_arc_arc601 4 |
.#define bfd_mach_arc_arc700 3 |
.#define bfd_mach_arc_arcv2 5 |
.#define bfd_mach_arc_5 5 |
.#define bfd_mach_arc_6 6 |
.#define bfd_mach_arc_7 7 |
.#define bfd_mach_arc_8 8 |
. bfd_arch_m32c, {* Renesas M16C/M32C. *} |
.#define bfd_mach_m16c 0x75 |
.#define bfd_mach_m32c 0x78 |
384,8 → 363,6 |
.#define bfd_mach_fr550 550 |
. bfd_arch_moxie, {* The moxie processor *} |
.#define bfd_mach_moxie 1 |
. bfd_arch_ft32, {* The ft32 processor *} |
.#define bfd_mach_ft32 1 |
. bfd_arch_mcore, |
. bfd_arch_mep, |
.#define bfd_mach_mep 1 |
421,7 → 398,6 |
.#define bfd_mach_avr5 5 |
.#define bfd_mach_avr51 51 |
.#define bfd_mach_avr6 6 |
.#define bfd_mach_avrtiny 100 |
.#define bfd_mach_avrxmega1 101 |
.#define bfd_mach_avrxmega2 102 |
.#define bfd_mach_avrxmega3 103 |
451,6 → 427,7 |
. bfd_arch_score, {* Sunplus score *} |
.#define bfd_mach_score3 3 |
.#define bfd_mach_score7 7 |
. bfd_arch_openrisc, {* OpenRISC *} |
. bfd_arch_mmix, {* Donald Knuth's educational processor. *} |
. bfd_arch_xstormy16, |
.#define bfd_mach_xstormy16 1 |
503,12 → 480,8 |
. bfd_arch_aarch64, {* AArch64 *} |
.#define bfd_mach_aarch64 0 |
.#define bfd_mach_aarch64_ilp32 32 |
. bfd_arch_nios2, {* Nios II *} |
. bfd_arch_nios2, |
.#define bfd_mach_nios2 0 |
.#define bfd_mach_nios2r1 1 |
.#define bfd_mach_nios2r2 2 |
. bfd_arch_visium, {* Visium *} |
.#define bfd_mach_visium 1 |
. bfd_arch_last |
. }; |
*/ |
574,7 → 547,6 |
extern const bfd_arch_info_type bfd_hppa_arch; |
extern const bfd_arch_info_type bfd_i370_arch; |
extern const bfd_arch_info_type bfd_i386_arch; |
extern const bfd_arch_info_type bfd_iamcu_arch; |
extern const bfd_arch_info_type bfd_i860_arch; |
extern const bfd_arch_info_type bfd_i960_arch; |
extern const bfd_arch_info_type bfd_ia64_arch; |
600,13 → 572,12 |
extern const bfd_arch_info_type bfd_mn10200_arch; |
extern const bfd_arch_info_type bfd_mn10300_arch; |
extern const bfd_arch_info_type bfd_moxie_arch; |
extern const bfd_arch_info_type bfd_ft32_arch; |
extern const bfd_arch_info_type bfd_msp430_arch; |
extern const bfd_arch_info_type bfd_mt_arch; |
extern const bfd_arch_info_type bfd_nds32_arch; |
extern const bfd_arch_info_type bfd_nios2_arch; |
extern const bfd_arch_info_type bfd_ns32k_arch; |
extern const bfd_arch_info_type bfd_or1k_arch; |
extern const bfd_arch_info_type bfd_openrisc_arch; |
extern const bfd_arch_info_type bfd_or32_arch; |
extern const bfd_arch_info_type bfd_pdp11_arch; |
extern const bfd_arch_info_type bfd_pj_arch; |
extern const bfd_arch_info_type bfd_plugin_arch; |
630,7 → 601,6 |
extern const bfd_arch_info_type bfd_v850_arch; |
extern const bfd_arch_info_type bfd_v850_rh850_arch; |
extern const bfd_arch_info_type bfd_vax_arch; |
extern const bfd_arch_info_type bfd_visium_arch; |
extern const bfd_arch_info_type bfd_w65_arch; |
extern const bfd_arch_info_type bfd_we32k_arch; |
extern const bfd_arch_info_type bfd_xstormy16_arch; |
666,7 → 636,6 |
&bfd_hppa_arch, |
&bfd_i370_arch, |
&bfd_i386_arch, |
&bfd_iamcu_arch, |
&bfd_i860_arch, |
&bfd_i960_arch, |
&bfd_ia64_arch, |
692,13 → 661,12 |
&bfd_mn10200_arch, |
&bfd_mn10300_arch, |
&bfd_moxie_arch, |
&bfd_ft32_arch, |
&bfd_msp430_arch, |
&bfd_mt_arch, |
&bfd_nds32_arch, |
&bfd_nios2_arch, |
&bfd_ns32k_arch, |
&bfd_or1k_arch, |
&bfd_openrisc_arch, |
&bfd_or32_arch, |
&bfd_pdp11_arch, |
&bfd_powerpc_arch, |
&bfd_rs6000_arch, |
719,7 → 687,6 |
&bfd_v850_arch, |
&bfd_v850_rh850_arch, |
&bfd_vax_arch, |
&bfd_visium_arch, |
&bfd_w65_arch, |
&bfd_we32k_arch, |
&bfd_xstormy16_arch, |
/contrib/toolchain/binutils/bfd/bfd-in3.h |
---|
7,7 → 7,7 |
/* Main header file for the bfd library -- portable access to object files. |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990-2013 Free Software Foundation, Inc. |
Contributed by Cygnus Support. |
279,7 → 279,7 |
/* Object and core file sections. */ |
#define align_power(addr, align) \ |
(((addr) + ((bfd_vma) 1 << (align)) - 1) & (-((bfd_vma) 1 << (align)))) |
(((addr) + ((bfd_vma) 1 << (align)) - 1) & ((bfd_vma) -1 << (align))) |
typedef struct bfd_section *sec_ptr; |
299,13 → 299,13 |
#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0) |
#define bfd_get_section_limit_octets(bfd, sec) \ |
((bfd)->direction != write_direction && (sec)->rawsize != 0 \ |
? (sec)->rawsize : (sec)->size) |
#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE) |
#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE) |
#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE) |
/* Find the address one past the end of SEC. */ |
#define bfd_get_section_limit(bfd, sec) \ |
(bfd_get_section_limit_octets(bfd, sec) / bfd_octets_per_byte (bfd)) |
(((bfd)->direction != write_direction && (sec)->rawsize != 0 \ |
? (sec)->rawsize : (sec)->size) / bfd_octets_per_byte (bfd)) |
/* Return TRUE if input section SEC has been discarded. */ |
#define discarded_section(sec) \ |
444,16 → 444,6 |
this size. */ |
extern unsigned long bfd_hash_set_default_size (unsigned long); |
/* Types of compressed DWARF debug sections. We currently support |
zlib. */ |
enum compressed_debug_section_type |
{ |
COMPRESS_DEBUG_NONE = 0, |
COMPRESS_DEBUG = 1 << 0, |
COMPRESS_DEBUG_GNU_ZLIB = COMPRESS_DEBUG | 1 << 1, |
COMPRESS_DEBUG_GABI_ZLIB = COMPRESS_DEBUG | 1 << 2 |
}; |
/* This structure is used to keep track of stabs in sections |
information while linking. */ |
534,6 → 524,8 |
#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char) |
#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE) |
extern bfd_boolean bfd_cache_close |
(bfd *abfd); |
/* NB: This declaration should match the autogenerated one in libbfd.h. */ |
678,7 → 670,7 |
(bfd *); |
extern struct bfd_link_needed_list *bfd_elf_get_runpath_list |
(bfd *, struct bfd_link_info *); |
extern int bfd_elf_discard_info |
extern bfd_boolean bfd_elf_discard_info |
(bfd *, struct bfd_link_info *); |
extern unsigned int _bfd_elf_default_action_discarded |
(struct bfd_section *); |
700,21 → 692,19 |
(bfd *abfd, void *phdrs); |
/* Create a new BFD as if by bfd_openr. Rather than opening a file, |
reconstruct an ELF file by reading the segments out of remote |
memory based on the ELF file header at EHDR_VMA and the ELF program |
headers it points to. If non-zero, SIZE is the known extent of the |
object. If not null, *LOADBASEP is filled in with the difference |
between the VMAs from which the segments were read, and the VMAs |
the file headers (and hence BFD's idea of each section's VMA) put |
them at. |
reconstruct an ELF file by reading the segments out of remote memory |
based on the ELF file header at EHDR_VMA and the ELF program headers it |
points to. If not null, *LOADBASEP is filled in with the difference |
between the VMAs from which the segments were read, and the VMAs the |
file headers (and hence BFD's idea of each section's VMA) put them at. |
The function TARGET_READ_MEMORY is called to copy LEN bytes from |
the remote memory at target address VMA into the local buffer at |
MYADDR; it should return zero on success or an `errno' code on |
failure. TEMPL must be a BFD for a target with the word size and |
byte order found in the remote memory. */ |
The function TARGET_READ_MEMORY is called to copy LEN bytes from the |
remote memory at target address VMA into the local buffer at MYADDR; it |
should return zero on success or an `errno' code on failure. TEMPL must |
be a BFD for an ELF target with the word size and byte order found in |
the remote memory. */ |
extern bfd *bfd_elf_bfd_from_remote_memory |
(bfd *templ, bfd_vma ehdr_vma, bfd_size_type size, bfd_vma *loadbasep, |
(bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep, |
int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr, |
bfd_size_type len)); |
826,6 → 816,12 |
union internal_auxent; |
#endif |
extern bfd_boolean bfd_coff_get_syment |
(bfd *, struct bfd_symbol *, struct internal_syment *); |
extern bfd_boolean bfd_coff_get_auxent |
(bfd *, struct bfd_symbol *, int, union internal_auxent *); |
extern bfd_boolean bfd_coff_set_symbol_class |
(bfd *, struct bfd_symbol *, unsigned int); |
856,23 → 852,6 |
extern void bfd_elf32_arm_vfp11_fix_veneer_locations |
(bfd *, struct bfd_link_info *); |
/* ARM STM STM32L4XX erratum workaround support. */ |
typedef enum |
{ |
BFD_ARM_STM32L4XX_FIX_NONE, |
BFD_ARM_STM32L4XX_FIX_DEFAULT, |
BFD_ARM_STM32L4XX_FIX_ALL |
} bfd_arm_stm32l4xx_fix; |
extern void bfd_elf32_arm_set_stm32l4xx_fix |
(bfd *, struct bfd_link_info *); |
extern bfd_boolean bfd_elf32_arm_stm32l4xx_erratum_scan |
(bfd *, struct bfd_link_info *); |
extern void bfd_elf32_arm_stm32l4xx_fix_veneer_locations |
(bfd *, struct bfd_link_info *); |
/* ARM Interworking support. Called from linker. */ |
extern bfd_boolean bfd_arm_allocate_interworking_sections |
(struct bfd_link_info *); |
902,7 → 881,7 |
void bfd_elf32_arm_set_target_relocs |
(bfd *, struct bfd_link_info *, int, char *, int, int, bfd_arm_vfp11_fix, |
bfd_arm_stm32l4xx_fix, int, int, int, int, int); |
int, int, int, int, int); |
extern bfd_boolean bfd_elf32_arm_get_bfd_for_interworking |
(bfd *, struct bfd_link_info *); |
910,20 → 889,16 |
extern bfd_boolean bfd_elf32_arm_add_glue_sections_to_bfd |
(bfd *, struct bfd_link_info *); |
/* ELF ARM mapping symbol support. */ |
/* ELF ARM mapping symbol support */ |
#define BFD_ARM_SPECIAL_SYM_TYPE_MAP (1 << 0) |
#define BFD_ARM_SPECIAL_SYM_TYPE_TAG (1 << 1) |
#define BFD_ARM_SPECIAL_SYM_TYPE_OTHER (1 << 2) |
#define BFD_ARM_SPECIAL_SYM_TYPE_ANY (~0) |
extern bfd_boolean bfd_is_arm_special_symbol_name |
(const char *, int); |
(const char * name, int type); |
extern void bfd_elf32_arm_set_byteswap_code |
(struct bfd_link_info *, int); |
extern void bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *, int); |
extern void bfd_elf32_arm_use_long_plt (void); |
/* ARM Note section processing. */ |
extern bfd_boolean bfd_arm_merge_machines |
(bfd *, bfd *); |
968,10 → 943,10 |
(bfd *); |
extern void bfd_elf64_aarch64_set_options |
(bfd *, struct bfd_link_info *, int, int, int, int, int); |
(bfd *, struct bfd_link_info *, int, int, int); |
extern void bfd_elf32_aarch64_set_options |
(bfd *, struct bfd_link_info *, int, int, int, int, int); |
(bfd *, struct bfd_link_info *, int, int, int); |
/* ELF AArch64 mapping symbol support. */ |
#define BFD_AARCH64_SPECIAL_SYM_TYPE_MAP (1 << 0) |
1023,17 → 998,29 |
extern void bfd_elf64_ia64_after_parse |
(int); |
/* V850 Note manipulation routines. */ |
extern bfd_boolean v850_elf_create_sections |
(struct bfd_link_info *); |
/* This structure is used for a comdat section, as in PE. A comdat |
section is associated with a particular symbol. When the linker |
sees a comdat section, it keeps only one of the sections with a |
given name and associated with a given symbol. */ |
extern bfd_boolean v850_elf_set_note |
(bfd *, unsigned int, unsigned int); |
struct coff_comdat_info |
{ |
/* The name of the symbol associated with a comdat section. */ |
const char *name; |
/* The local symbol table index of the symbol associated with a |
comdat section. This is only meaningful to the object file format |
specific code; it is not an index into the list returned by |
bfd_canonicalize_symtab. */ |
long symbol; |
}; |
extern struct coff_comdat_info * bfd_coff_get_comdat_section |
(bfd *, struct bfd_section *); |
/* Extracted from init.c. */ |
void bfd_init (void); |
/* Extracted from opncls.c. */ |
/* Set to N to open the next N BFDs using an alternate id space. */ |
extern unsigned int bfd_use_reserved_id; |
bfd *bfd_fopen (const char *filename, const char *target, |
const char *mode, int fd); |
1042,7 → 1029,7 |
bfd *bfd_fdopenr (const char *filename, const char *target, int fd); |
bfd *bfd_openstreamr (const char * filename, const char * target, void * stream); |
bfd *bfd_openstreamr (const char *, const char *, void *); |
bfd *bfd_openr_iovec (const char *filename, const char *target, |
void *(*open_func) (struct bfd *nbfd, |
1080,9 → 1067,7 |
char *bfd_get_debug_link_info (bfd *abfd, unsigned long *crc32_out); |
char *bfd_get_alt_debug_link_info (bfd * abfd, |
bfd_size_type *buildid_len, |
bfd_byte **buildid_out); |
char *bfd_get_alt_debug_link_info (bfd *abfd, unsigned long *crc32_out); |
char *bfd_follow_gnu_debuglink (bfd *abfd, const char *dir); |
1218,7 → 1203,6 |
/* Extracted from bfdwin.c. */ |
/* Extracted from section.c. */ |
typedef struct bfd_section |
{ |
/* The name of the section; the name isn't a copy, the pointer is |
1226,10 → 1210,10 |
const char *name; |
/* A unique sequence number. */ |
unsigned int id; |
int id; |
/* Which section in the bfd; 0..n-1 as sections are created in a bfd. */ |
unsigned int index; |
int index; |
/* The next section in the list belonging to the BFD, or NULL. */ |
struct bfd_section *next; |
1405,10 → 1389,6 |
executables or shared objects. This is for COFF only. */ |
#define SEC_COFF_SHARED 0x8000000 |
/* This section should be compressed. This is for ELF linker |
internal use only. */ |
#define SEC_ELF_COMPRESS 0x8000000 |
/* When a section with this flag is being linked, then if the size of |
the input section is less than a page, it should not cross a page |
boundary. If the size of the input section is one page or more, |
1416,18 → 1396,11 |
TMS320C54X only. */ |
#define SEC_TIC54X_BLOCK 0x10000000 |
/* This section should be renamed. This is for ELF linker |
internal use only. */ |
#define SEC_ELF_RENAME 0x10000000 |
/* Conditionally link this section; do not link if there are no |
references found to any symbol in the section. This is for TI |
TMS320C54X only. */ |
#define SEC_TIC54X_CLINK 0x20000000 |
/* This section contains vliw code. This is for Toshiba MeP only. */ |
#define SEC_MEP_VLIW 0x20000000 |
/* Indicate that section has the no read flag set. This happens |
when memory read flag isn't set. */ |
#define SEC_COFF_NOREAD 0x40000000 |
1467,8 → 1440,6 |
#define SEC_INFO_TYPE_MERGE 2 |
#define SEC_INFO_TYPE_EH_FRAME 3 |
#define SEC_INFO_TYPE_JUST_SYMS 4 |
#define SEC_INFO_TYPE_TARGET 5 |
#define SEC_INFO_TYPE_EH_FRAME_ENTRY 6 |
/* Nonzero if this section uses RELA relocations, rather than REL. */ |
unsigned int use_rela_p:1; |
1623,32 → 1594,6 |
int size; |
}; |
/* Note: the following are provided as inline functions rather than macros |
because not all callers use the return value. A macro implementation |
would use a comma expression, eg: "((ptr)->foo = val, TRUE)" and some |
compilers will complain about comma expressions that have no effect. */ |
static inline bfd_boolean |
bfd_set_section_userdata (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, void * val) |
{ |
ptr->userdata = val; |
return TRUE; |
} |
static inline bfd_boolean |
bfd_set_section_vma (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, bfd_vma val) |
{ |
ptr->vma = ptr->lma = val; |
ptr->user_set_vma = TRUE; |
return TRUE; |
} |
static inline bfd_boolean |
bfd_set_section_alignment (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, unsigned int val) |
{ |
ptr->alignment_power = val; |
return TRUE; |
} |
/* These sections are global, and are managed by BFD. The application |
and target back end are not permitted to change the values in |
these sections. */ |
1810,7 → 1755,7 |
asection *bfd_get_section_by_name (bfd *abfd, const char *name); |
asection *bfd_get_next_section_by_name (bfd *ibfd, asection *sec); |
asection *bfd_get_next_section_by_name (asection *sec); |
asection *bfd_get_linker_section (bfd *abfd, const char *name); |
1835,8 → 1780,6 |
asection *bfd_make_section (bfd *, const char *name); |
int bfd_get_next_section_id (void); |
bfd_boolean bfd_set_section_flags |
(bfd *abfd, asection *sec, flagword flags); |
1933,9 → 1876,7 |
#define bfd_mach_i960_jx 7 |
#define bfd_mach_i960_hx 8 |
bfd_arch_or1k, /* OpenRISC 1000 */ |
#define bfd_mach_or1k 1 |
#define bfd_mach_or1knd 2 |
bfd_arch_or32, /* OpenRISC 32 */ |
bfd_arch_sparc, /* SPARC */ |
#define bfd_mach_sparc 1 |
1991,18 → 1932,11 |
#define bfd_mach_mips_octeon 6501 |
#define bfd_mach_mips_octeonp 6601 |
#define bfd_mach_mips_octeon2 6502 |
#define bfd_mach_mips_octeon3 6503 |
#define bfd_mach_mips_xlr 887682 /* decimal 'XLR' */ |
#define bfd_mach_mipsisa32 32 |
#define bfd_mach_mipsisa32r2 33 |
#define bfd_mach_mipsisa32r3 34 |
#define bfd_mach_mipsisa32r5 36 |
#define bfd_mach_mipsisa32r6 37 |
#define bfd_mach_mipsisa64 64 |
#define bfd_mach_mipsisa64r2 65 |
#define bfd_mach_mipsisa64r3 66 |
#define bfd_mach_mipsisa64r5 68 |
#define bfd_mach_mipsisa64r6 69 |
#define bfd_mach_mips_micromips 96 |
bfd_arch_i386, /* Intel 386 */ |
#define bfd_mach_i386_intel_syntax (1 << 0) |
2023,10 → 1957,6 |
#define bfd_mach_i386_i386_nacl (bfd_mach_i386_i386 | bfd_mach_i386_nacl) |
#define bfd_mach_x86_64_nacl (bfd_mach_x86_64 | bfd_mach_i386_nacl) |
#define bfd_mach_x64_32_nacl (bfd_mach_x64_32 | bfd_mach_i386_nacl) |
bfd_arch_iamcu, /* Intel MCU */ |
#define bfd_mach_iamcu (1 << 8) |
#define bfd_mach_i386_iamcu (bfd_mach_i386_i386 | bfd_mach_iamcu) |
#define bfd_mach_i386_iamcu_intel_syntax (bfd_mach_i386_iamcu | bfd_mach_i386_intel_syntax) |
bfd_arch_we32k, /* AT&T WE32xxx */ |
bfd_arch_tahoe, /* CCI/Harris Tahoe */ |
bfd_arch_i860, /* Intel 860 */ |
2141,12 → 2071,6 |
#define bfd_mach_arm_ep9312 11 |
#define bfd_mach_arm_iWMMXt 12 |
#define bfd_mach_arm_iWMMXt2 13 |
bfd_arch_nds32, /* Andes NDS32 */ |
#define bfd_mach_n1 1 |
#define bfd_mach_n1h 2 |
#define bfd_mach_n1h_v2 3 |
#define bfd_mach_n1h_v3 4 |
#define bfd_mach_n1h_v3m 5 |
bfd_arch_ns32k, /* National Semiconductors ns32000 */ |
bfd_arch_w65, /* WDC 65816 */ |
bfd_arch_tic30, /* Texas Instruments TMS320C30 */ |
2165,12 → 2089,10 |
#define bfd_mach_v850e2v3 0x45325633 |
#define bfd_mach_v850e3v5 0x45335635 /* ('E'|'3'|'V'|'5') */ |
bfd_arch_arc, /* ARC Cores */ |
#define bfd_mach_arc_a4 0 |
#define bfd_mach_arc_a5 1 |
#define bfd_mach_arc_arc600 2 |
#define bfd_mach_arc_arc601 4 |
#define bfd_mach_arc_arc700 3 |
#define bfd_mach_arc_arcv2 5 |
#define bfd_mach_arc_5 5 |
#define bfd_mach_arc_6 6 |
#define bfd_mach_arc_7 7 |
#define bfd_mach_arc_8 8 |
bfd_arch_m32c, /* Renesas M16C/M32C. */ |
#define bfd_mach_m16c 0x75 |
#define bfd_mach_m32c 0x78 |
2196,8 → 2118,6 |
#define bfd_mach_fr550 550 |
bfd_arch_moxie, /* The moxie processor */ |
#define bfd_mach_moxie 1 |
bfd_arch_ft32, /* The ft32 processor */ |
#define bfd_mach_ft32 1 |
bfd_arch_mcore, |
bfd_arch_mep, |
#define bfd_mach_mep 1 |
2233,7 → 2153,6 |
#define bfd_mach_avr5 5 |
#define bfd_mach_avr51 51 |
#define bfd_mach_avr6 6 |
#define bfd_mach_avrtiny 100 |
#define bfd_mach_avrxmega1 101 |
#define bfd_mach_avrxmega2 102 |
#define bfd_mach_avrxmega3 103 |
2263,6 → 2182,7 |
bfd_arch_score, /* Sunplus score */ |
#define bfd_mach_score3 3 |
#define bfd_mach_score7 7 |
bfd_arch_openrisc, /* OpenRISC */ |
bfd_arch_mmix, /* Donald Knuth's educational processor. */ |
bfd_arch_xstormy16, |
#define bfd_mach_xstormy16 1 |
2315,12 → 2235,8 |
bfd_arch_aarch64, /* AArch64 */ |
#define bfd_mach_aarch64 0 |
#define bfd_mach_aarch64_ilp32 32 |
bfd_arch_nios2, /* Nios II */ |
bfd_arch_nios2, |
#define bfd_mach_nios2 0 |
#define bfd_mach_nios2r1 1 |
#define bfd_mach_nios2r2 2 |
bfd_arch_visium, /* Visium */ |
#define bfd_mach_visium 1 |
bfd_arch_last |
}; |
2386,7 → 2302,6 |
(enum bfd_architecture arch, unsigned long machine); |
/* Extracted from reloc.c. */ |
typedef enum bfd_reloc_status |
{ |
/* No errors detected. */ |
2436,7 → 2351,6 |
} |
arelent; |
enum complain_overflow |
{ |
/* Do not complain on overflow. */ |
2455,7 → 2369,6 |
unsigned number. */ |
complain_overflow_unsigned |
}; |
struct bfd_symbol; /* Forward declaration. */ |
struct reloc_howto_struct |
{ |
2983,12 → 2896,6 |
BFD_RELOC_MICROMIPS_10_PCREL_S1, |
BFD_RELOC_MICROMIPS_16_PCREL_S1, |
/* MIPS PC-relative relocations. */ |
BFD_RELOC_MIPS_21_PCREL_S2, |
BFD_RELOC_MIPS_26_PCREL_S2, |
BFD_RELOC_MIPS_18_PCREL_S3, |
BFD_RELOC_MIPS_19_PCREL_S2, |
/* microMIPS versions of generic BFD relocs. */ |
BFD_RELOC_MICROMIPS_GPREL16, |
BFD_RELOC_MICROMIPS_HI16, |
3063,13 → 2970,6 |
BFD_RELOC_MOXIE_10_PCREL, |
/* FT32 ELF relocations. */ |
BFD_RELOC_FT32_10, |
BFD_RELOC_FT32_20, |
BFD_RELOC_FT32_17, |
BFD_RELOC_FT32_18, |
/* Fujitsu Frv Relocations. */ |
BFD_RELOC_FRV_LABEL16, |
BFD_RELOC_FRV_LABEL24, |
3194,7 → 3094,6 |
BFD_RELOC_386_TLS_DESC_CALL, |
BFD_RELOC_386_TLS_DESC, |
BFD_RELOC_386_IRELATIVE, |
BFD_RELOC_386_GOT32X, |
/* x86-64/elf relocations */ |
BFD_RELOC_X86_64_GOT32, |
3226,8 → 3125,6 |
BFD_RELOC_X86_64_IRELATIVE, |
BFD_RELOC_X86_64_PC32_BND, |
BFD_RELOC_X86_64_PLT32_BND, |
BFD_RELOC_X86_64_GOTPCRELX, |
BFD_RELOC_X86_64_REX_GOTPCRELX, |
/* ns32k relocations */ |
BFD_RELOC_NS32K_IMM_8, |
3303,7 → 3200,6 |
BFD_RELOC_PPC_VLE_SDAREL_HI16D, |
BFD_RELOC_PPC_VLE_SDAREL_HA16A, |
BFD_RELOC_PPC_VLE_SDAREL_HA16D, |
BFD_RELOC_PPC_REL16DX_HA, |
BFD_RELOC_PPC64_HIGHER, |
BFD_RELOC_PPC64_HIGHER_S, |
BFD_RELOC_PPC64_HIGHEST, |
3329,8 → 3225,6 |
BFD_RELOC_PPC64_PLTGOT16_LO_DS, |
BFD_RELOC_PPC64_ADDR16_HIGH, |
BFD_RELOC_PPC64_ADDR16_HIGHA, |
BFD_RELOC_PPC64_ADDR64_LOCAL, |
BFD_RELOC_PPC64_ENTRY, |
/* PowerPC and PowerPC64 thread-local storage relocations. */ |
BFD_RELOC_PPC_TLS, |
3644,74 → 3538,17 |
BFD_RELOC_SH_GOTOFFFUNCDESC20, |
BFD_RELOC_SH_FUNCDESC, |
/* ARC relocs. */ |
BFD_RELOC_ARC_NONE, |
BFD_RELOC_ARC_8, |
BFD_RELOC_ARC_16, |
BFD_RELOC_ARC_24, |
BFD_RELOC_ARC_32, |
BFD_RELOC_ARC_N8, |
BFD_RELOC_ARC_N16, |
BFD_RELOC_ARC_N24, |
BFD_RELOC_ARC_N32, |
BFD_RELOC_ARC_SDA, |
BFD_RELOC_ARC_SECTOFF, |
BFD_RELOC_ARC_S21H_PCREL, |
BFD_RELOC_ARC_S21W_PCREL, |
BFD_RELOC_ARC_S25H_PCREL, |
BFD_RELOC_ARC_S25W_PCREL, |
BFD_RELOC_ARC_SDA32, |
BFD_RELOC_ARC_SDA_LDST, |
BFD_RELOC_ARC_SDA_LDST1, |
BFD_RELOC_ARC_SDA_LDST2, |
BFD_RELOC_ARC_SDA16_LD, |
BFD_RELOC_ARC_SDA16_LD1, |
BFD_RELOC_ARC_SDA16_LD2, |
BFD_RELOC_ARC_S13_PCREL, |
BFD_RELOC_ARC_W, |
BFD_RELOC_ARC_32_ME, |
BFD_RELOC_ARC_32_ME_S, |
BFD_RELOC_ARC_N32_ME, |
BFD_RELOC_ARC_SECTOFF_ME, |
BFD_RELOC_ARC_SDA32_ME, |
BFD_RELOC_ARC_W_ME, |
BFD_RELOC_AC_SECTOFF_U8, |
BFD_RELOC_AC_SECTOFF_U8_1, |
BFD_RELOC_AC_SECTOFF_U8_2, |
BFD_RELOC_AC_SECTFOFF_S9, |
BFD_RELOC_AC_SECTFOFF_S9_1, |
BFD_RELOC_AC_SECTFOFF_S9_2, |
BFD_RELOC_ARC_SECTOFF_ME_1, |
BFD_RELOC_ARC_SECTOFF_ME_2, |
BFD_RELOC_ARC_SECTOFF_1, |
BFD_RELOC_ARC_SECTOFF_2, |
BFD_RELOC_ARC_SDA16_ST2, |
BFD_RELOC_ARC_32_PCREL, |
BFD_RELOC_ARC_PC32, |
BFD_RELOC_ARC_GOT32, |
BFD_RELOC_ARC_GOTPC32, |
BFD_RELOC_ARC_PLT32, |
BFD_RELOC_ARC_COPY, |
BFD_RELOC_ARC_GLOB_DAT, |
BFD_RELOC_ARC_JMP_SLOT, |
BFD_RELOC_ARC_RELATIVE, |
BFD_RELOC_ARC_GOTOFF, |
BFD_RELOC_ARC_GOTPC, |
BFD_RELOC_ARC_S21W_PCREL_PLT, |
BFD_RELOC_ARC_S25H_PCREL_PLT, |
BFD_RELOC_ARC_TLS_DTPMOD, |
BFD_RELOC_ARC_TLS_TPOFF, |
BFD_RELOC_ARC_TLS_GD_GOT, |
BFD_RELOC_ARC_TLS_GD_LD, |
BFD_RELOC_ARC_TLS_GD_CALL, |
BFD_RELOC_ARC_TLS_IE_GOT, |
BFD_RELOC_ARC_TLS_DTPOFF, |
BFD_RELOC_ARC_TLS_DTPOFF_S9, |
BFD_RELOC_ARC_TLS_LE_S9, |
BFD_RELOC_ARC_TLS_LE_32, |
BFD_RELOC_ARC_S25W_PCREL_PLT, |
BFD_RELOC_ARC_S21H_PCREL_PLT, |
/* ARC Cores relocs. |
ARC 22 bit pc-relative branch. The lowest two bits must be zero and are |
not stored in the instruction. The high 20 bits are installed in bits 26 |
through 7 of the instruction. */ |
BFD_RELOC_ARC_B22_PCREL, |
/* ARC 26 bit absolute branch. The lowest two bits must be zero and are not |
stored in the instruction. The high 24 bits are installed in bits 23 |
through 0. */ |
BFD_RELOC_ARC_B26, |
/* ADI Blackfin 16 bit immediate absolute reloc. */ |
BFD_RELOC_BFIN_16_IMM, |
3957,205 → 3794,6 |
BFD_RELOC_M32R_GOTPC_HI_SLO, |
BFD_RELOC_M32R_GOTPC_LO, |
/* NDS32 relocs. |
This is a 20 bit absolute address. */ |
BFD_RELOC_NDS32_20, |
/* This is a 9-bit pc-relative reloc with the right 1 bit assumed to be 0. */ |
BFD_RELOC_NDS32_9_PCREL, |
/* This is a 9-bit pc-relative reloc with the right 1 bit assumed to be 0. */ |
BFD_RELOC_NDS32_WORD_9_PCREL, |
/* This is an 15-bit reloc with the right 1 bit assumed to be 0. */ |
BFD_RELOC_NDS32_15_PCREL, |
/* This is an 17-bit reloc with the right 1 bit assumed to be 0. */ |
BFD_RELOC_NDS32_17_PCREL, |
/* This is a 25-bit reloc with the right 1 bit assumed to be 0. */ |
BFD_RELOC_NDS32_25_PCREL, |
/* This is a 20-bit reloc containing the high 20 bits of an address |
used with the lower 12 bits */ |
BFD_RELOC_NDS32_HI20, |
/* This is a 12-bit reloc containing the lower 12 bits of an address |
then shift right by 3. This is used with ldi,sdi... */ |
BFD_RELOC_NDS32_LO12S3, |
/* This is a 12-bit reloc containing the lower 12 bits of an address |
then shift left by 2. This is used with lwi,swi... */ |
BFD_RELOC_NDS32_LO12S2, |
/* This is a 12-bit reloc containing the lower 12 bits of an address |
then shift left by 1. This is used with lhi,shi... */ |
BFD_RELOC_NDS32_LO12S1, |
/* This is a 12-bit reloc containing the lower 12 bits of an address |
then shift left by 0. This is used with lbisbi... */ |
BFD_RELOC_NDS32_LO12S0, |
/* This is a 12-bit reloc containing the lower 12 bits of an address |
then shift left by 0. This is only used with branch relaxations */ |
BFD_RELOC_NDS32_LO12S0_ORI, |
/* This is a 15-bit reloc containing the small data area 18-bit signed offset |
and shift left by 3 for use in ldi, sdi... */ |
BFD_RELOC_NDS32_SDA15S3, |
/* This is a 15-bit reloc containing the small data area 17-bit signed offset |
and shift left by 2 for use in lwi, swi... */ |
BFD_RELOC_NDS32_SDA15S2, |
/* This is a 15-bit reloc containing the small data area 16-bit signed offset |
and shift left by 1 for use in lhi, shi... */ |
BFD_RELOC_NDS32_SDA15S1, |
/* This is a 15-bit reloc containing the small data area 15-bit signed offset |
and shift left by 0 for use in lbi, sbi... */ |
BFD_RELOC_NDS32_SDA15S0, |
/* This is a 16-bit reloc containing the small data area 16-bit signed offset |
and shift left by 3 */ |
BFD_RELOC_NDS32_SDA16S3, |
/* This is a 17-bit reloc containing the small data area 17-bit signed offset |
and shift left by 2 for use in lwi.gp, swi.gp... */ |
BFD_RELOC_NDS32_SDA17S2, |
/* This is a 18-bit reloc containing the small data area 18-bit signed offset |
and shift left by 1 for use in lhi.gp, shi.gp... */ |
BFD_RELOC_NDS32_SDA18S1, |
/* This is a 19-bit reloc containing the small data area 19-bit signed offset |
and shift left by 0 for use in lbi.gp, sbi.gp... */ |
BFD_RELOC_NDS32_SDA19S0, |
/* for PIC */ |
BFD_RELOC_NDS32_GOT20, |
BFD_RELOC_NDS32_9_PLTREL, |
BFD_RELOC_NDS32_25_PLTREL, |
BFD_RELOC_NDS32_COPY, |
BFD_RELOC_NDS32_GLOB_DAT, |
BFD_RELOC_NDS32_JMP_SLOT, |
BFD_RELOC_NDS32_RELATIVE, |
BFD_RELOC_NDS32_GOTOFF, |
BFD_RELOC_NDS32_GOTOFF_HI20, |
BFD_RELOC_NDS32_GOTOFF_LO12, |
BFD_RELOC_NDS32_GOTPC20, |
BFD_RELOC_NDS32_GOT_HI20, |
BFD_RELOC_NDS32_GOT_LO12, |
BFD_RELOC_NDS32_GOTPC_HI20, |
BFD_RELOC_NDS32_GOTPC_LO12, |
/* for relax */ |
BFD_RELOC_NDS32_INSN16, |
BFD_RELOC_NDS32_LABEL, |
BFD_RELOC_NDS32_LONGCALL1, |
BFD_RELOC_NDS32_LONGCALL2, |
BFD_RELOC_NDS32_LONGCALL3, |
BFD_RELOC_NDS32_LONGJUMP1, |
BFD_RELOC_NDS32_LONGJUMP2, |
BFD_RELOC_NDS32_LONGJUMP3, |
BFD_RELOC_NDS32_LOADSTORE, |
BFD_RELOC_NDS32_9_FIXED, |
BFD_RELOC_NDS32_15_FIXED, |
BFD_RELOC_NDS32_17_FIXED, |
BFD_RELOC_NDS32_25_FIXED, |
BFD_RELOC_NDS32_LONGCALL4, |
BFD_RELOC_NDS32_LONGCALL5, |
BFD_RELOC_NDS32_LONGCALL6, |
BFD_RELOC_NDS32_LONGJUMP4, |
BFD_RELOC_NDS32_LONGJUMP5, |
BFD_RELOC_NDS32_LONGJUMP6, |
BFD_RELOC_NDS32_LONGJUMP7, |
/* for PIC */ |
BFD_RELOC_NDS32_PLTREL_HI20, |
BFD_RELOC_NDS32_PLTREL_LO12, |
BFD_RELOC_NDS32_PLT_GOTREL_HI20, |
BFD_RELOC_NDS32_PLT_GOTREL_LO12, |
/* for floating point */ |
BFD_RELOC_NDS32_SDA12S2_DP, |
BFD_RELOC_NDS32_SDA12S2_SP, |
BFD_RELOC_NDS32_LO12S2_DP, |
BFD_RELOC_NDS32_LO12S2_SP, |
/* for dwarf2 debug_line. */ |
BFD_RELOC_NDS32_DWARF2_OP1, |
BFD_RELOC_NDS32_DWARF2_OP2, |
BFD_RELOC_NDS32_DWARF2_LEB, |
/* for eliminate 16-bit instructions */ |
BFD_RELOC_NDS32_UPDATE_TA, |
/* for PIC object relaxation */ |
BFD_RELOC_NDS32_PLT_GOTREL_LO20, |
BFD_RELOC_NDS32_PLT_GOTREL_LO15, |
BFD_RELOC_NDS32_PLT_GOTREL_LO19, |
BFD_RELOC_NDS32_GOT_LO15, |
BFD_RELOC_NDS32_GOT_LO19, |
BFD_RELOC_NDS32_GOTOFF_LO15, |
BFD_RELOC_NDS32_GOTOFF_LO19, |
BFD_RELOC_NDS32_GOT15S2, |
BFD_RELOC_NDS32_GOT17S2, |
/* NDS32 relocs. |
This is a 5 bit absolute address. */ |
BFD_RELOC_NDS32_5, |
/* This is a 10-bit unsigned pc-relative reloc with the right 1 bit assumed to be 0. */ |
BFD_RELOC_NDS32_10_UPCREL, |
/* If fp were omitted, fp can used as another gp. */ |
BFD_RELOC_NDS32_SDA_FP7U2_RELA, |
/* relaxation relative relocation types */ |
BFD_RELOC_NDS32_RELAX_ENTRY, |
BFD_RELOC_NDS32_GOT_SUFF, |
BFD_RELOC_NDS32_GOTOFF_SUFF, |
BFD_RELOC_NDS32_PLT_GOT_SUFF, |
BFD_RELOC_NDS32_MULCALL_SUFF, |
BFD_RELOC_NDS32_PTR, |
BFD_RELOC_NDS32_PTR_COUNT, |
BFD_RELOC_NDS32_PTR_RESOLVED, |
BFD_RELOC_NDS32_PLTBLOCK, |
BFD_RELOC_NDS32_RELAX_REGION_BEGIN, |
BFD_RELOC_NDS32_RELAX_REGION_END, |
BFD_RELOC_NDS32_MINUEND, |
BFD_RELOC_NDS32_SUBTRAHEND, |
BFD_RELOC_NDS32_DIFF8, |
BFD_RELOC_NDS32_DIFF16, |
BFD_RELOC_NDS32_DIFF32, |
BFD_RELOC_NDS32_DIFF_ULEB128, |
BFD_RELOC_NDS32_EMPTY, |
/* This is a 25 bit absolute address. */ |
BFD_RELOC_NDS32_25_ABS, |
/* For ex9 and ifc using. */ |
BFD_RELOC_NDS32_DATA, |
BFD_RELOC_NDS32_TRAN, |
BFD_RELOC_NDS32_17IFC_PCREL, |
BFD_RELOC_NDS32_10IFCU_PCREL, |
/* For TLS. */ |
BFD_RELOC_NDS32_TPOFF, |
BFD_RELOC_NDS32_TLS_LE_HI20, |
BFD_RELOC_NDS32_TLS_LE_LO12, |
BFD_RELOC_NDS32_TLS_LE_ADD, |
BFD_RELOC_NDS32_TLS_LE_LS, |
BFD_RELOC_NDS32_GOTTPOFF, |
BFD_RELOC_NDS32_TLS_IE_HI20, |
BFD_RELOC_NDS32_TLS_IE_LO12S2, |
BFD_RELOC_NDS32_TLS_TPOFF, |
BFD_RELOC_NDS32_TLS_LE_20, |
BFD_RELOC_NDS32_TLS_LE_15S0, |
BFD_RELOC_NDS32_TLS_LE_15S1, |
BFD_RELOC_NDS32_TLS_LE_15S2, |
/* This is a 9-bit reloc */ |
BFD_RELOC_V850_9_PCREL, |
4613,28 → 4251,6 |
in .byte hlo8(symbol) */ |
BFD_RELOC_AVR_8_HLO, |
/* AVR relocations to mark the difference of two local symbols. |
These are only needed to support linker relaxation and can be ignored |
when not relaxing. The field is set to the value of the difference |
assuming no relaxation. The relocation encodes the position of the |
second symbol so the linker can determine whether to adjust the field |
value. */ |
BFD_RELOC_AVR_DIFF8, |
BFD_RELOC_AVR_DIFF16, |
BFD_RELOC_AVR_DIFF32, |
/* This is a 7 bit reloc for the AVR that stores SRAM address for 16bit |
lds and sts instructions supported only tiny core. */ |
BFD_RELOC_AVR_LDS_STS_16, |
/* This is a 6 bit reloc for the AVR that stores an I/O register |
number for the IN and OUT instructions */ |
BFD_RELOC_AVR_PORT6, |
/* This is a 5 bit reloc for the AVR that stores an I/O register |
number for the SBIC, SBIS, SBI and CBI instructions */ |
BFD_RELOC_AVR_PORT5, |
/* Renesas RL78 Relocations. */ |
BFD_RELOC_RL78_NEG8, |
BFD_RELOC_RL78_NEG16, |
4669,7 → 4285,6 |
BFD_RELOC_RL78_HI8, |
BFD_RELOC_RL78_LO16, |
BFD_RELOC_RL78_CODE, |
BFD_RELOC_RL78_SADDR, |
/* Renesas RX Relocations. */ |
BFD_RELOC_RX_NEG8, |
5299,31 → 4914,9 |
BFD_RELOC_860_HIGOT, |
BFD_RELOC_860_HIGOTOFF, |
/* OpenRISC 1000 Relocations. */ |
BFD_RELOC_OR1K_REL_26, |
BFD_RELOC_OR1K_GOTPC_HI16, |
BFD_RELOC_OR1K_GOTPC_LO16, |
BFD_RELOC_OR1K_GOT16, |
BFD_RELOC_OR1K_PLT26, |
BFD_RELOC_OR1K_GOTOFF_HI16, |
BFD_RELOC_OR1K_GOTOFF_LO16, |
BFD_RELOC_OR1K_COPY, |
BFD_RELOC_OR1K_GLOB_DAT, |
BFD_RELOC_OR1K_JMP_SLOT, |
BFD_RELOC_OR1K_RELATIVE, |
BFD_RELOC_OR1K_TLS_GD_HI16, |
BFD_RELOC_OR1K_TLS_GD_LO16, |
BFD_RELOC_OR1K_TLS_LDM_HI16, |
BFD_RELOC_OR1K_TLS_LDM_LO16, |
BFD_RELOC_OR1K_TLS_LDO_HI16, |
BFD_RELOC_OR1K_TLS_LDO_LO16, |
BFD_RELOC_OR1K_TLS_IE_HI16, |
BFD_RELOC_OR1K_TLS_IE_LO16, |
BFD_RELOC_OR1K_TLS_LE_HI16, |
BFD_RELOC_OR1K_TLS_LE_LO16, |
BFD_RELOC_OR1K_TLS_TPOFF, |
BFD_RELOC_OR1K_TLS_DTPOFF, |
BFD_RELOC_OR1K_TLS_DTPMOD, |
/* OpenRISC Relocations. */ |
BFD_RELOC_OPENRISC_ABS_26, |
BFD_RELOC_OPENRISC_REL_26, |
/* H8 elf Relocations. */ |
BFD_RELOC_H8_DIR16A8, |
5431,24 → 5024,6 |
BFD_RELOC_NIOS2_JUMP_SLOT, |
BFD_RELOC_NIOS2_RELATIVE, |
BFD_RELOC_NIOS2_GOTOFF, |
BFD_RELOC_NIOS2_CALL26_NOAT, |
BFD_RELOC_NIOS2_GOT_LO, |
BFD_RELOC_NIOS2_GOT_HA, |
BFD_RELOC_NIOS2_CALL_LO, |
BFD_RELOC_NIOS2_CALL_HA, |
BFD_RELOC_NIOS2_R2_S12, |
BFD_RELOC_NIOS2_R2_I10_1_PCREL, |
BFD_RELOC_NIOS2_R2_T1I7_1_PCREL, |
BFD_RELOC_NIOS2_R2_T1I7_2, |
BFD_RELOC_NIOS2_R2_T2I4, |
BFD_RELOC_NIOS2_R2_T2I4_1, |
BFD_RELOC_NIOS2_R2_T2I4_2, |
BFD_RELOC_NIOS2_R2_X1I7_2, |
BFD_RELOC_NIOS2_R2_X2L5, |
BFD_RELOC_NIOS2_R2_F1I5_2, |
BFD_RELOC_NIOS2_R2_L5I4X1, |
BFD_RELOC_NIOS2_R2_T1X1I6, |
BFD_RELOC_NIOS2_R2_T1X1I6_2, |
/* IQ2000 Relocations. */ |
BFD_RELOC_IQ2000_OFFSET_16, |
5835,24 → 5410,6 |
BFD_RELOC_AARCH64_ADR_GOTPAGE. Valid in ILP32 ABI only. */ |
BFD_RELOC_AARCH64_LD32_GOT_LO12_NC, |
/* Unsigned 16 bit byte offset for 64 bit load/store from the GOT entry |
for this symbol. Valid in LP64 ABI only. */ |
BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC, |
/* Unsigned 16 bit byte higher offset for 64 bit load/store from the GOT entry |
for this symbol. Valid in LP64 ABI only. */ |
BFD_RELOC_AARCH64_MOVW_GOTOFF_G1, |
/* Unsigned 15 bit byte offset for 64 bit load/store from the page of |
the GOT entry for this symbol. Valid in LP64 ABI only. */ |
BFD_RELOC_AARCH64_LD64_GOTOFF_LO15, |
/* Scaled 14 bit byte offset to the page base of the global offset table. */ |
BFD_RELOC_AARCH64_LD32_GOTPAGE_LO14, |
/* Scaled 15 bit byte offset to the page base of the global offset table. */ |
BFD_RELOC_AARCH64_LD64_GOTPAGE_LO15, |
/* Get to the page base of the global offset table entry for a symbols |
tls_index structure as part of an adrp instruction using a 21 bit PC |
relative value. Used in conjunction with |
5859,19 → 5416,16 |
BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC. */ |
BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21, |
/* AArch64 TLS General Dynamic */ |
BFD_RELOC_AARCH64_TLSGD_ADR_PREL21, |
/* Unsigned 12 bit byte offset to global offset table entry for a symbols |
tls_index structure. Used in conjunction with |
BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21. */ |
BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC, |
/* AArch64 TLS General Dynamic relocation. */ |
BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC, |
/* AArch64 TLS INITIAL EXEC relocation. */ |
BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1, |
/* AArch64 TLS General Dynamic relocation. */ |
BFD_RELOC_AARCH64_TLSGD_MOVW_G1, |
/* AArch64 TLS INITIAL EXEC relocation. */ |
BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC, |
/* AArch64 TLS INITIAL EXEC relocation. */ |
BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21, |
5885,76 → 5439,6 |
/* AArch64 TLS INITIAL EXEC relocation. */ |
BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19, |
/* AArch64 TLS INITIAL EXEC relocation. */ |
BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC, |
/* AArch64 TLS INITIAL EXEC relocation. */ |
BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1, |
/* bit[23:12] of byte offset to module TLS base address. */ |
BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_HI12, |
/* Unsigned 12 bit byte offset to module TLS base address. */ |
BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12, |
/* No overflow check version of BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12. */ |
BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC, |
/* Unsigned 12 bit byte offset to global offset table entry for a symbols |
tls_index structure. Used in conjunction with |
BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21. */ |
BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC, |
/* GOT entry page address for AArch64 TLS Local Dynamic, used with ADRP |
instruction. */ |
BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21, |
/* GOT entry address for AArch64 TLS Local Dynamic, used with ADR instruction. */ |
BFD_RELOC_AARCH64_TLSLD_ADR_PREL21, |
/* bit[11:1] of byte offset to module TLS base address, encoded in ldst |
instructions. */ |
BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12, |
/* Similar as BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12, but no overflow check. */ |
BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC, |
/* bit[11:2] of byte offset to module TLS base address, encoded in ldst |
instructions. */ |
BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12, |
/* Similar as BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12, but no overflow check. */ |
BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC, |
/* bit[11:3] of byte offset to module TLS base address, encoded in ldst |
instructions. */ |
BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12, |
/* Similar as BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12, but no overflow check. */ |
BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC, |
/* bit[11:0] of byte offset to module TLS base address, encoded in ldst |
instructions. */ |
BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12, |
/* Similar as BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12, but no overflow check. */ |
BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC, |
/* bit[15:0] of byte offset to module TLS base address. */ |
BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0, |
/* No overflow check version of BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0 */ |
BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0_NC, |
/* bit[31:16] of byte offset to module TLS base address. */ |
BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1, |
/* No overflow check version of BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1 */ |
BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1_NC, |
/* bit[47:32] of byte offset to module TLS base address. */ |
BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G2, |
/* AArch64 TLS LOCAL EXEC relocation. */ |
BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2, |
6054,14 → 5538,6 |
address. Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL. */ |
BFD_RELOC_AARCH64_LDST_LO12, |
/* AArch64 pseudo relocation code for TLS local dynamic mode. It's to be |
used internally by the AArch64 assembler and not (currently) written to |
any object files. */ |
BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12, |
/* Similar as BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12, but no overflow check. */ |
BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12_NC, |
/* AArch64 pseudo relocation code to be used internally by the AArch64 |
assembler and not (currently) written to any object files. */ |
BFD_RELOC_AARCH64_LD_GOT_LO12_NC, |
6286,17 → 5762,7 |
/* Adapteva EPIPHANY - 8 bit immediate for 16 bit mov instruction. */ |
BFD_RELOC_EPIPHANY_IMM8, |
/* Visium Relocations. */ |
BFD_RELOC_VISIUM_HI16, |
BFD_RELOC_VISIUM_LO16, |
BFD_RELOC_VISIUM_IM16, |
BFD_RELOC_VISIUM_REL16, |
BFD_RELOC_VISIUM_HI16_PCREL, |
BFD_RELOC_VISIUM_LO16_PCREL, |
BFD_RELOC_VISIUM_IM16_PCREL, |
BFD_RELOC_UNUSED }; |
typedef enum bfd_reloc_code_real bfd_reloc_code_real_type; |
reloc_howto_type *bfd_reloc_type_lookup |
(bfd *abfd, bfd_reloc_code_real_type code); |
6494,7 → 5960,6 |
(ibfd, isymbol, obfd, osymbol)) |
/* Extracted from bfd.c. */ |
enum bfd_direction |
{ |
no_direction = 0, |
6503,21 → 5968,11 |
both_direction = 3 |
}; |
enum bfd_plugin_format |
struct bfd |
{ |
bfd_plugin_uknown = 0, |
bfd_plugin_yes = 1, |
bfd_plugin_no = 2 |
}; |
/* A unique identifier of the BFD */ |
unsigned int id; |
struct bfd_build_id |
{ |
bfd_size_type size; |
bfd_byte data[1]; |
}; |
struct bfd |
{ |
/* The filename the application opened the BFD with. */ |
const char *filename; |
6540,17 → 5995,17 |
/* File modified time, if mtime_set is TRUE. */ |
long mtime; |
/* A unique identifier of the BFD */ |
unsigned int id; |
/* Reserved for an unimplemented file locking extension. */ |
int ifd; |
/* The format which belongs to the BFD. (object, core, etc.) */ |
ENUM_BITFIELD (bfd_format) format : 3; |
bfd_format format; |
/* The direction with which the BFD was opened. */ |
ENUM_BITFIELD (bfd_direction) direction : 2; |
enum bfd_direction direction; |
/* Format_specific flags. */ |
flagword flags : 18; |
flagword flags; |
/* Values that may appear in the flags field of a BFD. These also |
appear in the object_flags field of the bfd_target structure, where |
6609,87 → 6064,36 |
struct. */ |
#define BFD_IN_MEMORY 0x800 |
/* The sections in this BFD specify a memory page. */ |
#define HAS_LOAD_PAGE 0x1000 |
/* This BFD has been created by the linker and doesn't correspond |
to any input file. */ |
#define BFD_LINKER_CREATED 0x1000 |
#define BFD_LINKER_CREATED 0x2000 |
/* This may be set before writing out a BFD to request that it |
be written using values for UIDs, GIDs, timestamps, etc. that |
will be consistent from run to run. */ |
#define BFD_DETERMINISTIC_OUTPUT 0x2000 |
#define BFD_DETERMINISTIC_OUTPUT 0x4000 |
/* Compress sections in this BFD. */ |
#define BFD_COMPRESS 0x4000 |
#define BFD_COMPRESS 0x8000 |
/* Decompress sections in this BFD. */ |
#define BFD_DECOMPRESS 0x8000 |
#define BFD_DECOMPRESS 0x10000 |
/* BFD is a dummy, for plugins. */ |
#define BFD_PLUGIN 0x10000 |
#define BFD_PLUGIN 0x20000 |
/* Compress sections in this BFD with SHF_COMPRESSED from gABI. */ |
#define BFD_COMPRESS_GABI 0x20000 |
/* Flags bits to be saved in bfd_preserve_save. */ |
#define BFD_FLAGS_SAVED \ |
(BFD_IN_MEMORY | BFD_COMPRESS | BFD_DECOMPRESS | BFD_PLUGIN \ |
| BFD_COMPRESS_GABI) |
(BFD_IN_MEMORY | BFD_COMPRESS | BFD_DECOMPRESS | BFD_PLUGIN) |
/* Flags bits which are for BFD use only. */ |
#define BFD_FLAGS_FOR_BFD_USE_MASK \ |
(BFD_IN_MEMORY | BFD_COMPRESS | BFD_DECOMPRESS | BFD_LINKER_CREATED \ |
| BFD_PLUGIN | BFD_TRADITIONAL_FORMAT | BFD_DETERMINISTIC_OUTPUT \ |
| BFD_COMPRESS_GABI) |
| BFD_PLUGIN | BFD_TRADITIONAL_FORMAT | BFD_DETERMINISTIC_OUTPUT) |
/* Is the file descriptor being cached? That is, can it be closed as |
needed, and re-opened when accessed later? */ |
unsigned int cacheable : 1; |
/* Marks whether there was a default target specified when the |
BFD was opened. This is used to select which matching algorithm |
to use to choose the back end. */ |
unsigned int target_defaulted : 1; |
/* ... and here: (``once'' means at least once). */ |
unsigned int opened_once : 1; |
/* Set if we have a locally maintained mtime value, rather than |
getting it from the file each time. */ |
unsigned int mtime_set : 1; |
/* Flag set if symbols from this BFD should not be exported. */ |
unsigned int no_export : 1; |
/* Remember when output has begun, to stop strange things |
from happening. */ |
unsigned int output_has_begun : 1; |
/* Have archive map. */ |
unsigned int has_armap : 1; |
/* Set if this is a thin archive. */ |
unsigned int is_thin_archive : 1; |
/* Set if only required symbols should be added in the link hash table for |
this object. Used by VMS linkers. */ |
unsigned int selective_search : 1; |
/* Set if this is the linker output BFD. */ |
unsigned int is_linker_output : 1; |
/* Set if this is the linker input BFD. */ |
unsigned int is_linker_input : 1; |
/* If this is an input for a compiler plug-in library. */ |
ENUM_BITFIELD (bfd_plugin_format) plugin_format : 2; |
/* Set if this is a plugin output file. */ |
unsigned int lto_output : 1; |
/* Set to dummy BFD created when claimed by a compiler plug-in |
library. */ |
bfd *plugin_dummy_bfd; |
/* Currently my_archive is tested before adding origin to |
anything. I believe that this can become always an add of |
origin, with origin set to 0 for non archive files. */ |
6714,21 → 6118,17 |
/* The number of sections. */ |
unsigned int section_count; |
/* A field used by _bfd_generic_link_add_archive_symbols. This will |
be used only for archive elements. */ |
int archive_pass; |
/* Stuff only useful for object files: |
The start address. */ |
bfd_vma start_address; |
/* Used for input and output. */ |
unsigned int symcount; |
/* Symbol table for output BFD (with symcount entries). |
Also used by the linker to cache input BFD symbols. */ |
struct bfd_symbol **outsymbols; |
/* Used for input and output. */ |
unsigned int symcount; |
/* Used for slurped dynamic symbol tables. */ |
unsigned int dynsymcount; |
6743,13 → 6143,13 |
struct bfd *nested_archives; /* List of nested archive in a flattened |
thin archive. */ |
union { |
/* For input BFDs, a chain of BFDs involved in a link. */ |
struct bfd *next; |
/* For output BFD, the linker hash table. */ |
struct bfd_link_hash_table *hash; |
} link; |
/* A chain of BFD structures involved in a link. */ |
struct bfd *link_next; |
/* A field used by _bfd_generic_link_add_archive_symbols. This will |
be used only for archive elements. */ |
int archive_pass; |
/* Used by the back end to hold private data. */ |
union |
{ |
6801,19 → 6201,40 |
of objalloc.h. */ |
void *memory; |
/* For input BFDs, the build ID, if the object has one. */ |
const struct bfd_build_id *build_id; |
}; |
/* Is the file descriptor being cached? That is, can it be closed as |
needed, and re-opened when accessed later? */ |
unsigned int cacheable : 1; |
/* See note beside bfd_set_section_userdata. */ |
static inline bfd_boolean |
bfd_set_cacheable (bfd * abfd, bfd_boolean val) |
{ |
abfd->cacheable = val; |
return TRUE; |
} |
/* Marks whether there was a default target specified when the |
BFD was opened. This is used to select which matching algorithm |
to use to choose the back end. */ |
unsigned int target_defaulted : 1; |
/* ... and here: (``once'' means at least once). */ |
unsigned int opened_once : 1; |
/* Set if we have a locally maintained mtime value, rather than |
getting it from the file each time. */ |
unsigned int mtime_set : 1; |
/* Flag set if symbols from this BFD should not be exported. */ |
unsigned int no_export : 1; |
/* Remember when output has begun, to stop strange things |
from happening. */ |
unsigned int output_has_begun : 1; |
/* Have archive map. */ |
unsigned int has_armap : 1; |
/* Set if this is a thin archive. */ |
unsigned int is_thin_archive : 1; |
/* Set if only required symbols should be added in the link hash table for |
this object. Used by VMS linkers. */ |
unsigned int selective_search : 1; |
}; |
typedef enum bfd_error |
{ |
bfd_error_no_error = 0, |
6849,7 → 6270,6 |
void bfd_perror (const char *message); |
typedef void (*bfd_error_handler_type) (const char *, ...); |
bfd_error_handler_type bfd_set_error_handler (bfd_error_handler_type); |
6858,7 → 6278,6 |
bfd_error_handler_type bfd_get_error_handler (void); |
typedef void (*bfd_assert_handler_type) (const char *bfd_formatmsg, |
const char *bfd_version, |
const char *bfd_file, |
6914,12 → 6333,12 |
#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \ |
BFD_SEND (abfd, _bfd_find_nearest_line, \ |
(abfd, syms, sec, off, file, func, line, NULL)) |
(abfd, sec, syms, off, file, func, line)) |
#define bfd_find_nearest_line_discriminator(abfd, sec, syms, off, file, func, \ |
line, disc) \ |
BFD_SEND (abfd, _bfd_find_nearest_line, \ |
(abfd, syms, sec, off, file, func, line, disc)) |
BFD_SEND (abfd, _bfd_find_nearest_line_discriminator, \ |
(abfd, sec, syms, off, file, func, line, disc)) |
#define bfd_find_line(abfd, syms, sym, file, line) \ |
BFD_SEND (abfd, _bfd_find_line, \ |
6968,6 → 6387,9 |
#define bfd_link_hash_table_create(abfd) \ |
BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd)) |
#define bfd_link_hash_table_free(abfd, hash) \ |
BFD_SEND (abfd, _bfd_link_hash_table_free, (hash)) |
#define bfd_link_add_symbols(abfd, info) \ |
BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info)) |
7015,22 → 6437,6 |
char *bfd_demangle (bfd *, const char *, int); |
void bfd_update_compression_header |
(bfd *abfd, bfd_byte *contents, asection *sec); |
bfd_boolean bfd_check_compression_header |
(bfd *abfd, bfd_byte *contents, asection *sec, |
bfd_size_type *uncompressed_size); |
int bfd_get_compression_header_size (bfd *abfd, asection *sec); |
bfd_size_type bfd_convert_section_size |
(bfd *ibfd, asection *isec, bfd *obfd, bfd_size_type size); |
bfd_boolean bfd_convert_section_contents |
(bfd *ibfd, asection *isec, bfd *obfd, |
bfd_byte **ptr, bfd_size_type *ptr_size); |
/* Extracted from archive.c. */ |
symindex bfd_get_next_mapent |
(bfd *abfd, symindex previous, carsym **sym); |
7076,7 → 6482,6 |
enum bfd_flavour |
{ |
/* N.B. Update bfd_flavour_name if you change this. */ |
bfd_target_unknown_flavour, |
bfd_target_aout_flavour, |
bfd_target_coff_flavour, |
7294,12 → 6699,12 |
NAME##_make_empty_symbol, \ |
NAME##_print_symbol, \ |
NAME##_get_symbol_info, \ |
NAME##_get_symbol_version_string, \ |
NAME##_bfd_is_local_label_name, \ |
NAME##_bfd_is_target_special_symbol, \ |
NAME##_get_lineno, \ |
NAME##_find_nearest_line, \ |
NAME##_find_line, \ |
_bfd_generic_find_nearest_line_discriminator, \ |
_bfd_generic_find_line, \ |
NAME##_find_inliner_info, \ |
NAME##_bfd_make_debug_symbol, \ |
NAME##_read_minisymbols, \ |
7316,14 → 6721,14 |
void (*_bfd_get_symbol_info) |
(bfd *, struct bfd_symbol *, symbol_info *); |
#define bfd_get_symbol_info(b,p,e) BFD_SEND (b, _bfd_get_symbol_info, (b,p,e)) |
const char *(*_bfd_get_symbol_version_string) |
(bfd *, struct bfd_symbol *, bfd_boolean *); |
#define bfd_get_symbol_version_string(b,s,h) BFD_SEND (b, _bfd_get_symbol_version_string, (b,s,h)) |
bfd_boolean (*_bfd_is_local_label_name) (bfd *, const char *); |
bfd_boolean (*_bfd_is_target_special_symbol) (bfd *, asymbol *); |
alent * (*_get_lineno) (bfd *, struct bfd_symbol *); |
bfd_boolean (*_bfd_find_nearest_line) |
(bfd *, struct bfd_symbol **, struct bfd_section *, bfd_vma, |
(bfd *, struct bfd_section *, struct bfd_symbol **, bfd_vma, |
const char **, const char **, unsigned int *); |
bfd_boolean (*_bfd_find_nearest_line_discriminator) |
(bfd *, struct bfd_section *, struct bfd_symbol **, bfd_vma, |
const char **, const char **, unsigned int *, unsigned int *); |
bfd_boolean (*_bfd_find_line) |
(bfd *, struct bfd_symbol **, struct bfd_symbol *, |
7377,6 → 6782,7 |
NAME##_bfd_get_relocated_section_contents, \ |
NAME##_bfd_relax_section, \ |
NAME##_bfd_link_hash_table_create, \ |
NAME##_bfd_link_hash_table_free, \ |
NAME##_bfd_link_add_symbols, \ |
NAME##_bfd_link_just_syms, \ |
NAME##_bfd_copy_link_hash_symbol_type, \ |
7403,6 → 6809,9 |
struct bfd_link_hash_table * |
(*_bfd_link_hash_table_create) (bfd *); |
/* Release the memory associated with the linker hash table. */ |
void (*_bfd_link_hash_table_free) (struct bfd_link_hash_table *); |
/* Add symbols from this object file into the hash table. */ |
bfd_boolean (*_bfd_link_add_symbols) (bfd *, struct bfd_link_info *); |
7409,8 → 6818,7 |
/* Indicate that we are only retrieving symbol values from this section. */ |
void (*_bfd_link_just_syms) (asection *, struct bfd_link_info *); |
/* Copy the symbol type and other attributes for a linker script |
assignment of one symbol to another. */ |
/* Copy the symbol type of a linker hash table entry. */ |
#define bfd_copy_link_hash_symbol_type(b, t, f) \ |
BFD_SEND (b, _bfd_copy_link_hash_symbol_type, (b, t, f)) |
void (*_bfd_copy_link_hash_symbol_type) |
7496,8 → 6904,6 |
(int (*search_func) (const bfd_target *, void *), |
void *); |
const char *bfd_flavour_name (enum bfd_flavour flavour); |
/* Extracted from format.c. */ |
bfd_boolean bfd_check_format (bfd *abfd, bfd_format format); |
7540,6 → 6946,10 |
(bfd *abfd, asection *sec, bfd_byte *outbuf, asymbol **symbol_table); |
/* Extracted from compress.c. */ |
bfd_boolean bfd_compress_section_contents |
(bfd *abfd, asection *section, bfd_byte *uncompressed_buffer, |
bfd_size_type uncompressed_size); |
bfd_boolean bfd_get_full_section_contents |
(bfd *abfd, asection *section, bfd_byte **ptr); |
7546,11 → 6956,6 |
void bfd_cache_section_contents |
(asection *sec, void *contents); |
bfd_boolean bfd_is_section_compressed_with_header |
(bfd *abfd, asection *section, |
int *compression_header_size_p, |
bfd_size_type *uncompressed_size_p); |
bfd_boolean bfd_is_section_compressed |
(bfd *abfd, asection *section); |
7560,9 → 6965,6 |
bfd_boolean bfd_init_section_compress_status |
(bfd *abfd, asection *section); |
bfd_boolean bfd_compress_section |
(bfd *abfd, asection *section, bfd_byte *uncompressed_buffer); |
#ifdef __cplusplus |
} |
#endif |
/contrib/toolchain/binutils/bfd/bfd.c |
---|
1,5 → 1,5 |
/* Generic BFD library interface and support routines. |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990-2013 Free Software Foundation, Inc. |
Written by Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
44,21 → 44,11 |
. both_direction = 3 |
. }; |
. |
.enum bfd_plugin_format |
.struct bfd |
. { |
. bfd_plugin_uknown = 0, |
. bfd_plugin_yes = 1, |
. bfd_plugin_no = 2 |
. }; |
. {* A unique identifier of the BFD *} |
. unsigned int id; |
. |
.struct bfd_build_id |
. { |
. bfd_size_type size; |
. bfd_byte data[1]; |
. }; |
. |
.struct bfd |
.{ |
. {* The filename the application opened the BFD with. *} |
. const char *filename; |
. |
81,17 → 71,17 |
. {* File modified time, if mtime_set is TRUE. *} |
. long mtime; |
. |
. {* A unique identifier of the BFD *} |
. unsigned int id; |
. {* Reserved for an unimplemented file locking extension. *} |
. int ifd; |
. |
. {* The format which belongs to the BFD. (object, core, etc.) *} |
. ENUM_BITFIELD (bfd_format) format : 3; |
. bfd_format format; |
. |
. {* The direction with which the BFD was opened. *} |
. ENUM_BITFIELD (bfd_direction) direction : 2; |
. enum bfd_direction direction; |
. |
. {* Format_specific flags. *} |
. flagword flags : 18; |
. flagword flags; |
. |
. {* Values that may appear in the flags field of a BFD. These also |
. appear in the object_flags field of the bfd_target structure, where |
150,87 → 140,36 |
. struct. *} |
.#define BFD_IN_MEMORY 0x800 |
. |
. {* The sections in this BFD specify a memory page. *} |
.#define HAS_LOAD_PAGE 0x1000 |
. |
. {* This BFD has been created by the linker and doesn't correspond |
. to any input file. *} |
.#define BFD_LINKER_CREATED 0x1000 |
.#define BFD_LINKER_CREATED 0x2000 |
. |
. {* This may be set before writing out a BFD to request that it |
. be written using values for UIDs, GIDs, timestamps, etc. that |
. will be consistent from run to run. *} |
.#define BFD_DETERMINISTIC_OUTPUT 0x2000 |
.#define BFD_DETERMINISTIC_OUTPUT 0x4000 |
. |
. {* Compress sections in this BFD. *} |
.#define BFD_COMPRESS 0x4000 |
.#define BFD_COMPRESS 0x8000 |
. |
. {* Decompress sections in this BFD. *} |
.#define BFD_DECOMPRESS 0x8000 |
.#define BFD_DECOMPRESS 0x10000 |
. |
. {* BFD is a dummy, for plugins. *} |
.#define BFD_PLUGIN 0x10000 |
.#define BFD_PLUGIN 0x20000 |
. |
. {* Compress sections in this BFD with SHF_COMPRESSED from gABI. *} |
.#define BFD_COMPRESS_GABI 0x20000 |
. |
. {* Flags bits to be saved in bfd_preserve_save. *} |
.#define BFD_FLAGS_SAVED \ |
. (BFD_IN_MEMORY | BFD_COMPRESS | BFD_DECOMPRESS | BFD_PLUGIN \ |
. | BFD_COMPRESS_GABI) |
. (BFD_IN_MEMORY | BFD_COMPRESS | BFD_DECOMPRESS | BFD_PLUGIN) |
. |
. {* Flags bits which are for BFD use only. *} |
.#define BFD_FLAGS_FOR_BFD_USE_MASK \ |
. (BFD_IN_MEMORY | BFD_COMPRESS | BFD_DECOMPRESS | BFD_LINKER_CREATED \ |
. | BFD_PLUGIN | BFD_TRADITIONAL_FORMAT | BFD_DETERMINISTIC_OUTPUT \ |
. | BFD_COMPRESS_GABI) |
. | BFD_PLUGIN | BFD_TRADITIONAL_FORMAT | BFD_DETERMINISTIC_OUTPUT) |
. |
. {* Is the file descriptor being cached? That is, can it be closed as |
. needed, and re-opened when accessed later? *} |
. unsigned int cacheable : 1; |
. |
. {* Marks whether there was a default target specified when the |
. BFD was opened. This is used to select which matching algorithm |
. to use to choose the back end. *} |
. unsigned int target_defaulted : 1; |
. |
. {* ... and here: (``once'' means at least once). *} |
. unsigned int opened_once : 1; |
. |
. {* Set if we have a locally maintained mtime value, rather than |
. getting it from the file each time. *} |
. unsigned int mtime_set : 1; |
. |
. {* Flag set if symbols from this BFD should not be exported. *} |
. unsigned int no_export : 1; |
. |
. {* Remember when output has begun, to stop strange things |
. from happening. *} |
. unsigned int output_has_begun : 1; |
. |
. {* Have archive map. *} |
. unsigned int has_armap : 1; |
. |
. {* Set if this is a thin archive. *} |
. unsigned int is_thin_archive : 1; |
. |
. {* Set if only required symbols should be added in the link hash table for |
. this object. Used by VMS linkers. *} |
. unsigned int selective_search : 1; |
. |
. {* Set if this is the linker output BFD. *} |
. unsigned int is_linker_output : 1; |
. |
. {* Set if this is the linker input BFD. *} |
. unsigned int is_linker_input : 1; |
. |
. {* If this is an input for a compiler plug-in library. *} |
. ENUM_BITFIELD (bfd_plugin_format) plugin_format : 2; |
. |
. {* Set if this is a plugin output file. *} |
. unsigned int lto_output : 1; |
. |
. {* Set to dummy BFD created when claimed by a compiler plug-in |
. library. *} |
. bfd *plugin_dummy_bfd; |
. |
. {* Currently my_archive is tested before adding origin to |
. anything. I believe that this can become always an add of |
. origin, with origin set to 0 for non archive files. *} |
255,21 → 194,17 |
. {* The number of sections. *} |
. unsigned int section_count; |
. |
. {* A field used by _bfd_generic_link_add_archive_symbols. This will |
. be used only for archive elements. *} |
. int archive_pass; |
. |
. {* Stuff only useful for object files: |
. The start address. *} |
. bfd_vma start_address; |
. |
. {* Used for input and output. *} |
. unsigned int symcount; |
. |
. {* Symbol table for output BFD (with symcount entries). |
. Also used by the linker to cache input BFD symbols. *} |
. struct bfd_symbol **outsymbols; |
. |
. {* Used for input and output. *} |
. unsigned int symcount; |
. |
. {* Used for slurped dynamic symbol tables. *} |
. unsigned int dynsymcount; |
. |
284,13 → 219,13 |
. struct bfd *nested_archives; {* List of nested archive in a flattened |
. thin archive. *} |
. |
. union { |
. {* For input BFDs, a chain of BFDs involved in a link. *} |
. struct bfd *next; |
. {* For output BFD, the linker hash table. *} |
. struct bfd_link_hash_table *hash; |
. } link; |
. {* A chain of BFD structures involved in a link. *} |
. struct bfd *link_next; |
. |
. {* A field used by _bfd_generic_link_add_archive_symbols. This will |
. be used only for archive elements. *} |
. int archive_pass; |
. |
. {* Used by the back end to hold private data. *} |
. union |
. { |
342,18 → 277,40 |
. of objalloc.h. *} |
. void *memory; |
. |
. {* For input BFDs, the build ID, if the object has one. *} |
. const struct bfd_build_id *build_id; |
. {* Is the file descriptor being cached? That is, can it be closed as |
. needed, and re-opened when accessed later? *} |
. unsigned int cacheable : 1; |
. |
. {* Marks whether there was a default target specified when the |
. BFD was opened. This is used to select which matching algorithm |
. to use to choose the back end. *} |
. unsigned int target_defaulted : 1; |
. |
. {* ... and here: (``once'' means at least once). *} |
. unsigned int opened_once : 1; |
. |
. {* Set if we have a locally maintained mtime value, rather than |
. getting it from the file each time. *} |
. unsigned int mtime_set : 1; |
. |
. {* Flag set if symbols from this BFD should not be exported. *} |
. unsigned int no_export : 1; |
. |
. {* Remember when output has begun, to stop strange things |
. from happening. *} |
. unsigned int output_has_begun : 1; |
. |
. {* Have archive map. *} |
. unsigned int has_armap : 1; |
. |
. {* Set if this is a thin archive. *} |
. unsigned int is_thin_archive : 1; |
. |
. {* Set if only required symbols should be added in the link hash table for |
. this object. Used by VMS linkers. *} |
. unsigned int selective_search : 1; |
.}; |
. |
.{* See note beside bfd_set_section_userdata. *} |
.static inline bfd_boolean |
.bfd_set_cacheable (bfd * abfd, bfd_boolean val) |
.{ |
. abfd->cacheable = val; |
. return TRUE; |
.} |
. |
*/ |
#include "sysdep.h" |
1090,11 → 1047,11 |
{ |
if (fn != NULL) |
(*_bfd_error_handler) |
(_("BFD %s internal error, aborting at %s:%d in %s\n"), |
(_("BFD %s internal error, aborting at %s line %d in %s\n"), |
BFD_VERSION_STRING, file, line, fn); |
else |
(*_bfd_error_handler) |
(_("BFD %s internal error, aborting at %s:%d\n"), |
(_("BFD %s internal error, aborting at %s line %d\n"), |
BFD_VERSION_STRING, file, line); |
(*_bfd_error_handler) (_("Please report this bug.\n")); |
_exit (EXIT_FAILURE); |
1108,11 → 1065,9 |
int bfd_get_arch_size (bfd *abfd); |
DESCRIPTION |
Returns the normalized architecture address size, in bits, as |
determined by the object file's format. By normalized, we mean |
either 32 or 64. For ELF, this information is included in the |
header. Use bfd_arch_bits_per_address for number of bits in |
the architecture address. |
Returns the architecture address size, in bits, as determined |
by the object file's format. For ELF, this information is |
included in the header. |
RETURNS |
Returns the arch size in bits if known, <<-1>> otherwise. |
1124,7 → 1079,7 |
if (abfd->xvec->flavour == bfd_target_elf_flavour) |
return get_elf_backend_data (abfd)->s->arch_size; |
return bfd_arch_bits_per_address (abfd) > 32 ? 64 : 32; |
return -1; |
} |
/* |
1478,12 → 1433,12 |
. |
.#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \ |
. BFD_SEND (abfd, _bfd_find_nearest_line, \ |
. (abfd, syms, sec, off, file, func, line, NULL)) |
. (abfd, sec, syms, off, file, func, line)) |
. |
.#define bfd_find_nearest_line_discriminator(abfd, sec, syms, off, file, func, \ |
. line, disc) \ |
. BFD_SEND (abfd, _bfd_find_nearest_line, \ |
. (abfd, syms, sec, off, file, func, line, disc)) |
. BFD_SEND (abfd, _bfd_find_nearest_line_discriminator, \ |
. (abfd, sec, syms, off, file, func, line, disc)) |
. |
.#define bfd_find_line(abfd, syms, sym, file, line) \ |
. BFD_SEND (abfd, _bfd_find_line, \ |
1532,6 → 1487,9 |
.#define bfd_link_hash_table_create(abfd) \ |
. BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd)) |
. |
.#define bfd_link_hash_table_free(abfd, hash) \ |
. BFD_SEND (abfd, _bfd_link_hash_table_free, (hash)) |
. |
.#define bfd_link_add_symbols(abfd, info) \ |
. BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info)) |
. |
1957,316 → 1915,3 |
return res; |
} |
/* |
FUNCTION |
bfd_update_compression_header |
SYNOPSIS |
void bfd_update_compression_header |
(bfd *abfd, bfd_byte *contents, asection *sec); |
DESCRIPTION |
Set the compression header at CONTENTS of SEC in ABFD and update |
elf_section_flags for compression. |
*/ |
void |
bfd_update_compression_header (bfd *abfd, bfd_byte *contents, |
asection *sec) |
{ |
if ((abfd->flags & BFD_COMPRESS) != 0) |
{ |
if (bfd_get_flavour (abfd) == bfd_target_elf_flavour) |
{ |
if ((abfd->flags & BFD_COMPRESS_GABI) != 0) |
{ |
const struct elf_backend_data *bed |
= get_elf_backend_data (abfd); |
/* Set the SHF_COMPRESSED bit. */ |
elf_section_flags (sec) |= SHF_COMPRESSED; |
if (bed->s->elfclass == ELFCLASS32) |
{ |
Elf32_External_Chdr *echdr |
= (Elf32_External_Chdr *) contents; |
bfd_put_32 (abfd, ELFCOMPRESS_ZLIB, &echdr->ch_type); |
bfd_put_32 (abfd, sec->size, &echdr->ch_size); |
bfd_put_32 (abfd, 1 << sec->alignment_power, |
&echdr->ch_addralign); |
} |
else |
{ |
Elf64_External_Chdr *echdr |
= (Elf64_External_Chdr *) contents; |
bfd_put_32 (abfd, ELFCOMPRESS_ZLIB, &echdr->ch_type); |
bfd_put_32 (abfd, 0, &echdr->ch_reserved); |
bfd_put_64 (abfd, sec->size, &echdr->ch_size); |
bfd_put_64 (abfd, 1 << sec->alignment_power, |
&echdr->ch_addralign); |
} |
} |
else |
{ |
/* Clear the SHF_COMPRESSED bit. */ |
elf_section_flags (sec) &= ~SHF_COMPRESSED; |
/* Write the zlib header. It should be "ZLIB" followed by |
the uncompressed section size, 8 bytes in big-endian |
order. */ |
memcpy (contents, "ZLIB", 4); |
bfd_putb64 (sec->size, contents + 4); |
} |
} |
} |
else |
abort (); |
} |
/* |
FUNCTION |
bfd_check_compression_header |
SYNOPSIS |
bfd_boolean bfd_check_compression_header |
(bfd *abfd, bfd_byte *contents, asection *sec, |
bfd_size_type *uncompressed_size); |
DESCRIPTION |
Check the compression header at CONTENTS of SEC in ABFD and |
store the uncompressed size in UNCOMPRESSED_SIZE if the |
compression header is valid. |
RETURNS |
Return TRUE if the compression header is valid. |
*/ |
bfd_boolean |
bfd_check_compression_header (bfd *abfd, bfd_byte *contents, |
asection *sec, |
bfd_size_type *uncompressed_size) |
{ |
if (bfd_get_flavour (abfd) == bfd_target_elf_flavour |
&& (elf_section_flags (sec) & SHF_COMPRESSED) != 0) |
{ |
Elf_Internal_Chdr chdr; |
const struct elf_backend_data *bed = get_elf_backend_data (abfd); |
if (bed->s->elfclass == ELFCLASS32) |
{ |
Elf32_External_Chdr *echdr = (Elf32_External_Chdr *) contents; |
chdr.ch_type = bfd_get_32 (abfd, &echdr->ch_type); |
chdr.ch_size = bfd_get_32 (abfd, &echdr->ch_size); |
chdr.ch_addralign = bfd_get_32 (abfd, &echdr->ch_addralign); |
} |
else |
{ |
Elf64_External_Chdr *echdr = (Elf64_External_Chdr *) contents; |
chdr.ch_type = bfd_get_32 (abfd, &echdr->ch_type); |
chdr.ch_size = bfd_get_64 (abfd, &echdr->ch_size); |
chdr.ch_addralign = bfd_get_64 (abfd, &echdr->ch_addralign); |
} |
if (chdr.ch_type == ELFCOMPRESS_ZLIB |
&& chdr.ch_addralign == 1U << sec->alignment_power) |
{ |
*uncompressed_size = chdr.ch_size; |
return TRUE; |
} |
} |
return FALSE; |
} |
/* |
FUNCTION |
bfd_get_compression_header_size |
SYNOPSIS |
int bfd_get_compression_header_size (bfd *abfd, asection *sec); |
DESCRIPTION |
Return the size of the compression header of SEC in ABFD. |
RETURNS |
Return the size of the compression header in bytes. |
*/ |
int |
bfd_get_compression_header_size (bfd *abfd, asection *sec) |
{ |
if (bfd_get_flavour (abfd) == bfd_target_elf_flavour) |
{ |
if (sec == NULL) |
{ |
if (!(abfd->flags & BFD_COMPRESS_GABI)) |
return 0; |
} |
else if (!(elf_section_flags (sec) & SHF_COMPRESSED)) |
return 0; |
if (get_elf_backend_data (abfd)->s->elfclass == ELFCLASS32) |
return sizeof (Elf32_External_Chdr); |
else |
return sizeof (Elf64_External_Chdr); |
} |
return 0; |
} |
/* |
FUNCTION |
bfd_convert_section_size |
SYNOPSIS |
bfd_size_type bfd_convert_section_size |
(bfd *ibfd, asection *isec, bfd *obfd, bfd_size_type size); |
DESCRIPTION |
Convert the size @var{size} of the section @var{isec} in input |
BFD @var{ibfd} to the section size in output BFD @var{obfd}. |
*/ |
bfd_size_type |
bfd_convert_section_size (bfd *ibfd, sec_ptr isec, bfd *obfd, |
bfd_size_type size) |
{ |
bfd_size_type hdr_size; |
/* Do nothing if input file will be decompressed. */ |
if ((ibfd->flags & BFD_DECOMPRESS)) |
return size; |
/* Do nothing if either input or output aren't ELF. */ |
if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour |
|| bfd_get_flavour (obfd) != bfd_target_elf_flavour) |
return size; |
/* Do nothing if ELF classes of input and output are the same. */ |
if (get_elf_backend_data (ibfd)->s->elfclass |
== get_elf_backend_data (obfd)->s->elfclass) |
return size; |
/* Do nothing if the input section isn't a SHF_COMPRESSED section. */ |
hdr_size = bfd_get_compression_header_size (ibfd, isec); |
if (hdr_size == 0) |
return size; |
/* Adjust the size of the output SHF_COMPRESSED section. */ |
if (hdr_size == sizeof (Elf32_External_Chdr)) |
return (size - sizeof (Elf32_External_Chdr) |
+ sizeof (Elf64_External_Chdr)); |
else |
return (size - sizeof (Elf64_External_Chdr) |
+ sizeof (Elf32_External_Chdr)); |
} |
/* |
FUNCTION |
bfd_convert_section_contents |
SYNOPSIS |
bfd_boolean bfd_convert_section_contents |
(bfd *ibfd, asection *isec, bfd *obfd, |
bfd_byte **ptr, bfd_size_type *ptr_size); |
DESCRIPTION |
Convert the contents, stored in @var{*ptr}, of the section |
@var{isec} in input BFD @var{ibfd} to output BFD @var{obfd} |
if needed. The original buffer pointed to by @var{*ptr} may |
be freed and @var{*ptr} is returned with memory malloc'd by this |
function, and the new size written to @var{ptr_size}. |
*/ |
bfd_boolean |
bfd_convert_section_contents (bfd *ibfd, sec_ptr isec, bfd *obfd, |
bfd_byte **ptr, bfd_size_type *ptr_size) |
{ |
bfd_byte *contents; |
bfd_size_type ihdr_size, ohdr_size, size; |
Elf_Internal_Chdr chdr; |
bfd_boolean use_memmove; |
/* Do nothing if input file will be decompressed. */ |
if ((ibfd->flags & BFD_DECOMPRESS)) |
return TRUE; |
/* Do nothing if either input or output aren't ELF. */ |
if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour |
|| bfd_get_flavour (obfd) != bfd_target_elf_flavour) |
return TRUE; |
/* Do nothing if ELF classes of input and output are the same. */ |
if (get_elf_backend_data (ibfd)->s->elfclass |
== get_elf_backend_data (obfd)->s->elfclass) |
return TRUE; |
/* Do nothing if the input section isn't a SHF_COMPRESSED section. */ |
ihdr_size = bfd_get_compression_header_size (ibfd, isec); |
if (ihdr_size == 0) |
return TRUE; |
contents = *ptr; |
/* Convert the contents of the input SHF_COMPRESSED section to |
output. Get the input compression header and the size of the |
output compression header. */ |
if (ihdr_size == sizeof (Elf32_External_Chdr)) |
{ |
Elf32_External_Chdr *echdr = (Elf32_External_Chdr *) contents; |
chdr.ch_type = bfd_get_32 (ibfd, &echdr->ch_type); |
chdr.ch_size = bfd_get_32 (ibfd, &echdr->ch_size); |
chdr.ch_addralign = bfd_get_32 (ibfd, &echdr->ch_addralign); |
ohdr_size = sizeof (Elf64_External_Chdr); |
use_memmove = FALSE; |
} |
else |
{ |
Elf64_External_Chdr *echdr = (Elf64_External_Chdr *) contents; |
chdr.ch_type = bfd_get_32 (ibfd, &echdr->ch_type); |
chdr.ch_size = bfd_get_64 (ibfd, &echdr->ch_size); |
chdr.ch_addralign = bfd_get_64 (ibfd, &echdr->ch_addralign); |
ohdr_size = sizeof (Elf32_External_Chdr); |
use_memmove = TRUE; |
} |
size = bfd_get_section_size (isec) - ihdr_size + ohdr_size; |
if (!use_memmove) |
{ |
contents = (bfd_byte *) bfd_malloc (size); |
if (contents == NULL) |
return FALSE; |
} |
/* Write out the output compression header. */ |
if (ohdr_size == sizeof (Elf32_External_Chdr)) |
{ |
Elf32_External_Chdr *echdr = (Elf32_External_Chdr *) contents; |
bfd_put_32 (obfd, ELFCOMPRESS_ZLIB, &echdr->ch_type); |
bfd_put_32 (obfd, chdr.ch_size, &echdr->ch_size); |
bfd_put_32 (obfd, chdr.ch_addralign, &echdr->ch_addralign); |
} |
else |
{ |
Elf64_External_Chdr *echdr = (Elf64_External_Chdr *) contents; |
bfd_put_32 (obfd, ELFCOMPRESS_ZLIB, &echdr->ch_type); |
bfd_put_32 (obfd, 0, &echdr->ch_reserved); |
bfd_put_64 (obfd, chdr.ch_size, &echdr->ch_size); |
bfd_put_64 (obfd, chdr.ch_addralign, &echdr->ch_addralign); |
} |
/* Copy the compressed contents. */ |
if (use_memmove) |
memmove (contents + ohdr_size, *ptr + ihdr_size, size - ohdr_size); |
else |
{ |
memcpy (contents + ohdr_size, *ptr + ihdr_size, size - ohdr_size); |
free (*ptr); |
*ptr = contents; |
} |
*ptr_size = size; |
return TRUE; |
} |
/contrib/toolchain/binutils/bfd/bfd.h |
---|
7,7 → 7,7 |
/* Main header file for the bfd library -- portable access to object files. |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990-2013 Free Software Foundation, Inc. |
Contributed by Cygnus Support. |
279,7 → 279,7 |
/* Object and core file sections. */ |
#define align_power(addr, align) \ |
(((addr) + ((bfd_vma) 1 << (align)) - 1) & (-((bfd_vma) 1 << (align)))) |
(((addr) + ((bfd_vma) 1 << (align)) - 1) & ((bfd_vma) -1 << (align))) |
typedef struct bfd_section *sec_ptr; |
299,13 → 299,13 |
#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0) |
#define bfd_get_section_limit_octets(bfd, sec) \ |
((bfd)->direction != write_direction && (sec)->rawsize != 0 \ |
? (sec)->rawsize : (sec)->size) |
#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE) |
#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE) |
#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE) |
/* Find the address one past the end of SEC. */ |
#define bfd_get_section_limit(bfd, sec) \ |
(bfd_get_section_limit_octets(bfd, sec) / bfd_octets_per_byte (bfd)) |
(((bfd)->direction != write_direction && (sec)->rawsize != 0 \ |
? (sec)->rawsize : (sec)->size) / bfd_octets_per_byte (bfd)) |
/* Return TRUE if input section SEC has been discarded. */ |
#define discarded_section(sec) \ |
444,16 → 444,6 |
this size. */ |
extern unsigned long bfd_hash_set_default_size (unsigned long); |
/* Types of compressed DWARF debug sections. We currently support |
zlib. */ |
enum compressed_debug_section_type |
{ |
COMPRESS_DEBUG_NONE = 0, |
COMPRESS_DEBUG = 1 << 0, |
COMPRESS_DEBUG_GNU_ZLIB = COMPRESS_DEBUG | 1 << 1, |
COMPRESS_DEBUG_GABI_ZLIB = COMPRESS_DEBUG | 1 << 2 |
}; |
/* This structure is used to keep track of stabs in sections |
information while linking. */ |
534,6 → 524,8 |
#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char) |
#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE) |
extern bfd_boolean bfd_cache_close |
(bfd *abfd); |
/* NB: This declaration should match the autogenerated one in libbfd.h. */ |
678,7 → 670,7 |
(bfd *); |
extern struct bfd_link_needed_list *bfd_elf_get_runpath_list |
(bfd *, struct bfd_link_info *); |
extern int bfd_elf_discard_info |
extern bfd_boolean bfd_elf_discard_info |
(bfd *, struct bfd_link_info *); |
extern unsigned int _bfd_elf_default_action_discarded |
(struct bfd_section *); |
700,21 → 692,19 |
(bfd *abfd, void *phdrs); |
/* Create a new BFD as if by bfd_openr. Rather than opening a file, |
reconstruct an ELF file by reading the segments out of remote |
memory based on the ELF file header at EHDR_VMA and the ELF program |
headers it points to. If non-zero, SIZE is the known extent of the |
object. If not null, *LOADBASEP is filled in with the difference |
between the VMAs from which the segments were read, and the VMAs |
the file headers (and hence BFD's idea of each section's VMA) put |
them at. |
reconstruct an ELF file by reading the segments out of remote memory |
based on the ELF file header at EHDR_VMA and the ELF program headers it |
points to. If not null, *LOADBASEP is filled in with the difference |
between the VMAs from which the segments were read, and the VMAs the |
file headers (and hence BFD's idea of each section's VMA) put them at. |
The function TARGET_READ_MEMORY is called to copy LEN bytes from |
the remote memory at target address VMA into the local buffer at |
MYADDR; it should return zero on success or an `errno' code on |
failure. TEMPL must be a BFD for a target with the word size and |
byte order found in the remote memory. */ |
The function TARGET_READ_MEMORY is called to copy LEN bytes from the |
remote memory at target address VMA into the local buffer at MYADDR; it |
should return zero on success or an `errno' code on failure. TEMPL must |
be a BFD for an ELF target with the word size and byte order found in |
the remote memory. */ |
extern bfd *bfd_elf_bfd_from_remote_memory |
(bfd *templ, bfd_vma ehdr_vma, bfd_size_type size, bfd_vma *loadbasep, |
(bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep, |
int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr, |
bfd_size_type len)); |
826,6 → 816,12 |
union internal_auxent; |
#endif |
extern bfd_boolean bfd_coff_get_syment |
(bfd *, struct bfd_symbol *, struct internal_syment *); |
extern bfd_boolean bfd_coff_get_auxent |
(bfd *, struct bfd_symbol *, int, union internal_auxent *); |
extern bfd_boolean bfd_coff_set_symbol_class |
(bfd *, struct bfd_symbol *, unsigned int); |
856,23 → 852,6 |
extern void bfd_elf32_arm_vfp11_fix_veneer_locations |
(bfd *, struct bfd_link_info *); |
/* ARM STM STM32L4XX erratum workaround support. */ |
typedef enum |
{ |
BFD_ARM_STM32L4XX_FIX_NONE, |
BFD_ARM_STM32L4XX_FIX_DEFAULT, |
BFD_ARM_STM32L4XX_FIX_ALL |
} bfd_arm_stm32l4xx_fix; |
extern void bfd_elf32_arm_set_stm32l4xx_fix |
(bfd *, struct bfd_link_info *); |
extern bfd_boolean bfd_elf32_arm_stm32l4xx_erratum_scan |
(bfd *, struct bfd_link_info *); |
extern void bfd_elf32_arm_stm32l4xx_fix_veneer_locations |
(bfd *, struct bfd_link_info *); |
/* ARM Interworking support. Called from linker. */ |
extern bfd_boolean bfd_arm_allocate_interworking_sections |
(struct bfd_link_info *); |
902,7 → 881,7 |
void bfd_elf32_arm_set_target_relocs |
(bfd *, struct bfd_link_info *, int, char *, int, int, bfd_arm_vfp11_fix, |
bfd_arm_stm32l4xx_fix, int, int, int, int, int); |
int, int, int, int, int); |
extern bfd_boolean bfd_elf32_arm_get_bfd_for_interworking |
(bfd *, struct bfd_link_info *); |
910,20 → 889,16 |
extern bfd_boolean bfd_elf32_arm_add_glue_sections_to_bfd |
(bfd *, struct bfd_link_info *); |
/* ELF ARM mapping symbol support. */ |
/* ELF ARM mapping symbol support */ |
#define BFD_ARM_SPECIAL_SYM_TYPE_MAP (1 << 0) |
#define BFD_ARM_SPECIAL_SYM_TYPE_TAG (1 << 1) |
#define BFD_ARM_SPECIAL_SYM_TYPE_OTHER (1 << 2) |
#define BFD_ARM_SPECIAL_SYM_TYPE_ANY (~0) |
extern bfd_boolean bfd_is_arm_special_symbol_name |
(const char *, int); |
(const char * name, int type); |
extern void bfd_elf32_arm_set_byteswap_code |
(struct bfd_link_info *, int); |
extern void bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *, int); |
extern void bfd_elf32_arm_use_long_plt (void); |
/* ARM Note section processing. */ |
extern bfd_boolean bfd_arm_merge_machines |
(bfd *, bfd *); |
968,10 → 943,10 |
(bfd *); |
extern void bfd_elf64_aarch64_set_options |
(bfd *, struct bfd_link_info *, int, int, int, int, int); |
(bfd *, struct bfd_link_info *, int, int, int); |
extern void bfd_elf32_aarch64_set_options |
(bfd *, struct bfd_link_info *, int, int, int, int, int); |
(bfd *, struct bfd_link_info *, int, int, int); |
/* ELF AArch64 mapping symbol support. */ |
#define BFD_AARCH64_SPECIAL_SYM_TYPE_MAP (1 << 0) |
1023,17 → 998,29 |
extern void bfd_elf64_ia64_after_parse |
(int); |
/* V850 Note manipulation routines. */ |
extern bfd_boolean v850_elf_create_sections |
(struct bfd_link_info *); |
/* This structure is used for a comdat section, as in PE. A comdat |
section is associated with a particular symbol. When the linker |
sees a comdat section, it keeps only one of the sections with a |
given name and associated with a given symbol. */ |
extern bfd_boolean v850_elf_set_note |
(bfd *, unsigned int, unsigned int); |
struct coff_comdat_info |
{ |
/* The name of the symbol associated with a comdat section. */ |
const char *name; |
/* The local symbol table index of the symbol associated with a |
comdat section. This is only meaningful to the object file format |
specific code; it is not an index into the list returned by |
bfd_canonicalize_symtab. */ |
long symbol; |
}; |
extern struct coff_comdat_info * bfd_coff_get_comdat_section |
(bfd *, struct bfd_section *); |
/* Extracted from init.c. */ |
void bfd_init (void); |
/* Extracted from opncls.c. */ |
/* Set to N to open the next N BFDs using an alternate id space. */ |
extern unsigned int bfd_use_reserved_id; |
bfd *bfd_fopen (const char *filename, const char *target, |
const char *mode, int fd); |
1042,7 → 1029,7 |
bfd *bfd_fdopenr (const char *filename, const char *target, int fd); |
bfd *bfd_openstreamr (const char * filename, const char * target, void * stream); |
bfd *bfd_openstreamr (const char *, const char *, void *); |
bfd *bfd_openr_iovec (const char *filename, const char *target, |
void *(*open_func) (struct bfd *nbfd, |
1080,9 → 1067,7 |
char *bfd_get_debug_link_info (bfd *abfd, unsigned long *crc32_out); |
char *bfd_get_alt_debug_link_info (bfd * abfd, |
bfd_size_type *buildid_len, |
bfd_byte **buildid_out); |
char *bfd_get_alt_debug_link_info (bfd *abfd, unsigned long *crc32_out); |
char *bfd_follow_gnu_debuglink (bfd *abfd, const char *dir); |
1218,7 → 1203,6 |
/* Extracted from bfdwin.c. */ |
/* Extracted from section.c. */ |
typedef struct bfd_section |
{ |
/* The name of the section; the name isn't a copy, the pointer is |
1226,10 → 1210,10 |
const char *name; |
/* A unique sequence number. */ |
unsigned int id; |
int id; |
/* Which section in the bfd; 0..n-1 as sections are created in a bfd. */ |
unsigned int index; |
int index; |
/* The next section in the list belonging to the BFD, or NULL. */ |
struct bfd_section *next; |
1405,10 → 1389,6 |
executables or shared objects. This is for COFF only. */ |
#define SEC_COFF_SHARED 0x8000000 |
/* This section should be compressed. This is for ELF linker |
internal use only. */ |
#define SEC_ELF_COMPRESS 0x8000000 |
/* When a section with this flag is being linked, then if the size of |
the input section is less than a page, it should not cross a page |
boundary. If the size of the input section is one page or more, |
1416,18 → 1396,11 |
TMS320C54X only. */ |
#define SEC_TIC54X_BLOCK 0x10000000 |
/* This section should be renamed. This is for ELF linker |
internal use only. */ |
#define SEC_ELF_RENAME 0x10000000 |
/* Conditionally link this section; do not link if there are no |
references found to any symbol in the section. This is for TI |
TMS320C54X only. */ |
#define SEC_TIC54X_CLINK 0x20000000 |
/* This section contains vliw code. This is for Toshiba MeP only. */ |
#define SEC_MEP_VLIW 0x20000000 |
/* Indicate that section has the no read flag set. This happens |
when memory read flag isn't set. */ |
#define SEC_COFF_NOREAD 0x40000000 |
1467,8 → 1440,6 |
#define SEC_INFO_TYPE_MERGE 2 |
#define SEC_INFO_TYPE_EH_FRAME 3 |
#define SEC_INFO_TYPE_JUST_SYMS 4 |
#define SEC_INFO_TYPE_TARGET 5 |
#define SEC_INFO_TYPE_EH_FRAME_ENTRY 6 |
/* Nonzero if this section uses RELA relocations, rather than REL. */ |
unsigned int use_rela_p:1; |
1623,32 → 1594,6 |
int size; |
}; |
/* Note: the following are provided as inline functions rather than macros |
because not all callers use the return value. A macro implementation |
would use a comma expression, eg: "((ptr)->foo = val, TRUE)" and some |
compilers will complain about comma expressions that have no effect. */ |
static inline bfd_boolean |
bfd_set_section_userdata (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, void * val) |
{ |
ptr->userdata = val; |
return TRUE; |
} |
static inline bfd_boolean |
bfd_set_section_vma (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, bfd_vma val) |
{ |
ptr->vma = ptr->lma = val; |
ptr->user_set_vma = TRUE; |
return TRUE; |
} |
static inline bfd_boolean |
bfd_set_section_alignment (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, unsigned int val) |
{ |
ptr->alignment_power = val; |
return TRUE; |
} |
/* These sections are global, and are managed by BFD. The application |
and target back end are not permitted to change the values in |
these sections. */ |
1810,7 → 1755,7 |
asection *bfd_get_section_by_name (bfd *abfd, const char *name); |
asection *bfd_get_next_section_by_name (bfd *ibfd, asection *sec); |
asection *bfd_get_next_section_by_name (asection *sec); |
asection *bfd_get_linker_section (bfd *abfd, const char *name); |
1835,8 → 1780,6 |
asection *bfd_make_section (bfd *, const char *name); |
int bfd_get_next_section_id (void); |
bfd_boolean bfd_set_section_flags |
(bfd *abfd, asection *sec, flagword flags); |
1933,9 → 1876,7 |
#define bfd_mach_i960_jx 7 |
#define bfd_mach_i960_hx 8 |
bfd_arch_or1k, /* OpenRISC 1000 */ |
#define bfd_mach_or1k 1 |
#define bfd_mach_or1knd 2 |
bfd_arch_or32, /* OpenRISC 32 */ |
bfd_arch_sparc, /* SPARC */ |
#define bfd_mach_sparc 1 |
1991,18 → 1932,11 |
#define bfd_mach_mips_octeon 6501 |
#define bfd_mach_mips_octeonp 6601 |
#define bfd_mach_mips_octeon2 6502 |
#define bfd_mach_mips_octeon3 6503 |
#define bfd_mach_mips_xlr 887682 /* decimal 'XLR' */ |
#define bfd_mach_mipsisa32 32 |
#define bfd_mach_mipsisa32r2 33 |
#define bfd_mach_mipsisa32r3 34 |
#define bfd_mach_mipsisa32r5 36 |
#define bfd_mach_mipsisa32r6 37 |
#define bfd_mach_mipsisa64 64 |
#define bfd_mach_mipsisa64r2 65 |
#define bfd_mach_mipsisa64r3 66 |
#define bfd_mach_mipsisa64r5 68 |
#define bfd_mach_mipsisa64r6 69 |
#define bfd_mach_mips_micromips 96 |
bfd_arch_i386, /* Intel 386 */ |
#define bfd_mach_i386_intel_syntax (1 << 0) |
2023,10 → 1957,6 |
#define bfd_mach_i386_i386_nacl (bfd_mach_i386_i386 | bfd_mach_i386_nacl) |
#define bfd_mach_x86_64_nacl (bfd_mach_x86_64 | bfd_mach_i386_nacl) |
#define bfd_mach_x64_32_nacl (bfd_mach_x64_32 | bfd_mach_i386_nacl) |
bfd_arch_iamcu, /* Intel MCU */ |
#define bfd_mach_iamcu (1 << 8) |
#define bfd_mach_i386_iamcu (bfd_mach_i386_i386 | bfd_mach_iamcu) |
#define bfd_mach_i386_iamcu_intel_syntax (bfd_mach_i386_iamcu | bfd_mach_i386_intel_syntax) |
bfd_arch_we32k, /* AT&T WE32xxx */ |
bfd_arch_tahoe, /* CCI/Harris Tahoe */ |
bfd_arch_i860, /* Intel 860 */ |
2141,12 → 2071,6 |
#define bfd_mach_arm_ep9312 11 |
#define bfd_mach_arm_iWMMXt 12 |
#define bfd_mach_arm_iWMMXt2 13 |
bfd_arch_nds32, /* Andes NDS32 */ |
#define bfd_mach_n1 1 |
#define bfd_mach_n1h 2 |
#define bfd_mach_n1h_v2 3 |
#define bfd_mach_n1h_v3 4 |
#define bfd_mach_n1h_v3m 5 |
bfd_arch_ns32k, /* National Semiconductors ns32000 */ |
bfd_arch_w65, /* WDC 65816 */ |
bfd_arch_tic30, /* Texas Instruments TMS320C30 */ |
2165,12 → 2089,10 |
#define bfd_mach_v850e2v3 0x45325633 |
#define bfd_mach_v850e3v5 0x45335635 /* ('E'|'3'|'V'|'5') */ |
bfd_arch_arc, /* ARC Cores */ |
#define bfd_mach_arc_a4 0 |
#define bfd_mach_arc_a5 1 |
#define bfd_mach_arc_arc600 2 |
#define bfd_mach_arc_arc601 4 |
#define bfd_mach_arc_arc700 3 |
#define bfd_mach_arc_arcv2 5 |
#define bfd_mach_arc_5 5 |
#define bfd_mach_arc_6 6 |
#define bfd_mach_arc_7 7 |
#define bfd_mach_arc_8 8 |
bfd_arch_m32c, /* Renesas M16C/M32C. */ |
#define bfd_mach_m16c 0x75 |
#define bfd_mach_m32c 0x78 |
2196,8 → 2118,6 |
#define bfd_mach_fr550 550 |
bfd_arch_moxie, /* The moxie processor */ |
#define bfd_mach_moxie 1 |
bfd_arch_ft32, /* The ft32 processor */ |
#define bfd_mach_ft32 1 |
bfd_arch_mcore, |
bfd_arch_mep, |
#define bfd_mach_mep 1 |
2233,7 → 2153,6 |
#define bfd_mach_avr5 5 |
#define bfd_mach_avr51 51 |
#define bfd_mach_avr6 6 |
#define bfd_mach_avrtiny 100 |
#define bfd_mach_avrxmega1 101 |
#define bfd_mach_avrxmega2 102 |
#define bfd_mach_avrxmega3 103 |
2263,6 → 2182,7 |
bfd_arch_score, /* Sunplus score */ |
#define bfd_mach_score3 3 |
#define bfd_mach_score7 7 |
bfd_arch_openrisc, /* OpenRISC */ |
bfd_arch_mmix, /* Donald Knuth's educational processor. */ |
bfd_arch_xstormy16, |
#define bfd_mach_xstormy16 1 |
2315,12 → 2235,8 |
bfd_arch_aarch64, /* AArch64 */ |
#define bfd_mach_aarch64 0 |
#define bfd_mach_aarch64_ilp32 32 |
bfd_arch_nios2, /* Nios II */ |
bfd_arch_nios2, |
#define bfd_mach_nios2 0 |
#define bfd_mach_nios2r1 1 |
#define bfd_mach_nios2r2 2 |
bfd_arch_visium, /* Visium */ |
#define bfd_mach_visium 1 |
bfd_arch_last |
}; |
2386,7 → 2302,6 |
(enum bfd_architecture arch, unsigned long machine); |
/* Extracted from reloc.c. */ |
typedef enum bfd_reloc_status |
{ |
/* No errors detected. */ |
2436,7 → 2351,6 |
} |
arelent; |
enum complain_overflow |
{ |
/* Do not complain on overflow. */ |
2455,7 → 2369,6 |
unsigned number. */ |
complain_overflow_unsigned |
}; |
struct bfd_symbol; /* Forward declaration. */ |
struct reloc_howto_struct |
{ |
2983,12 → 2896,6 |
BFD_RELOC_MICROMIPS_10_PCREL_S1, |
BFD_RELOC_MICROMIPS_16_PCREL_S1, |
/* MIPS PC-relative relocations. */ |
BFD_RELOC_MIPS_21_PCREL_S2, |
BFD_RELOC_MIPS_26_PCREL_S2, |
BFD_RELOC_MIPS_18_PCREL_S3, |
BFD_RELOC_MIPS_19_PCREL_S2, |
/* microMIPS versions of generic BFD relocs. */ |
BFD_RELOC_MICROMIPS_GPREL16, |
BFD_RELOC_MICROMIPS_HI16, |
3063,13 → 2970,6 |
BFD_RELOC_MOXIE_10_PCREL, |
/* FT32 ELF relocations. */ |
BFD_RELOC_FT32_10, |
BFD_RELOC_FT32_20, |
BFD_RELOC_FT32_17, |
BFD_RELOC_FT32_18, |
/* Fujitsu Frv Relocations. */ |
BFD_RELOC_FRV_LABEL16, |
BFD_RELOC_FRV_LABEL24, |
3194,7 → 3094,6 |
BFD_RELOC_386_TLS_DESC_CALL, |
BFD_RELOC_386_TLS_DESC, |
BFD_RELOC_386_IRELATIVE, |
BFD_RELOC_386_GOT32X, |
/* x86-64/elf relocations */ |
BFD_RELOC_X86_64_GOT32, |
3226,8 → 3125,6 |
BFD_RELOC_X86_64_IRELATIVE, |
BFD_RELOC_X86_64_PC32_BND, |
BFD_RELOC_X86_64_PLT32_BND, |
BFD_RELOC_X86_64_GOTPCRELX, |
BFD_RELOC_X86_64_REX_GOTPCRELX, |
/* ns32k relocations */ |
BFD_RELOC_NS32K_IMM_8, |
3303,7 → 3200,6 |
BFD_RELOC_PPC_VLE_SDAREL_HI16D, |
BFD_RELOC_PPC_VLE_SDAREL_HA16A, |
BFD_RELOC_PPC_VLE_SDAREL_HA16D, |
BFD_RELOC_PPC_REL16DX_HA, |
BFD_RELOC_PPC64_HIGHER, |
BFD_RELOC_PPC64_HIGHER_S, |
BFD_RELOC_PPC64_HIGHEST, |
3329,8 → 3225,6 |
BFD_RELOC_PPC64_PLTGOT16_LO_DS, |
BFD_RELOC_PPC64_ADDR16_HIGH, |
BFD_RELOC_PPC64_ADDR16_HIGHA, |
BFD_RELOC_PPC64_ADDR64_LOCAL, |
BFD_RELOC_PPC64_ENTRY, |
/* PowerPC and PowerPC64 thread-local storage relocations. */ |
BFD_RELOC_PPC_TLS, |
3644,74 → 3538,17 |
BFD_RELOC_SH_GOTOFFFUNCDESC20, |
BFD_RELOC_SH_FUNCDESC, |
/* ARC relocs. */ |
BFD_RELOC_ARC_NONE, |
BFD_RELOC_ARC_8, |
BFD_RELOC_ARC_16, |
BFD_RELOC_ARC_24, |
BFD_RELOC_ARC_32, |
BFD_RELOC_ARC_N8, |
BFD_RELOC_ARC_N16, |
BFD_RELOC_ARC_N24, |
BFD_RELOC_ARC_N32, |
BFD_RELOC_ARC_SDA, |
BFD_RELOC_ARC_SECTOFF, |
BFD_RELOC_ARC_S21H_PCREL, |
BFD_RELOC_ARC_S21W_PCREL, |
BFD_RELOC_ARC_S25H_PCREL, |
BFD_RELOC_ARC_S25W_PCREL, |
BFD_RELOC_ARC_SDA32, |
BFD_RELOC_ARC_SDA_LDST, |
BFD_RELOC_ARC_SDA_LDST1, |
BFD_RELOC_ARC_SDA_LDST2, |
BFD_RELOC_ARC_SDA16_LD, |
BFD_RELOC_ARC_SDA16_LD1, |
BFD_RELOC_ARC_SDA16_LD2, |
BFD_RELOC_ARC_S13_PCREL, |
BFD_RELOC_ARC_W, |
BFD_RELOC_ARC_32_ME, |
BFD_RELOC_ARC_32_ME_S, |
BFD_RELOC_ARC_N32_ME, |
BFD_RELOC_ARC_SECTOFF_ME, |
BFD_RELOC_ARC_SDA32_ME, |
BFD_RELOC_ARC_W_ME, |
BFD_RELOC_AC_SECTOFF_U8, |
BFD_RELOC_AC_SECTOFF_U8_1, |
BFD_RELOC_AC_SECTOFF_U8_2, |
BFD_RELOC_AC_SECTFOFF_S9, |
BFD_RELOC_AC_SECTFOFF_S9_1, |
BFD_RELOC_AC_SECTFOFF_S9_2, |
BFD_RELOC_ARC_SECTOFF_ME_1, |
BFD_RELOC_ARC_SECTOFF_ME_2, |
BFD_RELOC_ARC_SECTOFF_1, |
BFD_RELOC_ARC_SECTOFF_2, |
BFD_RELOC_ARC_SDA16_ST2, |
BFD_RELOC_ARC_32_PCREL, |
BFD_RELOC_ARC_PC32, |
BFD_RELOC_ARC_GOT32, |
BFD_RELOC_ARC_GOTPC32, |
BFD_RELOC_ARC_PLT32, |
BFD_RELOC_ARC_COPY, |
BFD_RELOC_ARC_GLOB_DAT, |
BFD_RELOC_ARC_JMP_SLOT, |
BFD_RELOC_ARC_RELATIVE, |
BFD_RELOC_ARC_GOTOFF, |
BFD_RELOC_ARC_GOTPC, |
BFD_RELOC_ARC_S21W_PCREL_PLT, |
BFD_RELOC_ARC_S25H_PCREL_PLT, |
BFD_RELOC_ARC_TLS_DTPMOD, |
BFD_RELOC_ARC_TLS_TPOFF, |
BFD_RELOC_ARC_TLS_GD_GOT, |
BFD_RELOC_ARC_TLS_GD_LD, |
BFD_RELOC_ARC_TLS_GD_CALL, |
BFD_RELOC_ARC_TLS_IE_GOT, |
BFD_RELOC_ARC_TLS_DTPOFF, |
BFD_RELOC_ARC_TLS_DTPOFF_S9, |
BFD_RELOC_ARC_TLS_LE_S9, |
BFD_RELOC_ARC_TLS_LE_32, |
BFD_RELOC_ARC_S25W_PCREL_PLT, |
BFD_RELOC_ARC_S21H_PCREL_PLT, |
/* ARC Cores relocs. |
ARC 22 bit pc-relative branch. The lowest two bits must be zero and are |
not stored in the instruction. The high 20 bits are installed in bits 26 |
through 7 of the instruction. */ |
BFD_RELOC_ARC_B22_PCREL, |
/* ARC 26 bit absolute branch. The lowest two bits must be zero and are not |
stored in the instruction. The high 24 bits are installed in bits 23 |
through 0. */ |
BFD_RELOC_ARC_B26, |
/* ADI Blackfin 16 bit immediate absolute reloc. */ |
BFD_RELOC_BFIN_16_IMM, |
3957,205 → 3794,6 |
BFD_RELOC_M32R_GOTPC_HI_SLO, |
BFD_RELOC_M32R_GOTPC_LO, |
/* NDS32 relocs. |
This is a 20 bit absolute address. */ |
BFD_RELOC_NDS32_20, |
/* This is a 9-bit pc-relative reloc with the right 1 bit assumed to be 0. */ |
BFD_RELOC_NDS32_9_PCREL, |
/* This is a 9-bit pc-relative reloc with the right 1 bit assumed to be 0. */ |
BFD_RELOC_NDS32_WORD_9_PCREL, |
/* This is an 15-bit reloc with the right 1 bit assumed to be 0. */ |
BFD_RELOC_NDS32_15_PCREL, |
/* This is an 17-bit reloc with the right 1 bit assumed to be 0. */ |
BFD_RELOC_NDS32_17_PCREL, |
/* This is a 25-bit reloc with the right 1 bit assumed to be 0. */ |
BFD_RELOC_NDS32_25_PCREL, |
/* This is a 20-bit reloc containing the high 20 bits of an address |
used with the lower 12 bits */ |
BFD_RELOC_NDS32_HI20, |
/* This is a 12-bit reloc containing the lower 12 bits of an address |
then shift right by 3. This is used with ldi,sdi... */ |
BFD_RELOC_NDS32_LO12S3, |
/* This is a 12-bit reloc containing the lower 12 bits of an address |
then shift left by 2. This is used with lwi,swi... */ |
BFD_RELOC_NDS32_LO12S2, |
/* This is a 12-bit reloc containing the lower 12 bits of an address |
then shift left by 1. This is used with lhi,shi... */ |
BFD_RELOC_NDS32_LO12S1, |
/* This is a 12-bit reloc containing the lower 12 bits of an address |
then shift left by 0. This is used with lbisbi... */ |
BFD_RELOC_NDS32_LO12S0, |
/* This is a 12-bit reloc containing the lower 12 bits of an address |
then shift left by 0. This is only used with branch relaxations */ |
BFD_RELOC_NDS32_LO12S0_ORI, |
/* This is a 15-bit reloc containing the small data area 18-bit signed offset |
and shift left by 3 for use in ldi, sdi... */ |
BFD_RELOC_NDS32_SDA15S3, |
/* This is a 15-bit reloc containing the small data area 17-bit signed offset |
and shift left by 2 for use in lwi, swi... */ |
BFD_RELOC_NDS32_SDA15S2, |
/* This is a 15-bit reloc containing the small data area 16-bit signed offset |
and shift left by 1 for use in lhi, shi... */ |
BFD_RELOC_NDS32_SDA15S1, |
/* This is a 15-bit reloc containing the small data area 15-bit signed offset |
and shift left by 0 for use in lbi, sbi... */ |
BFD_RELOC_NDS32_SDA15S0, |
/* This is a 16-bit reloc containing the small data area 16-bit signed offset |
and shift left by 3 */ |
BFD_RELOC_NDS32_SDA16S3, |
/* This is a 17-bit reloc containing the small data area 17-bit signed offset |
and shift left by 2 for use in lwi.gp, swi.gp... */ |
BFD_RELOC_NDS32_SDA17S2, |
/* This is a 18-bit reloc containing the small data area 18-bit signed offset |
and shift left by 1 for use in lhi.gp, shi.gp... */ |
BFD_RELOC_NDS32_SDA18S1, |
/* This is a 19-bit reloc containing the small data area 19-bit signed offset |
and shift left by 0 for use in lbi.gp, sbi.gp... */ |
BFD_RELOC_NDS32_SDA19S0, |
/* for PIC */ |
BFD_RELOC_NDS32_GOT20, |
BFD_RELOC_NDS32_9_PLTREL, |
BFD_RELOC_NDS32_25_PLTREL, |
BFD_RELOC_NDS32_COPY, |
BFD_RELOC_NDS32_GLOB_DAT, |
BFD_RELOC_NDS32_JMP_SLOT, |
BFD_RELOC_NDS32_RELATIVE, |
BFD_RELOC_NDS32_GOTOFF, |
BFD_RELOC_NDS32_GOTOFF_HI20, |
BFD_RELOC_NDS32_GOTOFF_LO12, |
BFD_RELOC_NDS32_GOTPC20, |
BFD_RELOC_NDS32_GOT_HI20, |
BFD_RELOC_NDS32_GOT_LO12, |
BFD_RELOC_NDS32_GOTPC_HI20, |
BFD_RELOC_NDS32_GOTPC_LO12, |
/* for relax */ |
BFD_RELOC_NDS32_INSN16, |
BFD_RELOC_NDS32_LABEL, |
BFD_RELOC_NDS32_LONGCALL1, |
BFD_RELOC_NDS32_LONGCALL2, |
BFD_RELOC_NDS32_LONGCALL3, |
BFD_RELOC_NDS32_LONGJUMP1, |
BFD_RELOC_NDS32_LONGJUMP2, |
BFD_RELOC_NDS32_LONGJUMP3, |
BFD_RELOC_NDS32_LOADSTORE, |
BFD_RELOC_NDS32_9_FIXED, |
BFD_RELOC_NDS32_15_FIXED, |
BFD_RELOC_NDS32_17_FIXED, |
BFD_RELOC_NDS32_25_FIXED, |
BFD_RELOC_NDS32_LONGCALL4, |
BFD_RELOC_NDS32_LONGCALL5, |
BFD_RELOC_NDS32_LONGCALL6, |
BFD_RELOC_NDS32_LONGJUMP4, |
BFD_RELOC_NDS32_LONGJUMP5, |
BFD_RELOC_NDS32_LONGJUMP6, |
BFD_RELOC_NDS32_LONGJUMP7, |
/* for PIC */ |
BFD_RELOC_NDS32_PLTREL_HI20, |
BFD_RELOC_NDS32_PLTREL_LO12, |
BFD_RELOC_NDS32_PLT_GOTREL_HI20, |
BFD_RELOC_NDS32_PLT_GOTREL_LO12, |
/* for floating point */ |
BFD_RELOC_NDS32_SDA12S2_DP, |
BFD_RELOC_NDS32_SDA12S2_SP, |
BFD_RELOC_NDS32_LO12S2_DP, |
BFD_RELOC_NDS32_LO12S2_SP, |
/* for dwarf2 debug_line. */ |
BFD_RELOC_NDS32_DWARF2_OP1, |
BFD_RELOC_NDS32_DWARF2_OP2, |
BFD_RELOC_NDS32_DWARF2_LEB, |
/* for eliminate 16-bit instructions */ |
BFD_RELOC_NDS32_UPDATE_TA, |
/* for PIC object relaxation */ |
BFD_RELOC_NDS32_PLT_GOTREL_LO20, |
BFD_RELOC_NDS32_PLT_GOTREL_LO15, |
BFD_RELOC_NDS32_PLT_GOTREL_LO19, |
BFD_RELOC_NDS32_GOT_LO15, |
BFD_RELOC_NDS32_GOT_LO19, |
BFD_RELOC_NDS32_GOTOFF_LO15, |
BFD_RELOC_NDS32_GOTOFF_LO19, |
BFD_RELOC_NDS32_GOT15S2, |
BFD_RELOC_NDS32_GOT17S2, |
/* NDS32 relocs. |
This is a 5 bit absolute address. */ |
BFD_RELOC_NDS32_5, |
/* This is a 10-bit unsigned pc-relative reloc with the right 1 bit assumed to be 0. */ |
BFD_RELOC_NDS32_10_UPCREL, |
/* If fp were omitted, fp can used as another gp. */ |
BFD_RELOC_NDS32_SDA_FP7U2_RELA, |
/* relaxation relative relocation types */ |
BFD_RELOC_NDS32_RELAX_ENTRY, |
BFD_RELOC_NDS32_GOT_SUFF, |
BFD_RELOC_NDS32_GOTOFF_SUFF, |
BFD_RELOC_NDS32_PLT_GOT_SUFF, |
BFD_RELOC_NDS32_MULCALL_SUFF, |
BFD_RELOC_NDS32_PTR, |
BFD_RELOC_NDS32_PTR_COUNT, |
BFD_RELOC_NDS32_PTR_RESOLVED, |
BFD_RELOC_NDS32_PLTBLOCK, |
BFD_RELOC_NDS32_RELAX_REGION_BEGIN, |
BFD_RELOC_NDS32_RELAX_REGION_END, |
BFD_RELOC_NDS32_MINUEND, |
BFD_RELOC_NDS32_SUBTRAHEND, |
BFD_RELOC_NDS32_DIFF8, |
BFD_RELOC_NDS32_DIFF16, |
BFD_RELOC_NDS32_DIFF32, |
BFD_RELOC_NDS32_DIFF_ULEB128, |
BFD_RELOC_NDS32_EMPTY, |
/* This is a 25 bit absolute address. */ |
BFD_RELOC_NDS32_25_ABS, |
/* For ex9 and ifc using. */ |
BFD_RELOC_NDS32_DATA, |
BFD_RELOC_NDS32_TRAN, |
BFD_RELOC_NDS32_17IFC_PCREL, |
BFD_RELOC_NDS32_10IFCU_PCREL, |
/* For TLS. */ |
BFD_RELOC_NDS32_TPOFF, |
BFD_RELOC_NDS32_TLS_LE_HI20, |
BFD_RELOC_NDS32_TLS_LE_LO12, |
BFD_RELOC_NDS32_TLS_LE_ADD, |
BFD_RELOC_NDS32_TLS_LE_LS, |
BFD_RELOC_NDS32_GOTTPOFF, |
BFD_RELOC_NDS32_TLS_IE_HI20, |
BFD_RELOC_NDS32_TLS_IE_LO12S2, |
BFD_RELOC_NDS32_TLS_TPOFF, |
BFD_RELOC_NDS32_TLS_LE_20, |
BFD_RELOC_NDS32_TLS_LE_15S0, |
BFD_RELOC_NDS32_TLS_LE_15S1, |
BFD_RELOC_NDS32_TLS_LE_15S2, |
/* This is a 9-bit reloc */ |
BFD_RELOC_V850_9_PCREL, |
4613,28 → 4251,6 |
in .byte hlo8(symbol) */ |
BFD_RELOC_AVR_8_HLO, |
/* AVR relocations to mark the difference of two local symbols. |
These are only needed to support linker relaxation and can be ignored |
when not relaxing. The field is set to the value of the difference |
assuming no relaxation. The relocation encodes the position of the |
second symbol so the linker can determine whether to adjust the field |
value. */ |
BFD_RELOC_AVR_DIFF8, |
BFD_RELOC_AVR_DIFF16, |
BFD_RELOC_AVR_DIFF32, |
/* This is a 7 bit reloc for the AVR that stores SRAM address for 16bit |
lds and sts instructions supported only tiny core. */ |
BFD_RELOC_AVR_LDS_STS_16, |
/* This is a 6 bit reloc for the AVR that stores an I/O register |
number for the IN and OUT instructions */ |
BFD_RELOC_AVR_PORT6, |
/* This is a 5 bit reloc for the AVR that stores an I/O register |
number for the SBIC, SBIS, SBI and CBI instructions */ |
BFD_RELOC_AVR_PORT5, |
/* Renesas RL78 Relocations. */ |
BFD_RELOC_RL78_NEG8, |
BFD_RELOC_RL78_NEG16, |
4669,7 → 4285,6 |
BFD_RELOC_RL78_HI8, |
BFD_RELOC_RL78_LO16, |
BFD_RELOC_RL78_CODE, |
BFD_RELOC_RL78_SADDR, |
/* Renesas RX Relocations. */ |
BFD_RELOC_RX_NEG8, |
5299,31 → 4914,9 |
BFD_RELOC_860_HIGOT, |
BFD_RELOC_860_HIGOTOFF, |
/* OpenRISC 1000 Relocations. */ |
BFD_RELOC_OR1K_REL_26, |
BFD_RELOC_OR1K_GOTPC_HI16, |
BFD_RELOC_OR1K_GOTPC_LO16, |
BFD_RELOC_OR1K_GOT16, |
BFD_RELOC_OR1K_PLT26, |
BFD_RELOC_OR1K_GOTOFF_HI16, |
BFD_RELOC_OR1K_GOTOFF_LO16, |
BFD_RELOC_OR1K_COPY, |
BFD_RELOC_OR1K_GLOB_DAT, |
BFD_RELOC_OR1K_JMP_SLOT, |
BFD_RELOC_OR1K_RELATIVE, |
BFD_RELOC_OR1K_TLS_GD_HI16, |
BFD_RELOC_OR1K_TLS_GD_LO16, |
BFD_RELOC_OR1K_TLS_LDM_HI16, |
BFD_RELOC_OR1K_TLS_LDM_LO16, |
BFD_RELOC_OR1K_TLS_LDO_HI16, |
BFD_RELOC_OR1K_TLS_LDO_LO16, |
BFD_RELOC_OR1K_TLS_IE_HI16, |
BFD_RELOC_OR1K_TLS_IE_LO16, |
BFD_RELOC_OR1K_TLS_LE_HI16, |
BFD_RELOC_OR1K_TLS_LE_LO16, |
BFD_RELOC_OR1K_TLS_TPOFF, |
BFD_RELOC_OR1K_TLS_DTPOFF, |
BFD_RELOC_OR1K_TLS_DTPMOD, |
/* OpenRISC Relocations. */ |
BFD_RELOC_OPENRISC_ABS_26, |
BFD_RELOC_OPENRISC_REL_26, |
/* H8 elf Relocations. */ |
BFD_RELOC_H8_DIR16A8, |
5431,24 → 5024,6 |
BFD_RELOC_NIOS2_JUMP_SLOT, |
BFD_RELOC_NIOS2_RELATIVE, |
BFD_RELOC_NIOS2_GOTOFF, |
BFD_RELOC_NIOS2_CALL26_NOAT, |
BFD_RELOC_NIOS2_GOT_LO, |
BFD_RELOC_NIOS2_GOT_HA, |
BFD_RELOC_NIOS2_CALL_LO, |
BFD_RELOC_NIOS2_CALL_HA, |
BFD_RELOC_NIOS2_R2_S12, |
BFD_RELOC_NIOS2_R2_I10_1_PCREL, |
BFD_RELOC_NIOS2_R2_T1I7_1_PCREL, |
BFD_RELOC_NIOS2_R2_T1I7_2, |
BFD_RELOC_NIOS2_R2_T2I4, |
BFD_RELOC_NIOS2_R2_T2I4_1, |
BFD_RELOC_NIOS2_R2_T2I4_2, |
BFD_RELOC_NIOS2_R2_X1I7_2, |
BFD_RELOC_NIOS2_R2_X2L5, |
BFD_RELOC_NIOS2_R2_F1I5_2, |
BFD_RELOC_NIOS2_R2_L5I4X1, |
BFD_RELOC_NIOS2_R2_T1X1I6, |
BFD_RELOC_NIOS2_R2_T1X1I6_2, |
/* IQ2000 Relocations. */ |
BFD_RELOC_IQ2000_OFFSET_16, |
5835,24 → 5410,6 |
BFD_RELOC_AARCH64_ADR_GOTPAGE. Valid in ILP32 ABI only. */ |
BFD_RELOC_AARCH64_LD32_GOT_LO12_NC, |
/* Unsigned 16 bit byte offset for 64 bit load/store from the GOT entry |
for this symbol. Valid in LP64 ABI only. */ |
BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC, |
/* Unsigned 16 bit byte higher offset for 64 bit load/store from the GOT entry |
for this symbol. Valid in LP64 ABI only. */ |
BFD_RELOC_AARCH64_MOVW_GOTOFF_G1, |
/* Unsigned 15 bit byte offset for 64 bit load/store from the page of |
the GOT entry for this symbol. Valid in LP64 ABI only. */ |
BFD_RELOC_AARCH64_LD64_GOTOFF_LO15, |
/* Scaled 14 bit byte offset to the page base of the global offset table. */ |
BFD_RELOC_AARCH64_LD32_GOTPAGE_LO14, |
/* Scaled 15 bit byte offset to the page base of the global offset table. */ |
BFD_RELOC_AARCH64_LD64_GOTPAGE_LO15, |
/* Get to the page base of the global offset table entry for a symbols |
tls_index structure as part of an adrp instruction using a 21 bit PC |
relative value. Used in conjunction with |
5859,19 → 5416,16 |
BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC. */ |
BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21, |
/* AArch64 TLS General Dynamic */ |
BFD_RELOC_AARCH64_TLSGD_ADR_PREL21, |
/* Unsigned 12 bit byte offset to global offset table entry for a symbols |
tls_index structure. Used in conjunction with |
BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21. */ |
BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC, |
/* AArch64 TLS General Dynamic relocation. */ |
BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC, |
/* AArch64 TLS INITIAL EXEC relocation. */ |
BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1, |
/* AArch64 TLS General Dynamic relocation. */ |
BFD_RELOC_AARCH64_TLSGD_MOVW_G1, |
/* AArch64 TLS INITIAL EXEC relocation. */ |
BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC, |
/* AArch64 TLS INITIAL EXEC relocation. */ |
BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21, |
5885,76 → 5439,6 |
/* AArch64 TLS INITIAL EXEC relocation. */ |
BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19, |
/* AArch64 TLS INITIAL EXEC relocation. */ |
BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC, |
/* AArch64 TLS INITIAL EXEC relocation. */ |
BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1, |
/* bit[23:12] of byte offset to module TLS base address. */ |
BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_HI12, |
/* Unsigned 12 bit byte offset to module TLS base address. */ |
BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12, |
/* No overflow check version of BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12. */ |
BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC, |
/* Unsigned 12 bit byte offset to global offset table entry for a symbols |
tls_index structure. Used in conjunction with |
BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21. */ |
BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC, |
/* GOT entry page address for AArch64 TLS Local Dynamic, used with ADRP |
instruction. */ |
BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21, |
/* GOT entry address for AArch64 TLS Local Dynamic, used with ADR instruction. */ |
BFD_RELOC_AARCH64_TLSLD_ADR_PREL21, |
/* bit[11:1] of byte offset to module TLS base address, encoded in ldst |
instructions. */ |
BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12, |
/* Similar as BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12, but no overflow check. */ |
BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC, |
/* bit[11:2] of byte offset to module TLS base address, encoded in ldst |
instructions. */ |
BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12, |
/* Similar as BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12, but no overflow check. */ |
BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC, |
/* bit[11:3] of byte offset to module TLS base address, encoded in ldst |
instructions. */ |
BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12, |
/* Similar as BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12, but no overflow check. */ |
BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC, |
/* bit[11:0] of byte offset to module TLS base address, encoded in ldst |
instructions. */ |
BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12, |
/* Similar as BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12, but no overflow check. */ |
BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC, |
/* bit[15:0] of byte offset to module TLS base address. */ |
BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0, |
/* No overflow check version of BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0 */ |
BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0_NC, |
/* bit[31:16] of byte offset to module TLS base address. */ |
BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1, |
/* No overflow check version of BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1 */ |
BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1_NC, |
/* bit[47:32] of byte offset to module TLS base address. */ |
BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G2, |
/* AArch64 TLS LOCAL EXEC relocation. */ |
BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2, |
6054,14 → 5538,6 |
address. Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL. */ |
BFD_RELOC_AARCH64_LDST_LO12, |
/* AArch64 pseudo relocation code for TLS local dynamic mode. It's to be |
used internally by the AArch64 assembler and not (currently) written to |
any object files. */ |
BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12, |
/* Similar as BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12, but no overflow check. */ |
BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12_NC, |
/* AArch64 pseudo relocation code to be used internally by the AArch64 |
assembler and not (currently) written to any object files. */ |
BFD_RELOC_AARCH64_LD_GOT_LO12_NC, |
6286,17 → 5762,7 |
/* Adapteva EPIPHANY - 8 bit immediate for 16 bit mov instruction. */ |
BFD_RELOC_EPIPHANY_IMM8, |
/* Visium Relocations. */ |
BFD_RELOC_VISIUM_HI16, |
BFD_RELOC_VISIUM_LO16, |
BFD_RELOC_VISIUM_IM16, |
BFD_RELOC_VISIUM_REL16, |
BFD_RELOC_VISIUM_HI16_PCREL, |
BFD_RELOC_VISIUM_LO16_PCREL, |
BFD_RELOC_VISIUM_IM16_PCREL, |
BFD_RELOC_UNUSED }; |
typedef enum bfd_reloc_code_real bfd_reloc_code_real_type; |
reloc_howto_type *bfd_reloc_type_lookup |
(bfd *abfd, bfd_reloc_code_real_type code); |
6494,7 → 5960,6 |
(ibfd, isymbol, obfd, osymbol)) |
/* Extracted from bfd.c. */ |
enum bfd_direction |
{ |
no_direction = 0, |
6503,21 → 5968,11 |
both_direction = 3 |
}; |
enum bfd_plugin_format |
struct bfd |
{ |
bfd_plugin_uknown = 0, |
bfd_plugin_yes = 1, |
bfd_plugin_no = 2 |
}; |
/* A unique identifier of the BFD */ |
unsigned int id; |
struct bfd_build_id |
{ |
bfd_size_type size; |
bfd_byte data[1]; |
}; |
struct bfd |
{ |
/* The filename the application opened the BFD with. */ |
const char *filename; |
6540,17 → 5995,17 |
/* File modified time, if mtime_set is TRUE. */ |
long mtime; |
/* A unique identifier of the BFD */ |
unsigned int id; |
/* Reserved for an unimplemented file locking extension. */ |
int ifd; |
/* The format which belongs to the BFD. (object, core, etc.) */ |
ENUM_BITFIELD (bfd_format) format : 3; |
bfd_format format; |
/* The direction with which the BFD was opened. */ |
ENUM_BITFIELD (bfd_direction) direction : 2; |
enum bfd_direction direction; |
/* Format_specific flags. */ |
flagword flags : 18; |
flagword flags; |
/* Values that may appear in the flags field of a BFD. These also |
appear in the object_flags field of the bfd_target structure, where |
6609,87 → 6064,36 |
struct. */ |
#define BFD_IN_MEMORY 0x800 |
/* The sections in this BFD specify a memory page. */ |
#define HAS_LOAD_PAGE 0x1000 |
/* This BFD has been created by the linker and doesn't correspond |
to any input file. */ |
#define BFD_LINKER_CREATED 0x1000 |
#define BFD_LINKER_CREATED 0x2000 |
/* This may be set before writing out a BFD to request that it |
be written using values for UIDs, GIDs, timestamps, etc. that |
will be consistent from run to run. */ |
#define BFD_DETERMINISTIC_OUTPUT 0x2000 |
#define BFD_DETERMINISTIC_OUTPUT 0x4000 |
/* Compress sections in this BFD. */ |
#define BFD_COMPRESS 0x4000 |
#define BFD_COMPRESS 0x8000 |
/* Decompress sections in this BFD. */ |
#define BFD_DECOMPRESS 0x8000 |
#define BFD_DECOMPRESS 0x10000 |
/* BFD is a dummy, for plugins. */ |
#define BFD_PLUGIN 0x10000 |
#define BFD_PLUGIN 0x20000 |
/* Compress sections in this BFD with SHF_COMPRESSED from gABI. */ |
#define BFD_COMPRESS_GABI 0x20000 |
/* Flags bits to be saved in bfd_preserve_save. */ |
#define BFD_FLAGS_SAVED \ |
(BFD_IN_MEMORY | BFD_COMPRESS | BFD_DECOMPRESS | BFD_PLUGIN \ |
| BFD_COMPRESS_GABI) |
(BFD_IN_MEMORY | BFD_COMPRESS | BFD_DECOMPRESS | BFD_PLUGIN) |
/* Flags bits which are for BFD use only. */ |
#define BFD_FLAGS_FOR_BFD_USE_MASK \ |
(BFD_IN_MEMORY | BFD_COMPRESS | BFD_DECOMPRESS | BFD_LINKER_CREATED \ |
| BFD_PLUGIN | BFD_TRADITIONAL_FORMAT | BFD_DETERMINISTIC_OUTPUT \ |
| BFD_COMPRESS_GABI) |
| BFD_PLUGIN | BFD_TRADITIONAL_FORMAT | BFD_DETERMINISTIC_OUTPUT) |
/* Is the file descriptor being cached? That is, can it be closed as |
needed, and re-opened when accessed later? */ |
unsigned int cacheable : 1; |
/* Marks whether there was a default target specified when the |
BFD was opened. This is used to select which matching algorithm |
to use to choose the back end. */ |
unsigned int target_defaulted : 1; |
/* ... and here: (``once'' means at least once). */ |
unsigned int opened_once : 1; |
/* Set if we have a locally maintained mtime value, rather than |
getting it from the file each time. */ |
unsigned int mtime_set : 1; |
/* Flag set if symbols from this BFD should not be exported. */ |
unsigned int no_export : 1; |
/* Remember when output has begun, to stop strange things |
from happening. */ |
unsigned int output_has_begun : 1; |
/* Have archive map. */ |
unsigned int has_armap : 1; |
/* Set if this is a thin archive. */ |
unsigned int is_thin_archive : 1; |
/* Set if only required symbols should be added in the link hash table for |
this object. Used by VMS linkers. */ |
unsigned int selective_search : 1; |
/* Set if this is the linker output BFD. */ |
unsigned int is_linker_output : 1; |
/* Set if this is the linker input BFD. */ |
unsigned int is_linker_input : 1; |
/* If this is an input for a compiler plug-in library. */ |
ENUM_BITFIELD (bfd_plugin_format) plugin_format : 2; |
/* Set if this is a plugin output file. */ |
unsigned int lto_output : 1; |
/* Set to dummy BFD created when claimed by a compiler plug-in |
library. */ |
bfd *plugin_dummy_bfd; |
/* Currently my_archive is tested before adding origin to |
anything. I believe that this can become always an add of |
origin, with origin set to 0 for non archive files. */ |
6714,21 → 6118,17 |
/* The number of sections. */ |
unsigned int section_count; |
/* A field used by _bfd_generic_link_add_archive_symbols. This will |
be used only for archive elements. */ |
int archive_pass; |
/* Stuff only useful for object files: |
The start address. */ |
bfd_vma start_address; |
/* Used for input and output. */ |
unsigned int symcount; |
/* Symbol table for output BFD (with symcount entries). |
Also used by the linker to cache input BFD symbols. */ |
struct bfd_symbol **outsymbols; |
/* Used for input and output. */ |
unsigned int symcount; |
/* Used for slurped dynamic symbol tables. */ |
unsigned int dynsymcount; |
6743,13 → 6143,13 |
struct bfd *nested_archives; /* List of nested archive in a flattened |
thin archive. */ |
union { |
/* For input BFDs, a chain of BFDs involved in a link. */ |
struct bfd *next; |
/* For output BFD, the linker hash table. */ |
struct bfd_link_hash_table *hash; |
} link; |
/* A chain of BFD structures involved in a link. */ |
struct bfd *link_next; |
/* A field used by _bfd_generic_link_add_archive_symbols. This will |
be used only for archive elements. */ |
int archive_pass; |
/* Used by the back end to hold private data. */ |
union |
{ |
6801,19 → 6201,40 |
of objalloc.h. */ |
void *memory; |
/* For input BFDs, the build ID, if the object has one. */ |
const struct bfd_build_id *build_id; |
}; |
/* Is the file descriptor being cached? That is, can it be closed as |
needed, and re-opened when accessed later? */ |
unsigned int cacheable : 1; |
/* See note beside bfd_set_section_userdata. */ |
static inline bfd_boolean |
bfd_set_cacheable (bfd * abfd, bfd_boolean val) |
{ |
abfd->cacheable = val; |
return TRUE; |
} |
/* Marks whether there was a default target specified when the |
BFD was opened. This is used to select which matching algorithm |
to use to choose the back end. */ |
unsigned int target_defaulted : 1; |
/* ... and here: (``once'' means at least once). */ |
unsigned int opened_once : 1; |
/* Set if we have a locally maintained mtime value, rather than |
getting it from the file each time. */ |
unsigned int mtime_set : 1; |
/* Flag set if symbols from this BFD should not be exported. */ |
unsigned int no_export : 1; |
/* Remember when output has begun, to stop strange things |
from happening. */ |
unsigned int output_has_begun : 1; |
/* Have archive map. */ |
unsigned int has_armap : 1; |
/* Set if this is a thin archive. */ |
unsigned int is_thin_archive : 1; |
/* Set if only required symbols should be added in the link hash table for |
this object. Used by VMS linkers. */ |
unsigned int selective_search : 1; |
}; |
typedef enum bfd_error |
{ |
bfd_error_no_error = 0, |
6849,7 → 6270,6 |
void bfd_perror (const char *message); |
typedef void (*bfd_error_handler_type) (const char *, ...); |
bfd_error_handler_type bfd_set_error_handler (bfd_error_handler_type); |
6858,7 → 6278,6 |
bfd_error_handler_type bfd_get_error_handler (void); |
typedef void (*bfd_assert_handler_type) (const char *bfd_formatmsg, |
const char *bfd_version, |
const char *bfd_file, |
6914,12 → 6333,12 |
#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \ |
BFD_SEND (abfd, _bfd_find_nearest_line, \ |
(abfd, syms, sec, off, file, func, line, NULL)) |
(abfd, sec, syms, off, file, func, line)) |
#define bfd_find_nearest_line_discriminator(abfd, sec, syms, off, file, func, \ |
line, disc) \ |
BFD_SEND (abfd, _bfd_find_nearest_line, \ |
(abfd, syms, sec, off, file, func, line, disc)) |
BFD_SEND (abfd, _bfd_find_nearest_line_discriminator, \ |
(abfd, sec, syms, off, file, func, line, disc)) |
#define bfd_find_line(abfd, syms, sym, file, line) \ |
BFD_SEND (abfd, _bfd_find_line, \ |
6968,6 → 6387,9 |
#define bfd_link_hash_table_create(abfd) \ |
BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd)) |
#define bfd_link_hash_table_free(abfd, hash) \ |
BFD_SEND (abfd, _bfd_link_hash_table_free, (hash)) |
#define bfd_link_add_symbols(abfd, info) \ |
BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info)) |
7015,22 → 6437,6 |
char *bfd_demangle (bfd *, const char *, int); |
void bfd_update_compression_header |
(bfd *abfd, bfd_byte *contents, asection *sec); |
bfd_boolean bfd_check_compression_header |
(bfd *abfd, bfd_byte *contents, asection *sec, |
bfd_size_type *uncompressed_size); |
int bfd_get_compression_header_size (bfd *abfd, asection *sec); |
bfd_size_type bfd_convert_section_size |
(bfd *ibfd, asection *isec, bfd *obfd, bfd_size_type size); |
bfd_boolean bfd_convert_section_contents |
(bfd *ibfd, asection *isec, bfd *obfd, |
bfd_byte **ptr, bfd_size_type *ptr_size); |
/* Extracted from archive.c. */ |
symindex bfd_get_next_mapent |
(bfd *abfd, symindex previous, carsym **sym); |
7076,7 → 6482,6 |
enum bfd_flavour |
{ |
/* N.B. Update bfd_flavour_name if you change this. */ |
bfd_target_unknown_flavour, |
bfd_target_aout_flavour, |
bfd_target_coff_flavour, |
7294,12 → 6699,12 |
NAME##_make_empty_symbol, \ |
NAME##_print_symbol, \ |
NAME##_get_symbol_info, \ |
NAME##_get_symbol_version_string, \ |
NAME##_bfd_is_local_label_name, \ |
NAME##_bfd_is_target_special_symbol, \ |
NAME##_get_lineno, \ |
NAME##_find_nearest_line, \ |
NAME##_find_line, \ |
_bfd_generic_find_nearest_line_discriminator, \ |
_bfd_generic_find_line, \ |
NAME##_find_inliner_info, \ |
NAME##_bfd_make_debug_symbol, \ |
NAME##_read_minisymbols, \ |
7316,14 → 6721,14 |
void (*_bfd_get_symbol_info) |
(bfd *, struct bfd_symbol *, symbol_info *); |
#define bfd_get_symbol_info(b,p,e) BFD_SEND (b, _bfd_get_symbol_info, (b,p,e)) |
const char *(*_bfd_get_symbol_version_string) |
(bfd *, struct bfd_symbol *, bfd_boolean *); |
#define bfd_get_symbol_version_string(b,s,h) BFD_SEND (b, _bfd_get_symbol_version_string, (b,s,h)) |
bfd_boolean (*_bfd_is_local_label_name) (bfd *, const char *); |
bfd_boolean (*_bfd_is_target_special_symbol) (bfd *, asymbol *); |
alent * (*_get_lineno) (bfd *, struct bfd_symbol *); |
bfd_boolean (*_bfd_find_nearest_line) |
(bfd *, struct bfd_symbol **, struct bfd_section *, bfd_vma, |
(bfd *, struct bfd_section *, struct bfd_symbol **, bfd_vma, |
const char **, const char **, unsigned int *); |
bfd_boolean (*_bfd_find_nearest_line_discriminator) |
(bfd *, struct bfd_section *, struct bfd_symbol **, bfd_vma, |
const char **, const char **, unsigned int *, unsigned int *); |
bfd_boolean (*_bfd_find_line) |
(bfd *, struct bfd_symbol **, struct bfd_symbol *, |
7377,6 → 6782,7 |
NAME##_bfd_get_relocated_section_contents, \ |
NAME##_bfd_relax_section, \ |
NAME##_bfd_link_hash_table_create, \ |
NAME##_bfd_link_hash_table_free, \ |
NAME##_bfd_link_add_symbols, \ |
NAME##_bfd_link_just_syms, \ |
NAME##_bfd_copy_link_hash_symbol_type, \ |
7403,6 → 6809,9 |
struct bfd_link_hash_table * |
(*_bfd_link_hash_table_create) (bfd *); |
/* Release the memory associated with the linker hash table. */ |
void (*_bfd_link_hash_table_free) (struct bfd_link_hash_table *); |
/* Add symbols from this object file into the hash table. */ |
bfd_boolean (*_bfd_link_add_symbols) (bfd *, struct bfd_link_info *); |
7409,8 → 6818,7 |
/* Indicate that we are only retrieving symbol values from this section. */ |
void (*_bfd_link_just_syms) (asection *, struct bfd_link_info *); |
/* Copy the symbol type and other attributes for a linker script |
assignment of one symbol to another. */ |
/* Copy the symbol type of a linker hash table entry. */ |
#define bfd_copy_link_hash_symbol_type(b, t, f) \ |
BFD_SEND (b, _bfd_copy_link_hash_symbol_type, (b, t, f)) |
void (*_bfd_copy_link_hash_symbol_type) |
7496,8 → 6904,6 |
(int (*search_func) (const bfd_target *, void *), |
void *); |
const char *bfd_flavour_name (enum bfd_flavour flavour); |
/* Extracted from format.c. */ |
bfd_boolean bfd_check_format (bfd *abfd, bfd_format format); |
7540,6 → 6946,10 |
(bfd *abfd, asection *sec, bfd_byte *outbuf, asymbol **symbol_table); |
/* Extracted from compress.c. */ |
bfd_boolean bfd_compress_section_contents |
(bfd *abfd, asection *section, bfd_byte *uncompressed_buffer, |
bfd_size_type uncompressed_size); |
bfd_boolean bfd_get_full_section_contents |
(bfd *abfd, asection *section, bfd_byte **ptr); |
7546,11 → 6956,6 |
void bfd_cache_section_contents |
(asection *sec, void *contents); |
bfd_boolean bfd_is_section_compressed_with_header |
(bfd *abfd, asection *section, |
int *compression_header_size_p, |
bfd_size_type *uncompressed_size_p); |
bfd_boolean bfd_is_section_compressed |
(bfd *abfd, asection *section); |
7560,9 → 6965,6 |
bfd_boolean bfd_init_section_compress_status |
(bfd *abfd, asection *section); |
bfd_boolean bfd_compress_section |
(bfd *abfd, asection *section, bfd_byte *uncompressed_buffer); |
#ifdef __cplusplus |
} |
#endif |
/contrib/toolchain/binutils/bfd/bfd_stdint.h |
---|
1,4 → 1,4 |
/* generated for gcc.exe (GCC) 4.9.3 */ |
/* generated for gcc.exe (GCC) 4.8.1 */ |
#ifndef GCC_GENERATED_STDINT_H |
#define GCC_GENERATED_STDINT_H 1 |
/contrib/toolchain/binutils/bfd/bfdver.h |
---|
1,4 → 1,4 |
#define BFD_VERSION_DATE 20160125 |
#define BFD_VERSION 226000000 |
#define BFD_VERSION_STRING "(GNU Binutils) " "2.26.20160125" |
#define BFD_VERSION_DATE 20131202 |
#define BFD_VERSION 224000000 |
#define BFD_VERSION_STRING "(GNU Binutils) " "2.24" |
#define REPORT_BUGS_TO "<http://www.sourceware.org/bugzilla/>" |
/contrib/toolchain/binutils/bfd/binary.c |
---|
1,5 → 1,6 |
/* BFD back-end for binary objects. |
Copyright (C) 1994-2015 Free Software Foundation, Inc. |
Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, |
2004, 2005, 2006, 2007, 2009, 2011 Free Software Foundation, Inc. |
Written by Ian Lance Taylor, Cygnus Support, <ian@cygnus.com> |
This file is part of BFD, the Binary File Descriptor library. |
190,8 → 191,6 |
#define binary_make_empty_symbol _bfd_generic_make_empty_symbol |
#define binary_print_symbol _bfd_nosymbols_print_symbol |
#define binary_get_symbol_version_string \ |
_bfd_nosymbols_get_symbol_version_string |
/* Get information about a symbol. */ |
206,7 → 205,6 |
#define binary_bfd_is_local_label_name bfd_generic_is_local_label_name |
#define binary_get_lineno _bfd_nosymbols_get_lineno |
#define binary_find_nearest_line _bfd_nosymbols_find_nearest_line |
#define binary_find_line _bfd_nosymbols_find_line |
#define binary_find_inliner_info _bfd_nosymbols_find_inliner_info |
#define binary_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol |
#define binary_read_minisymbols _bfd_generic_read_minisymbols |
308,6 → 306,7 |
#define binary_section_already_linked _bfd_generic_section_already_linked |
#define binary_bfd_define_common_symbol bfd_generic_define_common_symbol |
#define binary_bfd_link_hash_table_create _bfd_generic_link_hash_table_create |
#define binary_bfd_link_hash_table_free _bfd_generic_link_hash_table_free |
#define binary_bfd_link_just_syms _bfd_generic_link_just_syms |
#define binary_bfd_copy_link_hash_symbol_type \ |
_bfd_generic_copy_link_hash_symbol_type |
/contrib/toolchain/binutils/bfd/coff-i386.c |
---|
1,5 → 1,7 |
/* BFD back-end for Intel 386 COFF files. |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2012 |
Free Software Foundation, Inc. |
Written by Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
340,8 → 342,6 |
PCRELOFFSET) /* pcrel_offset */ |
}; |
#define NUM_HOWTOS (sizeof (howto_table) / sizeof (howto_table[0])) |
/* Turn a howto into a reloc nunmber */ |
#define SELECT_RELOC(x,howto) { x.r_type = howto->type; } |
350,7 → 350,7 |
#define RTYPE2HOWTO(cache_ptr, dst) \ |
((cache_ptr)->howto = \ |
((dst)->r_type < NUM_HOWTOS \ |
((dst)->r_type < sizeof (howto_table) / sizeof (howto_table[0]) \ |
? howto_table + (dst)->r_type \ |
: NULL)) |
379,7 → 379,7 |
coffsym = (obj_symbols (abfd) \ |
+ (cache_ptr->sym_ptr_ptr - symbols)); \ |
else if (ptr) \ |
coffsym = coff_symbol_from (ptr); \ |
coffsym = coff_symbol_from (abfd, ptr); \ |
if (coffsym != (coff_symbol_type *) NULL \ |
&& coffsym->native->u.syment.n_scnum == 0) \ |
cache_ptr->addend = - coffsym->native->u.syment.n_value; \ |
388,8 → 388,7 |
cache_ptr->addend = - (ptr->section->vma + ptr->value); \ |
else \ |
cache_ptr->addend = 0; \ |
if (ptr && reloc.r_type < NUM_HOWTOS \ |
&& howto_table[reloc.r_type].pc_relative) \ |
if (ptr && howto_table[reloc.r_type].pc_relative) \ |
cache_ptr->addend += asect->vma; \ |
} |
417,7 → 416,7 |
struct internal_syment *syms, |
asection **sections) |
{ |
if (bfd_link_relocatable (info)) |
if (info->relocatable) |
return TRUE; |
return _bfd_coff_generic_relocate_section (output_bfd, info, input_bfd, |
441,7 → 440,7 |
{ |
reloc_howto_type *howto; |
if (rel->r_type >= NUM_HOWTOS) |
if (rel->r_type >= sizeof (howto_table) / sizeof (howto_table[0])) |
{ |
bfd_set_error (bfd_error_bad_value); |
return NULL; |
509,12 → 508,7 |
*addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase; |
} |
/* PR 17099 - Absolute R_PCRLONG relocations do not need a symbol. */ |
if (rel->r_type == R_PCRLONG && sym == NULL) |
*addendp -= rel->r_vaddr; |
else |
BFD_ASSERT (sym != NULL); |
if (rel->r_type == R_SECREL32 && sym != NULL) |
{ |
bfd_vma osect_vma; |
582,7 → 576,7 |
{ |
unsigned int i; |
for (i = 0; i < NUM_HOWTOS; i++) |
for (i = 0; i < sizeof (howto_table) / sizeof (howto_table[0]); i++) |
if (howto_table[i].name != NULL |
&& strcasecmp (howto_table[i].name, r_name) == 0) |
return &howto_table[i]; |
613,11 → 607,14 |
#include "coffcode.h" |
#define _bfd_generic_find_nearest_line_discriminator \ |
coff_find_nearest_line_discriminator |
const bfd_target |
#ifdef TARGET_SYM |
TARGET_SYM = |
#else |
i386_coff_vec = |
i386coff_vec = |
#endif |
{ |
#ifdef TARGET_NAME |
/contrib/toolchain/binutils/bfd/coffcode.h |
---|
1,5 → 1,5 |
/* Support for the generic parts of most COFF variants, for BFD. |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990-2013 Free Software Foundation, Inc. |
Written by Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
337,9 → 337,6 |
. union internal_auxent auxent; |
. struct internal_syment syment; |
. } u; |
. |
. {* Selector for the union above. *} |
. bfd_boolean is_sym; |
.} combined_entry_type; |
. |
. |
931,7 → 928,12 |
bfd_coff_swap_sym_in (abfd, esym, & isym); |
BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); |
if (sizeof (internal_s->s_name) > SYMNMLEN) |
{ |
/* This case implies that the matching |
symbol name will be in the string table. */ |
abort (); |
} |
if (isym.n_scnum == section->target_index) |
{ |
962,12 → 964,8 |
/* All 3 branches use this. */ |
symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); |
/* PR 17512 file: 078-11867-0.004 */ |
if (symname == NULL) |
{ |
_bfd_error_handler (_("%B: unable to load COMDAT section name"), abfd); |
break; |
} |
abort (); |
switch (seen_state) |
{ |
1009,13 → 1007,6 |
seen_state = 1; |
/* PR 17512: file: e2cfe54f. */ |
if (esym + bfd_coff_symesz (abfd) >= esymend) |
{ |
_bfd_error_handler (_("%B: warning: No symbol for section '%s' found"), |
abfd, symname); |
break; |
} |
/* This is the section symbol. */ |
bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)), |
isym.n_type, isym.n_sclass, |
1169,7 → 1160,7 |
flagword *flags_ptr) |
{ |
struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; |
unsigned long styp_flags = internal_s->s_flags; |
long styp_flags = internal_s->s_flags; |
flagword sec_flags; |
bfd_boolean result = TRUE; |
bfd_boolean is_dbg = FALSE; |
1192,7 → 1183,7 |
/* Process each flag bit in styp_flags in turn. */ |
while (styp_flags) |
{ |
unsigned long flag = styp_flags & - styp_flags; |
long flag = styp_flags & - styp_flags; |
char * unhandled = NULL; |
styp_flags &= ~ flag; |
1352,10 → 1343,6 |
. COFF_SYMBOL_PE_SECTION |
.}; |
. |
.typedef asection * (*coff_gc_mark_hook_fn) |
. (asection *, struct bfd_link_info *, struct internal_reloc *, |
. struct coff_link_hash_entry *, struct internal_syment *); |
. |
Special entry points for gdb to swap in coff symbol table parts: |
.typedef struct |
.{ |
1406,7 → 1393,6 |
. unsigned int _bfd_coff_default_section_alignment_power; |
. bfd_boolean _bfd_coff_force_symnames_in_strings; |
. unsigned int _bfd_coff_debug_string_prefix_length; |
. unsigned int _bfd_coff_max_nscns; |
. |
. void (*_bfd_coff_swap_filehdr_in) |
. (bfd *, void *, void *); |
1544,9 → 1530,6 |
. ((coff_backend_info (abfd)->_bfd_coff_set_long_section_names) (abfd, enable)) |
.#define bfd_coff_default_section_alignment_power(abfd) \ |
. (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power) |
.#define bfd_coff_max_nscns(abfd) \ |
. (coff_backend_info (abfd)->_bfd_coff_max_nscns) |
. |
.#define bfd_coff_swap_filehdr_in(abfd, i,o) \ |
. ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o)) |
. |
1810,7 → 1793,6 |
in case this symbol winds up getting written out. The value 0 |
for n_numaux is already correct. */ |
native->is_sym = TRUE; |
native->u.syment.n_type = T_NULL; |
native->u.syment.n_sclass = sclass; |
2084,11 → 2066,7 |
#endif |
if ((internal_f->f_flags & F_GO32STUB) != 0) |
{ |
coff->go32stub = (char *) bfd_alloc (abfd, (bfd_size_type) GO32_STUBSIZE); |
if (coff->go32stub == NULL) |
return NULL; |
} |
if (coff->go32stub != NULL) |
memcpy (coff->go32stub, internal_f->go32stub, GO32_STUBSIZE); |
2114,6 → 2092,12 |
machine = 0; |
switch (internal_f->f_magic) |
{ |
#ifdef OR32_MAGIC_BIG |
case OR32_MAGIC_BIG: |
case OR32_MAGIC_LITTLE: |
arch = bfd_arch_or32; |
break; |
#endif |
#ifdef PPCMAGIC |
case PPCMAGIC: |
arch = bfd_arch_powerpc; |
2293,8 → 2277,6 |
bfd_size_type amt = bfd_coff_symesz (abfd); |
buf = bfd_malloc (amt); |
if (buf == NULL) |
return FALSE; |
if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0 |
|| bfd_bread (buf, amt, abfd) != amt) |
{ |
2518,13 → 2500,11 |
unsigned int indaux, |
combined_entry_type *aux) |
{ |
BFD_ASSERT (symbol->is_sym); |
int n_sclass = symbol->u.syment.n_sclass; |
if (CSECT_SYM_P (n_sclass) |
&& indaux + 1 == symbol->u.syment.n_numaux) |
{ |
BFD_ASSERT (! aux->is_sym); |
if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) == XTY_LD) |
{ |
aux->u.auxent.x_csect.x_scnlen.p = |
2557,7 → 2537,6 |
/* Return TRUE if we don't want to pointerize this aux entry, which |
is the case for the lastfirst aux entry for a C_LEAFPROC symbol. */ |
return (indaux == 1 |
&& symbol->is_sym |
&& (symbol->u.syment.n_sclass == C_LEAFPROC |
|| symbol->u.syment.n_sclass == C_LEAFSTAT |
|| symbol->u.syment.n_sclass == C_LEAFEXT)); |
2580,8 → 2559,6 |
combined_entry_type *aux ATTRIBUTE_UNUSED, |
unsigned int indaux ATTRIBUTE_UNUSED) |
{ |
BFD_ASSERT (symbol->is_sym); |
BFD_ASSERT (! aux->is_sym); |
#ifdef RS6000COFF_C |
if (CSECT_SYM_P (symbol->u.syment.n_sclass) |
&& indaux + 1 == symbol->u.syment.n_numaux) |
2683,17 → 2660,11 |
amt = s->reloc_count; |
amt *= sizeof (arelent *); |
p = bfd_malloc (amt); |
if (p == NULL) |
{ |
if (s->reloc_count > 0) |
if (p == NULL && s->reloc_count > 0) |
return FALSE; |
} |
else |
{ |
memcpy (p, s->orelocation, (size_t) amt); |
qsort (p, s->reloc_count, sizeof (arelent *), compare_arelent_ptr); |
} |
} |
#endif |
if (bfd_seek (abfd, s->rel_filepos, SEEK_SET) != 0) |
3093,6 → 3064,15 |
return TRUE; |
#endif |
#ifdef OR32_MAGIC_BIG |
case bfd_arch_or32: |
if (bfd_big_endian (abfd)) |
* magicp = OR32_MAGIC_BIG; |
else |
* magicp = OR32_MAGIC_LITTLE; |
return TRUE; |
#endif |
default: /* Unknown architecture. */ |
/* Fall through to "return FALSE" below, to avoid |
"statement never reached" errors on the one below. */ |
3156,7 → 3136,7 |
asection *current; |
file_ptr sofar = bfd_coff_filhsz (abfd); |
bfd_boolean align_adjust; |
unsigned int target_index; |
int target_index; |
#ifdef ALIGN_SECTIONS_IN_FILE |
asection *previous = NULL; |
file_ptr old_sofar; |
3165,8 → 3145,7 |
#ifdef COFF_IMAGE_WITH_PE |
int page_size; |
if (coff_data (abfd)->link_info |
|| (pe_data (abfd) && pe_data (abfd)->pe_opthdr.FileAlignment)) |
if (coff_data (abfd)->link_info) |
{ |
page_size = pe_data (abfd)->pe_opthdr.FileAlignment; |
3174,16 → 3153,7 |
This repairs 'ld -r' for arm-wince-pe target. */ |
if (page_size == 0) |
page_size = 1; |
/* PR 17512: file: 0ac816d3. */ |
if (page_size < 0) |
{ |
bfd_set_error (bfd_error_file_too_big); |
(*_bfd_error_handler) |
(_("%B: page size is too large (0x%x)"), abfd, page_size); |
return FALSE; |
} |
} |
else |
page_size = PE_DEF_FILE_ALIGNMENT; |
#else |
3206,10 → 3176,9 |
{ |
coff_symbol_type *cf; |
cf = coff_symbol_from (*symp); |
cf = coff_symbol_from (abfd, *symp); |
if (cf != NULL |
&& cf->native != NULL |
&& cf->native->is_sym |
&& SYMNAME_IN_DEBUG (&cf->native->u.syment)) |
{ |
size_t len; |
3335,7 → 3304,7 |
} |
#endif /* ! COFF_IMAGE_WITH_PE */ |
if (target_index >= bfd_coff_max_nscns (abfd)) |
if (target_index >= 32768) |
{ |
bfd_set_error (bfd_error_file_too_big); |
(*_bfd_error_handler) |
3904,10 → 3873,9 |
/* See if this is the section symbol. */ |
if (strcmp ((*psym)->name, current->name) == 0) |
{ |
csym = coff_symbol_from (*psym); |
csym = coff_symbol_from (abfd, *psym); |
if (csym == NULL |
|| csym->native == NULL |
|| ! csym->native->is_sym |
|| csym->native->u.syment.n_numaux < 1 |
|| csym->native->u.syment.n_sclass != C_STAT |
|| csym->native->u.syment.n_type != T_NULL) |
3930,7 → 3898,6 |
x_associated field is not currently supported. */ |
aux = csym->native + 1; |
BFD_ASSERT (! aux->is_sym); |
switch (current->flags & SEC_LINK_DUPLICATES) |
{ |
case SEC_LINK_DUPLICATES_DISCARD: |
4076,6 → 4043,8 |
internal_f.f_flags |= F_DYNLOAD; |
#endif |
memset (&internal_a, 0, sizeof internal_a); |
/* Set up architecture-dependent stuff. */ |
{ |
unsigned int magic = 0; |
4185,6 → 4154,11 |
internal_a.magic = MIPS_PE_MAGIC; |
#endif |
#ifdef OR32 |
#define __A_MAGIC_SET__ |
internal_a.magic = NMAGIC; /* Assume separate i/d. */ |
#endif |
#ifndef __A_MAGIC_SET__ |
#include "Your aouthdr magic number is not being set!" |
#else |
4351,18 → 4325,7 |
} |
#endif |
#ifdef COFF_WITH_PE |
{ |
/* After object contents are finalized so we can compute a reasonable hash, |
but before header is written so we can update it to point to debug directory. */ |
struct pe_tdata *pe = pe_data (abfd); |
if (pe->build_id.after_write_object_contents != NULL) |
(*pe->build_id.after_write_object_contents) (abfd); |
} |
#endif |
/* Now write header. */ |
/* Now write them. */ |
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) |
return FALSE; |
4497,11 → 4460,11 |
void * area = bfd_alloc (abfd, size); |
if (!area) |
return NULL; |
return (NULL); |
if (bfd_seek (abfd, where, SEEK_SET) != 0 |
|| bfd_bread (area, size, abfd) != size) |
return NULL; |
return area; |
return (NULL); |
return (area); |
} |
/* |
4535,8 → 4498,6 |
const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); |
const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); |
if (s1 == NULL || s2 == NULL) |
return 0; |
if (s1->symbol.value < s2->symbol.value) |
return -1; |
else if (s1->symbol.value > s2->symbol.value) |
4554,11 → 4515,9 |
unsigned int counter; |
alent *cache_ptr; |
bfd_vma prev_offset = 0; |
bfd_boolean ordered = TRUE; |
int ordered = 1; |
unsigned int nbr_func; |
LINENO *src; |
bfd_boolean have_func; |
bfd_boolean ret = TRUE; |
BFD_ASSERT (asect->lineno == NULL); |
4581,67 → 4540,40 |
asect->lineno = lineno_cache; |
src = native_lineno; |
nbr_func = 0; |
have_func = FALSE; |
for (counter = 0; counter < asect->lineno_count; counter++, src++) |
for (counter = 0; counter < asect->lineno_count; counter++) |
{ |
struct internal_lineno dst; |
bfd_coff_swap_lineno_in (abfd, src, &dst); |
cache_ptr->line_number = dst.l_lnno; |
/* Appease memory checkers that get all excited about |
uninitialised memory when copying alents if u.offset is |
larger than u.sym. (64-bit BFD on 32-bit host.) */ |
memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); |
if (cache_ptr->line_number == 0) |
{ |
combined_entry_type * ent; |
bfd_vma symndx; |
bfd_boolean warned; |
bfd_signed_vma symndx; |
coff_symbol_type *sym; |
have_func = FALSE; |
nbr_func++; |
warned = FALSE; |
symndx = dst.l_addr.l_symndx; |
if (symndx >= obj_raw_syment_count (abfd)) |
if (symndx < 0 |
|| (bfd_vma) symndx >= obj_raw_syment_count (abfd)) |
{ |
(*_bfd_error_handler) |
(_("%B: warning: illegal symbol index 0x%lx in line number entry %d"), |
abfd, (long) symndx, counter); |
cache_ptr->line_number = -1; |
ret = FALSE; |
continue; |
(_("%B: warning: illegal symbol index %ld in line numbers"), |
abfd, (long) symndx); |
symndx = 0; |
warned = TRUE; |
} |
ent = obj_raw_syments (abfd) + symndx; |
/* FIXME: We should not be casting between ints and |
pointers like this. */ |
if (! ent->is_sym) |
{ |
(*_bfd_error_handler) |
(_("%B: warning: illegal symbol index 0x%lx in line number entry %d"), |
abfd, (long) symndx, counter); |
cache_ptr->line_number = -1; |
ret = FALSE; |
continue; |
} |
sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); |
/* PR 17512 file: 078-10659-0.004 */ |
if (sym < obj_symbols (abfd) |
|| sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) |
{ |
(*_bfd_error_handler) |
(_("%B: warning: illegal symbol in line number entry %d"), |
abfd, counter); |
cache_ptr->line_number = -1; |
ret = FALSE; |
continue; |
} |
have_func = TRUE; |
nbr_func++; |
sym = ((coff_symbol_type *) |
((symndx + obj_raw_syments (abfd)) |
->u.syment._n._n_n._n_zeroes)); |
cache_ptr->u.sym = (asymbol *) sym; |
if (sym->lineno != NULL) |
if (sym->lineno != NULL && ! warned) |
(*_bfd_error_handler) |
(_("%B: warning: duplicate line number information for `%s'"), |
abfd, bfd_asymbol_name (&sym->symbol)); |
4648,21 → 4580,17 |
sym->lineno = cache_ptr; |
if (sym->symbol.value < prev_offset) |
ordered = FALSE; |
ordered = 0; |
prev_offset = sym->symbol.value; |
} |
else if (!have_func) |
/* Drop line information that has no associated function. |
PR 17521: file: 078-10659-0.004. */ |
continue; |
else |
cache_ptr->u.offset = (dst.l_addr.l_paddr |
- bfd_section_vma (abfd, asect)); |
cache_ptr->u.offset = dst.l_addr.l_paddr |
- bfd_section_vma (abfd, asect); |
cache_ptr++; |
src++; |
} |
asect->lineno_count = cache_ptr - lineno_cache; |
memset (cache_ptr, 0, sizeof (*cache_ptr)); |
cache_ptr->line_number = 0; |
bfd_release (abfd, native_lineno); |
/* On some systems (eg AIX5.3) the lineno table may not be sorted. */ |
4679,17 → 4607,15 |
alent **p = func_table; |
unsigned int i; |
for (i = 0; i < asect->lineno_count; i++) |
for (i = 0; i < counter; i++) |
if (lineno_cache[i].line_number == 0) |
*p++ = &lineno_cache[i]; |
BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); |
/* Sort by functions. */ |
qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); |
/* Create the new sorted table. */ |
amt = (bfd_size_type) asect->lineno_count * sizeof (alent); |
amt = ((bfd_size_type) asect->lineno_count + 1) * sizeof (alent); |
n_lineno_cache = (alent *) bfd_alloc (abfd, amt); |
if (n_lineno_cache != NULL) |
{ |
4700,29 → 4626,25 |
coff_symbol_type *sym; |
alent *old_ptr = func_table[i]; |
/* Update the function entry. */ |
sym = (coff_symbol_type *) old_ptr->u.sym; |
/* PR binutils/17512: Point the lineno to where |
this entry will be after the memcpy below. */ |
sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); |
/* Copy the function and line number entries. */ |
do |
/* Copy the function entry and update it. */ |
*n_cache_ptr = *old_ptr; |
sym = (coff_symbol_type *)n_cache_ptr->u.sym; |
sym->lineno = n_cache_ptr; |
n_cache_ptr++; |
old_ptr++; |
/* Copy the line number entries. */ |
while (old_ptr->line_number != 0) |
*n_cache_ptr++ = *old_ptr++; |
while (old_ptr->line_number != 0); |
} |
BFD_ASSERT ((bfd_size_type) (n_cache_ptr - n_lineno_cache) == (amt / sizeof (alent))); |
n_cache_ptr->line_number = 0; |
memcpy (lineno_cache, n_lineno_cache, amt); |
} |
else |
ret = FALSE; |
bfd_release (abfd, func_table); |
} |
else |
ret = FALSE; |
} |
return ret; |
return TRUE; |
} |
/* Slurp in the symbol table, converting it to generic form. Note |
4737,7 → 4659,6 |
unsigned int *table_ptr; |
bfd_size_type amt; |
unsigned int number_of_symbols = 0; |
bfd_boolean ret = TRUE; |
if (obj_symbols (abfd)) |
return TRUE; |
4755,7 → 4676,7 |
amt = obj_raw_syment_count (abfd); |
amt *= sizeof (unsigned int); |
table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); |
table_ptr = (unsigned int *) bfd_alloc (abfd, amt); |
if (table_ptr == NULL) |
return FALSE; |
4769,9 → 4690,8 |
{ |
combined_entry_type *src = native_symbols + this_index; |
table_ptr[this_index] = number_of_symbols; |
dst->symbol.the_bfd = abfd; |
dst->symbol.the_bfd = abfd; |
BFD_ASSERT (src->is_sym); |
dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); |
/* We use the native name field to point to the cached field. */ |
src->u.syment._n._n_n._n_zeroes = (bfd_hostptr_t) dst; |
4778,8 → 4698,6 |
dst->symbol.section = coff_section_from_bfd_index (abfd, |
src->u.syment.n_scnum); |
dst->symbol.flags = 0; |
/* PR 17512: file: 079-7098-0.001:0.1. */ |
dst->symbol.value = 0; |
dst->done_lineno = FALSE; |
switch (src->u.syment.n_sclass) |
5053,14 → 4971,13 |
#if defined(TIC80COFF) || defined(TICOFF) |
case C_UEXT: /* Tentative external definition. */ |
#endif |
case C_EXTLAB: /* External load time label. */ |
case C_HIDDEN: /* Ext symbol in dmert public lib. */ |
default: |
(*_bfd_error_handler) |
(_("%B: Unrecognized storage class %d for %s symbol `%s'"), |
abfd, src->u.syment.n_sclass, |
dst->symbol.section->name, dst->symbol.name); |
ret = FALSE; |
case C_EXTLAB: /* External load time label. */ |
case C_HIDDEN: /* Ext symbol in dmert public lib. */ |
dst->symbol.flags = BSF_DEBUGGING; |
dst->symbol.value = (src->u.syment.n_value); |
break; |
5067,9 → 4984,9 |
} |
dst->native = src; |
dst->symbol.udata.i = 0; |
dst->lineno = NULL; |
this_index += (src->u.syment.n_numaux) + 1; |
dst++; |
number_of_symbols++; |
5088,13 → 5005,12 |
p = abfd->sections; |
while (p) |
{ |
if (! coff_slurp_line_table (abfd, p)) |
return FALSE; |
coff_slurp_line_table (abfd, p); |
p = p->next; |
} |
} |
return ret; |
return TRUE; |
} |
/* Classify a COFF symbol. A couple of targets have globally visible |
5153,13 → 5069,13 |
if (syment->n_value == 0) |
{ |
asection *sec; |
char * name; |
char buf[SYMNMLEN + 1]; |
name = _bfd_coff_internal_syment_name (abfd, syment, buf) |
sec = coff_section_from_bfd_index (abfd, syment->n_scnum); |
if (sec != NULL && name != NULL |
&& (strcmp (bfd_get_section_name (abfd, sec), name) == 0)) |
if (sec != NULL |
&& (strcmp (bfd_get_section_name (abfd, sec), |
_bfd_coff_internal_syment_name (abfd, syment, buf)) |
== 0)) |
return COFF_SYMBOL_PE_SECTION; |
} |
#endif |
5228,9 → 5144,8 |
coffsym = (obj_symbols (abfd) \ |
+ (cache_ptr->sym_ptr_ptr - symbols)); \ |
else if (ptr) \ |
coffsym = coff_symbol_from (ptr); \ |
coffsym = coff_symbol_from (abfd, ptr); \ |
if (coffsym != NULL \ |
&& coffsym->native->is_sym \ |
&& coffsym->native->u.syment.n_scnum == 0) \ |
cache_ptr->addend = 0; \ |
else if (ptr && bfd_asymbol_bfd (ptr) == abfd \ |
5353,7 → 5268,7 |
static reloc_howto_type * |
coff_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED, |
asection *sec ATTRIBUTE_UNUSED, |
struct internal_reloc *rel ATTRIBUTE_UNUSED, |
struct internal_reloc *rel, |
struct coff_link_hash_entry *h ATTRIBUTE_UNUSED, |
struct internal_syment *sym ATTRIBUTE_UNUSED, |
bfd_vma *addendp ATTRIBUTE_UNUSED) |
5445,6 → 5360,10 |
} |
#endif |
#ifndef coff_bfd_link_hash_table_free |
#define coff_bfd_link_hash_table_free _bfd_generic_link_hash_table_free |
#endif |
/* If coff_relocate_section is defined, we can use the optimized COFF |
backend linker. Otherwise we must continue to use the old linker. */ |
5578,7 → 5497,6 |
#else |
2, |
#endif |
32768, |
coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in, |
coff_SWAP_reloc_in, coff_bad_format_hook, coff_set_arch_mach_hook, |
coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook, |
5619,7 → 5537,6 |
#else |
2, |
#endif |
32768, |
coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in, |
coff_SWAP_reloc_in, ticoff0_bad_format_hook, coff_set_arch_mach_hook, |
coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook, |
5661,7 → 5578,6 |
#else |
2, |
#endif |
32768, |
coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in, |
coff_SWAP_reloc_in, ticoff1_bad_format_hook, coff_set_arch_mach_hook, |
coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook, |
5675,253 → 5591,6 |
}; |
#endif |
#ifdef COFF_WITH_PE_BIGOBJ |
/* The UID for bigobj files. */ |
static const char header_bigobj_classid[16] = |
{ |
0xC7, 0xA1, 0xBA, 0xD1, |
0xEE, 0xBA, |
0xa9, 0x4b, |
0xAF, 0x20, |
0xFA, 0xF6, 0x6A, 0xA4, 0xDC, 0xB8 |
}; |
/* Swap routines. */ |
static void |
coff_bigobj_swap_filehdr_in (bfd * abfd, void * src, void * dst) |
{ |
struct external_ANON_OBJECT_HEADER_BIGOBJ *filehdr_src = |
(struct external_ANON_OBJECT_HEADER_BIGOBJ *) src; |
struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; |
filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->Machine); |
filehdr_dst->f_nscns = H_GET_32 (abfd, filehdr_src->NumberOfSections); |
filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->TimeDateStamp); |
filehdr_dst->f_symptr = |
GET_FILEHDR_SYMPTR (abfd, filehdr_src->PointerToSymbolTable); |
filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->NumberOfSymbols); |
filehdr_dst->f_opthdr = 0; |
filehdr_dst->f_flags = 0; |
/* Check other magic numbers. */ |
if (H_GET_16 (abfd, filehdr_src->Sig1) != IMAGE_FILE_MACHINE_UNKNOWN |
|| H_GET_16 (abfd, filehdr_src->Sig2) != 0xffff |
|| H_GET_16 (abfd, filehdr_src->Version) != 2 |
|| memcmp (filehdr_src->ClassID, header_bigobj_classid, 16) != 0) |
filehdr_dst->f_opthdr = 0xffff; |
/* Note that CLR metadata are ignored. */ |
} |
static unsigned int |
coff_bigobj_swap_filehdr_out (bfd *abfd, void * in, void * out) |
{ |
struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in; |
struct external_ANON_OBJECT_HEADER_BIGOBJ *filehdr_out = |
(struct external_ANON_OBJECT_HEADER_BIGOBJ *) out; |
memset (filehdr_out, 0, sizeof (*filehdr_out)); |
H_PUT_16 (abfd, IMAGE_FILE_MACHINE_UNKNOWN, filehdr_out->Sig1); |
H_PUT_16 (abfd, 0xffff, filehdr_out->Sig2); |
H_PUT_16 (abfd, 2, filehdr_out->Version); |
memcpy (filehdr_out->ClassID, header_bigobj_classid, 16); |
H_PUT_16 (abfd, filehdr_in->f_magic, filehdr_out->Machine); |
H_PUT_32 (abfd, filehdr_in->f_nscns, filehdr_out->NumberOfSections); |
H_PUT_32 (abfd, filehdr_in->f_timdat, filehdr_out->TimeDateStamp); |
PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr, |
filehdr_out->PointerToSymbolTable); |
H_PUT_32 (abfd, filehdr_in->f_nsyms, filehdr_out->NumberOfSymbols); |
return bfd_coff_filhsz (abfd); |
} |
static void |
coff_bigobj_swap_sym_in (bfd * abfd, void * ext1, void * in1) |
{ |
SYMENT_BIGOBJ *ext = (SYMENT_BIGOBJ *) ext1; |
struct internal_syment *in = (struct internal_syment *) in1; |
if (ext->e.e_name[0] == 0) |
{ |
in->_n._n_n._n_zeroes = 0; |
in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e.e.e_offset); |
} |
else |
{ |
#if SYMNMLEN != E_SYMNMLEN |
#error we need to cope with truncating or extending SYMNMLEN |
#else |
memcpy (in->_n._n_name, ext->e.e_name, SYMNMLEN); |
#endif |
} |
in->n_value = H_GET_32 (abfd, ext->e_value); |
in->n_scnum = H_GET_32 (abfd, ext->e_scnum); |
in->n_type = H_GET_16 (abfd, ext->e_type); |
in->n_sclass = H_GET_8 (abfd, ext->e_sclass); |
in->n_numaux = H_GET_8 (abfd, ext->e_numaux); |
} |
static unsigned int |
coff_bigobj_swap_sym_out (bfd * abfd, void * inp, void * extp) |
{ |
struct internal_syment *in = (struct internal_syment *) inp; |
SYMENT_BIGOBJ *ext = (SYMENT_BIGOBJ *) extp; |
if (in->_n._n_name[0] == 0) |
{ |
H_PUT_32 (abfd, 0, ext->e.e.e_zeroes); |
H_PUT_32 (abfd, in->_n._n_n._n_offset, ext->e.e.e_offset); |
} |
else |
{ |
#if SYMNMLEN != E_SYMNMLEN |
#error we need to cope with truncating or extending SYMNMLEN |
#else |
memcpy (ext->e.e_name, in->_n._n_name, SYMNMLEN); |
#endif |
} |
H_PUT_32 (abfd, in->n_value, ext->e_value); |
H_PUT_32 (abfd, in->n_scnum, ext->e_scnum); |
H_PUT_16 (abfd, in->n_type, ext->e_type); |
H_PUT_8 (abfd, in->n_sclass, ext->e_sclass); |
H_PUT_8 (abfd, in->n_numaux, ext->e_numaux); |
return SYMESZ_BIGOBJ; |
} |
static void |
coff_bigobj_swap_aux_in (bfd *abfd, |
void * ext1, |
int type, |
int in_class, |
int indx, |
int numaux, |
void * in1) |
{ |
AUXENT_BIGOBJ *ext = (AUXENT_BIGOBJ *) ext1; |
union internal_auxent *in = (union internal_auxent *) in1; |
switch (in_class) |
{ |
case C_FILE: |
if (numaux > 1) |
{ |
if (indx == 0) |
memcpy (in->x_file.x_fname, ext->File.Name, |
numaux * sizeof (AUXENT_BIGOBJ)); |
} |
else |
memcpy (in->x_file.x_fname, ext->File.Name, sizeof (ext->File.Name)); |
break; |
case C_STAT: |
case C_LEAFSTAT: |
case C_HIDDEN: |
if (type == T_NULL) |
{ |
in->x_scn.x_scnlen = H_GET_32 (abfd, ext->Section.Length); |
in->x_scn.x_nreloc = |
H_GET_16 (abfd, ext->Section.NumberOfRelocations); |
in->x_scn.x_nlinno = |
H_GET_16 (abfd, ext->Section.NumberOfLinenumbers); |
in->x_scn.x_checksum = H_GET_32 (abfd, ext->Section.Checksum); |
in->x_scn.x_associated = H_GET_16 (abfd, ext->Section.Number) |
| (H_GET_16 (abfd, ext->Section.HighNumber) << 16); |
in->x_scn.x_comdat = H_GET_8 (abfd, ext->Section.Selection); |
return; |
} |
break; |
default: |
in->x_sym.x_tagndx.l = H_GET_32 (abfd, ext->Sym.WeakDefaultSymIndex); |
/* Characteristics is ignored. */ |
break; |
} |
} |
static unsigned int |
coff_bigobj_swap_aux_out (bfd * abfd, |
void * inp, |
int type, |
int in_class, |
int indx ATTRIBUTE_UNUSED, |
int numaux ATTRIBUTE_UNUSED, |
void * extp) |
{ |
union internal_auxent * in = (union internal_auxent *) inp; |
AUXENT_BIGOBJ *ext = (AUXENT_BIGOBJ *) extp; |
memset (ext, 0, AUXESZ); |
switch (in_class) |
{ |
case C_FILE: |
memcpy (ext->File.Name, in->x_file.x_fname, sizeof (ext->File.Name)); |
return AUXESZ; |
case C_STAT: |
case C_LEAFSTAT: |
case C_HIDDEN: |
if (type == T_NULL) |
{ |
H_PUT_32 (abfd, in->x_scn.x_scnlen, ext->Section.Length); |
H_PUT_16 (abfd, in->x_scn.x_nreloc, |
ext->Section.NumberOfRelocations); |
H_PUT_16 (abfd, in->x_scn.x_nlinno, |
ext->Section.NumberOfLinenumbers); |
H_PUT_32 (abfd, in->x_scn.x_checksum, ext->Section.Checksum); |
H_PUT_16 (abfd, in->x_scn.x_associated & 0xffff, |
ext->Section.Number); |
H_PUT_16 (abfd, (in->x_scn.x_associated >> 16), |
ext->Section.HighNumber); |
H_PUT_8 (abfd, in->x_scn.x_comdat, ext->Section.Selection); |
return AUXESZ; |
} |
break; |
} |
H_PUT_32 (abfd, in->x_sym.x_tagndx.l, ext->Sym.WeakDefaultSymIndex); |
H_PUT_32 (abfd, 1, ext->Sym.WeakSearchType); |
return AUXESZ; |
} |
static bfd_coff_backend_data bigobj_swap_table = |
{ |
coff_bigobj_swap_aux_in, coff_bigobj_swap_sym_in, coff_SWAP_lineno_in, |
coff_bigobj_swap_aux_out, coff_bigobj_swap_sym_out, |
coff_SWAP_lineno_out, coff_SWAP_reloc_out, |
coff_bigobj_swap_filehdr_out, coff_SWAP_aouthdr_out, |
coff_SWAP_scnhdr_out, |
FILHSZ_BIGOBJ, AOUTSZ, SCNHSZ, SYMESZ_BIGOBJ, AUXESZ_BIGOBJ, |
RELSZ, LINESZ, FILNMLEN_BIGOBJ, |
TRUE, |
COFF_DEFAULT_LONG_SECTION_NAMES, |
COFF_DEFAULT_SECTION_ALIGNMENT_POWER, |
FALSE, |
2, |
1U << 31, |
coff_bigobj_swap_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in, |
coff_SWAP_reloc_in, coff_bad_format_hook, coff_set_arch_mach_hook, |
coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook, |
coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook, |
coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate, |
coff_classify_symbol, coff_compute_section_file_positions, |
coff_start_final_link, coff_relocate_section, coff_rtype_to_howto, |
coff_adjust_symndx, coff_link_add_one_symbol, |
coff_link_output_has_begun, coff_final_link_postscript, |
bfd_pe_print_pdata /* huh */ |
}; |
#endif /* COFF_WITH_PE_BIGOBJ */ |
#ifndef coff_close_and_cleanup |
#define coff_close_and_cleanup _bfd_generic_close_and_cleanup |
#endif |
5997,7 → 5666,7 |
#endif |
#ifndef coff_bfd_gc_sections |
#define coff_bfd_gc_sections bfd_coff_gc_sections |
#define coff_bfd_gc_sections bfd_generic_gc_sections |
#endif |
#ifndef coff_bfd_lookup_section_flags |
/contrib/toolchain/binutils/bfd/coffgen.c |
---|
1,5 → 1,7 |
/* Support for the generic parts of COFF, for BFD. |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 |
Free Software Foundation, Inc. |
Written by Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
84,8 → 86,9 |
strings = _bfd_coff_read_string_table (abfd); |
if (strings == NULL) |
return FALSE; |
if ((bfd_size_type)(strindex + 2) >= obj_coff_strings_len (abfd)) |
return FALSE; |
/* FIXME: For extra safety, we should make sure that |
strindex does not run us past the end, but right now we |
don't know the length of the string table. */ |
strings += strindex; |
name = (char *) bfd_alloc (abfd, |
(bfd_size_type) strlen (strings) + 1 + 1); |
146,9 → 149,8 |
/* Compress/decompress DWARF debug sections with names: .debug_* and |
.zdebug_*, after the section flags is set. */ |
if ((flags & SEC_DEBUGGING) |
&& strlen (name) > 7 |
&& ((name[1] == 'd' && name[6] == '_') |
|| (strlen (name) > 8 && name[1] == 'z' && name[7] == '_'))) |
|| (name[1] == 'z' && name[7] == '_'))) |
{ |
enum { nothing, compress, decompress } action = nothing; |
char *new_name = NULL; |
178,8 → 180,6 |
abfd, name); |
return FALSE; |
} |
if (return_section->compress_status == COMPRESS_SECTION_DONE) |
{ |
if (name[1] != 'z') |
{ |
unsigned int len = strlen (name); |
191,7 → 191,6 |
new_name[1] = 'z'; |
memcpy (new_name + 2, name + 1, len); |
} |
} |
break; |
case decompress: |
if (!bfd_init_section_decompress_status (abfd, return_section)) |
369,10 → 368,6 |
bfd_release (abfd, opthdr); |
return NULL; |
} |
/* PR 17512: file: 11056-1136-0.004. */ |
if (internal_f.f_opthdr < aoutsz) |
memset (((char *) opthdr) + internal_f.f_opthdr, 0, aoutsz - internal_f.f_opthdr); |
bfd_coff_swap_aouthdr_in (abfd, opthdr, (void *) &internal_a); |
bfd_release (abfd, opthdr); |
} |
471,11 → 466,6 |
if (strings == NULL) |
return NULL; |
} |
/* PR 17910: Only check for string overflow if the length has been set. |
Some DLLs, eg those produced by Visual Studio, may not set the length field. */ |
if (obj_coff_strings_len (abfd) > 0 |
&& sym->_n._n_n._n_offset >= obj_coff_strings_len (abfd)) |
return NULL; |
return strings + sym->_n._n_n._n_offset; |
} |
} |
639,6 → 629,22 |
return total; |
} |
/* Takes a bfd and a symbol, returns a pointer to the coff specific |
area of the symbol if there is one. */ |
coff_symbol_type * |
coff_symbol_from (bfd *ignore_abfd ATTRIBUTE_UNUSED, |
asymbol *symbol) |
{ |
if (!bfd_family_coff (bfd_asymbol_bfd (symbol))) |
return (coff_symbol_type *) NULL; |
if (bfd_asymbol_bfd (symbol)->tdata.coff_obj_data == (coff_data_type *) NULL) |
return (coff_symbol_type *) NULL; |
return (coff_symbol_type *) symbol; |
} |
static void |
fixup_symbol_value (bfd *abfd, |
coff_symbol_type *coff_symbol_ptr, |
755,9 → 761,7 |
for (symbol_index = 0; symbol_index < symbol_count; symbol_index++) |
{ |
coff_symbol_type *coff_symbol_ptr; |
coff_symbol_ptr = coff_symbol_from (symbol_ptr_ptr[symbol_index]); |
coff_symbol_type *coff_symbol_ptr = coff_symbol_from (bfd_ptr, symbol_ptr_ptr[symbol_index]); |
symbol_ptr_ptr[symbol_index]->udata.i = symbol_index; |
if (coff_symbol_ptr && coff_symbol_ptr->native) |
{ |
764,7 → 768,6 |
combined_entry_type *s = coff_symbol_ptr->native; |
int i; |
BFD_ASSERT (s->is_sym); |
if (s->u.syment.n_sclass == C_FILE) |
{ |
if (last_file != NULL) |
801,15 → 804,14 |
for (symbol_index = 0; symbol_index < symbol_count; symbol_index++) |
{ |
coff_symbol_type *coff_symbol_ptr; |
coff_symbol_type *coff_symbol_ptr = |
coff_symbol_from (bfd_ptr, symbol_ptr_ptr[symbol_index]); |
coff_symbol_ptr = coff_symbol_from (symbol_ptr_ptr[symbol_index]); |
if (coff_symbol_ptr && coff_symbol_ptr->native) |
{ |
int i; |
combined_entry_type *s = coff_symbol_ptr->native; |
BFD_ASSERT (s->is_sym); |
if (s->fix_value) |
{ |
/* FIXME: We should use a union here. */ |
833,8 → 835,6 |
for (i = 0; i < s->u.syment.n_numaux; i++) |
{ |
combined_entry_type *a = s + i + 1; |
BFD_ASSERT (! a->is_sym); |
if (a->fix_tag) |
{ |
a->u.auxent.x_sym.x_tagndx.l = |
878,7 → 878,6 |
} |
name_length = strlen (name); |
BFD_ASSERT (native->is_sym); |
if (native->u.syment.n_sclass == C_FILE |
&& native->u.syment.n_numaux > 0) |
{ |
894,7 → 893,6 |
else |
strncpy (native->u.syment._n._n_name, ".file", SYMNMLEN); |
BFD_ASSERT (! (native + 1)->is_sym); |
auxent = &(native + 1)->u.auxent; |
filnmlen = bfd_coff_filnmlen (abfd); |
997,8 → 995,6 |
void * buf; |
bfd_size_type symesz; |
BFD_ASSERT (native->is_sym); |
if (native->u.syment.n_sclass == C_FILE) |
symbol->flags |= BSF_DEBUGGING; |
1039,7 → 1035,6 |
return FALSE; |
for (j = 0; j < native->u.syment.n_numaux; j++) |
{ |
BFD_ASSERT (! (native + j + 1)->is_sym); |
bfd_coff_swap_aux_out (abfd, |
&((native + j + 1)->u.auxent), |
type, n_sclass, (int) j, |
1089,8 → 1084,6 |
return TRUE; |
} |
native = dummy; |
native->is_sym = TRUE; |
native[1].is_sym = FALSE; |
native->u.syment.n_type = T_NULL; |
native->u.syment.n_flags = 0; |
native->u.syment.n_numaux = 0; |
1131,7 → 1124,7 |
/* Copy the any flags from the file header into the symbol. |
FIXME: Why? */ |
{ |
coff_symbol_type *c = coff_symbol_from (symbol); |
coff_symbol_type *c = coff_symbol_from (abfd, symbol); |
if (c != (coff_symbol_type *) NULL) |
native->u.syment.n_flags = bfd_asymbol_bfd (&c->symbol)->flags; |
} |
1176,7 → 1169,6 |
return TRUE; |
} |
BFD_ASSERT (native->is_sym); |
/* If this symbol has an associated line number, we must store the |
symbol index in the line number field. We also tag the auxent to |
point to the right place in the lineno table. */ |
1263,7 → 1255,7 |
for (p = abfd->outsymbols, i = 0; i < limit; i++, p++) |
{ |
asymbol *symbol = *p; |
coff_symbol_type *c_symbol = coff_symbol_from (symbol); |
coff_symbol_type *c_symbol = coff_symbol_from (abfd, symbol); |
if (c_symbol == (coff_symbol_type *) NULL |
|| c_symbol->native == (combined_entry_type *) NULL) |
1286,7 → 1278,6 |
symbol which has no associated section and we do not have to |
worry about this, all we need to know is that it is local. */ |
current_error_handler = bfd_set_error_handler (null_error_handler); |
BFD_ASSERT (c_symbol->native->is_sym); |
sym_class = bfd_coff_classify_symbol (abfd, |
&c_symbol->native->u.syment); |
(void) bfd_set_error_handler (current_error_handler); |
1363,7 → 1354,7 |
{ |
asymbol *q = *p; |
size_t name_length = strlen (q->name); |
coff_symbol_type *c_symbol = coff_symbol_from (q); |
coff_symbol_type *c_symbol = coff_symbol_from (abfd, q); |
size_t maxlen; |
/* Figure out whether the symbol name should go in the string |
1379,9 → 1370,6 |
file name, nor does it go in the .debug section. */ |
maxlen = bfd_coff_force_symnames_in_strings (abfd) ? 0 : SYMNMLEN; |
else if (! c_symbol->native->is_sym) |
maxlen = bfd_coff_force_symnames_in_strings (abfd) ? 0 : SYMNMLEN; |
else if (bfd_coff_symname_in_debug (abfd, |
&c_symbol->native->u.syment)) |
/* This symbol name is in the XCOFF .debug section. |
1472,7 → 1460,6 |
{ |
/* Found a linenumber entry, output. */ |
struct internal_lineno out; |
memset ((void *) & out, 0, sizeof (out)); |
out.l_lnno = 0; |
out.l_addr.l_symndx = l->u.offset; |
1520,7 → 1507,6 |
unsigned int type = symbol->u.syment.n_type; |
unsigned int n_sclass = symbol->u.syment.n_sclass; |
BFD_ASSERT (symbol->is_sym); |
if (coff_backend_info (abfd)->_bfd_coff_pointerize_aux_hook) |
{ |
if ((*coff_backend_info (abfd)->_bfd_coff_pointerize_aux_hook) |
1534,7 → 1520,6 |
if (n_sclass == C_FILE) |
return; |
BFD_ASSERT (! auxent->is_sym); |
/* Otherwise patch up. */ |
#define N_TMASK coff_data (abfd)->local_n_tmask |
#define N_BTSHFT coff_data (abfd)->local_n_btshft |
1562,7 → 1547,7 |
we didn't want to go to the trouble until someone needed it. */ |
static char * |
build_debug_section (bfd *abfd, asection ** sect_return) |
build_debug_section (bfd *abfd) |
{ |
char *debug_section; |
file_ptr position; |
1590,8 → 1575,6 |
|| bfd_bread (debug_section, sec_size, abfd) != sec_size |
|| bfd_seek (abfd, position, SEEK_SET) != 0) |
return NULL; |
* sect_return = sect; |
return debug_section; |
} |
1654,9 → 1637,7 |
/* Read in the external strings. The strings are not loaded until |
they are needed. This is because we have no simple way of |
detecting a missing string table in an archive. If the strings |
are loaded then the STRINGS and STRINGS_LEN fields in the |
coff_tdata structure will be set. */ |
detecting a missing string table in an archive. */ |
const char * |
_bfd_coff_read_string_table (bfd *abfd) |
1706,16 → 1687,10 |
return NULL; |
} |
strings = (char *) bfd_malloc (strsize + 1); |
strings = (char *) bfd_malloc (strsize); |
if (strings == NULL) |
return NULL; |
/* PR 17521 file: 079-54929-0.004. |
A corrupt file could contain an index that points into the first |
STRING_SIZE_SIZE bytes of the string table, so make sure that |
they are zero. */ |
memset (strings, 0, STRING_SIZE_SIZE); |
if (bfd_bread (strings + STRING_SIZE_SIZE, strsize - STRING_SIZE_SIZE, abfd) |
!= strsize - STRING_SIZE_SIZE) |
{ |
1724,9 → 1699,7 |
} |
obj_coff_strings (abfd) = strings; |
obj_coff_strings_len (abfd) = strsize; |
/* Terminate the string table, just in case. */ |
strings[strsize] = 0; |
return strings; |
} |
1746,7 → 1719,6 |
{ |
free (obj_coff_strings (abfd)); |
obj_coff_strings (abfd) = NULL; |
obj_coff_strings_len (abfd) = 0; |
} |
return TRUE; |
} |
1767,16 → 1739,12 |
char *raw_src; |
char *raw_end; |
const char *string_table = NULL; |
asection * debug_sec = NULL; |
char *debug_sec_data = NULL; |
char *debug_section = NULL; |
bfd_size_type size; |
if (obj_raw_syments (abfd) != NULL) |
return obj_raw_syments (abfd); |
if (! _bfd_coff_get_external_symbols (abfd)) |
return NULL; |
size = obj_raw_syment_count (abfd) * sizeof (combined_entry_type); |
internal = (combined_entry_type *) bfd_zalloc (abfd, size); |
if (internal == NULL && size != 0) |
1783,6 → 1751,9 |
return NULL; |
internal_end = internal + obj_raw_syment_count (abfd); |
if (! _bfd_coff_get_external_symbols (abfd)) |
return NULL; |
raw_src = (char *) obj_coff_external_syms (abfd); |
/* Mark the end of the symbols. */ |
1797,35 → 1768,17 |
raw_src < raw_end; |
raw_src += symesz, internal_ptr++) |
{ |
unsigned int i; |
bfd_coff_swap_sym_in (abfd, (void *) raw_src, |
(void *) & internal_ptr->u.syment); |
symbol_ptr = internal_ptr; |
internal_ptr->is_sym = TRUE; |
/* PR 17512: file: 1353-1166-0.004. */ |
if (symbol_ptr->u.syment.n_sclass == C_FILE |
&& symbol_ptr->u.syment.n_numaux > 0 |
&& raw_src + symesz + symbol_ptr->u.syment.n_numaux |
* symesz > raw_end) |
{ |
bfd_release (abfd, internal); |
return NULL; |
} |
for (i = 0; |
i < symbol_ptr->u.syment.n_numaux; |
i++) |
{ |
internal_ptr++; |
/* PR 17512: Prevent buffer overrun. */ |
if (internal_ptr >= internal_end) |
{ |
bfd_release (abfd, internal); |
return NULL; |
} |
raw_src += symesz; |
bfd_coff_swap_aux_in (abfd, (void *) raw_src, |
symbol_ptr->u.syment.n_type, |
1832,8 → 1785,6 |
symbol_ptr->u.syment.n_sclass, |
(int) i, symbol_ptr->u.syment.n_numaux, |
&(internal_ptr->u.auxent)); |
internal_ptr->is_sym = FALSE; |
coff_pointerize_aux (abfd, internal, symbol_ptr, i, |
internal_ptr); |
} |
1847,18 → 1798,12 |
for (internal_ptr = internal; internal_ptr < internal_end; |
internal_ptr++) |
{ |
BFD_ASSERT (internal_ptr->is_sym); |
if (internal_ptr->u.syment.n_sclass == C_FILE |
&& internal_ptr->u.syment.n_numaux > 0) |
{ |
combined_entry_type * aux = internal_ptr + 1; |
/* Make a file symbol point to the name in the auxent, since |
the text ".file" is redundant. */ |
BFD_ASSERT (! aux->is_sym); |
if (aux->u.auxent.x_file.x_n.x_zeroes == 0) |
if ((internal_ptr + 1)->u.auxent.x_file.x_n.x_zeroes == 0) |
{ |
/* The filename is a long one, point into the string table. */ |
if (string_table == NULL) |
1868,12 → 1813,10 |
return NULL; |
} |
if ((bfd_size_type)(aux->u.auxent.x_file.x_n.x_offset) |
>= obj_coff_strings_len (abfd)) |
internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t) _("<corrupt>"); |
else |
internal_ptr->u.syment._n._n_n._n_offset = |
(bfd_hostptr_t) (string_table + (aux->u.auxent.x_file.x_n.x_offset)); |
((bfd_hostptr_t) |
(string_table |
+ (internal_ptr + 1)->u.auxent.x_file.x_n.x_offset)); |
} |
else |
{ |
1883,15 → 1826,15 |
if (internal_ptr->u.syment.n_numaux > 1 |
&& coff_data (abfd)->pe) |
internal_ptr->u.syment._n._n_n._n_offset = |
(bfd_hostptr_t) |
((bfd_hostptr_t) |
copy_name (abfd, |
aux->u.auxent.x_file.x_fname, |
internal_ptr->u.syment.n_numaux * symesz); |
(internal_ptr + 1)->u.auxent.x_file.x_fname, |
internal_ptr->u.syment.n_numaux * symesz)); |
else |
internal_ptr->u.syment._n._n_n._n_offset = |
((bfd_hostptr_t) |
copy_name (abfd, |
aux->u.auxent.x_file.x_fname, |
(internal_ptr + 1)->u.auxent.x_file.x_fname, |
(size_t) bfd_coff_filnmlen (abfd))); |
} |
} |
1928,10 → 1871,6 |
if (string_table == NULL) |
return NULL; |
} |
if (internal_ptr->u.syment._n._n_n._n_offset >= obj_coff_strings_len (abfd) |
|| string_table + internal_ptr->u.syment._n._n_n._n_offset < string_table) |
internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t) _("<corrupt>"); |
else |
internal_ptr->u.syment._n._n_n._n_offset = |
((bfd_hostptr_t) |
(string_table |
1940,23 → 1879,12 |
else |
{ |
/* Long name in debug section. Very similar. */ |
if (debug_sec_data == NULL) |
debug_sec_data = build_debug_section (abfd, & debug_sec); |
if (debug_sec_data != NULL) |
{ |
BFD_ASSERT (debug_sec != NULL); |
/* PR binutils/17512: Catch out of range offsets into the debug data. */ |
if (internal_ptr->u.syment._n._n_n._n_offset > debug_sec->size |
|| debug_sec_data + internal_ptr->u.syment._n._n_n._n_offset < debug_sec_data) |
internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t) _("<corrupt>"); |
else |
if (debug_section == NULL) |
debug_section = build_debug_section (abfd); |
internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t) |
(debug_sec_data + internal_ptr->u.syment._n._n_n._n_offset); |
(debug_section + internal_ptr->u.syment._n._n_n._n_offset); |
} |
else |
internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t) ""; |
} |
} |
internal_ptr += internal_ptr->u.syment.n_numaux; |
} |
1987,7 → 1915,7 |
if (new_symbol == NULL) |
return NULL; |
new_symbol->symbol.section = 0; |
new_symbol->native = NULL; |
new_symbol->native = 0; |
new_symbol->lineno = NULL; |
new_symbol->done_lineno = FALSE; |
new_symbol->symbol.the_bfd = abfd; |
2013,7 → 1941,6 |
new_symbol->native = (combined_entry_type *) bfd_zalloc (abfd, amt); |
if (!new_symbol->native) |
return NULL; |
new_symbol->native->is_sym = TRUE; |
new_symbol->symbol.section = bfd_abs_section_ptr; |
new_symbol->symbol.flags = BSF_DEBUGGING; |
new_symbol->lineno = NULL; |
2029,12 → 1956,81 |
bfd_symbol_info (symbol, ret); |
if (coffsymbol (symbol)->native != NULL |
&& coffsymbol (symbol)->native->fix_value |
&& coffsymbol (symbol)->native->is_sym) |
&& coffsymbol (symbol)->native->fix_value) |
ret->value = coffsymbol (symbol)->native->u.syment.n_value - |
(bfd_hostptr_t) obj_raw_syments (abfd); |
} |
/* Return the COFF syment for a symbol. */ |
bfd_boolean |
bfd_coff_get_syment (bfd *abfd, |
asymbol *symbol, |
struct internal_syment *psyment) |
{ |
coff_symbol_type *csym; |
csym = coff_symbol_from (abfd, symbol); |
if (csym == NULL || csym->native == NULL) |
{ |
bfd_set_error (bfd_error_invalid_operation); |
return FALSE; |
} |
*psyment = csym->native->u.syment; |
if (csym->native->fix_value) |
psyment->n_value = psyment->n_value - |
(bfd_hostptr_t) obj_raw_syments (abfd); |
/* FIXME: We should handle fix_line here. */ |
return TRUE; |
} |
/* Return the COFF auxent for a symbol. */ |
bfd_boolean |
bfd_coff_get_auxent (bfd *abfd, |
asymbol *symbol, |
int indx, |
union internal_auxent *pauxent) |
{ |
coff_symbol_type *csym; |
combined_entry_type *ent; |
csym = coff_symbol_from (abfd, symbol); |
if (csym == NULL |
|| csym->native == NULL |
|| indx >= csym->native->u.syment.n_numaux) |
{ |
bfd_set_error (bfd_error_invalid_operation); |
return FALSE; |
} |
ent = csym->native + indx + 1; |
*pauxent = ent->u.auxent; |
if (ent->fix_tag) |
pauxent->x_sym.x_tagndx.l = |
((combined_entry_type *) pauxent->x_sym.x_tagndx.p |
- obj_raw_syments (abfd)); |
if (ent->fix_end) |
pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l = |
((combined_entry_type *) pauxent->x_sym.x_fcnary.x_fcn.x_endndx.p |
- obj_raw_syments (abfd)); |
if (ent->fix_scnlen) |
pauxent->x_csect.x_scnlen.l = |
((combined_entry_type *) pauxent->x_csect.x_scnlen.p |
- obj_raw_syments (abfd)); |
return TRUE; |
} |
/* Print out information about COFF symbol. */ |
void |
2068,15 → 2064,6 |
fprintf (file, "[%3ld]", (long) (combined - root)); |
/* PR 17512: file: 079-33786-0.001:0.1. */ |
if (combined < obj_raw_syments (abfd) |
|| combined >= obj_raw_syments (abfd) + obj_raw_syment_count (abfd)) |
{ |
fprintf (file, _("<corrupt info> %s"), symbol->name); |
break; |
} |
BFD_ASSERT (combined->is_sym); |
if (! combined->fix_value) |
val = (bfd_vma) combined->u.syment.n_value; |
else |
2096,7 → 2083,6 |
combined_entry_type *auxp = combined + aux + 1; |
long tagndx; |
BFD_ASSERT (! auxp->is_sym); |
if (auxp->fix_tag) |
tagndx = auxp->u.auxent.x_sym.x_tagndx.p - root; |
else |
2171,11 → 2157,8 |
l++; |
while (l->line_number) |
{ |
if (l->line_number > 0) |
{ |
fprintf (file, "\n%4d : ", l->line_number); |
bfd_fprintf_vma (abfd, file, l->u.offset + symbol->section->vma); |
} |
l++; |
} |
} |
2210,13 → 2193,13 |
bfd_boolean |
coff_find_nearest_line_with_names (bfd *abfd, |
const struct dwarf_debug_section *debug_sections, |
asection *section, |
asymbol **symbols, |
asection *section, |
bfd_vma offset, |
const char **filename_ptr, |
const char **functionname_ptr, |
unsigned int *line_ptr, |
const struct dwarf_debug_section *debug_sections) |
unsigned int *line_ptr) |
{ |
bfd_boolean found; |
unsigned int i; |
2241,32 → 2224,13 |
return TRUE; |
/* Also try examining DWARF2 debugging information. */ |
if (_bfd_dwarf2_find_nearest_line (abfd, symbols, NULL, section, offset, |
if (_bfd_dwarf2_find_nearest_line (abfd, debug_sections, |
section, symbols, offset, |
filename_ptr, functionname_ptr, |
line_ptr, NULL, debug_sections, 0, |
line_ptr, NULL, 0, |
&coff_data(abfd)->dwarf2_find_line_info)) |
return TRUE; |
/* If the DWARF lookup failed, but there is DWARF information available |
then the problem might be that the file has been rebased. This tool |
changes the VMAs of all the sections, but it does not update the DWARF |
information. So try again, using a bias against the address sought. */ |
if (coff_data (abfd)->dwarf2_find_line_info != NULL) |
{ |
bfd_signed_vma bias; |
bias = _bfd_dwarf2_find_symbol_bias (symbols, |
& coff_data (abfd)->dwarf2_find_line_info); |
if (bias |
&& _bfd_dwarf2_find_nearest_line (abfd, symbols, NULL, section, |
offset + bias, |
filename_ptr, functionname_ptr, |
line_ptr, NULL, debug_sections, 0, |
&coff_data(abfd)->dwarf2_find_line_info)) |
return TRUE; |
} |
*filename_ptr = 0; |
*functionname_ptr = 0; |
*line_ptr = 0; |
2286,7 → 2250,6 |
pend = p + cof->raw_syment_count; |
while (p < pend) |
{ |
BFD_ASSERT (p->is_sym); |
if (p->u.syment.n_sclass == C_FILE) |
break; |
p += 1 + p->u.syment.n_numaux; |
2310,7 → 2273,6 |
p2 < pend; |
p2 += 1 + p2->u.syment.n_numaux) |
{ |
BFD_ASSERT (p2->is_sym); |
if (p2->u.syment.n_scnum > 0 |
&& (section |
== coff_section_from_bfd_index (abfd, |
2322,8 → 2284,6 |
break; |
} |
} |
if (p2 >= pend) |
break; |
file_addr = (bfd_vma) p2->u.syment.n_value; |
/* PR 11512: Include the section address of the function name symbol. */ |
2388,8 → 2348,6 |
if (coff->native) |
{ |
combined_entry_type *s = coff->native; |
BFD_ASSERT (s->is_sym); |
s = s + 1 + s->u.syment.n_numaux; |
/* In XCOFF a debugging symbol can follow the |
2402,7 → 2360,6 |
{ |
/* The linenumber is stored in the auxent. */ |
union internal_auxent *a = &((s + 1)->u.auxent); |
line_base = a->x_sym.x_misc.x_lnsz.x_lnno; |
*line_ptr = line_base; |
} |
2452,21 → 2409,37 |
bfd_boolean |
coff_find_nearest_line (bfd *abfd, |
asection *section, |
asymbol **symbols, |
bfd_vma offset, |
const char **filename_ptr, |
const char **functionname_ptr, |
unsigned int *line_ptr) |
{ |
return coff_find_nearest_line_with_names (abfd, dwarf_debug_sections, |
section, symbols, offset, |
filename_ptr, functionname_ptr, |
line_ptr); |
} |
bfd_boolean |
coff_find_nearest_line_discriminator (bfd *abfd, |
asection *section, |
asymbol **symbols, |
bfd_vma offset, |
const char **filename_ptr, |
const char **functionname_ptr, |
unsigned int *line_ptr, |
unsigned int *discriminator_ptr) |
unsigned int *discriminator) |
{ |
if (discriminator_ptr) |
*discriminator_ptr = 0; |
return coff_find_nearest_line_with_names (abfd, symbols, section, offset, |
*discriminator = 0; |
return coff_find_nearest_line_with_names (abfd, dwarf_debug_sections, |
section, symbols, offset, |
filename_ptr, functionname_ptr, |
line_ptr, dwarf_debug_sections); |
line_ptr); |
} |
bfd_boolean |
coff_find_inliner_info (bfd *abfd, |
const char **filename_ptr, |
2486,7 → 2459,7 |
{ |
size_t size; |
if (!bfd_link_relocatable (info)) |
if (!info->relocatable) |
size = bfd_coff_filhsz (abfd) + bfd_coff_aoutsz (abfd); |
else |
size = bfd_coff_filhsz (abfd); |
2504,7 → 2477,7 |
{ |
coff_symbol_type * csym; |
csym = coff_symbol_from (symbol); |
csym = coff_symbol_from (abfd, symbol); |
if (csym == NULL) |
{ |
bfd_set_error (bfd_error_invalid_operation); |
2524,7 → 2497,6 |
if (native == NULL) |
return FALSE; |
native->is_sym = TRUE; |
native->u.syment.n_type = T_NULL; |
native->u.syment.n_sclass = symbol_class; |
2560,6 → 2532,16 |
return TRUE; |
} |
struct coff_comdat_info * |
bfd_coff_get_comdat_section (bfd *abfd, struct bfd_section *sec) |
{ |
if (bfd_get_flavour (abfd) == bfd_target_coff_flavour |
&& coff_section_data (abfd, sec) != NULL) |
return coff_section_data (abfd, sec)->comdat; |
else |
return NULL; |
} |
bfd_boolean |
_bfd_coff_section_already_linked (bfd *abfd, |
asection *sec, |
2626,431 → 2608,3 |
info->callbacks->einfo (_("%F%P: already_linked_table: %E\n")); |
return FALSE; |
} |
/* Initialize COOKIE for input bfd ABFD. */ |
static bfd_boolean |
init_reloc_cookie (struct coff_reloc_cookie *cookie, |
struct bfd_link_info *info ATTRIBUTE_UNUSED, |
bfd *abfd) |
{ |
/* Sometimes the symbol table does not yet have been loaded here. */ |
bfd_coff_slurp_symbol_table (abfd); |
cookie->abfd = abfd; |
cookie->sym_hashes = obj_coff_sym_hashes (abfd); |
cookie->symbols = obj_symbols (abfd); |
return TRUE; |
} |
/* Free the memory allocated by init_reloc_cookie, if appropriate. */ |
static void |
fini_reloc_cookie (struct coff_reloc_cookie *cookie ATTRIBUTE_UNUSED, |
bfd *abfd ATTRIBUTE_UNUSED) |
{ |
/* Nothing to do. */ |
} |
/* Initialize the relocation information in COOKIE for input section SEC |
of input bfd ABFD. */ |
static bfd_boolean |
init_reloc_cookie_rels (struct coff_reloc_cookie *cookie, |
struct bfd_link_info *info ATTRIBUTE_UNUSED, |
bfd *abfd, |
asection *sec) |
{ |
if (sec->reloc_count == 0) |
{ |
cookie->rels = NULL; |
cookie->relend = NULL; |
cookie->rel = NULL; |
return TRUE; |
} |
cookie->rels = _bfd_coff_read_internal_relocs (abfd, sec, FALSE, NULL, 0, NULL); |
if (cookie->rels == NULL) |
return FALSE; |
cookie->rel = cookie->rels; |
cookie->relend = (cookie->rels + sec->reloc_count); |
return TRUE; |
} |
/* Free the memory allocated by init_reloc_cookie_rels, |
if appropriate. */ |
static void |
fini_reloc_cookie_rels (struct coff_reloc_cookie *cookie, |
asection *sec) |
{ |
if (cookie->rels && coff_section_data (NULL, sec)->relocs != cookie->rels) |
free (cookie->rels); |
} |
/* Initialize the whole of COOKIE for input section SEC. */ |
static bfd_boolean |
init_reloc_cookie_for_section (struct coff_reloc_cookie *cookie, |
struct bfd_link_info *info, |
asection *sec) |
{ |
if (!init_reloc_cookie (cookie, info, sec->owner)) |
return FALSE; |
if (!init_reloc_cookie_rels (cookie, info, sec->owner, sec)) |
{ |
fini_reloc_cookie (cookie, sec->owner); |
return FALSE; |
} |
return TRUE; |
} |
/* Free the memory allocated by init_reloc_cookie_for_section, |
if appropriate. */ |
static void |
fini_reloc_cookie_for_section (struct coff_reloc_cookie *cookie, |
asection *sec) |
{ |
fini_reloc_cookie_rels (cookie, sec); |
fini_reloc_cookie (cookie, sec->owner); |
} |
static asection * |
_bfd_coff_gc_mark_hook (asection *sec, |
struct bfd_link_info *info ATTRIBUTE_UNUSED, |
struct internal_reloc *rel ATTRIBUTE_UNUSED, |
struct coff_link_hash_entry *h, |
struct internal_syment *sym) |
{ |
if (h != NULL) |
{ |
switch (h->root.type) |
{ |
case bfd_link_hash_defined: |
case bfd_link_hash_defweak: |
return h->root.u.def.section; |
case bfd_link_hash_common: |
return h->root.u.c.p->section; |
case bfd_link_hash_undefined: |
case bfd_link_hash_undefweak: |
default: |
break; |
} |
return NULL; |
} |
return coff_section_from_bfd_index (sec->owner, sym->n_scnum); |
} |
/* COOKIE->rel describes a relocation against section SEC, which is |
a section we've decided to keep. Return the section that contains |
the relocation symbol, or NULL if no section contains it. */ |
static asection * |
_bfd_coff_gc_mark_rsec (struct bfd_link_info *info, asection *sec, |
coff_gc_mark_hook_fn gc_mark_hook, |
struct coff_reloc_cookie *cookie) |
{ |
struct coff_link_hash_entry *h; |
h = cookie->sym_hashes[cookie->rel->r_symndx]; |
if (h != NULL) |
{ |
while (h->root.type == bfd_link_hash_indirect |
|| h->root.type == bfd_link_hash_warning) |
h = (struct coff_link_hash_entry *) h->root.u.i.link; |
return (*gc_mark_hook) (sec, info, cookie->rel, h, NULL); |
} |
return (*gc_mark_hook) (sec, info, cookie->rel, NULL, |
&(cookie->symbols |
+ obj_convert (sec->owner)[cookie->rel->r_symndx])->native->u.syment); |
} |
static bfd_boolean _bfd_coff_gc_mark |
(struct bfd_link_info *, asection *, coff_gc_mark_hook_fn); |
/* COOKIE->rel describes a relocation against section SEC, which is |
a section we've decided to keep. Mark the section that contains |
the relocation symbol. */ |
static bfd_boolean |
_bfd_coff_gc_mark_reloc (struct bfd_link_info *info, |
asection *sec, |
coff_gc_mark_hook_fn gc_mark_hook, |
struct coff_reloc_cookie *cookie) |
{ |
asection *rsec; |
rsec = _bfd_coff_gc_mark_rsec (info, sec, gc_mark_hook, cookie); |
if (rsec && !rsec->gc_mark) |
{ |
if (bfd_get_flavour (rsec->owner) != bfd_target_coff_flavour) |
rsec->gc_mark = 1; |
else if (!_bfd_coff_gc_mark (info, rsec, gc_mark_hook)) |
return FALSE; |
} |
return TRUE; |
} |
/* The mark phase of garbage collection. For a given section, mark |
it and any sections in this section's group, and all the sections |
which define symbols to which it refers. */ |
static bfd_boolean |
_bfd_coff_gc_mark (struct bfd_link_info *info, |
asection *sec, |
coff_gc_mark_hook_fn gc_mark_hook) |
{ |
bfd_boolean ret = TRUE; |
sec->gc_mark = 1; |
/* Look through the section relocs. */ |
if ((sec->flags & SEC_RELOC) != 0 |
&& sec->reloc_count > 0) |
{ |
struct coff_reloc_cookie cookie; |
if (!init_reloc_cookie_for_section (&cookie, info, sec)) |
ret = FALSE; |
else |
{ |
for (; cookie.rel < cookie.relend; cookie.rel++) |
{ |
if (!_bfd_coff_gc_mark_reloc (info, sec, gc_mark_hook, &cookie)) |
{ |
ret = FALSE; |
break; |
} |
} |
fini_reloc_cookie_for_section (&cookie, sec); |
} |
} |
return ret; |
} |
static bfd_boolean |
_bfd_coff_gc_mark_extra_sections (struct bfd_link_info *info, |
coff_gc_mark_hook_fn mark_hook ATTRIBUTE_UNUSED) |
{ |
bfd *ibfd; |
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next) |
{ |
asection *isec; |
bfd_boolean some_kept; |
if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour) |
continue; |
/* Ensure all linker created sections are kept, and see whether |
any other section is already marked. */ |
some_kept = FALSE; |
for (isec = ibfd->sections; isec != NULL; isec = isec->next) |
{ |
if ((isec->flags & SEC_LINKER_CREATED) != 0) |
isec->gc_mark = 1; |
else if (isec->gc_mark) |
some_kept = TRUE; |
} |
/* If no section in this file will be kept, then we can |
toss out debug sections. */ |
if (!some_kept) |
continue; |
/* Keep debug and special sections like .comment when they are |
not part of a group, or when we have single-member groups. */ |
for (isec = ibfd->sections; isec != NULL; isec = isec->next) |
if ((isec->flags & SEC_DEBUGGING) != 0 |
|| (isec->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0) |
isec->gc_mark = 1; |
} |
return TRUE; |
} |
/* Sweep symbols in swept sections. Called via coff_link_hash_traverse. */ |
static bfd_boolean |
coff_gc_sweep_symbol (struct coff_link_hash_entry *h, |
void *data ATTRIBUTE_UNUSED) |
{ |
if (h->root.type == bfd_link_hash_warning) |
h = (struct coff_link_hash_entry *) h->root.u.i.link; |
if ((h->root.type == bfd_link_hash_defined |
|| h->root.type == bfd_link_hash_defweak) |
&& !h->root.u.def.section->gc_mark |
&& !(h->root.u.def.section->owner->flags & DYNAMIC)) |
{ |
/* Do our best to hide the symbol. */ |
h->root.u.def.section = bfd_und_section_ptr; |
h->symbol_class = C_HIDDEN; |
} |
return TRUE; |
} |
/* The sweep phase of garbage collection. Remove all garbage sections. */ |
typedef bfd_boolean (*gc_sweep_hook_fn) |
(bfd *, struct bfd_link_info *, asection *, const struct internal_reloc *); |
static bfd_boolean |
coff_gc_sweep (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *info) |
{ |
bfd *sub; |
for (sub = info->input_bfds; sub != NULL; sub = sub->link.next) |
{ |
asection *o; |
if (bfd_get_flavour (sub) != bfd_target_coff_flavour) |
continue; |
for (o = sub->sections; o != NULL; o = o->next) |
{ |
/* Keep debug and special sections. */ |
if ((o->flags & (SEC_DEBUGGING | SEC_LINKER_CREATED)) != 0 |
|| (o->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0) |
o->gc_mark = 1; |
else if (CONST_STRNEQ (o->name, ".idata") |
|| CONST_STRNEQ (o->name, ".pdata") |
|| CONST_STRNEQ (o->name, ".xdata") |
|| CONST_STRNEQ (o->name, ".rsrc")) |
o->gc_mark = 1; |
if (o->gc_mark) |
continue; |
/* Skip sweeping sections already excluded. */ |
if (o->flags & SEC_EXCLUDE) |
continue; |
/* Since this is early in the link process, it is simple |
to remove a section from the output. */ |
o->flags |= SEC_EXCLUDE; |
if (info->print_gc_sections && o->size != 0) |
_bfd_error_handler (_("Removing unused section '%s' in file '%B'"), sub, o->name); |
#if 0 |
/* But we also have to update some of the relocation |
info we collected before. */ |
if (gc_sweep_hook |
&& (o->flags & SEC_RELOC) != 0 |
&& o->reloc_count > 0 |
&& !bfd_is_abs_section (o->output_section)) |
{ |
struct internal_reloc *internal_relocs; |
bfd_boolean r; |
internal_relocs |
= _bfd_coff_link_read_relocs (o->owner, o, NULL, NULL, |
info->keep_memory); |
if (internal_relocs == NULL) |
return FALSE; |
r = (*gc_sweep_hook) (o->owner, info, o, internal_relocs); |
if (coff_section_data (o)->relocs != internal_relocs) |
free (internal_relocs); |
if (!r) |
return FALSE; |
} |
#endif |
} |
} |
/* Remove the symbols that were in the swept sections from the dynamic |
symbol table. */ |
coff_link_hash_traverse (coff_hash_table (info), coff_gc_sweep_symbol, |
NULL); |
return TRUE; |
} |
/* Keep all sections containing symbols undefined on the command-line, |
and the section containing the entry symbol. */ |
static void |
_bfd_coff_gc_keep (struct bfd_link_info *info) |
{ |
struct bfd_sym_chain *sym; |
for (sym = info->gc_sym_list; sym != NULL; sym = sym->next) |
{ |
struct coff_link_hash_entry *h; |
h = coff_link_hash_lookup (coff_hash_table (info), sym->name, |
FALSE, FALSE, FALSE); |
if (h != NULL |
&& (h->root.type == bfd_link_hash_defined |
|| h->root.type == bfd_link_hash_defweak) |
&& !bfd_is_abs_section (h->root.u.def.section)) |
h->root.u.def.section->flags |= SEC_KEEP; |
} |
} |
/* Do mark and sweep of unused sections. */ |
bfd_boolean |
bfd_coff_gc_sections (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *info) |
{ |
bfd *sub; |
/* FIXME: Should we implement this? */ |
#if 0 |
const bfd_coff_backend_data *bed = coff_backend_info (abfd); |
if (!bed->can_gc_sections |
|| !is_coff_hash_table (info->hash)) |
{ |
(*_bfd_error_handler)(_("Warning: gc-sections option ignored")); |
return TRUE; |
} |
#endif |
_bfd_coff_gc_keep (info); |
/* Grovel through relocs to find out who stays ... */ |
for (sub = info->input_bfds; sub != NULL; sub = sub->link.next) |
{ |
asection *o; |
if (bfd_get_flavour (sub) != bfd_target_coff_flavour) |
continue; |
for (o = sub->sections; o != NULL; o = o->next) |
{ |
if (((o->flags & (SEC_EXCLUDE | SEC_KEEP)) == SEC_KEEP |
|| CONST_STRNEQ (o->name, ".vectors") |
|| CONST_STRNEQ (o->name, ".ctors") |
|| CONST_STRNEQ (o->name, ".dtors")) |
&& !o->gc_mark) |
{ |
if (!_bfd_coff_gc_mark (info, o, _bfd_coff_gc_mark_hook)) |
return FALSE; |
} |
} |
} |
/* Allow the backend to mark additional target specific sections. */ |
_bfd_coff_gc_mark_extra_sections (info, _bfd_coff_gc_mark_hook); |
/* ... and mark SEC_EXCLUDE for those that go. */ |
return coff_gc_sweep (abfd, info); |
} |
/contrib/toolchain/binutils/bfd/cofflink.c |
---|
1,5 → 1,6 |
/* COFF specific linker code. |
Copyright (C) 1994-2015 Free Software Foundation, Inc. |
Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, |
2004, 2005, 2006, 2007, 2008, 2009, 2011 Free Software Foundation, Inc. |
Written by Ian Lance Taylor, Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
29,11 → 30,9 |
#include "libcoff.h" |
#include "safe-ctype.h" |
static bfd_boolean coff_link_add_object_symbols (bfd *, struct bfd_link_info *); |
static bfd_boolean coff_link_check_archive_element |
(bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, const char *, |
bfd_boolean *); |
static bfd_boolean coff_link_add_symbols (bfd *, struct bfd_link_info *); |
static bfd_boolean coff_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info); |
static bfd_boolean coff_link_check_archive_element (bfd *abfd, struct bfd_link_info *info, bfd_boolean *pneeded); |
static bfd_boolean coff_link_add_symbols (bfd *abfd, struct bfd_link_info *info); |
/* Return TRUE if SYM is a weak, external symbol. */ |
#define IS_WEAK_EXTERNAL(abfd, sym) \ |
192,6 → 191,74 |
return TRUE; |
} |
/* Look through the symbols to see if this object file should be |
included in the link. */ |
static bfd_boolean |
coff_link_check_ar_symbols (bfd *abfd, |
struct bfd_link_info *info, |
bfd_boolean *pneeded, |
bfd **subsbfd) |
{ |
bfd_size_type symesz; |
bfd_byte *esym; |
bfd_byte *esym_end; |
*pneeded = FALSE; |
symesz = bfd_coff_symesz (abfd); |
esym = (bfd_byte *) obj_coff_external_syms (abfd); |
esym_end = esym + obj_raw_syment_count (abfd) * symesz; |
while (esym < esym_end) |
{ |
struct internal_syment sym; |
enum coff_symbol_classification classification; |
bfd_coff_swap_sym_in (abfd, esym, &sym); |
classification = bfd_coff_classify_symbol (abfd, &sym); |
if (classification == COFF_SYMBOL_GLOBAL |
|| classification == COFF_SYMBOL_COMMON) |
{ |
const char *name; |
char buf[SYMNMLEN + 1]; |
struct bfd_link_hash_entry *h; |
/* This symbol is externally visible, and is defined by this |
object file. */ |
name = _bfd_coff_internal_syment_name (abfd, &sym, buf); |
if (name == NULL) |
return FALSE; |
h = bfd_link_hash_lookup (info->hash, name, FALSE, FALSE, TRUE); |
/* Auto import. */ |
if (!h |
&& info->pei386_auto_import |
&& CONST_STRNEQ (name, "__imp_")) |
h = bfd_link_hash_lookup (info->hash, name + 6, FALSE, FALSE, TRUE); |
/* We are only interested in symbols that are currently |
undefined. If a symbol is currently known to be common, |
COFF linkers do not bring in an object file which defines |
it. */ |
if (h != (struct bfd_link_hash_entry *) NULL |
&& h->type == bfd_link_hash_undefined) |
{ |
if (!(*info->callbacks |
->add_archive_element) (info, abfd, name, subsbfd)) |
return FALSE; |
*pneeded = TRUE; |
return TRUE; |
} |
} |
esym += (sym.n_numaux + 1) * symesz; |
} |
/* We do not need this object file. */ |
return TRUE; |
} |
/* Check a single archive element to see if we need to include it in |
the link. *PNEEDED is set according to whether this element is |
needed in the link or not. This is called via |
200,25 → 267,43 |
static bfd_boolean |
coff_link_check_archive_element (bfd *abfd, |
struct bfd_link_info *info, |
struct bfd_link_hash_entry *h, |
const char *name, |
bfd_boolean *pneeded) |
{ |
*pneeded = FALSE; |
bfd *oldbfd; |
bfd_boolean needed; |
/* We are only interested in symbols that are currently undefined. |
If a symbol is currently known to be common, COFF linkers do not |
bring in an object file which defines it. */ |
if (h->type != bfd_link_hash_undefined) |
return TRUE; |
if (!_bfd_coff_get_external_symbols (abfd)) |
return FALSE; |
if (!(*info->callbacks->add_archive_element) (info, abfd, name, &abfd)) |
oldbfd = abfd; |
if (!coff_link_check_ar_symbols (abfd, info, pneeded, &abfd)) |
return FALSE; |
*pneeded = TRUE; |
return coff_link_add_object_symbols (abfd, info); |
needed = *pneeded; |
if (needed) |
{ |
/* Potentially, the add_archive_element hook may have set a |
substitute BFD for us. */ |
if (abfd != oldbfd) |
{ |
if (!info->keep_memory |
&& !_bfd_coff_free_symbols (oldbfd)) |
return FALSE; |
if (!_bfd_coff_get_external_symbols (abfd)) |
return FALSE; |
} |
if (!coff_link_add_symbols (abfd, info)) |
return FALSE; |
} |
if (!info->keep_memory || !needed) |
{ |
if (!_bfd_coff_free_symbols (abfd)) |
return FALSE; |
} |
return TRUE; |
} |
/* Add all the symbols from an object file to the hash table. */ |
static bfd_boolean |
507,7 → 592,7 |
/* If this is a non-traditional, non-relocatable link, try to |
optimize the handling of any .stab/.stabstr sections. */ |
if (! bfd_link_relocatable (info) |
if (! info->relocatable |
&& ! info->traditional_format |
&& bfd_get_flavour (info->output_bfd) == bfd_get_flavour (abfd) |
&& (info->strip != strip_all && info->strip != strip_debugger)) |
652,7 → 737,7 |
|| info->strip == strip_some) |
o->lineno_count += sec->lineno_count; |
if (bfd_link_relocatable (info)) |
if (info->relocatable) |
o->reloc_count += sec->reloc_count; |
if (sec->rawsize > max_contents_size) |
664,7 → 749,7 |
if (sec->reloc_count > max_reloc_count) |
max_reloc_count = sec->reloc_count; |
} |
else if (bfd_link_relocatable (info) |
else if (info->relocatable |
&& (p->type == bfd_section_reloc_link_order |
|| p->type == bfd_symbol_reloc_link_order)) |
++o->reloc_count; |
699,7 → 784,7 |
/* If doing a relocatable link, allocate space for the pointers we |
need to keep. */ |
if (bfd_link_relocatable (info)) |
if (info->relocatable) |
{ |
unsigned int i; |
747,7 → 832,7 |
memory until the end of the link. This wastes memory, |
but only when doing a relocatable link, which is not the |
common case. */ |
BFD_ASSERT (bfd_link_relocatable (info)); |
BFD_ASSERT (info->relocatable); |
amt = o->reloc_count; |
amt *= sizeof (struct internal_reloc); |
flaginfo.section_info[o->target_index].relocs = |
776,7 → 861,7 |
the opportunity to clear the output_has_begun fields of all the |
input BFD's. */ |
max_sym_count = 0; |
for (sub = info->input_bfds; sub != NULL; sub = sub->link.next) |
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next) |
{ |
size_t sz; |
799,7 → 884,7 |
flaginfo.contents = (bfd_byte *) bfd_malloc (max_contents_size); |
amt = max_reloc_count * relsz; |
flaginfo.external_relocs = (bfd_byte *) bfd_malloc (amt); |
if (! bfd_link_relocatable (info)) |
if (! info->relocatable) |
{ |
amt = max_reloc_count * sizeof (struct internal_reloc); |
flaginfo.internal_relocs = (struct internal_reloc *) bfd_malloc (amt); |
811,7 → 896,7 |
|| (flaginfo.linenos == NULL && max_lineno_count > 0) |
|| (flaginfo.contents == NULL && max_contents_size > 0) |
|| (flaginfo.external_relocs == NULL && max_reloc_count > 0) |
|| (! bfd_link_relocatable (info) |
|| (! info->relocatable |
&& flaginfo.internal_relocs == NULL |
&& max_reloc_count > 0)) |
goto error_return; |
861,7 → 946,7 |
if (flaginfo.info->strip != strip_all && flaginfo.info->discard != discard_all) |
{ |
/* Add local symbols from foreign inputs. */ |
for (sub = info->input_bfds; sub != NULL; sub = sub->link.next) |
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next) |
{ |
unsigned int i; |
891,7 → 976,7 |
== NULL)) |
|| (((flaginfo.info->discard == discard_sec_merge |
&& (bfd_get_section (sym)->flags & SEC_MERGE) |
&& ! bfd_link_relocatable (flaginfo.info)) |
&& ! flaginfo.info->relocatable) |
|| flaginfo.info->discard == discard_l) |
&& bfd_is_local_label_name (sub, bfd_asymbol_name(sym)))) |
continue; |
1031,7 → 1116,7 |
flaginfo.outsyms = NULL; |
} |
if (bfd_link_relocatable (info) && max_output_reloc_count > 0) |
if (info->relocatable && max_output_reloc_count > 0) |
{ |
/* Now that we have written out all the global symbols, we know |
the symbol indices to use for relocs against them, and we can |
1350,8 → 1435,8 |
internal_relocs = _bfd_coff_read_internal_relocs |
(input_bfd, a, FALSE, |
flaginfo->external_relocs, |
bfd_link_relocatable (flaginfo->info), |
(bfd_link_relocatable (flaginfo->info) |
flaginfo->info->relocatable, |
(flaginfo->info->relocatable |
? (flaginfo->section_info[ a->output_section->target_index ].relocs + a->output_section->reloc_count) |
: flaginfo->internal_relocs) |
); |
1436,7 → 1521,7 |
symbols that are going to be involved in the relocations. */ |
if (( flaginfo->info->strip != strip_none |
|| flaginfo->info->discard != discard_none) |
&& bfd_link_relocatable (flaginfo->info)) |
&& flaginfo->info->relocatable) |
{ |
/* Mark the symbol array as 'not-used'. */ |
memset (indexp, 0, obj_raw_syment_count (input_bfd) * sizeof * indexp); |
1483,7 → 1568,7 |
relocation. */ |
if ((flaginfo->info->strip != strip_none |
|| flaginfo->info->discard != discard_none) |
&& bfd_link_relocatable (flaginfo->info)) |
&& flaginfo->info->relocatable) |
dont_skip_symbol = *indexp; |
else |
dont_skip_symbol = FALSE; |
2003,9 → 2088,6 |
if (strings == NULL) |
return FALSE; |
} |
if ((bfd_size_type) auxp->x_file.x_n.x_offset >= obj_coff_strings_len (input_bfd)) |
filename = _("<corrupt>"); |
else |
filename = strings + auxp->x_file.x_n.x_offset; |
indx = _bfd_stringtab_add (flaginfo->strtab, filename, |
hash, copy); |
2360,8 → 2442,8 |
target_index = o->output_section->target_index; |
internal_relocs = (_bfd_coff_read_internal_relocs |
(input_bfd, o, FALSE, flaginfo->external_relocs, |
bfd_link_relocatable (flaginfo->info), |
(bfd_link_relocatable (flaginfo->info) |
flaginfo->info->relocatable, |
(flaginfo->info->relocatable |
? (flaginfo->section_info[target_index].relocs |
+ o->output_section->reloc_count) |
: flaginfo->internal_relocs))); |
2408,7 → 2490,7 |
flaginfo->sec_ptrs)) |
return FALSE; |
if (bfd_link_relocatable (flaginfo->info)) |
if (flaginfo->info->relocatable) |
{ |
bfd_vma offset; |
struct internal_reloc *irelend; |
2636,8 → 2718,8 |
/* When a weak symbol is not overridden by a strong one, |
turn it into an external symbol when not building a |
shared or relocatable object. */ |
if (! bfd_link_pic (flaginfo->info) |
&& ! bfd_link_relocatable (flaginfo->info) |
if (! flaginfo->info->shared |
&& ! flaginfo->info->relocatable |
&& IS_WEAK_EXTERNAL (flaginfo->output_bfd, isym)) |
isym.n_sclass = C_EXT; |
2690,7 → 2772,7 |
not matter. FIXME: Why not? */ |
if (sec->reloc_count > 0xffff |
&& (! obj_pe (output_bfd) |
|| bfd_link_relocatable (flaginfo->info))) |
|| flaginfo->info->relocatable)) |
(*_bfd_error_handler) |
(_("%s: %s: reloc overflow: 0x%lx > 0xffff"), |
bfd_get_filename (output_bfd), |
2699,7 → 2781,7 |
if (sec->lineno_count > 0xffff |
&& (! obj_pe (output_bfd) |
|| bfd_link_relocatable (flaginfo->info))) |
|| flaginfo->info->relocatable)) |
(*_bfd_error_handler) |
(_("%s: warning: %s: line number overflow: 0x%lx > 0xffff"), |
bfd_get_filename (output_bfd), |
2789,7 → 2871,7 |
size = bfd_get_reloc_size (howto); |
buf = (bfd_byte *) bfd_zmalloc (size); |
if (buf == NULL && size != 0) |
if (buf == NULL) |
return FALSE; |
rstat = _bfd_relocate_contents (howto, output_bfd, |
2915,7 → 2997,6 |
struct internal_syment *sym; |
bfd_vma addend; |
bfd_vma val; |
asection *sec; |
reloc_howto_type *howto; |
bfd_reloc_status_type rstat; |
2959,7 → 3040,7 |
then we should ignore the symbol value. */ |
if (howto->pc_relative && howto->pcrel_offset) |
{ |
if (bfd_link_relocatable (info)) |
if (info->relocatable) |
continue; |
if (sym != NULL && sym->n_scnum != 0) |
addend += sym->n_value; |
2966,9 → 3047,11 |
} |
val = 0; |
sec = NULL; |
if (h == NULL) |
{ |
asection *sec; |
if (symndx == -1) |
{ |
sec = bfd_abs_section_ptr; |
2990,6 → 3073,8 |
|| h->root.type == bfd_link_hash_defweak) |
{ |
/* Defined weak symbols are a GNU extension. */ |
asection *sec; |
sec = h->root.u.def.section; |
val = (h->root.u.def.value |
+ sec->output_section->vma |
3010,6 → 3095,7 |
will resolve a weak external only if a normal |
external causes the library member to be linked. |
See also linker.c: generic_link_check_archive_element. */ |
asection *sec; |
struct coff_link_hash_entry *h2 = |
h->auxbfd->tdata.coff_obj_data->sym_hashes[ |
h->aux->x_sym.x_tagndx.l]; |
3031,7 → 3117,7 |
val = 0; |
} |
else if (! bfd_link_relocatable (info)) |
else if (! info->relocatable) |
{ |
if (! ((*info->callbacks->undefined_symbol) |
(info, h->root.root.string, input_bfd, input_section, |
3040,15 → 3126,6 |
} |
} |
/* If the input section defining the symbol has been discarded |
then zero this reloc field. */ |
if (sec != NULL && discarded_section (sec)) |
{ |
_bfd_clear_contents (howto, input_bfd, input_section, |
contents + (rel->r_vaddr - input_section->vma)); |
continue; |
} |
if (info->base_file) |
{ |
/* Emit a reloc if the backend thinks it needs it. */ |
/contrib/toolchain/binutils/bfd/compress.c |
---|
1,5 → 1,6 |
/* Compressed section support (intended for debug sections). |
Copyright (C) 2008-2015 Free Software Foundation, Inc. |
Copyright 2008, 2010, 2011, 2012 |
Free Software Foundation, Inc. |
This file is part of BFD, the Binary File Descriptor library. |
19,13 → 20,13 |
MA 02110-1301, USA. */ |
#include "sysdep.h" |
#include <zlib.h> |
#include "bfd.h" |
#include "libbfd.h" |
#include "safe-ctype.h" |
#ifdef HAVE_ZLIB_H |
#include <zlib.h> |
#endif |
#define MAX_COMPRESSION_HEADER_SIZE 24 |
#ifdef HAVE_ZLIB_H |
static bfd_boolean |
decompress_contents (bfd_byte *compressed_buffer, |
bfd_size_type compressed_size, |
37,14 → 38,11 |
/* It is possible the section consists of several compressed |
buffers concatenated together, so we uncompress in a loop. */ |
/* PR 18313: The state field in the z_stream structure is supposed |
to be invisible to the user (ie us), but some compilers will |
still complain about it being used without initialisation. So |
we first zero the entire z_stream structure and then set the fields |
that we need. */ |
memset (& strm, 0, sizeof strm); |
strm.avail_in = compressed_size; |
strm.next_in = (Bytef*) compressed_buffer; |
strm.zalloc = NULL; |
strm.zfree = NULL; |
strm.opaque = NULL; |
strm.avail_in = compressed_size - 12; |
strm.next_in = (Bytef*) compressed_buffer + 12; |
strm.avail_out = uncompressed_size; |
BFD_ASSERT (Z_OK == 0); |
63,142 → 61,81 |
rc |= inflateEnd (&strm); |
return rc == Z_OK && strm.avail_out == 0; |
} |
#endif |
/* Compress data of the size specified in @var{uncompressed_size} |
/* |
FUNCTION |
bfd_compress_section_contents |
SYNOPSIS |
bfd_boolean bfd_compress_section_contents |
(bfd *abfd, asection *section, bfd_byte *uncompressed_buffer, |
bfd_size_type uncompressed_size); |
DESCRIPTION |
Compress data of the size specified in @var{uncompressed_size} |
and pointed to by @var{uncompressed_buffer} using zlib and store |
as the contents field. This function assumes the contents |
field was allocated using bfd_malloc() or equivalent. |
field was allocated using bfd_malloc() or equivalent. If zlib |
is not installed on this machine, the input is unmodified. |
Return the uncompressed size if the full section contents is |
compressed successfully. Otherwise return 0. */ |
Return @code{TRUE} if the full section contents is compressed |
successfully. |
*/ |
static bfd_size_type |
bfd_compress_section_contents (bfd *abfd, sec_ptr sec, |
bfd_byte *uncompressed_buffer, |
bfd_size_type uncompressed_size) |
bfd_boolean |
bfd_compress_section_contents (bfd *abfd ATTRIBUTE_UNUSED, |
sec_ptr sec ATTRIBUTE_UNUSED, |
bfd_byte *uncompressed_buffer ATTRIBUTE_UNUSED, |
bfd_size_type uncompressed_size ATTRIBUTE_UNUSED) |
{ |
#ifndef HAVE_ZLIB_H |
bfd_set_error (bfd_error_invalid_operation); |
return FALSE; |
#else |
uLong compressed_size; |
bfd_byte *buffer; |
bfd_size_type buffer_size; |
bfd_boolean decompress; |
int zlib_size = 0; |
int orig_compression_header_size; |
bfd_size_type orig_uncompressed_size; |
int header_size = bfd_get_compression_header_size (abfd, NULL); |
bfd_boolean compressed |
= bfd_is_section_compressed_with_header (abfd, sec, |
&orig_compression_header_size, |
&orig_uncompressed_size); |
bfd_byte *compressed_buffer; |
/* Either ELF compression header or the 12-byte, "ZLIB" + 8-byte size, |
overhead in .zdebug* section. */ |
if (!header_size) |
header_size = 12; |
compressed_size = compressBound (uncompressed_size) + 12; |
compressed_buffer = (bfd_byte *) bfd_malloc (compressed_size); |
if (compressed) |
{ |
/* We shouldn't decompress unsupported compressed section. */ |
if (orig_compression_header_size < 0) |
abort (); |
if (compressed_buffer == NULL) |
return FALSE; |
/* Different compression schemes. Just move the compressed section |
contents to the right position. */ |
if (orig_compression_header_size == 0) |
{ |
/* Convert it from .zdebug* section. Get the uncompressed |
size first. We need to substract the 12-byte overhead in |
.zdebug* section. Set orig_compression_header_size to |
the 12-bye overhead. */ |
orig_compression_header_size = 12; |
zlib_size = uncompressed_size - 12; |
} |
else |
{ |
/* Convert it to .zdebug* section. */ |
zlib_size = uncompressed_size - orig_compression_header_size; |
} |
/* Add the header size. */ |
compressed_size = zlib_size + header_size; |
} |
else |
compressed_size = compressBound (uncompressed_size) + header_size; |
/* Uncompress if it leads to smaller size. */ |
if (compressed && compressed_size > orig_uncompressed_size) |
{ |
decompress = TRUE; |
buffer_size = orig_uncompressed_size; |
} |
else |
{ |
decompress = FALSE; |
buffer_size = compressed_size; |
} |
buffer = (bfd_byte *) bfd_alloc (abfd, buffer_size); |
if (buffer == NULL) |
return 0; |
if (compressed) |
{ |
sec->size = orig_uncompressed_size; |
if (decompress) |
{ |
if (!decompress_contents (uncompressed_buffer |
+ orig_compression_header_size, |
zlib_size, buffer, buffer_size)) |
{ |
bfd_set_error (bfd_error_bad_value); |
bfd_release (abfd, buffer); |
return 0; |
} |
free (uncompressed_buffer); |
sec->contents = buffer; |
sec->compress_status = COMPRESS_SECTION_DONE; |
return orig_uncompressed_size; |
} |
else |
{ |
bfd_update_compression_header (abfd, buffer, sec); |
memmove (buffer + header_size, |
uncompressed_buffer + orig_compression_header_size, |
zlib_size); |
} |
} |
else |
{ |
if (compress ((Bytef*) buffer + header_size, |
if (compress ((Bytef*) compressed_buffer + 12, |
&compressed_size, |
(const Bytef*) uncompressed_buffer, |
uncompressed_size) != Z_OK) |
{ |
bfd_release (abfd, buffer); |
free (compressed_buffer); |
bfd_set_error (bfd_error_bad_value); |
return 0; |
return FALSE; |
} |
compressed_size += header_size; |
/* PR binutils/18087: If compression didn't make the section smaller, |
just keep it uncompressed. */ |
if (compressed_size < uncompressed_size) |
bfd_update_compression_header (abfd, buffer, sec); |
else |
{ |
/* NOTE: There is a small memory leak here since |
uncompressed_buffer is malloced and won't be freed. */ |
bfd_release (abfd, buffer); |
sec->contents = uncompressed_buffer; |
sec->compress_status = COMPRESS_SECTION_NONE; |
return uncompressed_size; |
} |
} |
/* Write the zlib header. In this case, it should be "ZLIB" followed |
by the uncompressed section size, 8 bytes in big-endian order. */ |
memcpy (compressed_buffer, "ZLIB", 4); |
compressed_buffer[11] = uncompressed_size; uncompressed_size >>= 8; |
compressed_buffer[10] = uncompressed_size; uncompressed_size >>= 8; |
compressed_buffer[9] = uncompressed_size; uncompressed_size >>= 8; |
compressed_buffer[8] = uncompressed_size; uncompressed_size >>= 8; |
compressed_buffer[7] = uncompressed_size; uncompressed_size >>= 8; |
compressed_buffer[6] = uncompressed_size; uncompressed_size >>= 8; |
compressed_buffer[5] = uncompressed_size; uncompressed_size >>= 8; |
compressed_buffer[4] = uncompressed_size; |
compressed_size += 12; |
/* Free the uncompressed contents if we compress in place. */ |
if (uncompressed_buffer == sec->contents) |
free (uncompressed_buffer); |
sec->contents = buffer; |
sec->contents = compressed_buffer; |
sec->size = compressed_size; |
sec->compress_status = COMPRESS_SECTION_DONE; |
return uncompressed_size; |
return TRUE; |
#endif /* HAVE_ZLIB_H */ |
} |
/* |
215,8 → 152,7 |
return @var{*ptr} with memory malloc'd by this function. |
Return @code{TRUE} if the full section contents is retrieved |
successfully. If the section has no contents then this function |
returns @code{TRUE} but @var{*ptr} is set to NULL. |
successfully. |
*/ |
bfd_boolean |
224,11 → 160,12 |
{ |
bfd_size_type sz; |
bfd_byte *p = *ptr; |
#ifdef HAVE_ZLIB_H |
bfd_boolean ret; |
bfd_size_type save_size; |
bfd_size_type save_rawsize; |
bfd_byte *compressed_buffer; |
unsigned int compression_header_size; |
#endif |
if (abfd->direction != write_direction && sec->rawsize != 0) |
sz = sec->rawsize; |
235,10 → 172,7 |
else |
sz = sec->size; |
if (sz == 0) |
{ |
*ptr = NULL; |
return TRUE; |
} |
switch (sec->compress_status) |
{ |
249,7 → 183,6 |
if (p == NULL) |
return FALSE; |
} |
if (!bfd_get_section_contents (abfd, sec, p, 0, sz)) |
{ |
if (*ptr != p) |
260,6 → 193,10 |
return TRUE; |
case DECOMPRESS_SECTION_SIZED: |
#ifndef HAVE_ZLIB_H |
bfd_set_error (bfd_error_invalid_operation); |
return FALSE; |
#else |
/* Read in the full compressed section contents. */ |
compressed_buffer = (bfd_byte *) bfd_malloc (sec->compressed_size); |
if (compressed_buffer == NULL) |
286,13 → 223,7 |
if (p == NULL) |
goto fail_compressed; |
compression_header_size = bfd_get_compression_header_size (abfd, sec); |
if (compression_header_size == 0) |
/* Set header size to the zlib header size if it is a |
SHF_COMPRESSED section. */ |
compression_header_size = 12; |
if (!decompress_contents (compressed_buffer + compression_header_size, |
sec->compressed_size, p, sz)) |
if (!decompress_contents (compressed_buffer, sec->compressed_size, p, sz)) |
{ |
bfd_set_error (bfd_error_bad_value); |
if (p != *ptr) |
305,10 → 236,9 |
free (compressed_buffer); |
*ptr = p; |
return TRUE; |
#endif |
case COMPRESS_SECTION_DONE: |
if (sec->contents == NULL) |
return FALSE; |
if (p == NULL) |
{ |
p = (bfd_byte *) bfd_malloc (sz); |
316,8 → 246,6 |
return FALSE; |
*ptr = p; |
} |
/* PR 17512; file: 5bc29788. */ |
if (p != sec->contents) |
memcpy (p, sec->contents, sz); |
return TRUE; |
348,108 → 276,41 |
sec->flags |= SEC_IN_MEMORY; |
} |
/* |
FUNCTION |
bfd_is_section_compressed_with_header |
bfd_is_section_compressed |
SYNOPSIS |
bfd_boolean bfd_is_section_compressed_with_header |
(bfd *abfd, asection *section, |
int *compression_header_size_p, |
bfd_size_type *uncompressed_size_p); |
bfd_boolean bfd_is_section_compressed |
(bfd *abfd, asection *section); |
DESCRIPTION |
Return @code{TRUE} if @var{section} is compressed. Compression |
header size is returned in @var{compression_header_size_p} and |
uncompressed size is returned in @var{uncompressed_size_p}. If |
compression is unsupported, compression header size is returned |
with -1 and uncompressed size is returned with 0. |
Return @code{TRUE} if @var{section} is compressed. |
*/ |
bfd_boolean |
bfd_is_section_compressed_with_header (bfd *abfd, sec_ptr sec, |
int *compression_header_size_p, |
bfd_size_type *uncompressed_size_p) |
bfd_is_section_compressed (bfd *abfd, sec_ptr sec) |
{ |
bfd_byte header[MAX_COMPRESSION_HEADER_SIZE]; |
int compression_header_size; |
int header_size; |
bfd_byte compressed_buffer [12]; |
unsigned int saved = sec->compress_status; |
bfd_boolean compressed; |
compression_header_size = bfd_get_compression_header_size (abfd, sec); |
if (compression_header_size > MAX_COMPRESSION_HEADER_SIZE) |
abort (); |
header_size = compression_header_size ? compression_header_size : 12; |
/* Don't decompress the section. */ |
sec->compress_status = COMPRESS_SECTION_NONE; |
/* Read the header. */ |
if (bfd_get_section_contents (abfd, sec, header, 0, header_size)) |
{ |
if (compression_header_size == 0) |
/* In this case, it should be "ZLIB" followed by the uncompressed |
section size, 8 bytes in big-endian order. */ |
compressed = CONST_STRNEQ ((char*) header , "ZLIB"); |
else |
compressed = TRUE; |
} |
else |
compressed = FALSE; |
/* Read the zlib header. In this case, it should be "ZLIB" followed |
by the uncompressed section size, 8 bytes in big-endian order. */ |
compressed = (bfd_get_section_contents (abfd, sec, compressed_buffer, 0, 12) |
&& CONST_STRNEQ ((char*) compressed_buffer, "ZLIB")); |
*uncompressed_size_p = sec->size; |
if (compressed) |
{ |
if (compression_header_size != 0) |
{ |
if (!bfd_check_compression_header (abfd, header, sec, |
uncompressed_size_p)) |
compression_header_size = -1; |
} |
/* Check for the pathalogical case of a debug string section that |
contains the string ZLIB.... as the first entry. We assume that |
no uncompressed .debug_str section would ever be big enough to |
have the first byte of its (big-endian) size be non-zero. */ |
else if (strcmp (sec->name, ".debug_str") == 0 |
&& ISPRINT (header[4])) |
compressed = FALSE; |
else |
*uncompressed_size_p = bfd_getb64 (header + 4); |
} |
/* Restore compress_status. */ |
sec->compress_status = saved; |
*compression_header_size_p = compression_header_size; |
return compressed; |
} |
/* |
FUNCTION |
bfd_is_section_compressed |
SYNOPSIS |
bfd_boolean bfd_is_section_compressed |
(bfd *abfd, asection *section); |
DESCRIPTION |
Return @code{TRUE} if @var{section} is compressed. |
*/ |
bfd_boolean |
bfd_is_section_compressed (bfd *abfd, sec_ptr sec) |
{ |
int compression_header_size; |
bfd_size_type uncompressed_size; |
return (bfd_is_section_compressed_with_header (abfd, sec, |
&compression_header_size, |
&uncompressed_size) |
&& compression_header_size >= 0 |
&& uncompressed_size > 0); |
} |
/* |
FUNCTION |
bfd_init_section_decompress_status |
SYNOPSIS |
462,55 → 323,53 |
DECOMPRESS_SECTION_SIZED. |
Return @code{FALSE} if the section is not a valid compressed |
section. Otherwise, return @code{TRUE}. |
section or zlib is not installed on this machine. Otherwise, |
return @code{TRUE}. |
*/ |
bfd_boolean |
bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec) |
bfd_init_section_decompress_status (bfd *abfd ATTRIBUTE_UNUSED, |
sec_ptr sec ATTRIBUTE_UNUSED) |
{ |
bfd_byte header[MAX_COMPRESSION_HEADER_SIZE]; |
int compression_header_size; |
int header_size; |
#ifndef HAVE_ZLIB_H |
bfd_set_error (bfd_error_invalid_operation); |
return FALSE; |
#else |
bfd_byte compressed_buffer [12]; |
bfd_size_type uncompressed_size; |
compression_header_size = bfd_get_compression_header_size (abfd, sec); |
if (compression_header_size > MAX_COMPRESSION_HEADER_SIZE) |
abort (); |
header_size = compression_header_size ? compression_header_size : 12; |
/* Read the header. */ |
if (sec->rawsize != 0 |
|| sec->contents != NULL |
|| sec->compress_status != COMPRESS_SECTION_NONE |
|| !bfd_get_section_contents (abfd, sec, header, 0, header_size)) |
|| !bfd_get_section_contents (abfd, sec, compressed_buffer, 0, 12)) |
{ |
bfd_set_error (bfd_error_invalid_operation); |
return FALSE; |
} |
if (compression_header_size == 0) |
/* Read the zlib header. In this case, it should be "ZLIB" followed |
by the uncompressed section size, 8 bytes in big-endian order. */ |
if (! CONST_STRNEQ ((char*) compressed_buffer, "ZLIB")) |
{ |
/* In this case, it should be "ZLIB" followed by the uncompressed |
section size, 8 bytes in big-endian order. */ |
if (! CONST_STRNEQ ((char*) header, "ZLIB")) |
{ |
bfd_set_error (bfd_error_wrong_format); |
return FALSE; |
} |
uncompressed_size = bfd_getb64 (header + 4); |
} |
else if (!bfd_check_compression_header (abfd, header, sec, |
&uncompressed_size)) |
{ |
bfd_set_error (bfd_error_wrong_format); |
return FALSE; |
} |
uncompressed_size = compressed_buffer[4]; uncompressed_size <<= 8; |
uncompressed_size += compressed_buffer[5]; uncompressed_size <<= 8; |
uncompressed_size += compressed_buffer[6]; uncompressed_size <<= 8; |
uncompressed_size += compressed_buffer[7]; uncompressed_size <<= 8; |
uncompressed_size += compressed_buffer[8]; uncompressed_size <<= 8; |
uncompressed_size += compressed_buffer[9]; uncompressed_size <<= 8; |
uncompressed_size += compressed_buffer[10]; uncompressed_size <<= 8; |
uncompressed_size += compressed_buffer[11]; |
sec->compressed_size = sec->size; |
sec->size = uncompressed_size; |
sec->compress_status = DECOMPRESS_SECTION_SIZED; |
return TRUE; |
#endif |
} |
/* |
526,12 → 385,18 |
compressed size and set compress_status to COMPRESS_SECTION_DONE. |
Return @code{FALSE} if the section is not a valid compressed |
section. Otherwise, return @code{TRUE}. |
section or zlib is not installed on this machine. Otherwise, |
return @code{TRUE}. |
*/ |
bfd_boolean |
bfd_init_section_compress_status (bfd *abfd, sec_ptr sec) |
bfd_init_section_compress_status (bfd *abfd ATTRIBUTE_UNUSED, |
sec_ptr sec ATTRIBUTE_UNUSED) |
{ |
#ifndef HAVE_ZLIB_H |
bfd_set_error (bfd_error_invalid_operation); |
return FALSE; |
#else |
bfd_size_type uncompressed_size; |
bfd_byte *uncompressed_buffer; |
bfd_boolean ret; |
554,50 → 419,11 |
0, uncompressed_size)) |
ret = FALSE; |
else |
{ |
uncompressed_size = bfd_compress_section_contents (abfd, sec, |
ret = bfd_compress_section_contents (abfd, sec, |
uncompressed_buffer, |
uncompressed_size); |
ret = uncompressed_size != 0; |
} |
free (uncompressed_buffer); |
return ret; |
#endif |
} |
/* |
FUNCTION |
bfd_compress_section |
SYNOPSIS |
bfd_boolean bfd_compress_section |
(bfd *abfd, asection *section, bfd_byte *uncompressed_buffer); |
DESCRIPTION |
If open for write, compress section, update section size with |
compressed size and set compress_status to COMPRESS_SECTION_DONE. |
Return @code{FALSE} if compression fail. Otherwise, return |
@code{TRUE}. |
*/ |
bfd_boolean |
bfd_compress_section (bfd *abfd, sec_ptr sec, bfd_byte *uncompressed_buffer) |
{ |
bfd_size_type uncompressed_size = sec->size; |
/* Error if not opened for write. */ |
if (abfd->direction != write_direction |
|| uncompressed_size == 0 |
|| uncompressed_buffer == NULL |
|| sec->contents != NULL |
|| sec->compressed_size != 0 |
|| sec->compress_status != COMPRESS_SECTION_NONE) |
{ |
bfd_set_error (bfd_error_invalid_operation); |
return FALSE; |
} |
/* Compress it. */ |
return bfd_compress_section_contents (abfd, sec, uncompressed_buffer, |
uncompressed_size) != 0; |
} |
/contrib/toolchain/binutils/bfd/config.h |
---|
1,5 → 1,5 |
/* config.h. Generated from config.in by configure. */ |
/* config.in. Generated from configure.ac by autoheader. */ |
/* 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). */ |
16,15 → 16,11 |
/* #undef ENABLE_NLS */ |
/* Define to 1 if you have the <alloca.h> header file. */ |
#define HAVE_ALLOCA_H 1 |
/* #undef HAVE_ALLOCA_H */ |
/* Define to 1 if you have the declaration of `asprintf', and to 0 if you |
don't. */ |
#define HAVE_DECL_ASPRINTF 0 |
/* Define to 1 if you have the declaration of `basename', and to 0 if you |
don't. */ |
#define HAVE_DECL_BASENAME 1 |
#define HAVE_DECL_BASENAME 0 |
/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */ |
#define HAVE_DECL_FFS 0 |
69,18 → 65,10 |
*/ |
#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 `vasprintf', and to 0 if you |
don't. */ |
#define HAVE_DECL_VASPRINTF 0 |
/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you |
don't. */ |
#define HAVE_DECL_VSNPRINTF 1 |
291,7 → 279,7 |
#define PACKAGE_NAME "bfd" |
/* Define to the full name and version of this package. */ |
#define PACKAGE_STRING "bfd 2.26" |
#define PACKAGE_STRING "bfd 2.24" |
/* Define to the one symbol short name of this package. */ |
#define PACKAGE_TARNAME "bfd" |
300,7 → 288,7 |
#define PACKAGE_URL "" |
/* Define to the version of this package. */ |
#define PACKAGE_VERSION "2.26" |
#define PACKAGE_VERSION "2.24" |
/* The size of `char', as computed by sizeof. */ |
/* #undef SIZEOF_CHAR */ |
373,7 → 361,7 |
/* Version number of package */ |
#define VERSION "2.26" |
#define VERSION "2.24" |
/* Number of bits in a file offset, on hosts where this is settable. */ |
/* #undef _FILE_OFFSET_BITS */ |
/contrib/toolchain/binutils/bfd/corefile.c |
---|
1,5 → 1,6 |
/* Core file generic interface routines for BFD. |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990, 1991, 1992, 1993, 1994, 2000, 2001, 2002, 2003, 2005, |
2007 Free Software Foundation, Inc. |
Written by Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
/contrib/toolchain/binutils/bfd/cpu-i386.c |
---|
1,5 → 1,7 |
/* BFD support for the Intel 386 architecture. |
Copyright (C) 1992-2015 Free Software Foundation, Inc. |
Copyright 1992, 1994, 1995, 1996, 1998, 2000, 2001, 2002, 2004, 2005, |
2007, 2009, 2010, 2011, 2013 |
Free Software Foundation, Inc. |
This file is part of BFD, the Binary File Descriptor library. |
/contrib/toolchain/binutils/bfd/dwarf1.c |
---|
1,5 → 1,6 |
/* DWARF 1 find nearest line (_bfd_dwarf1_find_nearest_line). |
Copyright (C) 1998-2015 Free Software Foundation, Inc. |
Copyright 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008, 2009, 2010 |
Free Software Foundation, Inc. |
Written by Gavin Romig-Koch of Cygnus Solutions (gavin@cygnus.com). |
449,8 → 450,8 |
bfd_boolean |
_bfd_dwarf1_find_nearest_line (bfd *abfd, |
asection *section, |
asymbol **symbols, |
asection *section, |
bfd_vma offset, |
const char **filename_ptr, |
const char **functionname_ptr, |
/contrib/toolchain/binutils/bfd/dwarf2.c |
---|
1,5 → 1,5 |
/* DWARF 2 support. |
Copyright (C) 1994-2015 Free Software Foundation, Inc. |
Copyright 1994-2013 Free Software Foundation, Inc. |
Adapted from gdb/dwarf2read.c by Gavin Koch of Cygnus Solutions |
(gavin@cygnus.com). |
156,11 → 156,8 |
use. */ |
struct funcinfo *inliner_chain; |
/* Section VMAs at the time the stash was built. */ |
bfd_vma *sec_vma; |
/* Number of sections whose VMA we must adjust. */ |
int adjusted_section_count; |
unsigned int adjusted_section_count; |
/* Array of sections with adjusted VMA. */ |
struct adjusted_section *adjusted_sections; |
222,9 → 219,6 |
/* The abbrev hash table. */ |
struct abbrev_info **abbrevs; |
/* DW_AT_language. */ |
int lang; |
/* Note that an error was found by comp_unit_find_nearest_line. */ |
int error; |
556,45 → 550,39 |
return TRUE; |
} |
/* VERBATIM |
The following function up to the END VERBATIM mark are |
copied directly from dwarf2read.c. */ |
/* Read dwarf information from a buffer. */ |
static unsigned int |
read_1_byte (bfd *abfd ATTRIBUTE_UNUSED, bfd_byte *buf, bfd_byte *end) |
read_1_byte (bfd *abfd ATTRIBUTE_UNUSED, bfd_byte *buf) |
{ |
if (buf + 1 > end) |
return 0; |
return bfd_get_8 (abfd, buf); |
} |
static int |
read_1_signed_byte (bfd *abfd ATTRIBUTE_UNUSED, bfd_byte *buf, bfd_byte *end) |
read_1_signed_byte (bfd *abfd ATTRIBUTE_UNUSED, bfd_byte *buf) |
{ |
if (buf + 1 > end) |
return 0; |
return bfd_get_signed_8 (abfd, buf); |
} |
static unsigned int |
read_2_bytes (bfd *abfd, bfd_byte *buf, bfd_byte *end) |
read_2_bytes (bfd *abfd, bfd_byte *buf) |
{ |
if (buf + 2 > end) |
return 0; |
return bfd_get_16 (abfd, buf); |
} |
static unsigned int |
read_4_bytes (bfd *abfd, bfd_byte *buf, bfd_byte *end) |
read_4_bytes (bfd *abfd, bfd_byte *buf) |
{ |
if (buf + 4 > end) |
return 0; |
return bfd_get_32 (abfd, buf); |
} |
static bfd_uint64_t |
read_8_bytes (bfd *abfd, bfd_byte *buf, bfd_byte *end) |
read_8_bytes (bfd *abfd, bfd_byte *buf) |
{ |
if (buf + 8 > end) |
return 0; |
return bfd_get_64 (abfd, buf); |
} |
601,34 → 589,19 |
static bfd_byte * |
read_n_bytes (bfd *abfd ATTRIBUTE_UNUSED, |
bfd_byte *buf, |
bfd_byte *end, |
unsigned int size ATTRIBUTE_UNUSED) |
{ |
if (buf + size > end) |
return NULL; |
return buf; |
} |
/* Scans a NUL terminated string starting at BUF, returning a pointer to it. |
Returns the number of characters in the string, *including* the NUL byte, |
in BYTES_READ_PTR. This value is set even if the function fails. Bytes |
at or beyond BUF_END will not be read. Returns NULL if there was a |
problem, or if the string is empty. */ |
static char * |
read_string (bfd * abfd ATTRIBUTE_UNUSED, |
bfd_byte * buf, |
bfd_byte * buf_end, |
unsigned int * bytes_read_ptr) |
{ |
bfd_byte *str = buf; |
/* Return a pointer to the embedded string. */ |
char *str = (char *) buf; |
if (buf >= buf_end) |
{ |
* bytes_read_ptr = 0; |
return NULL; |
} |
if (*str == '\0') |
{ |
* bytes_read_ptr = 1; |
635,29 → 608,15 |
return NULL; |
} |
while (buf < buf_end) |
if (* buf ++ == 0) |
{ |
* bytes_read_ptr = buf - str; |
return (char *) str; |
*bytes_read_ptr = strlen (str) + 1; |
return str; |
} |
* bytes_read_ptr = buf - str; |
return NULL; |
} |
/* END VERBATIM */ |
/* Reads an offset from BUF and then locates the string at this offset |
inside the debug string section. Returns a pointer to the string. |
Returns the number of bytes read from BUF, *not* the length of the string, |
in BYTES_READ_PTR. This value is set even if the function fails. Bytes |
at or beyond BUF_END will not be read from BUF. Returns NULL if there was |
a problem, or if the string is empty. Does not check for NUL termination |
of the string. */ |
static char * |
read_indirect_string (struct comp_unit * unit, |
bfd_byte * buf, |
bfd_byte * buf_end, |
unsigned int * bytes_read_ptr) |
{ |
bfd_uint64_t offset; |
664,16 → 623,10 |
struct dwarf2_debug *stash = unit->stash; |
char *str; |
if (buf + unit->offset_size > buf_end) |
{ |
* bytes_read_ptr = 0; |
return NULL; |
} |
if (unit->offset_size == 4) |
offset = read_4_bytes (unit->abfd, buf, buf_end); |
offset = read_4_bytes (unit->abfd, buf); |
else |
offset = read_8_bytes (unit->abfd, buf, buf_end); |
offset = read_8_bytes (unit->abfd, buf); |
*bytes_read_ptr = unit->offset_size; |
682,8 → 635,6 |
&stash->dwarf_str_buffer, &stash->dwarf_str_size)) |
return NULL; |
if (offset >= stash->dwarf_str_size) |
return NULL; |
str = (char *) stash->dwarf_str_buffer + offset; |
if (*str == '\0') |
return NULL; |
691,13 → 642,12 |
} |
/* Like read_indirect_string but uses a .debug_str located in |
an alternate file pointed to by the .gnu_debugaltlink section. |
an alternate filepointed to by the .gnu_debuglink section. |
Used to impement DW_FORM_GNU_strp_alt. */ |
static char * |
read_alt_indirect_string (struct comp_unit * unit, |
bfd_byte * buf, |
bfd_byte * buf_end, |
unsigned int * bytes_read_ptr) |
{ |
bfd_uint64_t offset; |
704,16 → 654,10 |
struct dwarf2_debug *stash = unit->stash; |
char *str; |
if (buf + unit->offset_size > buf_end) |
{ |
* bytes_read_ptr = 0; |
return NULL; |
} |
if (unit->offset_size == 4) |
offset = read_4_bytes (unit->abfd, buf, buf_end); |
offset = read_4_bytes (unit->abfd, buf); |
else |
offset = read_8_bytes (unit->abfd, buf, buf_end); |
offset = read_8_bytes (unit->abfd, buf); |
*bytes_read_ptr = unit->offset_size; |
746,8 → 690,6 |
&stash->alt_dwarf_str_size)) |
return NULL; |
if (offset >= stash->alt_dwarf_str_size) |
return NULL; |
str = (char *) stash->alt_dwarf_str_buffer + offset; |
if (*str == '\0') |
return NULL; |
794,22 → 736,14 |
&stash->alt_dwarf_info_size)) |
return NULL; |
if (offset >= stash->alt_dwarf_info_size) |
return NULL; |
return stash->alt_dwarf_info_buffer + offset; |
} |
static bfd_uint64_t |
read_address (struct comp_unit *unit, bfd_byte *buf, bfd_byte * buf_end) |
read_address (struct comp_unit *unit, bfd_byte *buf) |
{ |
int signed_vma = 0; |
int signed_vma = get_elf_backend_data (unit->abfd)->sign_extend_vma; |
if (bfd_get_flavour (unit->abfd) == bfd_target_elf_flavour) |
signed_vma = get_elf_backend_data (unit->abfd)->sign_extend_vma; |
if (buf + unit->addr_size > buf_end) |
return 0; |
if (signed_vma) |
{ |
switch (unit->addr_size) |
872,7 → 806,6 |
{ |
struct abbrev_info **abbrevs; |
bfd_byte *abbrev_ptr; |
bfd_byte *abbrev_end; |
struct abbrev_info *cur_abbrev; |
unsigned int abbrev_number, bytes_read, abbrev_name; |
unsigned int abbrev_form, hash_number; |
883,9 → 816,6 |
&stash->dwarf_abbrev_buffer, &stash->dwarf_abbrev_size)) |
return NULL; |
if (offset >= stash->dwarf_abbrev_size) |
return NULL; |
amt = sizeof (struct abbrev_info*) * ABBREV_HASH_SIZE; |
abbrevs = (struct abbrev_info **) bfd_zalloc (abfd, amt); |
if (abbrevs == NULL) |
892,8 → 822,7 |
return NULL; |
abbrev_ptr = stash->dwarf_abbrev_buffer + offset; |
abbrev_end = stash->dwarf_abbrev_buffer + stash->dwarf_abbrev_size; |
abbrev_number = safe_read_leb128 (abfd, abbrev_ptr, &bytes_read, FALSE, abbrev_end); |
abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); |
abbrev_ptr += bytes_read; |
/* Loop until we reach an abbrev number of 0. */ |
907,15 → 836,15 |
/* Read in abbrev header. */ |
cur_abbrev->number = abbrev_number; |
cur_abbrev->tag = (enum dwarf_tag) |
safe_read_leb128 (abfd, abbrev_ptr, &bytes_read, FALSE, abbrev_end); |
read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); |
abbrev_ptr += bytes_read; |
cur_abbrev->has_children = read_1_byte (abfd, abbrev_ptr, abbrev_end); |
cur_abbrev->has_children = read_1_byte (abfd, abbrev_ptr); |
abbrev_ptr += 1; |
/* Now read in declarations. */ |
abbrev_name = safe_read_leb128 (abfd, abbrev_ptr, &bytes_read, FALSE, abbrev_end); |
abbrev_name = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); |
abbrev_ptr += bytes_read; |
abbrev_form = safe_read_leb128 (abfd, abbrev_ptr, &bytes_read, FALSE, abbrev_end); |
abbrev_form = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); |
abbrev_ptr += bytes_read; |
while (abbrev_name) |
950,9 → 879,9 |
= (enum dwarf_attribute) abbrev_name; |
cur_abbrev->attrs[cur_abbrev->num_attrs++].form |
= (enum dwarf_form) abbrev_form; |
abbrev_name = safe_read_leb128 (abfd, abbrev_ptr, &bytes_read, FALSE, abbrev_end); |
abbrev_name = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); |
abbrev_ptr += bytes_read; |
abbrev_form = safe_read_leb128 (abfd, abbrev_ptr, &bytes_read, FALSE, abbrev_end); |
abbrev_form = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); |
abbrev_ptr += bytes_read; |
} |
970,7 → 899,7 |
if ((unsigned int) (abbrev_ptr - stash->dwarf_abbrev_buffer) |
>= stash->dwarf_abbrev_size) |
break; |
abbrev_number = safe_read_leb128 (abfd, abbrev_ptr, &bytes_read, FALSE, abbrev_end); |
abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); |
abbrev_ptr += bytes_read; |
if (lookup_abbrev (abbrev_number, abbrevs) != NULL) |
break; |
979,24 → 908,13 |
return abbrevs; |
} |
/* Returns true if the form is one which has a string value. */ |
/* Read an attribute value described by an attribute form. */ |
static inline bfd_boolean |
is_str_attr (enum dwarf_form form) |
{ |
return form == DW_FORM_string || form == DW_FORM_strp || form == DW_FORM_GNU_strp_alt; |
} |
/* Read and fill in the value of attribute ATTR as described by FORM. |
Read data starting from INFO_PTR, but never at or beyond INFO_PTR_END. |
Returns an updated INFO_PTR taking into account the amount of data read. */ |
static bfd_byte * |
read_attribute_value (struct attribute * attr, |
unsigned form, |
struct comp_unit * unit, |
bfd_byte * info_ptr, |
bfd_byte * info_ptr_end) |
bfd_byte *info_ptr) |
{ |
bfd *abfd = unit->abfd; |
unsigned int bytes_read; |
1003,13 → 921,6 |
struct dwarf_block *blk; |
bfd_size_type amt; |
if (info_ptr >= info_ptr_end) |
{ |
(*_bfd_error_handler) (_("Dwarf Error: Info pointer extends beyond end of attributes")); |
bfd_set_error (bfd_error_bad_value); |
return info_ptr; |
} |
attr->form = (enum dwarf_form) form; |
switch (form) |
1020,23 → 931,23 |
if (unit->version == 3 || unit->version == 4) |
{ |
if (unit->offset_size == 4) |
attr->u.val = read_4_bytes (unit->abfd, info_ptr, info_ptr_end); |
attr->u.val = read_4_bytes (unit->abfd, info_ptr); |
else |
attr->u.val = read_8_bytes (unit->abfd, info_ptr, info_ptr_end); |
attr->u.val = read_8_bytes (unit->abfd, info_ptr); |
info_ptr += unit->offset_size; |
break; |
} |
/* FALLTHROUGH */ |
case DW_FORM_addr: |
attr->u.val = read_address (unit, info_ptr, info_ptr_end); |
attr->u.val = read_address (unit, info_ptr); |
info_ptr += unit->addr_size; |
break; |
case DW_FORM_GNU_ref_alt: |
case DW_FORM_sec_offset: |
if (unit->offset_size == 4) |
attr->u.val = read_4_bytes (unit->abfd, info_ptr, info_ptr_end); |
attr->u.val = read_4_bytes (unit->abfd, info_ptr); |
else |
attr->u.val = read_8_bytes (unit->abfd, info_ptr, info_ptr_end); |
attr->u.val = read_8_bytes (unit->abfd, info_ptr); |
info_ptr += unit->offset_size; |
break; |
case DW_FORM_block2: |
1044,9 → 955,9 |
blk = (struct dwarf_block *) bfd_alloc (abfd, amt); |
if (blk == NULL) |
return NULL; |
blk->size = read_2_bytes (abfd, info_ptr, info_ptr_end); |
blk->size = read_2_bytes (abfd, info_ptr); |
info_ptr += 2; |
blk->data = read_n_bytes (abfd, info_ptr, info_ptr_end, blk->size); |
blk->data = read_n_bytes (abfd, info_ptr, blk->size); |
info_ptr += blk->size; |
attr->u.blk = blk; |
break; |
1055,34 → 966,34 |
blk = (struct dwarf_block *) bfd_alloc (abfd, amt); |
if (blk == NULL) |
return NULL; |
blk->size = read_4_bytes (abfd, info_ptr, info_ptr_end); |
blk->size = read_4_bytes (abfd, info_ptr); |
info_ptr += 4; |
blk->data = read_n_bytes (abfd, info_ptr, info_ptr_end, blk->size); |
blk->data = read_n_bytes (abfd, info_ptr, blk->size); |
info_ptr += blk->size; |
attr->u.blk = blk; |
break; |
case DW_FORM_data2: |
attr->u.val = read_2_bytes (abfd, info_ptr, info_ptr_end); |
attr->u.val = read_2_bytes (abfd, info_ptr); |
info_ptr += 2; |
break; |
case DW_FORM_data4: |
attr->u.val = read_4_bytes (abfd, info_ptr, info_ptr_end); |
attr->u.val = read_4_bytes (abfd, info_ptr); |
info_ptr += 4; |
break; |
case DW_FORM_data8: |
attr->u.val = read_8_bytes (abfd, info_ptr, info_ptr_end); |
attr->u.val = read_8_bytes (abfd, info_ptr); |
info_ptr += 8; |
break; |
case DW_FORM_string: |
attr->u.str = read_string (abfd, info_ptr, info_ptr_end, &bytes_read); |
attr->u.str = read_string (abfd, info_ptr, &bytes_read); |
info_ptr += bytes_read; |
break; |
case DW_FORM_strp: |
attr->u.str = read_indirect_string (unit, info_ptr, info_ptr_end, &bytes_read); |
attr->u.str = read_indirect_string (unit, info_ptr, &bytes_read); |
info_ptr += bytes_read; |
break; |
case DW_FORM_GNU_strp_alt: |
attr->u.str = read_alt_indirect_string (unit, info_ptr, info_ptr_end, &bytes_read); |
attr->u.str = read_alt_indirect_string (unit, info_ptr, &bytes_read); |
info_ptr += bytes_read; |
break; |
case DW_FORM_exprloc: |
1091,9 → 1002,9 |
blk = (struct dwarf_block *) bfd_alloc (abfd, amt); |
if (blk == NULL) |
return NULL; |
blk->size = safe_read_leb128 (abfd, info_ptr, &bytes_read, FALSE, info_ptr_end); |
blk->size = read_unsigned_leb128 (abfd, info_ptr, &bytes_read); |
info_ptr += bytes_read; |
blk->data = read_n_bytes (abfd, info_ptr, info_ptr_end, blk->size); |
blk->data = read_n_bytes (abfd, info_ptr, blk->size); |
info_ptr += blk->size; |
attr->u.blk = blk; |
break; |
1102,18 → 1013,18 |
blk = (struct dwarf_block *) bfd_alloc (abfd, amt); |
if (blk == NULL) |
return NULL; |
blk->size = read_1_byte (abfd, info_ptr, info_ptr_end); |
blk->size = read_1_byte (abfd, info_ptr); |
info_ptr += 1; |
blk->data = read_n_bytes (abfd, info_ptr, info_ptr_end, blk->size); |
blk->data = read_n_bytes (abfd, info_ptr, blk->size); |
info_ptr += blk->size; |
attr->u.blk = blk; |
break; |
case DW_FORM_data1: |
attr->u.val = read_1_byte (abfd, info_ptr, info_ptr_end); |
attr->u.val = read_1_byte (abfd, info_ptr); |
info_ptr += 1; |
break; |
case DW_FORM_flag: |
attr->u.val = read_1_byte (abfd, info_ptr, info_ptr_end); |
attr->u.val = read_1_byte (abfd, info_ptr); |
info_ptr += 1; |
break; |
case DW_FORM_flag_present: |
1120,41 → 1031,41 |
attr->u.val = 1; |
break; |
case DW_FORM_sdata: |
attr->u.sval = safe_read_leb128 (abfd, info_ptr, &bytes_read, TRUE, info_ptr_end); |
attr->u.sval = read_signed_leb128 (abfd, info_ptr, &bytes_read); |
info_ptr += bytes_read; |
break; |
case DW_FORM_udata: |
attr->u.val = safe_read_leb128 (abfd, info_ptr, &bytes_read, FALSE, info_ptr_end); |
attr->u.val = read_unsigned_leb128 (abfd, info_ptr, &bytes_read); |
info_ptr += bytes_read; |
break; |
case DW_FORM_ref1: |
attr->u.val = read_1_byte (abfd, info_ptr, info_ptr_end); |
attr->u.val = read_1_byte (abfd, info_ptr); |
info_ptr += 1; |
break; |
case DW_FORM_ref2: |
attr->u.val = read_2_bytes (abfd, info_ptr, info_ptr_end); |
attr->u.val = read_2_bytes (abfd, info_ptr); |
info_ptr += 2; |
break; |
case DW_FORM_ref4: |
attr->u.val = read_4_bytes (abfd, info_ptr, info_ptr_end); |
attr->u.val = read_4_bytes (abfd, info_ptr); |
info_ptr += 4; |
break; |
case DW_FORM_ref8: |
attr->u.val = read_8_bytes (abfd, info_ptr, info_ptr_end); |
attr->u.val = read_8_bytes (abfd, info_ptr); |
info_ptr += 8; |
break; |
case DW_FORM_ref_sig8: |
attr->u.val = read_8_bytes (abfd, info_ptr, info_ptr_end); |
attr->u.val = read_8_bytes (abfd, info_ptr); |
info_ptr += 8; |
break; |
case DW_FORM_ref_udata: |
attr->u.val = safe_read_leb128 (abfd, info_ptr, &bytes_read, FALSE, info_ptr_end); |
attr->u.val = read_unsigned_leb128 (abfd, info_ptr, &bytes_read); |
info_ptr += bytes_read; |
break; |
case DW_FORM_indirect: |
form = safe_read_leb128 (abfd, info_ptr, &bytes_read, FALSE, info_ptr_end); |
form = read_unsigned_leb128 (abfd, info_ptr, &bytes_read); |
info_ptr += bytes_read; |
info_ptr = read_attribute_value (attr, form, unit, info_ptr, info_ptr_end); |
info_ptr = read_attribute_value (attr, form, unit, info_ptr); |
break; |
default: |
(*_bfd_error_handler) (_("Dwarf Error: Invalid or unhandled FORM value: %#x."), |
1171,41 → 1082,13 |
read_attribute (struct attribute * attr, |
struct attr_abbrev * abbrev, |
struct comp_unit * unit, |
bfd_byte * info_ptr, |
bfd_byte * info_ptr_end) |
bfd_byte *info_ptr) |
{ |
attr->name = abbrev->name; |
info_ptr = read_attribute_value (attr, abbrev->form, unit, info_ptr, info_ptr_end); |
info_ptr = read_attribute_value (attr, abbrev->form, unit, info_ptr); |
return info_ptr; |
} |
/* Return whether DW_AT_name will return the same as DW_AT_linkage_name |
for a function. */ |
static bfd_boolean |
non_mangled (int lang) |
{ |
switch (lang) |
{ |
default: |
return FALSE; |
case DW_LANG_C89: |
case DW_LANG_C: |
case DW_LANG_Ada83: |
case DW_LANG_Cobol74: |
case DW_LANG_Cobol85: |
case DW_LANG_Fortran77: |
case DW_LANG_Pascal83: |
case DW_LANG_C99: |
case DW_LANG_Ada95: |
case DW_LANG_PLI: |
case DW_LANG_UPC: |
case DW_LANG_C11: |
return TRUE; |
} |
} |
/* Source line information table routines. */ |
#define FILE_ALLOC_CHUNK 5 |
1264,15 → 1147,14 |
struct funcinfo *caller_func; |
/* Source location file name where caller_func inlines this func. */ |
char *caller_file; |
/* Source location line number where caller_func inlines this func. */ |
int caller_line; |
/* Source location file name. */ |
char *file; |
/* Source location line number where caller_func inlines this func. */ |
int caller_line; |
/* Source location line number. */ |
int line; |
int tag; |
bfd_boolean is_linkage; |
const char *name; |
char *name; |
struct arange arange; |
/* Where the symbol is defined. */ |
asection *sec; |
1460,11 → 1342,7 |
char *name; |
size_t len; |
if (table->files[file - 1].dir |
/* PR 17512: file: 0317e960. */ |
&& table->files[file - 1].dir <= table->num_dirs |
/* PR 17512: file: 7f3d2e4b. */ |
&& table->dirs != NULL) |
if (table->files[file - 1].dir) |
subdir_name = table->dirs[table->files[file - 1].dir - 1]; |
if (!subdir_name || !IS_ABSOLUTE_PATH (subdir_name)) |
1685,24 → 1563,15 |
table->lcl_head = NULL; |
if (stash->dwarf_line_size < 16) |
{ |
(*_bfd_error_handler) |
(_("Dwarf Error: Line info section is too small (%ld)"), |
(long) stash->dwarf_line_size); |
bfd_set_error (bfd_error_bad_value); |
return NULL; |
} |
line_ptr = stash->dwarf_line_buffer + unit->line_offset; |
line_end = stash->dwarf_line_buffer + stash->dwarf_line_size; |
/* Read in the prologue. */ |
lh.total_length = read_4_bytes (abfd, line_ptr, line_end); |
lh.total_length = read_4_bytes (abfd, line_ptr); |
line_ptr += 4; |
offset_size = 4; |
if (lh.total_length == 0xffffffff) |
{ |
lh.total_length = read_8_bytes (abfd, line_ptr, line_end); |
lh.total_length = read_8_bytes (abfd, line_ptr); |
line_ptr += 8; |
offset_size = 8; |
} |
1709,23 → 1578,12 |
else if (lh.total_length == 0 && unit->addr_size == 8) |
{ |
/* Handle (non-standard) 64-bit DWARF2 formats. */ |
lh.total_length = read_4_bytes (abfd, line_ptr, line_end); |
lh.total_length = read_4_bytes (abfd, line_ptr); |
line_ptr += 4; |
offset_size = 8; |
} |
if (lh.total_length > stash->dwarf_line_size) |
{ |
(*_bfd_error_handler) |
(_("Dwarf Error: Line info data is bigger (0x%lx) than the section (0x%lx)"), |
(long) lh.total_length, (long) stash->dwarf_line_size); |
bfd_set_error (bfd_error_bad_value); |
return NULL; |
} |
line_end = line_ptr + lh.total_length; |
lh.version = read_2_bytes (abfd, line_ptr, line_end); |
lh.version = read_2_bytes (abfd, line_ptr); |
if (lh.version < 2 || lh.version > 4) |
{ |
(*_bfd_error_handler) |
1734,32 → 1592,20 |
return NULL; |
} |
line_ptr += 2; |
if (line_ptr + offset_size + (lh.version >=4 ? 6 : 5) >= line_end) |
{ |
(*_bfd_error_handler) |
(_("Dwarf Error: Ran out of room reading prologue")); |
bfd_set_error (bfd_error_bad_value); |
return NULL; |
} |
if (offset_size == 4) |
lh.prologue_length = read_4_bytes (abfd, line_ptr, line_end); |
lh.prologue_length = read_4_bytes (abfd, line_ptr); |
else |
lh.prologue_length = read_8_bytes (abfd, line_ptr, line_end); |
lh.prologue_length = read_8_bytes (abfd, line_ptr); |
line_ptr += offset_size; |
lh.minimum_instruction_length = read_1_byte (abfd, line_ptr, line_end); |
lh.minimum_instruction_length = read_1_byte (abfd, line_ptr); |
line_ptr += 1; |
if (lh.version >= 4) |
{ |
lh.maximum_ops_per_insn = read_1_byte (abfd, line_ptr, line_end); |
lh.maximum_ops_per_insn = read_1_byte (abfd, line_ptr); |
line_ptr += 1; |
} |
else |
lh.maximum_ops_per_insn = 1; |
if (lh.maximum_ops_per_insn == 0) |
{ |
(*_bfd_error_handler) |
1767,26 → 1613,14 |
bfd_set_error (bfd_error_bad_value); |
return NULL; |
} |
lh.default_is_stmt = read_1_byte (abfd, line_ptr, line_end); |
lh.default_is_stmt = read_1_byte (abfd, line_ptr); |
line_ptr += 1; |
lh.line_base = read_1_signed_byte (abfd, line_ptr, line_end); |
lh.line_base = read_1_signed_byte (abfd, line_ptr); |
line_ptr += 1; |
lh.line_range = read_1_byte (abfd, line_ptr, line_end); |
lh.line_range = read_1_byte (abfd, line_ptr); |
line_ptr += 1; |
lh.opcode_base = read_1_byte (abfd, line_ptr, line_end); |
lh.opcode_base = read_1_byte (abfd, line_ptr); |
line_ptr += 1; |
if (line_ptr + (lh.opcode_base - 1) >= line_end) |
{ |
(*_bfd_error_handler) (_("Dwarf Error: Ran out of room reading opcodes")); |
bfd_set_error (bfd_error_bad_value); |
return NULL; |
} |
amt = lh.opcode_base * sizeof (unsigned char); |
lh.standard_opcode_lengths = (unsigned char *) bfd_alloc (abfd, amt); |
1794,12 → 1628,12 |
for (i = 1; i < lh.opcode_base; ++i) |
{ |
lh.standard_opcode_lengths[i] = read_1_byte (abfd, line_ptr, line_end); |
lh.standard_opcode_lengths[i] = read_1_byte (abfd, line_ptr); |
line_ptr += 1; |
} |
/* Read directory table. */ |
while ((cur_dir = read_string (abfd, line_ptr, line_end, &bytes_read)) != NULL) |
while ((cur_dir = read_string (abfd, line_ptr, &bytes_read)) != NULL) |
{ |
line_ptr += bytes_read; |
1822,7 → 1656,7 |
line_ptr += bytes_read; |
/* Read file name table. */ |
while ((cur_file = read_string (abfd, line_ptr, line_end, &bytes_read)) != NULL) |
while ((cur_file = read_string (abfd, line_ptr, &bytes_read)) != NULL) |
{ |
line_ptr += bytes_read; |
1841,11 → 1675,13 |
table->files[table->num_files].name = cur_file; |
table->files[table->num_files].dir = |
safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end); |
read_unsigned_leb128 (abfd, line_ptr, &bytes_read); |
line_ptr += bytes_read; |
table->files[table->num_files].time = safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end); |
table->files[table->num_files].time = |
read_unsigned_leb128 (abfd, line_ptr, &bytes_read); |
line_ptr += bytes_read; |
table->files[table->num_files].size = safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end); |
table->files[table->num_files].size = |
read_unsigned_leb128 (abfd, line_ptr, &bytes_read); |
line_ptr += bytes_read; |
table->num_files++; |
} |
1875,7 → 1711,7 |
/* Decode the table. */ |
while (! end_sequence) |
{ |
op_code = read_1_byte (abfd, line_ptr, line_end); |
op_code = read_1_byte (abfd, line_ptr); |
line_ptr += 1; |
if (op_code >= lh.opcode_base) |
1882,8 → 1718,6 |
{ |
/* Special operand. */ |
adj_opcode = op_code - lh.opcode_base; |
if (lh.line_range == 0) |
goto line_fail; |
if (lh.maximum_ops_per_insn == 1) |
address += (adj_opcode / lh.line_range |
* lh.minimum_instruction_length); |
1909,9 → 1743,9 |
else switch (op_code) |
{ |
case DW_LNS_extended_op: |
exop_len = safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end); |
exop_len = read_unsigned_leb128 (abfd, line_ptr, &bytes_read); |
line_ptr += bytes_read; |
extended_op = read_1_byte (abfd, line_ptr, line_end); |
extended_op = read_1_byte (abfd, line_ptr); |
line_ptr += 1; |
switch (extended_op) |
1930,12 → 1764,12 |
goto line_fail; |
break; |
case DW_LNE_set_address: |
address = read_address (unit, line_ptr, line_end); |
address = read_address (unit, line_ptr); |
op_index = 0; |
line_ptr += unit->addr_size; |
break; |
case DW_LNE_define_file: |
cur_file = read_string (abfd, line_ptr, line_end, &bytes_read); |
cur_file = read_string (abfd, line_ptr, &bytes_read); |
line_ptr += bytes_read; |
if ((table->num_files % FILE_ALLOC_CHUNK) == 0) |
{ |
1950,19 → 1784,19 |
} |
table->files[table->num_files].name = cur_file; |
table->files[table->num_files].dir = |
safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end); |
read_unsigned_leb128 (abfd, line_ptr, &bytes_read); |
line_ptr += bytes_read; |
table->files[table->num_files].time = |
safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end); |
read_unsigned_leb128 (abfd, line_ptr, &bytes_read); |
line_ptr += bytes_read; |
table->files[table->num_files].size = |
safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end); |
read_unsigned_leb128 (abfd, line_ptr, &bytes_read); |
line_ptr += bytes_read; |
table->num_files++; |
break; |
case DW_LNE_set_discriminator: |
discriminator = |
safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end); |
read_unsigned_leb128 (abfd, line_ptr, &bytes_read); |
line_ptr += bytes_read; |
break; |
case DW_LNE_HP_source_file_correlation: |
1991,12 → 1825,12 |
case DW_LNS_advance_pc: |
if (lh.maximum_ops_per_insn == 1) |
address += (lh.minimum_instruction_length |
* safe_read_leb128 (abfd, line_ptr, &bytes_read, |
FALSE, line_end)); |
* read_unsigned_leb128 (abfd, line_ptr, |
&bytes_read)); |
else |
{ |
bfd_vma adjust = safe_read_leb128 (abfd, line_ptr, &bytes_read, |
FALSE, line_end); |
bfd_vma adjust = read_unsigned_leb128 (abfd, line_ptr, |
&bytes_read); |
address = ((op_index + adjust) / lh.maximum_ops_per_insn |
* lh.minimum_instruction_length); |
op_index = (op_index + adjust) % lh.maximum_ops_per_insn; |
2004,7 → 1838,7 |
line_ptr += bytes_read; |
break; |
case DW_LNS_advance_line: |
line += safe_read_leb128 (abfd, line_ptr, &bytes_read, TRUE, line_end); |
line += read_signed_leb128 (abfd, line_ptr, &bytes_read); |
line_ptr += bytes_read; |
break; |
case DW_LNS_set_file: |
2013,7 → 1847,7 |
/* The file and directory tables are 0 |
based, the references are 1 based. */ |
file = safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end); |
file = read_unsigned_leb128 (abfd, line_ptr, &bytes_read); |
line_ptr += bytes_read; |
if (filename) |
free (filename); |
2021,7 → 1855,7 |
break; |
} |
case DW_LNS_set_column: |
column = safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end); |
column = read_unsigned_leb128 (abfd, line_ptr, &bytes_read); |
line_ptr += bytes_read; |
break; |
case DW_LNS_negate_stmt: |
2043,7 → 1877,7 |
} |
break; |
case DW_LNS_fixed_advance_pc: |
address += read_2_bytes (abfd, line_ptr, line_end); |
address += read_2_bytes (abfd, line_ptr); |
op_index = 0; |
line_ptr += 2; |
break; |
2051,7 → 1885,7 |
/* Unknown standard opcode, ignore it. */ |
for (i = 0; i < lh.standard_opcode_lengths[op_code]; i++) |
{ |
(void) safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end); |
(void) read_unsigned_leb128 (abfd, line_ptr, &bytes_read); |
line_ptr += bytes_read; |
} |
break; |
2075,13 → 1909,11 |
return NULL; |
} |
/* If ADDR is within TABLE set the output parameters and return the |
range of addresses covered by the entry used to fill them out. |
Otherwise set * FILENAME_PTR to NULL and return 0. |
The parameters FILENAME_PTR, LINENUMBER_PTR and DISCRIMINATOR_PTR |
are pointers to the objects to be filled in. */ |
/* If ADDR is within TABLE set the output parameters and return TRUE, |
otherwise return FALSE. The output parameters, FILENAME_PTR and |
LINENUMBER_PTR, are pointers to the objects to be filled in. */ |
static bfd_vma |
static bfd_boolean |
lookup_address_in_line_info_table (struct line_info_table *table, |
bfd_vma addr, |
const char **filename_ptr, |
2123,12 → 1955,12 |
*linenumber_ptr = each_line->line; |
if (discriminator_ptr) |
*discriminator_ptr = each_line->discriminator; |
return seq->last_line->address - seq->low_pc; |
return TRUE; |
} |
} |
*filename_ptr = NULL; |
return 0; |
return FALSE; |
} |
/* Read in the .debug_ranges section for future reference. */ |
2144,19 → 1976,19 |
/* Function table functions. */ |
/* If ADDR is within UNIT's function tables, set FUNCTION_PTR, and return |
TRUE. Note that we need to find the function that has the smallest range |
that contains ADDR, to handle inlined functions without depending upon |
them being ordered in TABLE by increasing range. */ |
/* If ADDR is within TABLE, set FUNCTIONNAME_PTR, and return TRUE. |
Note that we need to find the function that has the smallest |
range that contains ADDR, to handle inlined functions without |
depending upon them being ordered in TABLE by increasing range. */ |
static bfd_boolean |
lookup_address_in_function_table (struct comp_unit *unit, |
bfd_vma addr, |
struct funcinfo **function_ptr) |
struct funcinfo **function_ptr, |
const char **functionname_ptr) |
{ |
struct funcinfo* each_func; |
struct funcinfo* best_fit = NULL; |
bfd_vma best_fit_len = 0; |
struct arange *arange; |
for (each_func = unit->function_table; |
2170,22 → 2002,24 |
if (addr >= arange->low && addr < arange->high) |
{ |
if (!best_fit |
|| arange->high - arange->low < best_fit_len) |
{ |
|| (arange->high - arange->low |
< best_fit->arange.high - best_fit->arange.low)) |
best_fit = each_func; |
best_fit_len = arange->high - arange->low; |
} |
} |
} |
} |
if (best_fit) |
{ |
*functionname_ptr = best_fit->name; |
*function_ptr = best_fit; |
return TRUE; |
} |
else |
{ |
return FALSE; |
} |
} |
/* If SYM at ADDR is within function table of UNIT, set FILENAME_PTR |
and LINENUMBER_PTR, and return TRUE. */ |
2199,7 → 2033,6 |
{ |
struct funcinfo* each_func; |
struct funcinfo* best_fit = NULL; |
bfd_vma best_fit_len = 0; |
struct arange *arange; |
const char *name = bfd_asymbol_name (sym); |
asection *sec = bfd_get_section (sym); |
2218,13 → 2051,11 |
&& each_func->name |
&& strcmp (name, each_func->name) == 0 |
&& (!best_fit |
|| arange->high - arange->low < best_fit_len)) |
{ |
|| (arange->high - arange->low |
< best_fit->arange.high - best_fit->arange.low))) |
best_fit = each_func; |
best_fit_len = arange->high - arange->low; |
} |
} |
} |
if (best_fit) |
{ |
2275,12 → 2106,10 |
static char * |
find_abstract_instance_name (struct comp_unit *unit, |
struct attribute *attr_ptr, |
bfd_boolean *is_linkage) |
struct attribute *attr_ptr) |
{ |
bfd *abfd = unit->abfd; |
bfd_byte *info_ptr; |
bfd_byte *info_ptr_end; |
unsigned int abbrev_number, bytes_read, i; |
struct abbrev_info *abbrev; |
bfd_uint64_t die_ref = attr_ptr->u.val; |
2297,30 → 2126,7 |
abort (); |
info_ptr = unit->sec_info_ptr + die_ref; |
info_ptr_end = unit->end_ptr; |
/* Now find the CU containing this pointer. */ |
if (info_ptr >= unit->info_ptr_unit && info_ptr < unit->end_ptr) |
; |
else |
{ |
/* Check other CUs to see if they contain the abbrev. */ |
struct comp_unit * u; |
for (u = unit->prev_unit; u != NULL; u = u->prev_unit) |
if (info_ptr >= u->info_ptr_unit && info_ptr < u->end_ptr) |
break; |
if (u == NULL) |
for (u = unit->next_unit; u != NULL; u = u->next_unit) |
if (info_ptr >= u->info_ptr_unit && info_ptr < u->end_ptr) |
break; |
if (u) |
unit = u; |
/* else FIXME: What do we do now ? */ |
} |
} |
else if (attr_ptr->form == DW_FORM_GNU_ref_alt) |
{ |
info_ptr = read_alt_indirect_ref (unit, die_ref); |
2329,20 → 2135,13 |
(*_bfd_error_handler) |
(_("Dwarf Error: Unable to read alt ref %u."), die_ref); |
bfd_set_error (bfd_error_bad_value); |
return NULL; |
return name; |
} |
info_ptr_end = unit->stash->alt_dwarf_info_buffer + unit->stash->alt_dwarf_info_size; |
/* FIXME: Do we need to locate the correct CU, in a similar |
fashion to the code in the DW_FORM_ref_addr case above ? */ |
} |
else |
{ |
info_ptr = unit->info_ptr_unit + die_ref; |
info_ptr_end = unit->end_ptr; |
} |
abbrev_number = safe_read_leb128 (abfd, info_ptr, &bytes_read, FALSE, info_ptr_end); |
abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read); |
info_ptr += bytes_read; |
if (abbrev_number) |
2359,7 → 2158,7 |
for (i = 0; i < abbrev->num_attrs; ++i) |
{ |
info_ptr = read_attribute (&attr, &abbrev->attrs[i], unit, |
info_ptr, info_ptr_end); |
info_ptr); |
if (info_ptr == NULL) |
break; |
switch (attr.name) |
2367,25 → 2166,15 |
case DW_AT_name: |
/* Prefer DW_AT_MIPS_linkage_name or DW_AT_linkage_name |
over DW_AT_name. */ |
if (name == NULL && is_str_attr (attr.form)) |
{ |
if (name == NULL) |
name = attr.u.str; |
if (non_mangled (unit->lang)) |
*is_linkage = TRUE; |
} |
break; |
case DW_AT_specification: |
name = find_abstract_instance_name (unit, &attr, is_linkage); |
name = find_abstract_instance_name (unit, &attr); |
break; |
case DW_AT_linkage_name: |
case DW_AT_MIPS_linkage_name: |
/* PR 16949: Corrupt debug info can place |
non-string forms into these attributes. */ |
if (is_str_attr (attr.form)) |
{ |
name = attr.u.str; |
*is_linkage = TRUE; |
} |
break; |
default: |
break; |
2401,7 → 2190,6 |
bfd_uint64_t offset) |
{ |
bfd_byte *ranges_ptr; |
bfd_byte *ranges_end; |
bfd_vma base_address = unit->base_address; |
if (! unit->stash->dwarf_ranges_buffer) |
2409,11 → 2197,7 |
if (! read_debug_ranges (unit)) |
return FALSE; |
} |
ranges_ptr = unit->stash->dwarf_ranges_buffer + offset; |
if (ranges_ptr < unit->stash->dwarf_ranges_buffer) |
return FALSE; |
ranges_end = unit->stash->dwarf_ranges_buffer + unit->stash->dwarf_ranges_size; |
for (;;) |
{ |
2420,13 → 2204,9 |
bfd_vma low_pc; |
bfd_vma high_pc; |
/* PR 17512: file: 62cada7d. */ |
if (ranges_ptr + 2 * unit->addr_size > ranges_end) |
return FALSE; |
low_pc = read_address (unit, ranges_ptr, ranges_end); |
low_pc = read_address (unit, ranges_ptr); |
ranges_ptr += unit->addr_size; |
high_pc = read_address (unit, ranges_ptr, ranges_end); |
high_pc = read_address (unit, ranges_ptr); |
ranges_ptr += unit->addr_size; |
if (low_pc == 0 && high_pc == 0) |
2453,7 → 2233,6 |
{ |
bfd *abfd = unit->abfd; |
bfd_byte *info_ptr = unit->first_child_die_ptr; |
bfd_byte *info_ptr_end = unit->stash->info_ptr_end; |
int nesting_level = 1; |
struct funcinfo **nested_funcs; |
int nested_funcs_size; |
2478,11 → 2257,7 |
bfd_vma high_pc = 0; |
bfd_boolean high_pc_relative = FALSE; |
/* PR 17512: file: 9f405d9d. */ |
if (info_ptr >= info_ptr_end) |
goto fail; |
abbrev_number = safe_read_leb128 (abfd, info_ptr, &bytes_read, FALSE, info_ptr_end); |
abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read); |
info_ptr += bytes_read; |
if (! abbrev_number) |
2546,7 → 2321,7 |
for (i = 0; i < abbrev->num_attrs; ++i) |
{ |
info_ptr = read_attribute (&attr, &abbrev->attrs[i], unit, info_ptr, info_ptr_end); |
info_ptr = read_attribute (&attr, &abbrev->attrs[i], unit, info_ptr); |
if (info_ptr == NULL) |
goto fail; |
2565,30 → 2340,19 |
case DW_AT_abstract_origin: |
case DW_AT_specification: |
func->name = find_abstract_instance_name (unit, &attr, |
&func->is_linkage); |
func->name = find_abstract_instance_name (unit, &attr); |
break; |
case DW_AT_name: |
/* Prefer DW_AT_MIPS_linkage_name or DW_AT_linkage_name |
over DW_AT_name. */ |
if (func->name == NULL && is_str_attr (attr.form)) |
{ |
if (func->name == NULL) |
func->name = attr.u.str; |
if (non_mangled (unit->lang)) |
func->is_linkage = TRUE; |
} |
break; |
case DW_AT_linkage_name: |
case DW_AT_MIPS_linkage_name: |
/* PR 16949: Corrupt debug info can place |
non-string forms into these attributes. */ |
if (is_str_attr (attr.form)) |
{ |
func->name = attr.u.str; |
func->is_linkage = TRUE; |
} |
break; |
case DW_AT_low_pc: |
2744,15 → 2508,15 |
bfd *abfd = stash->bfd_ptr; |
bfd_boolean high_pc_relative = FALSE; |
version = read_2_bytes (abfd, info_ptr, end_ptr); |
version = read_2_bytes (abfd, info_ptr); |
info_ptr += 2; |
BFD_ASSERT (offset_size == 4 || offset_size == 8); |
if (offset_size == 4) |
abbrev_offset = read_4_bytes (abfd, info_ptr, end_ptr); |
abbrev_offset = read_4_bytes (abfd, info_ptr); |
else |
abbrev_offset = read_8_bytes (abfd, info_ptr, end_ptr); |
abbrev_offset = read_8_bytes (abfd, info_ptr); |
info_ptr += offset_size; |
addr_size = read_1_byte (abfd, info_ptr, end_ptr); |
addr_size = read_1_byte (abfd, info_ptr); |
info_ptr += 1; |
if (version != 2 && version != 3 && version != 4) |
2789,7 → 2553,7 |
if (! abbrevs) |
return 0; |
abbrev_number = safe_read_leb128 (abfd, info_ptr, &bytes_read, FALSE, end_ptr); |
abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read); |
info_ptr += bytes_read; |
if (! abbrev_number) |
{ |
2824,7 → 2588,7 |
for (i = 0; i < abbrev->num_attrs; ++i) |
{ |
info_ptr = read_attribute (&attr, &abbrev->attrs[i], unit, info_ptr, end_ptr); |
info_ptr = read_attribute (&attr, &abbrev->attrs[i], unit, info_ptr); |
if (info_ptr == NULL) |
return NULL; |
2863,15 → 2627,6 |
case DW_AT_comp_dir: |
{ |
char *comp_dir = attr.u.str; |
/* PR 17512: file: 1fe726be. */ |
if (! is_str_attr (attr.form)) |
{ |
(*_bfd_error_handler) |
(_("Dwarf Error: DW_AT_comp_dir attribute encountered with a non-string form.")); |
comp_dir = NULL; |
} |
if (comp_dir) |
{ |
/* Irix 6.2 native cc prepends <machine>.: to the compilation |
2885,10 → 2640,6 |
break; |
} |
case DW_AT_language: |
unit->lang = attr.u.val; |
break; |
default: |
break; |
} |
2933,22 → 2684,24 |
/* If UNIT contains ADDR, set the output parameters to the values for |
the line containing ADDR. The output parameters, FILENAME_PTR, |
FUNCTION_PTR, and LINENUMBER_PTR, are pointers to the objects |
FUNCTIONNAME_PTR, and LINENUMBER_PTR, are pointers to the objects |
to be filled in. |
Returns the range of addresses covered by the entry that was used |
to fill in *LINENUMBER_PTR or 0 if it was not filled in. */ |
Return TRUE if UNIT contains ADDR, and no errors were encountered; |
FALSE otherwise. */ |
static bfd_vma |
static bfd_boolean |
comp_unit_find_nearest_line (struct comp_unit *unit, |
bfd_vma addr, |
const char **filename_ptr, |
struct funcinfo **function_ptr, |
const char **functionname_ptr, |
unsigned int *linenumber_ptr, |
unsigned int *discriminator_ptr, |
struct dwarf2_debug *stash) |
{ |
bfd_boolean line_p; |
bfd_boolean func_p; |
struct funcinfo *function; |
if (unit->error) |
return FALSE; |
2977,15 → 2730,16 |
} |
} |
*function_ptr = NULL; |
func_p = lookup_address_in_function_table (unit, addr, function_ptr); |
if (func_p && (*function_ptr)->tag == DW_TAG_inlined_subroutine) |
stash->inliner_chain = *function_ptr; |
return lookup_address_in_line_info_table (unit->line_table, addr, |
function = NULL; |
func_p = lookup_address_in_function_table (unit, addr, |
&function, functionname_ptr); |
if (func_p && (function->tag == DW_TAG_inlined_subroutine)) |
stash->inliner_chain = function; |
line_p = lookup_address_in_line_info_table (unit->line_table, addr, |
filename_ptr, |
linenumber_ptr, |
discriminator_ptr); |
return line_p || func_p; |
} |
/* Check to see if line info is already decoded in a comp_unit. |
3208,36 → 2962,12 |
return NULL; |
} |
/* Transfer VMAs from object file to separate debug file. */ |
static void |
set_debug_vma (bfd *orig_bfd, bfd *debug_bfd) |
{ |
asection *s, *d; |
for (s = orig_bfd->sections, d = debug_bfd->sections; |
s != NULL && d != NULL; |
s = s->next, d = d->next) |
{ |
if ((d->flags & SEC_DEBUGGING) != 0) |
break; |
/* ??? Assumes 1-1 correspondence between sections in the |
two files. */ |
if (strcmp (s->name, d->name) == 0) |
{ |
d->output_section = s->output_section; |
d->output_offset = s->output_offset; |
d->vma = s->vma; |
} |
} |
} |
/* Unset vmas for adjusted sections in STASH. */ |
static void |
unset_sections (struct dwarf2_debug *stash) |
{ |
int i; |
unsigned int i; |
struct adjusted_section *p; |
i = stash->adjusted_section_count; |
3246,23 → 2976,14 |
p->section->vma = 0; |
} |
/* Set VMAs for allocated and .debug_info sections in ORIG_BFD, a |
relocatable object file. VMAs are normally all zero in relocatable |
object files, so if we want to distinguish locations in sections by |
address we need to set VMAs so the sections do not overlap. We |
also set VMA on .debug_info so that when we have multiple |
.debug_info sections (or the linkonce variant) they also do not |
overlap. The multiple .debug_info sections make up a single |
logical section. ??? We should probably do the same for other |
debug sections. */ |
/* Set unique VMAs for loadable and DWARF sections in ABFD and save |
VMAs in STASH for unset_sections. */ |
static bfd_boolean |
place_sections (bfd *orig_bfd, struct dwarf2_debug *stash) |
place_sections (bfd *abfd, struct dwarf2_debug *stash) |
{ |
bfd *abfd; |
struct adjusted_section *p; |
int i; |
const char *debug_info_name; |
unsigned int i; |
if (stash->adjusted_section_count != 0) |
{ |
3270,79 → 2991,78 |
p = stash->adjusted_sections; |
for (; i > 0; i--, p++) |
p->section->vma = p->adj_vma; |
return TRUE; |
} |
else |
{ |
asection *sect; |
bfd_vma last_vma = 0, last_dwarf = 0; |
bfd_size_type amt; |
const char *debug_info_name; |
debug_info_name = stash->debug_sections[debug_info].uncompressed_name; |
i = 0; |
abfd = orig_bfd; |
while (1) |
{ |
asection *sect; |
for (sect = abfd->sections; sect != NULL; sect = sect->next) |
{ |
bfd_size_type sz; |
int is_debug_info; |
if ((sect->output_section != NULL |
&& sect->output_section != sect |
&& (sect->flags & SEC_DEBUGGING) == 0) |
|| sect->vma != 0) |
if (sect->vma != 0) |
continue; |
is_debug_info = (strcmp (sect->name, debug_info_name) == 0 |
|| CONST_STRNEQ (sect->name, GNU_LINKONCE_INFO)); |
/* We need to adjust the VMAs of any .debug_info sections. |
Skip compressed ones, since no relocations could target |
them - they should not appear in object files anyway. */ |
if (strcmp (sect->name, debug_info_name) == 0) |
is_debug_info = 1; |
else if (CONST_STRNEQ (sect->name, GNU_LINKONCE_INFO)) |
is_debug_info = 1; |
else |
is_debug_info = 0; |
if (!((sect->flags & SEC_ALLOC) != 0 && abfd == orig_bfd) |
&& !is_debug_info) |
if (!is_debug_info && (sect->flags & SEC_LOAD) == 0) |
continue; |
sz = sect->rawsize ? sect->rawsize : sect->size; |
if (sz == 0) |
continue; |
i++; |
} |
if (abfd == stash->bfd_ptr) |
break; |
abfd = stash->bfd_ptr; |
} |
if (i <= 1) |
stash->adjusted_section_count = -1; |
else |
{ |
bfd_vma last_vma = 0, last_dwarf = 0; |
bfd_size_type amt = i * sizeof (struct adjusted_section); |
p = (struct adjusted_section *) bfd_malloc (amt); |
if (p == NULL) |
amt = i * sizeof (struct adjusted_section); |
p = (struct adjusted_section *) bfd_alloc (abfd, amt); |
if (! p) |
return FALSE; |
stash->adjusted_sections = p; |
stash->adjusted_section_count = i; |
abfd = orig_bfd; |
while (1) |
{ |
asection *sect; |
for (sect = abfd->sections; sect != NULL; sect = sect->next) |
{ |
bfd_size_type sz; |
int is_debug_info; |
if ((sect->output_section != NULL |
&& sect->output_section != sect |
&& (sect->flags & SEC_DEBUGGING) == 0) |
|| sect->vma != 0) |
if (sect->vma != 0) |
continue; |
is_debug_info = (strcmp (sect->name, debug_info_name) == 0 |
|| CONST_STRNEQ (sect->name, GNU_LINKONCE_INFO)); |
/* We need to adjust the VMAs of any .debug_info sections. |
Skip compressed ones, since no relocations could target |
them - they should not appear in object files anyway. */ |
if (strcmp (sect->name, debug_info_name) == 0) |
is_debug_info = 1; |
else if (CONST_STRNEQ (sect->name, GNU_LINKONCE_INFO)) |
is_debug_info = 1; |
else |
is_debug_info = 0; |
if (!((sect->flags & SEC_ALLOC) != 0 && abfd == orig_bfd) |
&& !is_debug_info) |
if (!is_debug_info && (sect->flags & SEC_LOAD) == 0) |
continue; |
sz = sect->rawsize ? sect->rawsize : sect->size; |
if (sz == 0) |
continue; |
p->section = sect; |
if (is_debug_info) |
{ |
BFD_ASSERT (sect->alignment_power == 0); |
3349,30 → 3069,25 |
sect->vma = last_dwarf; |
last_dwarf += sz; |
} |
else |
else if (last_vma != 0) |
{ |
/* Align the new address to the current section |
alignment. */ |
last_vma = ((last_vma |
+ ~(-((bfd_vma) 1 << sect->alignment_power))) |
& (-((bfd_vma) 1 << sect->alignment_power))); |
+ ~((bfd_vma) -1 << sect->alignment_power)) |
& ((bfd_vma) -1 << sect->alignment_power)); |
sect->vma = last_vma; |
last_vma += sz; |
last_vma += sect->vma + sz; |
} |
else |
last_vma += sect->vma + sz; |
p->section = sect; |
p->adj_vma = sect->vma; |
p++; |
} |
if (abfd == stash->bfd_ptr) |
break; |
abfd = stash->bfd_ptr; |
} |
} |
if (orig_bfd != stash->bfd_ptr) |
set_debug_vma (orig_bfd, stash->bfd_ptr); |
return TRUE; |
} |
3391,7 → 3106,6 |
{ |
struct funcinfo* each_func; |
struct funcinfo* best_fit = NULL; |
bfd_vma best_fit_len = 0; |
struct info_list_node *node; |
struct arange *arange; |
const char *name = bfd_asymbol_name (sym); |
3410,13 → 3124,11 |
&& addr >= arange->low |
&& addr < arange->high |
&& (!best_fit |
|| arange->high - arange->low < best_fit_len)) |
{ |
|| (arange->high - arange->low |
< best_fit->arange.high - best_fit->arange.low))) |
best_fit = each_func; |
best_fit_len = arange->high - arange->low; |
} |
} |
} |
if (best_fit) |
{ |
3604,56 → 3316,6 |
filename_ptr, linenumber_ptr); |
} |
/* Save current section VMAs. */ |
static bfd_boolean |
save_section_vma (const bfd *abfd, struct dwarf2_debug *stash) |
{ |
asection *s; |
unsigned int i; |
if (abfd->section_count == 0) |
return TRUE; |
stash->sec_vma = bfd_malloc (sizeof (*stash->sec_vma) * abfd->section_count); |
if (stash->sec_vma == NULL) |
return FALSE; |
for (i = 0, s = abfd->sections; i < abfd->section_count; i++, s = s->next) |
{ |
if (s->output_section != NULL) |
stash->sec_vma[i] = s->output_section->vma + s->output_offset; |
else |
stash->sec_vma[i] = s->vma; |
} |
return TRUE; |
} |
/* Compare current section VMAs against those at the time the stash |
was created. If find_nearest_line is used in linker warnings or |
errors early in the link process, the debug info stash will be |
invalid for later calls. This is because we relocate debug info |
sections, so the stashed section contents depend on symbol values, |
which in turn depend on section VMAs. */ |
static bfd_boolean |
section_vma_same (const bfd *abfd, const struct dwarf2_debug *stash) |
{ |
asection *s; |
unsigned int i; |
for (i = 0, s = abfd->sections; i < abfd->section_count; i++, s = s->next) |
{ |
bfd_vma vma; |
if (s->output_section != NULL) |
vma = s->output_section->vma + s->output_offset; |
else |
vma = s->vma; |
if (vma != stash->sec_vma[i]) |
return FALSE; |
} |
return TRUE; |
} |
/* Read debug information from DEBUG_BFD when DEBUG_BFD is specified. |
If DEBUG_BFD is not specified, we read debug information from ABFD |
or its gnu_debuglink. The results will be stored in PINFO. |
3663,8 → 3325,7 |
_bfd_dwarf2_slurp_debug_info (bfd *abfd, bfd *debug_bfd, |
const struct dwarf_debug_section *debug_sections, |
asymbol **symbols, |
void **pinfo, |
bfd_boolean do_place) |
void **pinfo) |
{ |
bfd_size_type amt = sizeof (struct dwarf2_debug); |
bfd_size_type total_size; |
3672,22 → 3333,13 |
struct dwarf2_debug *stash = (struct dwarf2_debug *) *pinfo; |
if (stash != NULL) |
{ |
if (section_vma_same (abfd, stash)) |
return TRUE; |
_bfd_dwarf2_cleanup_debug_info (abfd, pinfo); |
memset (stash, 0, amt); |
} |
else |
{ |
stash = (struct dwarf2_debug *) bfd_zalloc (abfd, amt); |
if (! stash) |
return FALSE; |
} |
stash->debug_sections = debug_sections; |
stash->syms = symbols; |
if (!save_section_vma (abfd, stash)) |
return FALSE; |
*pinfo = stash; |
3709,8 → 3361,7 |
if ((debug_bfd = bfd_openr (debug_filename, NULL)) == NULL |
|| ! bfd_check_format (debug_bfd, bfd_object) |
|| (msec = find_debug_info (debug_bfd, |
debug_sections, NULL)) == NULL |
|| !bfd_generic_link_read_symbols (debug_bfd)) |
debug_sections, NULL)) == NULL) |
{ |
if (debug_bfd) |
bfd_close (debug_bfd); |
3718,17 → 3369,10 |
free (debug_filename); |
return FALSE; |
} |
symbols = bfd_get_outsymbols (debug_bfd); |
stash->syms = symbols; |
stash->close_on_cleanup = TRUE; |
} |
stash->bfd_ptr = debug_bfd; |
if (do_place |
&& !place_sections (abfd, stash)) |
return FALSE; |
/* There can be more than one DWARF2 info section in a BFD these |
days. First handle the easy case when there's only one. If |
there's more than one, try case two: none of the sections is |
3788,57 → 3432,6 |
return TRUE; |
} |
/* Scan the debug information in PINFO looking for a DW_TAG_subprogram |
abbrev with a DW_AT_low_pc attached to it. Then lookup that same |
symbol in SYMBOLS and return the difference between the low_pc and |
the symbol's address. Returns 0 if no suitable symbol could be found. */ |
bfd_signed_vma |
_bfd_dwarf2_find_symbol_bias (asymbol ** symbols, void ** pinfo) |
{ |
struct dwarf2_debug *stash; |
struct comp_unit * unit; |
stash = (struct dwarf2_debug *) *pinfo; |
if (stash == NULL) |
return 0; |
for (unit = stash->all_comp_units; unit; unit = unit->next_unit) |
{ |
struct funcinfo * func; |
if (unit->function_table == NULL) |
{ |
if (unit->line_table == NULL) |
unit->line_table = decode_line_info (unit, stash); |
if (unit->line_table != NULL) |
scan_unit_for_symbols (unit); |
} |
for (func = unit->function_table; func != NULL; func = func->prev_func) |
if (func->name && func->arange.low) |
{ |
asymbol ** psym; |
/* FIXME: Do we need to scan the aranges looking for the lowest pc value ? */ |
for (psym = symbols; * psym != NULL; psym++) |
{ |
asymbol * sym = * psym; |
if (sym->flags & BSF_FUNCTION |
&& sym->section != NULL |
&& strcmp (sym->name, func->name) == 0) |
return ((bfd_signed_vma) func->arange.low) - |
((bfd_signed_vma) (sym->value + sym->section->vma)); |
} |
} |
} |
return 0; |
} |
/* Find the source code location of SYMBOL. If SYMBOL is NULL |
then find the nearest source code location corresponding to |
the address SECTION + OFFSET. |
3851,17 → 3444,17 |
field and in the abbreviation offset, or zero to indicate that the |
default value should be used. */ |
bfd_boolean |
_bfd_dwarf2_find_nearest_line (bfd *abfd, |
asymbol **symbols, |
asymbol *symbol, |
static bfd_boolean |
find_line (bfd *abfd, |
const struct dwarf_debug_section *debug_sections, |
asection *section, |
bfd_vma offset, |
asymbol *symbol, |
asymbol **symbols, |
const char **filename_ptr, |
const char **functionname_ptr, |
unsigned int *linenumber_ptr, |
unsigned int *discriminator_ptr, |
const struct dwarf_debug_section *debug_sections, |
unsigned int addr_size, |
void **pinfo) |
{ |
3877,8 → 3470,7 |
/* What address are we looking for? */ |
bfd_vma addr; |
struct comp_unit* each; |
struct funcinfo *function = NULL; |
bfd_boolean found = FALSE; |
bfd_vma found = FALSE; |
bfd_boolean do_line; |
*filename_ptr = NULL; |
3888,25 → 3480,35 |
if (discriminator_ptr) |
*discriminator_ptr = 0; |
if (! _bfd_dwarf2_slurp_debug_info (abfd, NULL, debug_sections, |
symbols, pinfo, |
(abfd->flags & (EXEC_P | DYNAMIC)) == 0)) |
if (! _bfd_dwarf2_slurp_debug_info (abfd, NULL, |
debug_sections, symbols, pinfo)) |
return FALSE; |
stash = (struct dwarf2_debug *) *pinfo; |
do_line = symbol != NULL; |
/* In a relocatable file, 2 functions may have the same address. |
We change the section vma so that they won't overlap. */ |
if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0) |
{ |
if (! place_sections (abfd, stash)) |
return FALSE; |
} |
do_line = (section == NULL |
&& offset == 0 |
&& functionname_ptr == NULL |
&& symbol != NULL); |
if (do_line) |
{ |
BFD_ASSERT (section == NULL && offset == 0 && functionname_ptr == NULL); |
addr = symbol->value; |
section = bfd_get_section (symbol); |
addr = symbol->value; |
} |
else if (section != NULL |
&& functionname_ptr != NULL |
&& symbol == NULL) |
addr = offset; |
else |
{ |
BFD_ASSERT (section != NULL && functionname_ptr != NULL); |
addr = offset; |
} |
abort (); |
if (section->output_section) |
addr += section->output_section->vma + section->output_offset; |
3958,55 → 3560,17 |
} |
else |
{ |
bfd_vma min_range = (bfd_vma) -1; |
const char * local_filename = NULL; |
struct funcinfo *local_function = NULL; |
unsigned int local_linenumber = 0; |
unsigned int local_discriminator = 0; |
for (each = stash->all_comp_units; each; each = each->next_unit) |
{ |
bfd_vma range = (bfd_vma) -1; |
found = ((each->arange.high == 0 |
|| comp_unit_contains_address (each, addr)) |
&& (range = comp_unit_find_nearest_line (each, addr, |
& local_filename, |
& local_function, |
& local_linenumber, |
& local_discriminator, |
stash)) != 0); |
&& comp_unit_find_nearest_line (each, addr, |
filename_ptr, |
functionname_ptr, |
linenumber_ptr, |
discriminator_ptr, |
stash)); |
if (found) |
{ |
/* PRs 15935 15994: Bogus debug information may have provided us |
with an erroneous match. We attempt to counter this by |
selecting the match that has the smallest address range |
associated with it. (We are assuming that corrupt debug info |
will tend to result in extra large address ranges rather than |
extra small ranges). |
This does mean that we scan through all of the CUs associated |
with the bfd each time this function is called. But this does |
have the benefit of producing consistent results every time the |
function is called. */ |
if (range <= min_range) |
{ |
if (filename_ptr && local_filename) |
* filename_ptr = local_filename; |
if (local_function) |
function = local_function; |
if (discriminator_ptr && local_discriminator) |
* discriminator_ptr = local_discriminator; |
if (local_linenumber) |
* linenumber_ptr = local_linenumber; |
min_range = range; |
} |
} |
} |
if (* linenumber_ptr) |
{ |
found = TRUE; |
goto done; |
} |
} |
4025,13 → 3589,13 |
unsigned int offset_size = addr_size; |
bfd_byte *info_ptr_unit = stash->info_ptr; |
length = read_4_bytes (stash->bfd_ptr, stash->info_ptr, stash->info_ptr_end); |
length = read_4_bytes (stash->bfd_ptr, stash->info_ptr); |
/* A 0xffffff length is the DWARF3 way of indicating |
we use 64-bit offsets, instead of 32-bit offsets. */ |
if (length == 0xffffffff) |
{ |
offset_size = 8; |
length = read_8_bytes (stash->bfd_ptr, stash->info_ptr + 4, stash->info_ptr_end); |
length = read_8_bytes (stash->bfd_ptr, stash->info_ptr + 4); |
stash->info_ptr += 12; |
} |
/* A zero length is the IRIX way of indicating 64-bit offsets, |
4040,7 → 3604,7 |
else if (length == 0) |
{ |
offset_size = 8; |
length = read_4_bytes (stash->bfd_ptr, stash->info_ptr + 4, stash->info_ptr_end); |
length = read_4_bytes (stash->bfd_ptr, stash->info_ptr + 4); |
stash->info_ptr += 8; |
} |
/* In the absence of the hints above, we assume 32-bit DWARF2 |
4062,8 → 3626,6 |
if (length > 0) |
{ |
bfd_byte * new_ptr; |
each = parse_comp_unit (stash, length, info_ptr_unit, |
offset_size); |
if (!each) |
4070,18 → 3632,8 |
/* The dwarf information is damaged, don't trust it any |
more. */ |
break; |
stash->info_ptr += length; |
new_ptr = stash->info_ptr + length; |
/* PR 17512: file: 1500698c. */ |
if (new_ptr < stash->info_ptr) |
{ |
/* A corrupt length value - do not trust the info any more. */ |
found = FALSE; |
break; |
} |
else |
stash->info_ptr = new_ptr; |
if (stash->all_comp_units) |
stash->all_comp_units->prev_unit = each; |
else |
4108,10 → 3660,10 |
|| comp_unit_contains_address (each, addr)) |
&& comp_unit_find_nearest_line (each, addr, |
filename_ptr, |
&function, |
functionname_ptr, |
linenumber_ptr, |
discriminator_ptr, |
stash) != 0); |
stash)); |
if ((bfd_vma) (stash->info_ptr - stash->sec_info_ptr) |
== stash->sec->size) |
4127,28 → 3679,6 |
} |
done: |
if (function) |
{ |
if (!function->is_linkage) |
{ |
asymbol *fun; |
bfd_vma sec_vma; |
fun = _bfd_elf_find_function (abfd, symbols, section, offset, |
*filename_ptr ? NULL : filename_ptr, |
functionname_ptr); |
sec_vma = section->vma; |
if (section->output_section != NULL) |
sec_vma = section->output_section->vma + section->output_offset; |
if (fun != NULL |
&& fun->value + sec_vma == function->arange.low) |
function->name = *functionname_ptr; |
/* Even if we didn't find a linkage name, say that we have |
to stop a repeated search of symbols. */ |
function->is_linkage = TRUE; |
} |
*functionname_ptr = function->name; |
} |
if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0) |
unset_sections (stash); |
4155,7 → 3685,46 |
return found; |
} |
/* The DWARF2 version of find_nearest_line. |
Return TRUE if the line is found without error. */ |
bfd_boolean |
_bfd_dwarf2_find_nearest_line (bfd *abfd, |
const struct dwarf_debug_section *debug_sections, |
asection *section, |
asymbol **symbols, |
bfd_vma offset, |
const char **filename_ptr, |
const char **functionname_ptr, |
unsigned int *linenumber_ptr, |
unsigned int *discriminator_ptr, |
unsigned int addr_size, |
void **pinfo) |
{ |
return find_line (abfd, debug_sections, section, offset, NULL, symbols, |
filename_ptr, functionname_ptr, linenumber_ptr, |
discriminator_ptr, addr_size, pinfo); |
} |
/* The DWARF2 version of find_line. |
Return TRUE if the line is found without error. */ |
bfd_boolean |
_bfd_dwarf2_find_line (bfd *abfd, |
asymbol **symbols, |
asymbol *symbol, |
const char **filename_ptr, |
unsigned int *linenumber_ptr, |
unsigned int *discriminator_ptr, |
unsigned int addr_size, |
void **pinfo) |
{ |
return find_line (abfd, dwarf_debug_sections, NULL, 0, symbol, symbols, |
filename_ptr, NULL, linenumber_ptr, discriminator_ptr, |
addr_size, pinfo); |
} |
bfd_boolean |
_bfd_dwarf2_find_inliner_info (bfd *abfd ATTRIBUTE_UNUSED, |
const char **filename_ptr, |
const char **functionname_ptr, |
4259,116 → 3828,6 |
free (stash->alt_dwarf_str_buffer); |
if (stash->alt_dwarf_info_buffer) |
free (stash->alt_dwarf_info_buffer); |
if (stash->sec_vma) |
free (stash->sec_vma); |
if (stash->adjusted_sections) |
free (stash->adjusted_sections); |
if (stash->alt_bfd_ptr) |
bfd_close (stash->alt_bfd_ptr); |
} |
/* Find the function to a particular section and offset, |
for error reporting. */ |
asymbol * |
_bfd_elf_find_function (bfd *abfd, |
asymbol **symbols, |
asection *section, |
bfd_vma offset, |
const char **filename_ptr, |
const char **functionname_ptr) |
{ |
struct elf_find_function_cache |
{ |
asection *last_section; |
asymbol *func; |
const char *filename; |
bfd_size_type func_size; |
} *cache; |
if (symbols == NULL) |
return NULL; |
if (bfd_get_flavour (abfd) != bfd_target_elf_flavour) |
return NULL; |
cache = elf_tdata (abfd)->elf_find_function_cache; |
if (cache == NULL) |
{ |
cache = bfd_zalloc (abfd, sizeof (*cache)); |
elf_tdata (abfd)->elf_find_function_cache = cache; |
if (cache == NULL) |
return NULL; |
} |
if (cache->last_section != section |
|| cache->func == NULL |
|| offset < cache->func->value |
|| offset >= cache->func->value + cache->func_size) |
{ |
asymbol *file; |
bfd_vma low_func; |
asymbol **p; |
/* ??? Given multiple file symbols, it is impossible to reliably |
choose the right file name for global symbols. File symbols are |
local symbols, and thus all file symbols must sort before any |
global symbols. The ELF spec may be interpreted to say that a |
file symbol must sort before other local symbols, but currently |
ld -r doesn't do this. So, for ld -r output, it is possible to |
make a better choice of file name for local symbols by ignoring |
file symbols appearing after a given local symbol. */ |
enum { nothing_seen, symbol_seen, file_after_symbol_seen } state; |
const struct elf_backend_data *bed = get_elf_backend_data (abfd); |
file = NULL; |
low_func = 0; |
state = nothing_seen; |
cache->filename = NULL; |
cache->func = NULL; |
cache->func_size = 0; |
cache->last_section = section; |
for (p = symbols; *p != NULL; p++) |
{ |
asymbol *sym = *p; |
bfd_vma code_off; |
bfd_size_type size; |
if ((sym->flags & BSF_FILE) != 0) |
{ |
file = sym; |
if (state == symbol_seen) |
state = file_after_symbol_seen; |
continue; |
} |
size = bed->maybe_function_sym (sym, section, &code_off); |
if (size != 0 |
&& code_off <= offset |
&& (code_off > low_func |
|| (code_off == low_func |
&& size > cache->func_size))) |
{ |
cache->func = sym; |
cache->func_size = size; |
cache->filename = NULL; |
low_func = code_off; |
if (file != NULL |
&& ((sym->flags & BSF_LOCAL) != 0 |
|| state != file_after_symbol_seen)) |
cache->filename = bfd_asymbol_name (file); |
} |
if (state == nothing_seen) |
state = symbol_seen; |
} |
} |
if (cache->func == NULL) |
return NULL; |
if (filename_ptr) |
*filename_ptr = cache->filename; |
if (functionname_ptr) |
*functionname_ptr = bfd_asymbol_name (cache->func); |
return cache->func; |
} |
/contrib/toolchain/binutils/bfd/elf-attrs.c |
---|
1,5 → 1,6 |
/* ELF attributes support (based on ARM EABI attributes). |
Copyright (C) 2005-2015 Free Software Foundation, Inc. |
Copyright 2005, 2006, 2007, 2009, 2010, 2012 |
Free Software Foundation, Inc. |
This file is part of BFD, the Binary File Descriptor library. |
54,7 → 55,7 |
/* Return the size of a single attribute. */ |
static bfd_vma |
obj_attr_size (unsigned int tag, obj_attribute *attr) |
obj_attr_size (int tag, obj_attribute *attr) |
{ |
bfd_vma size; |
143,7 → 144,7 |
/* Write attribute ATTR to butter P, and return a pointer to the following |
byte. */ |
static bfd_byte * |
write_obj_attribute (bfd_byte *p, unsigned int tag, obj_attribute *attr) |
write_obj_attribute (bfd_byte *p, int tag, obj_attribute *attr) |
{ |
/* Suppress default entries. */ |
if (is_default_attr (attr)) |
189,7 → 190,7 |
attr = elf_known_obj_attributes (abfd)[vendor]; |
for (i = LEAST_KNOWN_OBJ_ATTRIBUTE; i < NUM_KNOWN_OBJ_ATTRIBUTES; i++) |
{ |
unsigned int tag = i; |
int tag = i; |
if (get_elf_backend_data (abfd)->obj_attrs_order) |
tag = get_elf_backend_data (abfd)->obj_attrs_order (i); |
p = write_obj_attribute (p, tag, &attr[tag]); |
227,7 → 228,7 |
/* Allocate/find an object attribute. */ |
static obj_attribute * |
elf_new_obj_attr (bfd *abfd, int vendor, unsigned int tag) |
elf_new_obj_attr (bfd *abfd, int vendor, int tag) |
{ |
obj_attribute *attr; |
obj_attribute_list *list; |
265,7 → 266,7 |
/* Return the value of an integer object attribute. */ |
int |
bfd_elf_get_obj_attr_int (bfd *abfd, int vendor, unsigned int tag) |
bfd_elf_get_obj_attr_int (bfd *abfd, int vendor, int tag) |
{ |
obj_attribute_list *p; |
291,7 → 292,7 |
/* Add an integer object attribute. */ |
void |
bfd_elf_add_obj_attr_int (bfd *abfd, int vendor, unsigned int tag, unsigned int i) |
bfd_elf_add_obj_attr_int (bfd *abfd, int vendor, int tag, unsigned int i) |
{ |
obj_attribute *attr; |
314,7 → 315,7 |
/* Add a string object attribute. */ |
void |
bfd_elf_add_obj_attr_string (bfd *abfd, int vendor, unsigned int tag, const char *s) |
bfd_elf_add_obj_attr_string (bfd *abfd, int vendor, int tag, const char *s) |
{ |
obj_attribute *attr; |
325,8 → 326,7 |
/* Add a int+string object attribute. */ |
void |
bfd_elf_add_obj_attr_int_string (bfd *abfd, int vendor, |
unsigned int tag, |
bfd_elf_add_obj_attr_int_string (bfd *abfd, int vendor, int tag, |
unsigned int i, const char *s) |
{ |
obj_attribute *attr; |
395,7 → 395,7 |
/* Determine whether a GNU object attribute tag takes an integer, a |
string or both. */ |
static int |
gnu_obj_attrs_arg_type (unsigned int tag) |
gnu_obj_attrs_arg_type (int tag) |
{ |
/* Except for Tag_compatibility, for GNU attributes we follow the |
same rule ARM ones > 32 follow: odd-numbered tags take strings |
410,7 → 410,7 |
/* Determine what arguments an attribute tag takes. */ |
int |
_bfd_elf_obj_attrs_arg_type (bfd *abfd, int vendor, unsigned int tag) |
_bfd_elf_obj_attrs_arg_type (bfd *abfd, int vendor, int tag) |
{ |
switch (vendor) |
{ |
431,13 → 431,9 |
{ |
bfd_byte *contents; |
bfd_byte *p; |
bfd_byte *p_end; |
bfd_vma len; |
const char *std_sec; |
/* PR 17512: file: 2844a11d. */ |
if (hdr->sh_size == 0) |
return; |
contents = (bfd_byte *) bfd_malloc (hdr->sh_size); |
if (!contents) |
return; |
448,31 → 444,23 |
return; |
} |
p = contents; |
p_end = p + hdr->sh_size; |
std_sec = get_elf_backend_data (abfd)->obj_attrs_vendor; |
if (*(p++) == 'A') |
{ |
len = hdr->sh_size - 1; |
while (len > 0 && p < p_end - 4) |
while (len > 0) |
{ |
unsigned namelen; |
int namelen; |
bfd_vma section_len; |
int vendor; |
section_len = bfd_get_32 (abfd, p); |
p += 4; |
if (section_len == 0) |
break; |
if (section_len > len) |
section_len = len; |
len -= section_len; |
section_len -= 4; |
namelen = strnlen ((char *) p, section_len) + 1; |
if (namelen == 0 || namelen >= section_len) |
break; |
section_len -= namelen; |
namelen = strlen ((char *) p) + 1; |
section_len -= namelen + 4; |
if (std_sec && strcmp ((char *) p, std_sec) == 0) |
vendor = OBJ_ATTR_PROC; |
else if (strcmp ((char *) p, "gnu") == 0) |
485,31 → 473,23 |
} |
p += namelen; |
while (section_len > 0 && p < p_end) |
while (section_len > 0) |
{ |
unsigned int tag; |
int tag; |
unsigned int n; |
unsigned int val; |
bfd_vma subsection_len; |
bfd_byte *end; |
tag = safe_read_leb128 (abfd, p, &n, FALSE, p_end); |
tag = read_unsigned_leb128 (abfd, p, &n); |
p += n; |
if (p < p_end - 4) |
subsection_len = bfd_get_32 (abfd, p); |
else |
subsection_len = 0; |
p += 4; |
if (subsection_len == 0) |
break; |
if (subsection_len > section_len) |
subsection_len = section_len; |
section_len -= subsection_len; |
subsection_len -= n + 4; |
end = p + subsection_len; |
/* PR 17512: file: 0e8c0c90. */ |
if (end > p_end) |
end = p_end; |
switch (tag) |
{ |
case Tag_File: |
517,13 → 497,13 |
{ |
int type; |
tag = safe_read_leb128 (abfd, p, &n, FALSE, end); |
tag = read_unsigned_leb128 (abfd, p, &n); |
p += n; |
type = _bfd_elf_obj_attrs_arg_type (abfd, vendor, tag); |
switch (type & (ATTR_TYPE_FLAG_INT_VAL | ATTR_TYPE_FLAG_STR_VAL)) |
{ |
case ATTR_TYPE_FLAG_INT_VAL | ATTR_TYPE_FLAG_STR_VAL: |
val = safe_read_leb128 (abfd, p, &n, FALSE, end); |
val = read_unsigned_leb128 (abfd, p, &n); |
p += n; |
bfd_elf_add_obj_attr_int_string (abfd, vendor, tag, |
val, (char *) p); |
535,7 → 515,7 |
p += strlen ((char *)p) + 1; |
break; |
case ATTR_TYPE_FLAG_INT_VAL: |
val = safe_read_leb128 (abfd, p, &n, FALSE, end); |
val = read_unsigned_leb128 (abfd, p, &n); |
p += n; |
bfd_elf_add_obj_attr_int (abfd, vendor, tag, val); |
break; |
667,7 → 647,7 |
for (; in_list || out_list; ) |
{ |
bfd *err_bfd = NULL; |
unsigned int err_tag = 0; |
int err_tag = 0; |
/* The tags for each list are in numerical order. */ |
/* If the tags are equal, then merge. */ |
/contrib/toolchain/binutils/bfd/elf-bfd.h |
---|
1,5 → 1,5 |
/* BFD back-end data structures for ELF files. |
Copyright (C) 1992-2015 Free Software Foundation, Inc. |
Copyright 1992-2013 Free Software Foundation, Inc. |
Written by Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
27,10 → 27,6 |
#include "elf/internal.h" |
#include "bfdlink.h" |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* The number of entries in a section is its size divided by the size |
of a single entry. This is normally only applicable to reloc and |
symbol table sections. |
108,15 → 104,6 |
struct elf_link_hash_entry *parent; |
}; |
/* ELF symbol version. */ |
enum elf_symbol_version |
{ |
unknown = 0, |
unversioned, |
versioned, |
versioned_hidden |
}; |
/* ELF linker hash table entries. */ |
struct elf_link_hash_entry |
187,8 → 174,8 |
unsigned int needs_plt : 1; |
/* Symbol appears in a non-ELF input file. */ |
unsigned int non_elf : 1; |
/* Symbol version information. */ |
ENUM_BITFIELD (elf_symbol_version) versioned : 2; |
/* Symbol should be marked as hidden in the version information. */ |
unsigned int hidden : 1; |
/* Symbol was forced to local scope due to a version script file. */ |
unsigned int forced_local : 1; |
/* Symbol was forced to be dynamic due to a version script file. */ |
209,9 → 196,6 |
unsigned int pointer_equality_needed : 1; |
/* Symbol is a unique global symbol. */ |
unsigned int unique_global : 1; |
/* Symbol is defined by a shared library with non-default visibility |
in a read/write section. */ |
unsigned int protected_def : 1; |
/* String table index in .dynstr if this is a dynamic symbol. */ |
unsigned long dynstr_index; |
255,8 → 239,7 |
_bfd_elf_symbol_refs_local_p (H, INFO, 1) |
/* Common symbols that are turned into definitions don't have the |
DEF_REGULAR flag set, so they might appear to be undefined. |
Symbols defined in linker scripts also don't have DEF_REGULAR set. */ |
DEF_REGULAR flag set, so they might appear to be undefined. */ |
#define ELF_COMMON_DEF_P(H) \ |
(!(H)->def_regular \ |
&& !(H)->def_dynamic \ |
297,9 → 280,7 |
If REMOVED == 0, this is the CIE that we have chosen to use for |
the output FDE. The CIE's REMOVED field is also 0, but the CIE |
might belong to a different .eh_frame input section from the FDE. |
May be NULL to signify that the FDE should be discarded. */ |
might belong to a different .eh_frame input section from the FDE. */ |
struct eh_cie_fde *cie_inf; |
struct eh_cie_fde *next_for_section; |
} fde; |
391,49 → 372,27 |
struct eh_frame_array_ent |
{ |
bfd_vma initial_loc; |
bfd_size_type range; |
bfd_vma fde; |
}; |
struct htab; |
#define DWARF2_EH_HDR 1 |
#define COMPACT_EH_HDR 2 |
/* Endian-neutral code indicating that a function cannot be unwound. */ |
#define COMPACT_EH_CANT_UNWIND_OPCODE 0x015d5d01 |
struct dwarf_eh_frame_hdr_info |
struct eh_frame_hdr_info |
{ |
struct htab *cies; |
unsigned int fde_count; |
asection *hdr_sec; |
unsigned int fde_count, array_count; |
struct eh_frame_array_ent *array; |
/* TRUE if we should try to merge CIEs between input sections. */ |
bfd_boolean merge_cies; |
/* TRUE if all .eh_frames have been parsd. */ |
bfd_boolean parsed_eh_frames; |
/* TRUE if .eh_frame_hdr should contain the sorted search table. |
We build it if we successfully read all .eh_frame input sections |
and recognize them. */ |
bfd_boolean table; |
struct eh_frame_array_ent *array; |
}; |
struct compact_eh_frame_hdr_info |
{ |
unsigned int allocated_entries; |
/* eh_frame_entry fragments. */ |
asection **entries; |
}; |
struct eh_frame_hdr_info |
{ |
asection *hdr_sec; |
unsigned int array_count; |
bfd_boolean frame_hdr_is_compact; |
union |
{ |
struct dwarf_eh_frame_hdr_info dwarf; |
struct compact_eh_frame_hdr_info compact; |
} |
u; |
}; |
/* Enum used to identify target specific extensions to the elf_obj_tdata |
and elf_link_hash_table structures. Note the enums deliberately start |
from 1 so that we can detect an uninitialized field. The generic value |
460,9 → 419,7 |
MICROBLAZE_ELF_DATA, |
MIPS_ELF_DATA, |
MN10300_ELF_DATA, |
NDS32_ELF_DATA, |
NIOS2_ELF_DATA, |
OR1K_ELF_DATA, |
PPC32_ELF_DATA, |
PPC64_ELF_DATA, |
S390_ELF_DATA, |
478,13 → 435,6 |
GENERIC_ELF_DATA |
}; |
struct elf_sym_strtab |
{ |
Elf_Internal_Sym sym; |
unsigned long dest_index; |
unsigned long destshndx_index; |
}; |
/* ELF linker hash table. */ |
struct elf_link_hash_table |
528,17 → 478,6 |
section. */ |
struct elf_strtab_hash *dynstr; |
/* The number of symbol strings found in the link which must be put |
into the .strtab section. */ |
bfd_size_type strtabcount; |
/* The array size of the symbol string table, which becomes the |
.strtab section. */ |
bfd_size_type strtabsize; |
/* The array of strings, which becomes the .strtab section. */ |
struct elf_sym_strtab *strtab; |
/* The number of buckets in the hash table in the .hash section. |
This is based on the number of dynamic symbols. */ |
bfd_size_type bucketcount; |
595,7 → 534,6 |
asection *iplt; |
asection *irelplt; |
asection *irelifunc; |
asection *dynsym; |
}; |
/* Look up an entry in an ELF linker hash table. */ |
1170,11 → 1108,6 |
unsigned int (*elf_backend_count_relocs) |
(struct bfd_link_info *, asection *); |
/* Say whether to sort relocs output by ld -r and ld --emit-relocs, |
by r_offset. If NULL, default to true. */ |
bfd_boolean (*sort_relocs_p) |
(asection *); |
/* This function, if defined, is called when an NT_PRSTATUS note is found |
in a core file. */ |
bfd_boolean (*elf_backend_grok_prstatus) |
1257,7 → 1190,7 |
/* This function implements `bfd_elf_bfd_from_remote_memory'; |
see elf.c, elfcode.h. */ |
bfd *(*elf_backend_bfd_from_remote_memory) |
(bfd *templ, bfd_vma ehdr_vma, bfd_size_type size, bfd_vma *loadbasep, |
(bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep, |
int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr, |
bfd_size_type len)); |
1292,9 → 1225,6 |
bfd_size_type (*maybe_function_sym) (const asymbol *sym, asection *sec, |
bfd_vma *code_off); |
/* Return the section which RELOC_SEC applies to. */ |
asection *(*get_reloc_section) (asection *reloc_sec); |
/* Used to handle bad SHF_LINK_ORDER input. */ |
bfd_error_handler_type link_order_error_handler; |
1344,12 → 1274,6 |
or give an error and return FALSE. */ |
bfd_boolean (*obj_attrs_handle_unknown) (bfd *, int); |
/* Encoding used for compact EH tables. */ |
int (*compact_eh_encoding) (struct bfd_link_info *); |
/* Opcode representing no unwind. */ |
int (*cant_unwind_opcode) (struct bfd_link_info *); |
/* This is non-zero if static TLS segments require a special alignment. */ |
unsigned static_tls_alignment; |
1417,15 → 1341,6 |
other file in the link needs to have a .note.GNU-stack section |
for a PT_GNU_STACK segment to be created. */ |
unsigned default_execstack : 1; |
/* True if elf_section_data(sec)->this_hdr.contents is sec->rawsize |
in length rather than sec->size in length, if sec->rawsize is |
non-zero and smaller than sec->size. */ |
unsigned caches_rawsize : 1; |
/* Address of protected data defined in the shared library may be |
external, i.e., due to copy relocation. */ |
unsigned extern_protected_data : 1; |
}; |
/* Information about reloc sections associated with a bfd_elf_section_data |
1504,9 → 1419,6 |
field acts as a chain pointer. */ |
struct eh_cie_fde *fde_list; |
/* Link from a text section to its .eh_frame_entry section. */ |
asection *eh_frame_entry; |
/* A pointer used for various section optimizations. */ |
void *sec_info; |
}; |
1520,7 → 1432,6 |
#define elf_next_in_group(sec) (elf_section_data(sec)->next_in_group) |
#define elf_fde_list(sec) (elf_section_data(sec)->fde_list) |
#define elf_sec_group(sec) (elf_section_data(sec)->sec_group) |
#define elf_section_eh_frame_entry(sec) (elf_section_data(sec)->eh_frame_entry) |
#define xvec_get_elf_backend_data(xvec) \ |
((const struct elf_backend_data *) (xvec)->backend_data) |
1559,7 → 1470,7 |
typedef struct obj_attribute_list |
{ |
struct obj_attribute_list *next; |
unsigned int tag; |
int tag; |
obj_attribute attr; |
} obj_attribute_list; |
1591,6 → 1502,13 |
bfd_byte data[1]; |
}; |
/* NT_GNU_BUILD_ID note type info for input BFDs. */ |
struct elf_build_id |
{ |
size_t size; |
bfd_byte data[1]; |
}; |
/* tdata information grabbed from an elf core file. */ |
struct core_elf_obj_tdata |
{ |
1642,26 → 1560,6 |
bfd_boolean flags_init; |
}; |
/* Indicate if the bfd contains symbols that have the STT_GNU_IFUNC |
symbol type or STB_GNU_UNIQUE binding. Used to set the osabi |
field in the ELF header structure. */ |
enum elf_gnu_symbols |
{ |
elf_gnu_symbol_none = 0, |
elf_gnu_symbol_any = 1 << 0, |
elf_gnu_symbol_ifunc = (elf_gnu_symbol_any | 1 << 1), |
elf_gnu_symbol_unique = (elf_gnu_symbol_any | 1 << 2), |
elf_gnu_symbol_all = (elf_gnu_symbol_ifunc | elf_gnu_symbol_unique) |
}; |
typedef struct elf_section_list |
{ |
Elf_Internal_Shdr hdr; |
unsigned int ndx; |
struct elf_section_list * next; |
} elf_section_list; |
/* Some private data is stashed away for future use using the tdata pointer |
in the bfd structure. */ |
1678,7 → 1576,7 |
Elf_Internal_Shdr dynversym_hdr; |
Elf_Internal_Shdr dynverref_hdr; |
Elf_Internal_Shdr dynverdef_hdr; |
elf_section_list * symtab_shndx_list; |
Elf_Internal_Shdr symtab_shndx_hdr; |
bfd_vma gp; /* The gp value */ |
unsigned int gp_size; /* The gp size */ |
unsigned int num_elf_sections; /* elf_sect_ptr size */ |
1745,6 → 1643,9 |
obj_attribute known_obj_attributes[2][NUM_KNOWN_OBJ_ATTRIBUTES]; |
obj_attribute_list *other_obj_attributes[2]; |
/* NT_GNU_BUILD_ID note type. */ |
struct elf_build_id *build_id; |
/* Linked-list containing information about every Systemtap section |
found in the object file. Each section corresponds to one entry |
in the list. */ |
1753,7 → 1654,7 |
Elf_Internal_Shdr **group_sect_ptr; |
int num_group; |
unsigned int symtab_section, dynsymtab_section; |
unsigned int symtab_section, symtab_shndx_section, dynsymtab_section; |
unsigned int dynversym_section, dynverdef_section, dynverref_section; |
/* An identifier used to distinguish different target |
1772,7 → 1673,10 |
symbols. */ |
bfd_boolean bad_symtab; |
enum elf_gnu_symbols has_gnu_symbols; |
/* True if the bfd contains symbols that have the STT_GNU_IFUNC |
symbol type or STB_GNU_UNIQUE binding. Used to set the osabi |
field in the ELF header structure. */ |
bfd_boolean has_gnu_symbols; |
/* Information grabbed from an elf core file. */ |
struct core_elf_obj_tdata *core; |
1795,7 → 1699,7 |
#define elf_stack_flags(bfd) (elf_tdata(bfd) -> o->stack_flags) |
#define elf_shstrtab(bfd) (elf_tdata(bfd) -> o->strtab_ptr) |
#define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section) |
#define elf_symtab_shndx_list(bfd) (elf_tdata(bfd) -> symtab_shndx_list) |
#define elf_symtab_shndx(bfd) (elf_tdata(bfd) -> symtab_shndx_section) |
#define elf_strtab_sec(bfd) (elf_tdata(bfd) -> o->strtab_section) |
#define elf_shstrtab_sec(bfd) (elf_tdata(bfd) -> o->shstrtab_section) |
#define elf_symtab_hdr(bfd) (elf_tdata(bfd) -> symtab_hdr) |
1862,8 → 1766,6 |
(bfd *, bfd *); |
extern bfd_boolean _bfd_elf_print_private_bfd_data |
(bfd *, void *); |
const char * _bfd_elf_get_symbol_version_string |
(bfd *, asymbol *, bfd_boolean *); |
extern void bfd_elf_print_symbol |
(bfd *, void *, asymbol *, bfd_print_symbol_type); |
1907,7 → 1809,7 |
extern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create |
(bfd *); |
extern void _bfd_elf_link_hash_table_free |
(bfd *); |
(struct bfd_link_hash_table *); |
extern void _bfd_elf_link_hash_copy_indirect |
(struct bfd_link_info *, struct elf_link_hash_entry *, |
struct elf_link_hash_entry *); |
1990,14 → 1892,20 |
extern bfd_boolean _bfd_elf_set_arch_mach |
(bfd *, enum bfd_architecture, unsigned long); |
extern bfd_boolean _bfd_elf_find_nearest_line |
(bfd *, asymbol **, asection *, bfd_vma, |
const char **, const char **, unsigned int *, unsigned int *); |
(bfd *, asection *, asymbol **, bfd_vma, const char **, const char **, |
unsigned int *); |
extern bfd_boolean _bfd_elf_find_nearest_line_discriminator |
(bfd *, asection *, asymbol **, bfd_vma, const char **, const char **, |
unsigned int *, unsigned int *); |
extern bfd_boolean _bfd_elf_find_line |
(bfd *, asymbol **, asymbol *, const char **, unsigned int *); |
extern bfd_boolean _bfd_elf_find_line_discriminator |
(bfd *, asymbol **, asymbol *, const char **, unsigned int *, unsigned int *); |
#define _bfd_generic_find_line _bfd_elf_find_line |
#define _bfd_generic_find_nearest_line_discriminator \ |
_bfd_elf_find_nearest_line_discriminator |
extern bfd_boolean _bfd_elf_find_inliner_info |
(bfd *, const char **, const char **, unsigned int *); |
extern asymbol *_bfd_elf_find_function |
(bfd *, asymbol **, asection *, bfd_vma, const char **, const char **); |
#define _bfd_elf_read_minisymbols _bfd_generic_read_minisymbols |
#define _bfd_elf_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol |
extern int _bfd_elf_sizeof_headers |
2025,6 → 1933,8 |
(struct sym_cache *, bfd *, unsigned long); |
extern asection *bfd_section_from_elf_index |
(bfd *, unsigned int); |
extern struct bfd_strtab_hash *_bfd_elf_stringtab_init |
(void); |
extern struct elf_strtab_hash * _bfd_elf_strtab_init |
(void); |
2051,13 → 1961,11 |
extern void _bfd_elf_strtab_finalize |
(struct elf_strtab_hash *); |
extern bfd_boolean bfd_elf_parse_eh_frame_entries |
(bfd *, struct bfd_link_info *); |
extern bfd_boolean _bfd_elf_parse_eh_frame_entry |
(struct bfd_link_info *, asection *, struct elf_reloc_cookie *); |
extern void _bfd_elf_begin_eh_frame_parsing |
(struct bfd_link_info *info); |
extern void _bfd_elf_parse_eh_frame |
(bfd *, struct bfd_link_info *, asection *, struct elf_reloc_cookie *); |
extern bfd_boolean _bfd_elf_end_eh_frame_parsing |
extern void _bfd_elf_end_eh_frame_parsing |
(struct bfd_link_info *info); |
extern bfd_boolean _bfd_elf_discard_section_eh_frame |
2069,15 → 1977,10 |
(bfd *, struct bfd_link_info *, asection *, bfd_vma); |
extern bfd_boolean _bfd_elf_write_section_eh_frame |
(bfd *, struct bfd_link_info *, asection *, bfd_byte *); |
bfd_boolean _bfd_elf_write_section_eh_frame_entry |
(bfd *, struct bfd_link_info *, asection *, bfd_byte *); |
extern bfd_boolean _bfd_elf_fixup_eh_frame_hdr (struct bfd_link_info *); |
extern bfd_boolean _bfd_elf_write_section_eh_frame_hdr |
(bfd *, struct bfd_link_info *); |
extern bfd_boolean _bfd_elf_eh_frame_present |
(struct bfd_link_info *); |
extern bfd_boolean _bfd_elf_eh_frame_entry_present |
(struct bfd_link_info *); |
extern bfd_boolean _bfd_elf_maybe_strip_eh_frame_hdr |
(struct bfd_link_info *); |
2087,6 → 1990,8 |
(struct bfd_link_info *, bfd *, long); |
extern bfd_boolean _bfd_elf_compute_section_file_positions |
(bfd *, struct bfd_link_info *); |
extern void _bfd_elf_assign_file_positions_for_relocs |
(bfd *); |
extern file_ptr _bfd_elf_assign_file_position_for_section |
(Elf_Internal_Shdr *, file_ptr, bfd_boolean); |
2101,8 → 2006,6 |
(bfd *, struct bfd_link_info *); |
extern bfd_boolean _bfd_elf_create_got_section |
(bfd *, struct bfd_link_info *); |
extern asection *_bfd_elf_section_for_symbol |
(struct elf_reloc_cookie *, unsigned long, bfd_boolean); |
extern struct elf_link_hash_entry *_bfd_elf_define_linkage_sym |
(bfd *, struct bfd_link_info *, asection *, const char *); |
extern void _bfd_elf_init_1_index_section |
2123,7 → 2026,7 |
struct elf_link_hash_entry **); |
extern bfd_boolean _bfd_elf_adjust_dynamic_copy |
(struct bfd_link_info *, struct elf_link_hash_entry *, asection *); |
(struct elf_link_hash_entry *, asection *); |
extern bfd_boolean _bfd_elf_dynamic_symbol_p |
(struct elf_link_hash_entry *, struct bfd_link_info *, bfd_boolean); |
2137,7 → 2040,7 |
extern bfd_boolean _bfd_elf_setup_sections |
(bfd *); |
extern void _bfd_elf_post_process_headers (bfd * , struct bfd_link_info *); |
extern void _bfd_elf_set_osabi (bfd * , struct bfd_link_info *); |
extern const bfd_target *bfd_elf32_object_p |
(bfd *); |
2296,7 → 2199,7 |
extern asection *_bfd_elf_gc_mark_rsec |
(struct bfd_link_info *, asection *, elf_gc_mark_hook_fn, |
struct elf_reloc_cookie *, bfd_boolean *); |
struct elf_reloc_cookie *); |
extern bfd_boolean _bfd_elf_gc_mark_reloc |
(struct bfd_link_info *, asection *, elf_gc_mark_hook_fn, |
2332,8 → 2235,6 |
extern bfd_size_type _bfd_elf_maybe_function_sym (const asymbol *, asection *, |
bfd_vma *); |
extern asection *_bfd_elf_get_reloc_section (asection *); |
extern int bfd_elf_get_default_section_type (flagword); |
extern bfd_boolean bfd_elf_lookup_section_flags |
2377,10 → 2278,6 |
(bfd *, char *, int *, const void *, int); |
extern char *elfcore_write_s390_tdb |
(bfd *, char *, int *, const void *, int); |
extern char *elfcore_write_s390_vxrs_low |
(bfd *, char *, int *, const void *, int); |
extern char *elfcore_write_s390_vxrs_high |
(bfd *, char *, int *, const void *, int); |
extern char *elfcore_write_arm_vfp |
(bfd *, char *, int *, const void *, int); |
extern char *elfcore_write_aarch_tls |
2431,23 → 2328,23 |
(bfd *, char *, int *, const struct elf_internal_linux_prpsinfo *); |
extern bfd *_bfd_elf32_bfd_from_remote_memory |
(bfd *templ, bfd_vma ehdr_vma, bfd_size_type size, bfd_vma *loadbasep, |
(bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep, |
int (*target_read_memory) (bfd_vma, bfd_byte *, bfd_size_type)); |
extern bfd *_bfd_elf64_bfd_from_remote_memory |
(bfd *templ, bfd_vma ehdr_vma, bfd_size_type size, bfd_vma *loadbasep, |
(bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep, |
int (*target_read_memory) (bfd_vma, bfd_byte *, bfd_size_type)); |
extern bfd_vma bfd_elf_obj_attr_size (bfd *); |
extern void bfd_elf_set_obj_attr_contents (bfd *, bfd_byte *, bfd_vma); |
extern int bfd_elf_get_obj_attr_int (bfd *, int, unsigned int); |
extern void bfd_elf_add_obj_attr_int (bfd *, int, unsigned int, unsigned int); |
extern int bfd_elf_get_obj_attr_int (bfd *, int, int); |
extern void bfd_elf_add_obj_attr_int (bfd *, int, int, unsigned int); |
#define bfd_elf_add_proc_attr_int(BFD, TAG, VALUE) \ |
bfd_elf_add_obj_attr_int ((BFD), OBJ_ATTR_PROC, (TAG), (VALUE)) |
extern void bfd_elf_add_obj_attr_string (bfd *, int, unsigned int, const char *); |
extern void bfd_elf_add_obj_attr_string (bfd *, int, int, const char *); |
#define bfd_elf_add_proc_attr_string(BFD, TAG, VALUE) \ |
bfd_elf_add_obj_attr_string ((BFD), OBJ_ATTR_PROC, (TAG), (VALUE)) |
extern void bfd_elf_add_obj_attr_int_string (bfd *, int, unsigned int, |
unsigned int, const char *); |
extern void bfd_elf_add_obj_attr_int_string (bfd *, int, int, unsigned int, |
const char *); |
#define bfd_elf_add_proc_attr_int_string(BFD, TAG, INTVAL, STRVAL) \ |
bfd_elf_add_obj_attr_int_string ((BFD), OBJ_ATTR_PROC, (TAG), \ |
(INTVAL), (STRVAL)) |
2454,7 → 2351,7 |
extern char *_bfd_elf_attr_strdup (bfd *, const char *); |
extern void _bfd_elf_copy_obj_attributes (bfd *, bfd *); |
extern int _bfd_elf_obj_attrs_arg_type (bfd *, int, unsigned int); |
extern int _bfd_elf_obj_attrs_arg_type (bfd *, int, int); |
extern void _bfd_elf_parse_attributes (bfd *, Elf_Internal_Shdr *); |
extern bfd_boolean _bfd_elf_merge_object_attributes (bfd *, bfd *); |
extern bfd_boolean _bfd_elf_merge_unknown_attribute_low (bfd *, bfd *, int); |
2486,9 → 2383,6 |
extern bfd_boolean _bfd_elf_allocate_ifunc_dyn_relocs |
(struct bfd_link_info *, struct elf_link_hash_entry *, |
struct elf_dyn_relocs **, unsigned int, unsigned int, unsigned int); |
extern long _bfd_elf_ifunc_get_synthetic_symtab |
(bfd *, long, asymbol **, long, asymbol **, asymbol **, asection *, |
bfd_vma *(*) (bfd *, asymbol **, asection *, asection *)); |
extern void elf_append_rela (bfd *, asection *, Elf_Internal_Rela *); |
extern void elf_append_rel (bfd *, asection *, Elf_Internal_Rela *); |
2520,7 → 2414,7 |
#define RELOC_FOR_GLOBAL_SYMBOL(info, input_bfd, input_section, rel, \ |
r_symndx, symtab_hdr, sym_hashes, \ |
h, sec, relocation, \ |
unresolved_reloc, warned, ignored) \ |
unresolved_reloc, warned) \ |
do \ |
{ \ |
/* It seems this can happen with erroneous or unsupported \ |
2530,17 → 2424,11 |
\ |
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; \ |
\ |
if (info->wrap_hash != NULL \ |
&& (input_section->flags & SEC_DEBUGGING) != 0) \ |
h = ((struct elf_link_hash_entry *) \ |
unwrap_hash_lookup (info, input_bfd, &h->root)); \ |
\ |
while (h->root.type == bfd_link_hash_indirect \ |
|| h->root.type == bfd_link_hash_warning) \ |
h = (struct elf_link_hash_entry *) h->root.u.i.link; \ |
\ |
warned = FALSE; \ |
ignored = FALSE; \ |
unresolved_reloc = FALSE; \ |
relocation = 0; \ |
if (h->root.type == bfd_link_hash_defined \ |
2563,8 → 2451,8 |
; \ |
else if (info->unresolved_syms_in_objects == RM_IGNORE \ |
&& ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) \ |
ignored = TRUE; \ |
else if (!bfd_link_relocatable (info)) \ |
; \ |
else if (!info->relocatable) \ |
{ \ |
bfd_boolean err; \ |
err = (info->unresolved_syms_in_objects == RM_GENERATE_ERROR \ |
2579,7 → 2467,6 |
} \ |
(void) unresolved_reloc; \ |
(void) warned; \ |
(void) ignored; \ |
} \ |
while (0) |
2599,7 → 2486,7 |
_bfd_clear_contents (howto, input_bfd, input_section, \ |
contents + rel[index].r_offset); \ |
\ |
if (bfd_link_relocatable (info) \ |
if (info->relocatable \ |
&& (input_section->flags & SEC_DEBUGGING)) \ |
{ \ |
/* Only remove relocations in debug sections since other \ |
2640,7 → 2527,4 |
(!(H)->unique_global \ |
&& ((INFO)->symbolic || ((INFO)->dynamic && !(H)->dynamic))) |
#ifdef __cplusplus |
} |
#endif |
#endif /* _LIBELF_H_ */ |
/contrib/toolchain/binutils/bfd/elf-eh-frame.c |
---|
1,5 → 1,6 |
/* .eh_frame section optimization. |
Copyright (C) 2001-2015 Free Software Foundation, Inc. |
Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, |
2012 Free Software Foundation, Inc. |
Written by Jakub Jelinek <jakub@redhat.com>. |
This file is part of BFD, the Binary File Descriptor library. |
40,12 → 41,10 |
bfd_vma augmentation_size; |
union { |
struct elf_link_hash_entry *h; |
struct { |
unsigned int bfd_id; |
unsigned int index; |
} sym; |
bfd_vma val; |
unsigned int reloc_index; |
} personality; |
asection *output_sec; |
struct eh_cie_fde *cie_inf; |
unsigned char per_encoding; |
unsigned char lsda_encoding; |
231,13 → 230,11 |
&& c1->augmentation_size == c2->augmentation_size |
&& memcmp (&c1->personality, &c2->personality, |
sizeof (c1->personality)) == 0 |
&& (c1->cie_inf->u.cie.u.sec->output_section |
== c2->cie_inf->u.cie.u.sec->output_section) |
&& c1->output_sec == c2->output_sec |
&& c1->per_encoding == c2->per_encoding |
&& c1->lsda_encoding == c2->lsda_encoding |
&& c1->fde_encoding == c2->fde_encoding |
&& c1->initial_insn_length == c2->initial_insn_length |
&& c1->initial_insn_length <= sizeof (c1->initial_instructions) |
&& memcmp (c1->initial_instructions, |
c2->initial_instructions, |
c1->initial_insn_length) == 0) |
257,7 → 254,6 |
cie_compute_hash (struct cie *c) |
{ |
hashval_t h = 0; |
size_t len; |
h = iterative_hash_object (c->length, h); |
h = iterative_hash_object (c->version, h); |
h = iterative_hash (c->augmentation, strlen (c->augmentation) + 1, h); |
266,15 → 262,12 |
h = iterative_hash_object (c->ra_column, h); |
h = iterative_hash_object (c->augmentation_size, h); |
h = iterative_hash_object (c->personality, h); |
h = iterative_hash_object (c->cie_inf->u.cie.u.sec->output_section, h); |
h = iterative_hash_object (c->output_sec, h); |
h = iterative_hash_object (c->per_encoding, h); |
h = iterative_hash_object (c->lsda_encoding, h); |
h = iterative_hash_object (c->fde_encoding, h); |
h = iterative_hash_object (c->initial_insn_length, h); |
len = c->initial_insn_length; |
if (len > sizeof (c->initial_instructions)) |
len = sizeof (c->initial_instructions); |
h = iterative_hash (c->initial_instructions, len, h); |
h = iterative_hash (c->initial_instructions, c->initial_insn_length, h); |
c->hash = h; |
return h; |
} |
452,111 → 445,18 |
return encoding | DW_EH_PE_pcrel; |
} |
/* Examine each .eh_frame_entry section and discard those |
those that are marked SEC_EXCLUDE. */ |
/* Called before calling _bfd_elf_parse_eh_frame on every input bfd's |
.eh_frame section. */ |
static void |
bfd_elf_discard_eh_frame_entry (struct eh_frame_hdr_info *hdr_info) |
void |
_bfd_elf_begin_eh_frame_parsing (struct bfd_link_info *info) |
{ |
unsigned int i; |
for (i = 0; i < hdr_info->array_count; i++) |
{ |
if (hdr_info->u.compact.entries[i]->flags & SEC_EXCLUDE) |
{ |
unsigned int j; |
for (j = i + 1; j < hdr_info->array_count; j++) |
hdr_info->u.compact.entries[j-1] = hdr_info->u.compact.entries[j]; |
hdr_info->array_count--; |
hdr_info->u.compact.entries[hdr_info->array_count] = NULL; |
i--; |
} |
} |
} |
/* Add a .eh_frame_entry section. */ |
static void |
bfd_elf_record_eh_frame_entry (struct eh_frame_hdr_info *hdr_info, |
asection *sec) |
{ |
if (hdr_info->array_count == hdr_info->u.compact.allocated_entries) |
{ |
if (hdr_info->u.compact.allocated_entries == 0) |
{ |
hdr_info->frame_hdr_is_compact = TRUE; |
hdr_info->u.compact.allocated_entries = 2; |
hdr_info->u.compact.entries = |
bfd_malloc (hdr_info->u.compact.allocated_entries |
* sizeof (hdr_info->u.compact.entries[0])); |
} |
else |
{ |
hdr_info->u.compact.allocated_entries *= 2; |
hdr_info->u.compact.entries = |
bfd_realloc (hdr_info->u.compact.entries, |
hdr_info->u.compact.allocated_entries |
* sizeof (hdr_info->u.compact.entries[0])); |
} |
BFD_ASSERT (hdr_info->u.compact.entries); |
} |
hdr_info->u.compact.entries[hdr_info->array_count++] = sec; |
} |
/* Parse a .eh_frame_entry section. Figure out which text section it |
references. */ |
bfd_boolean |
_bfd_elf_parse_eh_frame_entry (struct bfd_link_info *info, |
asection *sec, struct elf_reloc_cookie *cookie) |
{ |
struct elf_link_hash_table *htab; |
struct eh_frame_hdr_info *hdr_info; |
unsigned long r_symndx; |
asection *text_sec; |
htab = elf_hash_table (info); |
hdr_info = &htab->eh_info; |
if (sec->size == 0 |
|| sec->sec_info_type != SEC_INFO_TYPE_NONE) |
{ |
return TRUE; |
hdr_info = &elf_hash_table (info)->eh_info; |
hdr_info->merge_cies = !info->relocatable; |
} |
if (sec->output_section && bfd_is_abs_section (sec->output_section)) |
{ |
/* At least one of the sections is being discarded from the |
link, so we should just ignore them. */ |
return TRUE; |
} |
if (cookie->rel == cookie->relend) |
return FALSE; |
/* The first relocation is the function start. */ |
r_symndx = cookie->rel->r_info >> cookie->r_sym_shift; |
if (r_symndx == STN_UNDEF) |
return FALSE; |
text_sec = _bfd_elf_section_for_symbol (cookie, r_symndx, FALSE); |
if (text_sec == NULL) |
return FALSE; |
elf_section_eh_frame_entry (text_sec) = sec; |
if (text_sec->output_section |
&& bfd_is_abs_section (text_sec->output_section)) |
sec->flags |= SEC_EXCLUDE; |
sec->sec_info_type = SEC_INFO_TYPE_EH_FRAME_ENTRY; |
elf_section_data (sec)->sec_info = text_sec; |
bfd_elf_record_eh_frame_entry (hdr_info, sec); |
return TRUE; |
} |
/* Try to parse .eh_frame section SEC, which belongs to ABFD. Store the |
information in the section's sec_info field on success. COOKIE |
describes the relocations in SEC. */ |
587,6 → 487,8 |
htab = elf_hash_table (info); |
hdr_info = &htab->eh_info; |
if (hdr_info->parsed_eh_frames) |
return; |
if (sec->size == 0 |
|| sec->sec_info_type != SEC_INFO_TYPE_NONE) |
661,13 → 563,10 |
/* FIXME: octets_per_byte. */ |
#define ENSURE_NO_RELOCS(buf) \ |
while (cookie->rel < cookie->relend \ |
REQUIRE (!(cookie->rel < cookie->relend \ |
&& (cookie->rel->r_offset \ |
< (bfd_size_type) ((buf) - ehbuf))) \ |
{ \ |
REQUIRE (cookie->rel->r_info == 0); \ |
cookie->rel++; \ |
} |
< (bfd_size_type) ((buf) - ehbuf)) \ |
&& cookie->rel->r_info != 0)) |
/* FIXME: octets_per_byte. */ |
#define SKIP_RELOCS(buf) \ |
733,6 → 632,7 |
cie->cie_inf = this_inf; |
cie->length = hdr_length; |
cie->output_sec = sec->output_section; |
start = buf; |
REQUIRE (read_byte (&buf, end, &cie->version)); |
833,7 → 733,7 |
/* For shared libraries, try to get rid of as many RELATIVE relocs |
as possible. */ |
if (bfd_link_pic (info) |
if (info->shared |
&& (get_elf_backend_data (abfd) |
->elf_backend_can_make_relative_eh_frame |
(abfd, info, sec))) |
862,22 → 762,20 |
cie->fde_encoding = DW_EH_PE_absptr; |
initial_insn_length = end - buf; |
if (initial_insn_length <= sizeof (cie->initial_instructions)) |
{ |
cie->initial_insn_length = initial_insn_length; |
memcpy (cie->initial_instructions, buf, |
initial_insn_length <= sizeof (cie->initial_instructions) |
? initial_insn_length : sizeof (cie->initial_instructions)); |
memcpy (cie->initial_instructions, buf, initial_insn_length); |
} |
insns = buf; |
buf += initial_insn_length; |
ENSURE_NO_RELOCS (buf); |
if (!bfd_link_relocatable (info)) |
{ |
/* Keep info for merging cies. */ |
if (hdr_info->merge_cies) |
this_inf->u.cie.u.full_cie = cie; |
this_inf->u.cie.per_encoding_relative |
= (cie->per_encoding & 0x70) == DW_EH_PE_pcrel; |
} |
} |
else |
{ |
/* Find the corresponding CIE. */ |
902,8 → 800,7 |
REQUIRE (GET_RELOC (buf)); |
/* Chain together the FDEs for each section. */ |
rsec = _bfd_elf_gc_mark_rsec (info, sec, gc_mark_hook, |
cookie, NULL); |
rsec = _bfd_elf_gc_mark_rsec (info, sec, gc_mark_hook, cookie); |
/* RSEC will be NULL if FDE was cleared out as it was belonging to |
a discarded SHT_GROUP. */ |
if (rsec) |
919,16 → 816,6 |
length = get_DW_EH_PE_width (cie->fde_encoding, ptr_size); |
REQUIRE (skip_bytes (&buf, end, 2 * length)); |
SKIP_RELOCS (buf - length); |
if (!GET_RELOC (buf - length) |
&& read_value (abfd, buf - length, length, FALSE) == 0) |
{ |
(*info->callbacks->minfo) |
(_("discarding zero address range FDE in %B(%A).\n"), |
abfd, sec); |
this_inf->u.fde.cie_inf = NULL; |
} |
/* Skip the augmentation size, if present. */ |
if (cie->augmentation[0] == 'z') |
REQUIRE (read_uleb128 (&buf, end, &length)); |
1018,9 → 905,8 |
elf_section_data (sec)->sec_info = sec_info; |
sec->sec_info_type = SEC_INFO_TYPE_EH_FRAME; |
if (!bfd_link_relocatable (info)) |
if (hdr_info->merge_cies) |
{ |
/* Keep info for merging cies. */ |
sec_info->cies = local_cies; |
local_cies = NULL; |
} |
1030,7 → 916,7 |
(*info->callbacks->einfo) |
(_("%P: error in %B(%A); no .eh_frame_hdr table will be created.\n"), |
abfd, sec); |
hdr_info->u.dwarf.table = FALSE; |
hdr_info->table = FALSE; |
if (sec_info) |
free (sec_info); |
success: |
1041,89 → 927,17 |
#undef REQUIRE |
} |
/* Order eh_frame_hdr entries by the VMA of their text section. */ |
/* Finish a pass over all .eh_frame sections. */ |
static int |
cmp_eh_frame_hdr (const void *a, const void *b) |
{ |
bfd_vma text_a; |
bfd_vma text_b; |
asection *sec; |
sec = *(asection *const *)a; |
sec = (asection *) elf_section_data (sec)->sec_info; |
text_a = sec->output_section->vma + sec->output_offset; |
sec = *(asection *const *)b; |
sec = (asection *) elf_section_data (sec)->sec_info; |
text_b = sec->output_section->vma + sec->output_offset; |
if (text_a < text_b) |
return -1; |
return text_a > text_b; |
} |
/* Add space for a CANTUNWIND terminator to SEC if the text sections |
referenced by it and NEXT are not contiguous, or NEXT is NULL. */ |
static void |
add_eh_frame_hdr_terminator (asection *sec, |
asection *next) |
{ |
bfd_vma end; |
bfd_vma next_start; |
asection *text_sec; |
if (next) |
{ |
/* See if there is a gap (presumably a text section without unwind info) |
between these two entries. */ |
text_sec = (asection *) elf_section_data (sec)->sec_info; |
end = text_sec->output_section->vma + text_sec->output_offset |
+ text_sec->size; |
text_sec = (asection *) elf_section_data (next)->sec_info; |
next_start = text_sec->output_section->vma + text_sec->output_offset; |
if (end == next_start) |
return; |
} |
/* Add space for a CANTUNWIND terminator. */ |
if (!sec->rawsize) |
sec->rawsize = sec->size; |
bfd_set_section_size (sec->owner, sec, sec->size + 8); |
} |
/* Finish a pass over all .eh_frame_entry sections. */ |
bfd_boolean |
void |
_bfd_elf_end_eh_frame_parsing (struct bfd_link_info *info) |
{ |
struct eh_frame_hdr_info *hdr_info; |
unsigned int i; |
hdr_info = &elf_hash_table (info)->eh_info; |
if (info->eh_frame_hdr_type != COMPACT_EH_HDR |
|| hdr_info->array_count == 0) |
return FALSE; |
bfd_elf_discard_eh_frame_entry (hdr_info); |
qsort (hdr_info->u.compact.entries, hdr_info->array_count, |
sizeof (asection *), cmp_eh_frame_hdr); |
for (i = 0; i < hdr_info->array_count - 1; i++) |
{ |
add_eh_frame_hdr_terminator (hdr_info->u.compact.entries[i], |
hdr_info->u.compact.entries[i + 1]); |
hdr_info->parsed_eh_frames = TRUE; |
} |
/* Add a CANTUNWIND terminator after the last entry. */ |
add_eh_frame_hdr_terminator (hdr_info->u.compact.entries[i], NULL); |
return TRUE; |
} |
/* Mark all relocations against CIE or FDE ENT, which occurs in |
.eh_frame section SEC. COOKIE describes the relocations in SEC; |
its "rel" field can be changed freely. */ |
1163,7 → 977,7 |
/* At this stage, all cie_inf fields point to local CIEs, so we |
can use the same cookie to refer to them. */ |
cie = fde->u.fde.cie_inf; |
if (cie != NULL && !cie->u.cie.gc_mark) |
if (!cie->u.cie.gc_mark) |
{ |
cie->u.cie.gc_mark = 1; |
if (!mark_entry (info, eh_frame, cie, gc_mark_hook, cookie)) |
1213,12 → 1027,8 |
{ |
bfd_boolean per_binds_local; |
/* Work out the address of personality routine, or at least |
enough info that we could calculate the address had we made a |
final section layout. The symbol on the reloc is enough, |
either the hash for a global, or (bfd id, index) pair for a |
local. The assumption here is that no one uses addends on |
the reloc. */ |
/* Work out the address of personality routine, either as an absolute |
value or as a symbol. */ |
rel = cookie->rels + cie->personality.reloc_index; |
memset (&cie->personality, 0, sizeof (cie->personality)); |
#ifdef BFD64 |
1258,13 → 1068,14 |
return cie_inf; |
cie->local_personality = 1; |
cie->personality.sym.bfd_id = abfd->id; |
cie->personality.sym.index = r_symndx; |
cie->personality.val = (sym->st_value |
+ sym_sec->output_offset |
+ sym_sec->output_section->vma); |
per_binds_local = TRUE; |
} |
if (per_binds_local |
&& bfd_link_pic (info) |
&& info->shared |
&& (cie->per_encoding & 0x70) == DW_EH_PE_absptr |
&& (get_elf_backend_data (abfd) |
->elf_backend_can_make_relative_eh_frame (abfd, info, sec))) |
1275,15 → 1086,15 |
} |
/* See if we can merge this CIE with an earlier one. */ |
cie->output_sec = sec->output_section; |
cie_compute_hash (cie); |
if (hdr_info->u.dwarf.cies == NULL) |
if (hdr_info->cies == NULL) |
{ |
hdr_info->u.dwarf.cies = htab_try_create (1, cie_hash, cie_eq, free); |
if (hdr_info->u.dwarf.cies == NULL) |
hdr_info->cies = htab_try_create (1, cie_hash, cie_eq, free); |
if (hdr_info->cies == NULL) |
return cie_inf; |
} |
loc = htab_find_slot_with_hash (hdr_info->u.dwarf.cies, cie, |
cie->hash, INSERT); |
loc = htab_find_slot_with_hash (hdr_info->cies, cie, cie->hash, INSERT); |
if (loc == NULL) |
return cie_inf; |
1342,7 → 1153,7 |
/* There should only be one zero terminator, on the last input |
file supplying .eh_frame (crtend.o). Remove any others. */ |
ent->removed = sec->map_head.s != NULL; |
else if (!ent->cie && ent->u.fde.cie_inf != NULL) |
else if (!ent->cie) |
{ |
bfd_boolean keep; |
if ((sec->flags & SEC_LINKER_CREATED) != 0 && cookie->rels == NULL) |
1364,7 → 1175,7 |
} |
if (keep) |
{ |
if (bfd_link_pic (info) |
if (info->shared |
&& (((ent->fde_encoding & 0x70) == DW_EH_PE_absptr |
&& ent->make_relative == 0) |
|| (ent->fde_encoding & 0x70) == DW_EH_PE_aligned)) |
1373,13 → 1184,13 |
which we cannot turn into PC relative, |
don't create the binary search table, |
since it is affected by runtime relocations. */ |
hdr_info->u.dwarf.table = FALSE; |
hdr_info->table = FALSE; |
(*info->callbacks->einfo) |
(_("%P: FDE encoding in %B(%A) prevents .eh_frame_hdr" |
(_("%P: fde encoding in %B(%A) prevents .eh_frame_hdr" |
" table being created.\n"), abfd, sec); |
} |
ent->removed = 0; |
hdr_info->u.dwarf.fde_count++; |
hdr_info->fde_count++; |
ent->u.fde.cie_inf = find_merged_cie (abfd, info, sec, hdr_info, |
cookie, ent->u.fde.cie_inf); |
} |
1418,10 → 1229,10 |
htab = elf_hash_table (info); |
hdr_info = &htab->eh_info; |
if (!hdr_info->frame_hdr_is_compact && hdr_info->u.dwarf.cies != NULL) |
if (hdr_info->cies != NULL) |
{ |
htab_delete (hdr_info->u.dwarf.cies); |
hdr_info->u.dwarf.cies = NULL; |
htab_delete (hdr_info->cies); |
hdr_info->cies = NULL; |
} |
sec = hdr_info->hdr_sec; |
1428,18 → 1239,9 |
if (sec == NULL) |
return FALSE; |
if (info->eh_frame_hdr_type == COMPACT_EH_HDR) |
{ |
/* For compact frames we only add the header. The actual table comes |
from the .eh_frame_entry sections. */ |
sec->size = 8; |
} |
else |
{ |
sec->size = EH_FRAME_HDR_SIZE; |
if (hdr_info->u.dwarf.table) |
sec->size += 4 + hdr_info->u.dwarf.fde_count * 8; |
} |
if (hdr_info->table) |
sec->size += 4 + hdr_info->fde_count * 8; |
elf_eh_frame_hdr (abfd) = sec; |
return TRUE; |
1448,7 → 1250,6 |
/* Return true if there is at least one non-empty .eh_frame section in |
input files. Can only be called after ld has mapped input to |
output sections, and before sections are stripped. */ |
bfd_boolean |
_bfd_elf_eh_frame_present (struct bfd_link_info *info) |
{ |
1466,29 → 1267,6 |
return FALSE; |
} |
/* Return true if there is at least one .eh_frame_entry section in |
input files. */ |
bfd_boolean |
_bfd_elf_eh_frame_entry_present (struct bfd_link_info *info) |
{ |
asection *o; |
bfd *abfd; |
for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link.next) |
{ |
for (o = abfd->sections; o; o = o->next) |
{ |
const char *name = bfd_get_section_name (abfd, o); |
if (strcmp (name, ".eh_frame_entry") |
&& !bfd_is_abs_section (o->output_section)) |
return TRUE; |
} |
} |
return FALSE; |
} |
/* This function is called from size_dynamic_sections. |
It needs to decide whether .eh_frame_hdr should be output or not, |
because when the dynamic symbol table has been sized it is too late |
1499,8 → 1277,6 |
{ |
struct elf_link_hash_table *htab; |
struct eh_frame_hdr_info *hdr_info; |
struct bfd_link_hash_entry *bh = NULL; |
struct elf_link_hash_entry *h; |
htab = elf_hash_table (info); |
hdr_info = &htab->eh_info; |
1508,11 → 1284,8 |
return TRUE; |
if (bfd_is_abs_section (hdr_info->hdr_sec->output_section) |
|| info->eh_frame_hdr_type == 0 |
|| (info->eh_frame_hdr_type == DWARF2_EH_HDR |
&& !_bfd_elf_eh_frame_present (info)) |
|| (info->eh_frame_hdr_type == COMPACT_EH_HDR |
&& !_bfd_elf_eh_frame_entry_present (info))) |
|| !info->eh_frame_hdr |
|| !_bfd_elf_eh_frame_present (info)) |
{ |
hdr_info->hdr_sec->flags |= SEC_EXCLUDE; |
hdr_info->hdr_sec = NULL; |
1519,21 → 1292,7 |
return TRUE; |
} |
/* Add a hidden symbol so that systems without access to PHDRs can |
find the table. */ |
if (! (_bfd_generic_link_add_one_symbol |
(info, info->output_bfd, "__GNU_EH_FRAME_HDR", BSF_LOCAL, |
hdr_info->hdr_sec, 0, NULL, FALSE, FALSE, &bh))) |
return FALSE; |
h = (struct elf_link_hash_entry *) bh; |
h->def_regular = 1; |
h->other = STV_HIDDEN; |
get_elf_backend_data |
(info->output_bfd)->elf_backend_hide_symbol (info, h, TRUE); |
if (!hdr_info->frame_hdr_is_compact) |
hdr_info->u.dwarf.table = TRUE; |
hdr_info->table = TRUE; |
return TRUE; |
} |
1624,83 → 1383,6 |
+ extra_augmentation_data_bytes (sec_info->entry + mid)); |
} |
/* Write out .eh_frame_entry section. Add CANTUNWIND terminator if needed. |
Also check that the contents look sane. */ |
bfd_boolean |
_bfd_elf_write_section_eh_frame_entry (bfd *abfd, struct bfd_link_info *info, |
asection *sec, bfd_byte *contents) |
{ |
const struct elf_backend_data *bed; |
bfd_byte cantunwind[8]; |
bfd_vma addr; |
bfd_vma last_addr; |
bfd_vma offset; |
asection *text_sec = (asection *) elf_section_data (sec)->sec_info; |
if (!sec->rawsize) |
sec->rawsize = sec->size; |
BFD_ASSERT (sec->sec_info_type == SEC_INFO_TYPE_EH_FRAME_ENTRY); |
/* Check to make sure that the text section corresponding to this eh_frame_entry |
section has not been excluded. In particular, mips16 stub entries will be |
excluded outside of the normal process. */ |
if (sec->flags & SEC_EXCLUDE |
|| text_sec->flags & SEC_EXCLUDE) |
return TRUE; |
if (!bfd_set_section_contents (abfd, sec->output_section, contents, |
sec->output_offset, sec->rawsize)) |
return FALSE; |
last_addr = bfd_get_signed_32 (abfd, contents); |
/* Check that all the entries are in order. */ |
for (offset = 8; offset < sec->rawsize; offset += 8) |
{ |
addr = bfd_get_signed_32 (abfd, contents + offset) + offset; |
if (addr <= last_addr) |
{ |
(*_bfd_error_handler) (_("%B: %s not in order"), sec->owner, sec->name); |
return FALSE; |
} |
last_addr = addr; |
} |
addr = text_sec->output_section->vma + text_sec->output_offset |
+ text_sec->size; |
addr &= ~1; |
addr -= (sec->output_section->vma + sec->output_offset + sec->rawsize); |
if (addr & 1) |
{ |
(*_bfd_error_handler) (_("%B: %s invalid input section size"), |
sec->owner, sec->name); |
bfd_set_error (bfd_error_bad_value); |
return FALSE; |
} |
if (last_addr >= addr + sec->rawsize) |
{ |
(*_bfd_error_handler) (_("%B: %s points past end of text section"), |
sec->owner, sec->name); |
bfd_set_error (bfd_error_bad_value); |
return FALSE; |
} |
if (sec->size == sec->rawsize) |
return TRUE; |
bed = get_elf_backend_data (abfd); |
BFD_ASSERT (sec->size == sec->rawsize + 8); |
BFD_ASSERT ((addr & 1) == 0); |
BFD_ASSERT (bed->cant_unwind_opcode); |
bfd_put_32 (abfd, addr, cantunwind); |
bfd_put_32 (abfd, (*bed->cant_unwind_opcode) (info), cantunwind + 4); |
return bfd_set_section_contents (abfd, sec->output_section, cantunwind, |
sec->output_offset + sec->rawsize, 8); |
} |
/* Write out .eh_frame section. This is called with the relocated |
contents. */ |
1715,7 → 1397,6 |
struct eh_frame_hdr_info *hdr_info; |
unsigned int ptr_size; |
struct eh_cie_fde *ent; |
bfd_size_type sec_size; |
if (sec->sec_info_type != SEC_INFO_TYPE_EH_FRAME) |
/* FIXME: octets_per_byte. */ |
1730,14 → 1411,10 |
htab = elf_hash_table (info); |
hdr_info = &htab->eh_info; |
if (hdr_info->u.dwarf.table && hdr_info->u.dwarf.array == NULL) |
{ |
hdr_info->frame_hdr_is_compact = FALSE; |
hdr_info->u.dwarf.array = (struct eh_frame_array_ent *) |
bfd_malloc (hdr_info->u.dwarf.fde_count |
* sizeof (*hdr_info->u.dwarf.array)); |
} |
if (hdr_info->u.dwarf.array == NULL) |
if (hdr_info->table && hdr_info->array == NULL) |
hdr_info->array = (struct eh_frame_array_ent *) |
bfd_malloc (hdr_info->fde_count * sizeof(*hdr_info->array)); |
if (hdr_info->array == NULL) |
hdr_info = NULL; |
/* The new offsets can be bigger or smaller than the original offsets. |
1906,8 → 1583,6 |
value = ((ent->new_offset + sec->output_offset + 4) |
- (cie->new_offset + cie->u.cie.u.sec->output_offset)); |
bfd_put_32 (abfd, value, buf); |
if (bfd_link_relocatable (info)) |
continue; |
buf += 4; |
width = get_DW_EH_PE_width (ent->fde_encoding, ptr_size); |
value = read_value (abfd, buf, width, |
1972,11 → 1647,8 |
dwarf_vma is 64-bit. */ |
if (sizeof (address) > 4 && ptr_size == 4) |
address &= 0xffffffff; |
hdr_info->u.dwarf.array[hdr_info->array_count].initial_loc |
= address; |
hdr_info->u.dwarf.array[hdr_info->array_count].range |
= read_value (abfd, buf + width, width, FALSE); |
hdr_info->u.dwarf.array[hdr_info->array_count++].fde |
hdr_info->array[hdr_info->array_count].initial_loc = address; |
hdr_info->array[hdr_info->array_count++].fde |
= (sec->output_section->vma |
+ sec->output_offset |
+ ent->new_offset); |
2046,11 → 1718,7 |
the pointer size. _bfd_elf_discard_section_eh_frame should |
have padded CIE/FDE records to multiple of pointer size with |
size_of_output_cie_fde. */ |
sec_size = sec->size; |
if (sec_info->count != 0 |
&& sec_info->entry[sec_info->count - 1].size == 4) |
sec_size -= 4; |
if ((sec_size % ptr_size) != 0) |
if ((sec->size % ptr_size) != 0) |
abort (); |
/* FIXME: octets_per_byte. */ |
2071,118 → 1739,13 |
return 1; |
if (p->initial_loc < q->initial_loc) |
return -1; |
if (p->range > q->range) |
return 1; |
if (p->range < q->range) |
return -1; |
return 0; |
} |
/* Reorder .eh_frame_entry sections to match the associated text sections. |
This routine is called during the final linking step, just before writing |
the contents. At this stage, sections in the eh_frame_hdr_info are already |
sorted in order of increasing text section address and so we simply need |
to make the .eh_frame_entrys follow that same order. Note that it is |
invalid for a linker script to try to force a particular order of |
.eh_frame_entry sections. */ |
bfd_boolean |
_bfd_elf_fixup_eh_frame_hdr (struct bfd_link_info *info) |
{ |
asection *sec = NULL; |
asection *osec; |
struct eh_frame_hdr_info *hdr_info; |
unsigned int i; |
bfd_vma offset; |
struct bfd_link_order *p; |
hdr_info = &elf_hash_table (info)->eh_info; |
if (hdr_info->hdr_sec == NULL |
|| info->eh_frame_hdr_type != COMPACT_EH_HDR |
|| hdr_info->array_count == 0) |
return TRUE; |
/* Change section output offsets to be in text section order. */ |
offset = 8; |
osec = hdr_info->u.compact.entries[0]->output_section; |
for (i = 0; i < hdr_info->array_count; i++) |
{ |
sec = hdr_info->u.compact.entries[i]; |
if (sec->output_section != osec) |
{ |
(*_bfd_error_handler) |
(_("Invalid output section for .eh_frame_entry: %s"), |
sec->output_section->name); |
return FALSE; |
} |
sec->output_offset = offset; |
offset += sec->size; |
} |
/* Fix the link_order to match. */ |
for (p = sec->output_section->map_head.link_order; p != NULL; p = p->next) |
{ |
if (p->type != bfd_indirect_link_order) |
abort(); |
p->offset = p->u.indirect.section->output_offset; |
if (p->next != NULL) |
i--; |
} |
if (i != 0) |
{ |
(*_bfd_error_handler) |
(_("Invalid contents in %s section"), osec->name); |
return FALSE; |
} |
return TRUE; |
} |
/* The .eh_frame_hdr format for Compact EH frames: |
ubyte version (2) |
ubyte eh_ref_enc (DW_EH_PE_* encoding of typinfo references) |
uint32_t count (Number of entries in table) |
[array from .eh_frame_entry sections] */ |
static bfd_boolean |
write_compact_eh_frame_hdr (bfd *abfd, struct bfd_link_info *info) |
{ |
struct elf_link_hash_table *htab; |
struct eh_frame_hdr_info *hdr_info; |
asection *sec; |
const struct elf_backend_data *bed; |
bfd_vma count; |
bfd_byte contents[8]; |
unsigned int i; |
htab = elf_hash_table (info); |
hdr_info = &htab->eh_info; |
sec = hdr_info->hdr_sec; |
if (sec->size != 8) |
abort(); |
for (i = 0; i < sizeof (contents); i++) |
contents[i] = 0; |
contents[0] = COMPACT_EH_HDR; |
bed = get_elf_backend_data (abfd); |
BFD_ASSERT (bed->compact_eh_encoding); |
contents[1] = (*bed->compact_eh_encoding) (info); |
count = (sec->output_section->size - 8) / 8; |
bfd_put_32 (abfd, count, contents + 4); |
return bfd_set_section_contents (abfd, sec->output_section, contents, |
(file_ptr) sec->output_offset, sec->size); |
} |
/* The .eh_frame_hdr format for DWARF frames: |
/* Write out .eh_frame_hdr section. This must be called after |
_bfd_elf_write_section_eh_frame has been called on all input |
.eh_frame sections. |
.eh_frame_hdr format: |
ubyte version (currently 1) |
ubyte eh_frame_ptr_enc (DW_EH_PE_* encoding of pointer to start of |
.eh_frame section) |
2201,8 → 1764,8 |
FDE initial_location field and FDE address, |
sorted by increasing initial_loc). */ |
static bfd_boolean |
write_dwarf_eh_frame_hdr (bfd *abfd, struct bfd_link_info *info) |
bfd_boolean |
_bfd_elf_write_section_eh_frame_hdr (bfd *abfd, struct bfd_link_info *info) |
{ |
struct elf_link_hash_table *htab; |
struct eh_frame_hdr_info *hdr_info; |
2212,6 → 1775,9 |
htab = elf_hash_table (info); |
hdr_info = &htab->eh_info; |
sec = hdr_info->hdr_sec; |
if (info->eh_frame_hdr && sec != NULL) |
{ |
bfd_byte *contents; |
asection *eh_frame_sec; |
bfd_size_type size; |
2218,9 → 1784,8 |
bfd_vma encoded_eh_frame; |
size = EH_FRAME_HDR_SIZE; |
if (hdr_info->u.dwarf.array |
&& hdr_info->array_count == hdr_info->u.dwarf.fde_count) |
size += 4 + hdr_info->u.dwarf.fde_count * 8; |
if (hdr_info->array && hdr_info->array_count == hdr_info->fde_count) |
size += 4 + hdr_info->fde_count * 8; |
contents = (bfd_byte *) bfd_malloc (size); |
if (contents == NULL) |
return FALSE; |
2239,8 → 1804,7 |
contents[1] = get_elf_backend_data (abfd)->elf_backend_encode_eh_address |
(abfd, info, eh_frame_sec, 0, sec, 4, &encoded_eh_frame); |
if (hdr_info->u.dwarf.array |
&& hdr_info->array_count == hdr_info->u.dwarf.fde_count) |
if (hdr_info->array && hdr_info->array_count == hdr_info->fde_count) |
{ |
/* FDE count encoding. */ |
contents[2] = DW_EH_PE_udata4; |
2257,87 → 1821,33 |
if (contents[2] != DW_EH_PE_omit) |
{ |
unsigned int i; |
bfd_boolean overlap, overflow; |
bfd_put_32 (abfd, hdr_info->u.dwarf.fde_count, |
contents + EH_FRAME_HDR_SIZE); |
qsort (hdr_info->u.dwarf.array, hdr_info->u.dwarf.fde_count, |
sizeof (*hdr_info->u.dwarf.array), vma_compare); |
overlap = FALSE; |
overflow = FALSE; |
for (i = 0; i < hdr_info->u.dwarf.fde_count; i++) |
bfd_put_32 (abfd, hdr_info->fde_count, contents + EH_FRAME_HDR_SIZE); |
qsort (hdr_info->array, hdr_info->fde_count, |
sizeof (*hdr_info->array), vma_compare); |
for (i = 0; i < hdr_info->fde_count; i++) |
{ |
bfd_vma val; |
val = hdr_info->u.dwarf.array[i].initial_loc |
- sec->output_section->vma; |
val = ((val & 0xffffffff) ^ 0x80000000) - 0x80000000; |
if (elf_elfheader (abfd)->e_ident[EI_CLASS] == ELFCLASS64 |
&& (hdr_info->u.dwarf.array[i].initial_loc |
!= sec->output_section->vma + val)) |
overflow = TRUE; |
bfd_put_32 (abfd, val, contents + EH_FRAME_HDR_SIZE + i * 8 + 4); |
val = hdr_info->u.dwarf.array[i].fde - sec->output_section->vma; |
val = ((val & 0xffffffff) ^ 0x80000000) - 0x80000000; |
if (elf_elfheader (abfd)->e_ident[EI_CLASS] == ELFCLASS64 |
&& (hdr_info->u.dwarf.array[i].fde |
!= sec->output_section->vma + val)) |
overflow = TRUE; |
bfd_put_32 (abfd, val, contents + EH_FRAME_HDR_SIZE + i * 8 + 8); |
if (i != 0 |
&& (hdr_info->u.dwarf.array[i].initial_loc |
< (hdr_info->u.dwarf.array[i - 1].initial_loc |
+ hdr_info->u.dwarf.array[i - 1].range))) |
overlap = TRUE; |
bfd_put_32 (abfd, |
hdr_info->array[i].initial_loc |
- sec->output_section->vma, |
contents + EH_FRAME_HDR_SIZE + i * 8 + 4); |
bfd_put_32 (abfd, |
hdr_info->array[i].fde - sec->output_section->vma, |
contents + EH_FRAME_HDR_SIZE + i * 8 + 8); |
} |
if (overflow) |
(*info->callbacks->einfo) (_("%P: .eh_frame_hdr entry overflow.\n")); |
if (overlap) |
(*info->callbacks->einfo) |
(_("%P: .eh_frame_hdr refers to overlapping FDEs.\n")); |
if (overflow || overlap) |
{ |
bfd_set_error (bfd_error_bad_value); |
retval = FALSE; |
} |
} |
/* FIXME: octets_per_byte. */ |
if (!bfd_set_section_contents (abfd, sec->output_section, contents, |
retval = bfd_set_section_contents (abfd, sec->output_section, contents, |
(file_ptr) sec->output_offset, |
sec->size)) |
retval = FALSE; |
sec->size); |
free (contents); |
if (hdr_info->u.dwarf.array != NULL) |
free (hdr_info->u.dwarf.array); |
} |
if (hdr_info->array != NULL) |
free (hdr_info->array); |
return retval; |
} |
/* Write out .eh_frame_hdr section. This must be called after |
_bfd_elf_write_section_eh_frame has been called on all input |
.eh_frame sections. */ |
bfd_boolean |
_bfd_elf_write_section_eh_frame_hdr (bfd *abfd, struct bfd_link_info *info) |
{ |
struct elf_link_hash_table *htab; |
struct eh_frame_hdr_info *hdr_info; |
asection *sec; |
htab = elf_hash_table (info); |
hdr_info = &htab->eh_info; |
sec = hdr_info->hdr_sec; |
if (info->eh_frame_hdr_type == 0 || sec == NULL) |
return TRUE; |
if (info->eh_frame_hdr_type == COMPACT_EH_HDR) |
return write_compact_eh_frame_hdr (abfd, info); |
else |
return write_dwarf_eh_frame_hdr (abfd, info); |
} |
/* Return the width of FDE addresses. This is the default implementation. */ |
unsigned int |
/contrib/toolchain/binutils/bfd/elf-ifunc.c |
---|
1,5 → 1,6 |
/* ELF STT_GNU_IFUNC support. |
Copyright (C) 2009-2015 Free Software Foundation, Inc. |
Copyright 2009-2013 |
Free Software Foundation, Inc. |
This file is part of BFD, the Binary File Descriptor library. |
53,7 → 54,7 |
if (bed->plt_readonly) |
pltflags |= SEC_READONLY; |
if (bfd_link_pic (info)) |
if (info->shared) |
{ |
/* We need to create .rel[a].ifunc for shared objects. */ |
const char *rel_sec = (bed->rela_plts_and_copies_p |
125,7 → 126,7 |
But in non-shared executable, the address of its .plt slot may |
be used. Pointer equality may not work correctly. PIE should |
be used if pointer equality is required here. */ |
if (!bfd_link_pic (info) |
if (!info->shared |
&& (h->dynindx != -1 |
|| info->export_dynamic) |
&& h->pointer_equality_needed) |
145,7 → 146,7 |
/* When building shared library, we need to handle the case where it is |
marked with regular reference, but not non-GOT reference since the |
non-GOT reference bit may not be set here. */ |
if (bfd_link_pic (info) && !h->non_got_ref && h->ref_regular) |
if (info->shared && !h->non_got_ref && h->ref_regular) |
for (p = *head; p != NULL; p = p->next) |
if (p->count) |
{ |
220,7 → 221,7 |
/* We need dynamic relocation for STT_GNU_IFUNC symbol only when |
there is a non-GOT reference in a shared object. */ |
if (!bfd_link_pic (info) |
if (!info->shared |
|| !h->non_got_ref) |
*head = NULL; |
252,12 → 253,12 |
objects at run-time. |
We only need to relocate .got entry in shared object. */ |
if (h->got.refcount <= 0 |
|| (bfd_link_pic (info) |
|| (info->shared |
&& (h->dynindx == -1 |
|| h->forced_local)) |
|| (!bfd_link_pic (info) |
|| (!info->shared |
&& !h->pointer_equality_needed) |
|| bfd_link_pie (info) |
|| (info->executable && info->shared) |
|| htab->sgot == NULL) |
{ |
/* Use .got.plt. */ |
267,134 → 268,9 |
{ |
h->got.offset = htab->sgot->size; |
htab->sgot->size += got_entry_size; |
if (bfd_link_pic (info)) |
if (info->shared) |
htab->srelgot->size += sizeof_reloc; |
} |
return TRUE; |
} |
/* Similar to _bfd_elf_get_synthetic_symtab, optimized for unsorted PLT |
entries. PLT is the PLT section. PLT_SYM_VAL is a function pointer |
which returns an array of PLT entry symbol values. */ |
long |
_bfd_elf_ifunc_get_synthetic_symtab |
(bfd *abfd, long symcount ATTRIBUTE_UNUSED, |
asymbol **syms ATTRIBUTE_UNUSED, long dynsymcount, asymbol **dynsyms, |
asymbol **ret, asection *plt, |
bfd_vma *(*get_plt_sym_val) (bfd *, asymbol **, asection *, asection *)) |
{ |
const struct elf_backend_data *bed = get_elf_backend_data (abfd); |
asection *relplt; |
asymbol *s; |
const char *relplt_name; |
bfd_boolean (*slurp_relocs) (bfd *, asection *, asymbol **, bfd_boolean); |
arelent *p; |
long count, i, n; |
size_t size; |
Elf_Internal_Shdr *hdr; |
char *names; |
bfd_vma *plt_sym_val; |
*ret = NULL; |
if (plt == NULL) |
return 0; |
if ((abfd->flags & (DYNAMIC | EXEC_P)) == 0) |
return 0; |
if (dynsymcount <= 0) |
return 0; |
relplt_name = bed->relplt_name; |
if (relplt_name == NULL) |
relplt_name = bed->rela_plts_and_copies_p ? ".rela.plt" : ".rel.plt"; |
relplt = bfd_get_section_by_name (abfd, relplt_name); |
if (relplt == NULL) |
return 0; |
hdr = &elf_section_data (relplt)->this_hdr; |
if (hdr->sh_link != elf_dynsymtab (abfd) |
|| (hdr->sh_type != SHT_REL && hdr->sh_type != SHT_RELA)) |
return 0; |
slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table; |
if (! (*slurp_relocs) (abfd, relplt, dynsyms, TRUE)) |
return -1; |
count = relplt->size / hdr->sh_entsize; |
size = count * sizeof (asymbol); |
p = relplt->relocation; |
for (i = 0; i < count; i++, p += bed->s->int_rels_per_ext_rel) |
{ |
size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt"); |
if (p->addend != 0) |
{ |
#ifdef BFD64 |
size += sizeof ("+0x") - 1 + 8 + 8 * (bed->s->elfclass == ELFCLASS64); |
#else |
size += sizeof ("+0x") - 1 + 8; |
#endif |
} |
} |
plt_sym_val = get_plt_sym_val (abfd, dynsyms, plt, relplt); |
if (plt_sym_val == NULL) |
return -1; |
s = *ret = (asymbol *) bfd_malloc (size); |
if (s == NULL) |
{ |
free (plt_sym_val); |
return -1; |
} |
names = (char *) (s + count); |
p = relplt->relocation; |
n = 0; |
for (i = 0; i < count; i++, p += bed->s->int_rels_per_ext_rel) |
{ |
size_t len; |
bfd_vma addr; |
addr = plt_sym_val[i]; |
if (addr == (bfd_vma) -1) |
continue; |
*s = **p->sym_ptr_ptr; |
/* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set. Since |
we are defining a symbol, ensure one of them is set. */ |
if ((s->flags & BSF_LOCAL) == 0) |
s->flags |= BSF_GLOBAL; |
s->flags |= BSF_SYNTHETIC; |
s->section = plt; |
s->value = addr - plt->vma; |
s->name = names; |
s->udata.p = NULL; |
len = strlen ((*p->sym_ptr_ptr)->name); |
memcpy (names, (*p->sym_ptr_ptr)->name, len); |
names += len; |
if (p->addend != 0) |
{ |
char buf[30], *a; |
memcpy (names, "+0x", sizeof ("+0x") - 1); |
names += sizeof ("+0x") - 1; |
bfd_sprintf_vma (abfd, buf, p->addend); |
for (a = buf; *a == '0'; ++a) |
; |
len = strlen (a); |
memcpy (names, a, len); |
names += len; |
} |
memcpy (names, "@plt", sizeof ("@plt")); |
names += sizeof ("@plt"); |
++s, ++n; |
} |
free (plt_sym_val); |
return n; |
} |
/contrib/toolchain/binutils/bfd/elf-linux-psinfo.h |
---|
1,5 → 1,5 |
/* Definitions for PRPSINFO structures under ELF on GNU/Linux. |
Copyright (C) 2013-2015 Free Software Foundation, Inc. |
Copyright 2013 Free Software Foundation, Inc. |
This file is part of BFD, the Binary File Descriptor library. |
/contrib/toolchain/binutils/bfd/elf-nacl.c |
---|
1,5 → 1,5 |
/* Native Client support for ELF |
Copyright (C) 2012-2015 Free Software Foundation, Inc. |
Copyright 2012, 2013 Free Software Foundation, Inc. |
This file is part of BFD, the Binary File Descriptor library. |
/contrib/toolchain/binutils/bfd/elf-nacl.h |
---|
1,5 → 1,5 |
/* Native Client support for ELF |
Copyright (C) 2012-2015 Free Software Foundation, Inc. |
Copyright 2012, 2013 Free Software Foundation, Inc. |
This file is part of BFD, the Binary File Descriptor library. |
/contrib/toolchain/binutils/bfd/elf-strtab.c |
---|
1,5 → 1,6 |
/* ELF strtab with GC and suffix merging support. |
Copyright (C) 2001-2015 Free Software Foundation, Inc. |
Copyright 2001, 2002, 2003, 2005, 2006, 2007, 2008 |
Free Software Foundation, Inc. |
Written by Jakub Jelinek <jakub@redhat.com>. |
This file is part of BFD, the Binary File Descriptor library. |
/contrib/toolchain/binutils/bfd/elf-vxworks.c |
---|
1,5 → 1,5 |
/* VxWorks support for ELF |
Copyright (C) 2005-2015 Free Software Foundation, Inc. |
Copyright 2005, 2006, 2007, 2009, 2012 Free Software Foundation, Inc. |
This file is part of BFD, the Binary File Descriptor library. |
64,7 → 64,7 |
give the symbol weak binding to get the desired samantics. |
This transformation will be undone in |
elf_i386_vxworks_link_output_symbol_hook. */ |
if ((bfd_link_pic (info) || abfd->flags & DYNAMIC) |
if ((info->shared || abfd->flags & DYNAMIC) |
&& elf_vxworks_gott_symbol_p (abfd, *namep)) |
{ |
sym->st_info = ELF_ST_INFO (STB_WEAK, ELF_ST_TYPE (sym->st_info)); |
89,7 → 89,7 |
htab = elf_hash_table (info); |
bed = get_elf_backend_data (dynobj); |
if (!bfd_link_pic (info)) |
if (!info->shared) |
{ |
s = bfd_make_section_anyway_with_flags (dynobj, |
bed->default_use_rela_p |
/contrib/toolchain/binutils/bfd/elf-vxworks.h |
---|
1,5 → 1,5 |
/* VxWorks support for ELF |
Copyright (C) 2005-2015 Free Software Foundation, Inc. |
Copyright 2005, 2006, 2007 Free Software Foundation, Inc. |
This file is part of BFD, the Binary File Descriptor library. |
/contrib/toolchain/binutils/bfd/elf.c |
---|
1,6 → 1,6 |
/* ELF executable support for BFD. |
Copyright (C) 1993-2015 Free Software Foundation, Inc. |
Copyright 1993-2013 Free Software Foundation, Inc. |
This file is part of BFD, the Binary File Descriptor library. |
51,7 → 51,7 |
static int elf_sort_sections (const void *, const void *); |
static bfd_boolean assign_file_positions_except_relocs (bfd *, struct bfd_link_info *); |
static bfd_boolean prep_headers (bfd *); |
static bfd_boolean swap_out_syms (bfd *, struct elf_strtab_hash **, int) ; |
static bfd_boolean swap_out_syms (bfd *, struct bfd_strtab_hash **, int) ; |
static bfd_boolean elf_read_notes (bfd *, file_ptr, bfd_size_type) ; |
static bfd_boolean elf_parse_notes (bfd *abfd, char *buf, size_t size, |
file_ptr offset); |
297,14 → 297,13 |
/* Allocate and clear an extra byte at the end, to prevent crashes |
in case the string table is not terminated. */ |
if (shstrtabsize + 1 <= 1 |
|| bfd_seek (abfd, offset, SEEK_SET) != 0 |
|| (shstrtab = (bfd_byte *) bfd_alloc (abfd, shstrtabsize + 1)) == NULL) |
|| (shstrtab = (bfd_byte *) bfd_alloc (abfd, shstrtabsize + 1)) == NULL |
|| bfd_seek (abfd, offset, SEEK_SET) != 0) |
shstrtab = NULL; |
else if (bfd_bread (shstrtab, shstrtabsize, abfd) != shstrtabsize) |
{ |
if (bfd_get_error () != bfd_error_system_call) |
bfd_set_error (bfd_error_file_truncated); |
bfd_release (abfd, shstrtab); |
shstrtab = NULL; |
/* Once we've failed to read it, make sure we don't keep |
trying. Otherwise, we'll keep allocating space for |
333,20 → 332,10 |
hdr = elf_elfsections (abfd)[shindex]; |
if (hdr->contents == NULL) |
{ |
if (hdr->sh_type != SHT_STRTAB && hdr->sh_type < SHT_LOOS) |
{ |
/* PR 17512: file: f057ec89. */ |
_bfd_error_handler (_("%B: attempt to load strings from a non-string section (number %d)"), |
abfd, shindex); |
if (hdr->contents == NULL |
&& bfd_elf_get_str_section (abfd, shindex) == NULL) |
return NULL; |
} |
if (bfd_elf_get_str_section (abfd, shindex) == NULL) |
return NULL; |
} |
if (strindex >= hdr->sh_size) |
{ |
unsigned int shstrndx = elf_elfheader(abfd)->e_shstrndx; |
400,29 → 389,9 |
/* Normal syms might have section extension entries. */ |
shndx_hdr = NULL; |
if (elf_symtab_shndx_list (ibfd) != NULL) |
{ |
elf_section_list * entry; |
Elf_Internal_Shdr **sections = elf_elfsections (ibfd); |
if (symtab_hdr == &elf_tdata (ibfd)->symtab_hdr) |
shndx_hdr = &elf_tdata (ibfd)->symtab_shndx_hdr; |
/* Find an index section that is linked to this symtab section. */ |
for (entry = elf_symtab_shndx_list (ibfd); entry != NULL; entry = entry->next) |
if (sections[entry->hdr.sh_link] == symtab_hdr) |
{ |
shndx_hdr = & entry->hdr; |
break; |
}; |
if (shndx_hdr == NULL) |
{ |
if (symtab_hdr == & elf_symtab_hdr (ibfd)) |
/* Not really accurate, but this was how the old code used to work. */ |
shndx_hdr = & elf_symtab_shndx_list (ibfd)->hdr; |
/* Otherwise we do nothing. The assumption is that |
the index table will not be needed. */ |
} |
} |
/* Read the symbols. */ |
alloc_ext = NULL; |
alloc_extshndx = NULL; |
639,10 → 608,9 |
if (shdr->contents == NULL) |
{ |
_bfd_error_handler |
(_("%B: corrupt size field in group section header: 0x%lx"), abfd, shdr->sh_size); |
(_("%B: Corrupt size field in group section header: 0x%lx"), abfd, shdr->sh_size); |
bfd_set_error (bfd_error_bad_value); |
-- num_group; |
continue; |
return FALSE; |
} |
memset (shdr->contents, 0, amt); |
650,16 → 618,7 |
if (bfd_seek (abfd, shdr->sh_offset, SEEK_SET) != 0 |
|| (bfd_bread (shdr->contents, shdr->sh_size, abfd) |
!= shdr->sh_size)) |
{ |
_bfd_error_handler |
(_("%B: invalid size field in group section header: 0x%lx"), abfd, shdr->sh_size); |
bfd_set_error (bfd_error_bad_value); |
-- num_group; |
/* PR 17510: If the group contents are even partially |
corrupt, do not allow any of the contents to be used. */ |
memset (shdr->contents, 0, amt); |
continue; |
} |
return FALSE; |
/* Translate raw contents, a flag word followed by an |
array of elf section indices all in target byte order, |
667,7 → 626,6 |
pointers. */ |
src = shdr->contents + shdr->sh_size; |
dest = (Elf_Internal_Group *) (shdr->contents + amt); |
while (1) |
{ |
unsigned int idx; |
693,23 → 651,8 |
} |
} |
} |
/* PR 17510: Corrupt binaries might contain invalid groups. */ |
if (num_group != (unsigned) elf_tdata (abfd)->num_group) |
{ |
elf_tdata (abfd)->num_group = num_group; |
/* If all groups are invalid then fail. */ |
if (num_group == 0) |
{ |
elf_tdata (abfd)->group_sect_ptr = NULL; |
elf_tdata (abfd)->num_group = num_group = -1; |
(*_bfd_error_handler) (_("%B: no valid group sections found"), abfd); |
bfd_set_error (bfd_error_bad_value); |
} |
} |
} |
} |
if (num_group != (unsigned) -1) |
{ |
773,7 → 716,6 |
{ |
(*_bfd_error_handler) (_("%B: no group info for section %A"), |
abfd, newsect); |
return FALSE; |
} |
return TRUE; |
} |
837,22 → 779,9 |
for (i = 0; i < num_group; i++) |
{ |
Elf_Internal_Shdr *shdr = elf_tdata (abfd)->group_sect_ptr[i]; |
Elf_Internal_Group *idx; |
unsigned int n_elt; |
Elf_Internal_Group *idx = (Elf_Internal_Group *) shdr->contents; |
unsigned int n_elt = shdr->sh_size / 4; |
/* PR binutils/18758: Beware of corrupt binaries with invalid group data. */ |
if (shdr == NULL || shdr->bfd_section == NULL || shdr->contents == NULL) |
{ |
(*_bfd_error_handler) |
(_("%B: section group entry number %u is corrupt"), |
abfd, i); |
result = FALSE; |
continue; |
} |
idx = (Elf_Internal_Group *) shdr->contents; |
n_elt = shdr->sh_size / 4; |
while (--n_elt != 0) |
if ((++idx)->shdr->bfd_section) |
elf_sec_group (idx->shdr->bfd_section) = shdr->bfd_section; |
888,31 → 817,6 |
return elf_next_in_group (sec) != NULL; |
} |
static char * |
convert_debug_to_zdebug (bfd *abfd, const char *name) |
{ |
unsigned int len = strlen (name); |
char *new_name = bfd_alloc (abfd, len + 2); |
if (new_name == NULL) |
return NULL; |
new_name[0] = '.'; |
new_name[1] = 'z'; |
memcpy (new_name + 2, name + 1, len); |
return new_name; |
} |
static char * |
convert_zdebug_to_debug (bfd *abfd, const char *name) |
{ |
unsigned int len = strlen (name); |
char *new_name = bfd_alloc (abfd, len); |
if (new_name == NULL) |
return NULL; |
new_name[0] = '.'; |
memcpy (new_name + 1, name + 2, len - 1); |
return new_name; |
} |
/* Make a BFD section from an ELF section. We store a pointer to the |
BFD section in the bfd_section field of the header. */ |
1099,38 → 1003,27 |
|| (name[1] == 'z' && name[7] == '_'))) |
{ |
enum { nothing, compress, decompress } action = nothing; |
int compression_header_size; |
bfd_size_type uncompressed_size; |
bfd_boolean compressed |
= bfd_is_section_compressed_with_header (abfd, newsect, |
&compression_header_size, |
&uncompressed_size); |
char *new_name; |
if (compressed) |
if (bfd_is_section_compressed (abfd, newsect)) |
{ |
/* Compressed section. Check if we should decompress. */ |
if ((abfd->flags & BFD_DECOMPRESS)) |
action = decompress; |
} |
/* Compress the uncompressed section or convert from/to .zdebug* |
section. Check if we should compress. */ |
if (action == nothing) |
else |
{ |
if (newsect->size != 0 |
&& (abfd->flags & BFD_COMPRESS) |
&& compression_header_size >= 0 |
&& uncompressed_size > 0 |
&& (!compressed |
|| ((compression_header_size > 0) |
!= ((abfd->flags & BFD_COMPRESS_GABI) != 0)))) |
/* Normal section. Check if we should compress. */ |
if ((abfd->flags & BFD_COMPRESS) && newsect->size != 0) |
action = compress; |
else |
return TRUE; |
} |
if (action == compress) |
new_name = NULL; |
switch (action) |
{ |
case nothing: |
break; |
case compress: |
if (!bfd_init_section_compress_status (abfd, newsect)) |
{ |
(*_bfd_error_handler) |
1138,9 → 1031,19 |
abfd, name); |
return FALSE; |
} |
if (name[1] != 'z') |
{ |
unsigned int len = strlen (name); |
new_name = bfd_alloc (abfd, len + 2); |
if (new_name == NULL) |
return FALSE; |
new_name[0] = '.'; |
new_name[1] = 'z'; |
memcpy (new_name + 2, name + 1, len); |
} |
else |
{ |
break; |
case decompress: |
if (!bfd_init_section_decompress_status (abfd, newsect)) |
{ |
(*_bfd_error_handler) |
1148,28 → 1051,20 |
abfd, name); |
return FALSE; |
} |
} |
if (name[1] == 'z') |
{ |
unsigned int len = strlen (name); |
if (abfd->is_linker_input) |
{ |
if (name[1] == 'z' |
&& (action == decompress |
|| (action == compress |
&& (abfd->flags & BFD_COMPRESS_GABI) != 0))) |
{ |
/* Convert section name from .zdebug_* to .debug_* so |
that linker will consider this section as a debug |
section. */ |
char *new_name = convert_zdebug_to_debug (abfd, name); |
new_name = bfd_alloc (abfd, len); |
if (new_name == NULL) |
return FALSE; |
bfd_rename_section (abfd, newsect, new_name); |
new_name[0] = '.'; |
memcpy (new_name + 1, name + 2, len - 1); |
} |
break; |
} |
else |
/* For objdump, don't rename the section. For objcopy, delay |
section rename to elf_fake_sections. */ |
newsect->flags |= SEC_ELF_RENAME; |
if (new_name != NULL) |
bfd_rename_section (abfd, newsect, new_name); |
} |
return TRUE; |
1222,84 → 1117,16 |
|| bfd_get_flavour (obfd) != bfd_target_elf_flavour) |
return TRUE; |
if (!elf_flags_init (obfd)) |
{ |
BFD_ASSERT (!elf_flags_init (obfd) |
|| (elf_elfheader (obfd)->e_flags |
== elf_elfheader (ibfd)->e_flags)); |
elf_gp (obfd) = elf_gp (ibfd); |
elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags; |
elf_flags_init (obfd) = TRUE; |
} |
elf_gp (obfd) = elf_gp (ibfd); |
/* Also copy the EI_OSABI field. */ |
elf_elfheader (obfd)->e_ident[EI_OSABI] = |
elf_elfheader (ibfd)->e_ident[EI_OSABI]; |
/* Copy object attributes. */ |
_bfd_elf_copy_obj_attributes (ibfd, obfd); |
/* This is an feature for objcopy --only-keep-debug: When a section's type |
is changed to NOBITS, we preserve the sh_link and sh_info fields so that |
they can be matched up with the original. */ |
Elf_Internal_Shdr ** iheaders = elf_elfsections (ibfd); |
Elf_Internal_Shdr ** oheaders = elf_elfsections (obfd); |
if (iheaders != NULL && oheaders != NULL) |
{ |
unsigned int i; |
for (i = 0; i < elf_numsections (obfd); i++) |
{ |
unsigned int j; |
Elf_Internal_Shdr * oheader = oheaders[i]; |
if (oheader == NULL |
|| oheader->sh_type != SHT_NOBITS |
|| oheader->sh_size == 0 |
|| (oheader->sh_info != 0 && oheader->sh_link != 0)) |
continue; |
/* Scan for the matching section in the input bfd. |
FIXME: We could use something better than a linear scan here. |
Unfortunately we cannot compare names as the output string table |
is empty, so instead we check size, address and type. */ |
for (j = 0; j < elf_numsections (ibfd); j++) |
{ |
Elf_Internal_Shdr * iheader = iheaders[j]; |
/* Since --only-keep-debug turns all non-debug sections |
into SHT_NOBITS sections, the output SHT_NOBITS type |
matches any input type. */ |
if ((oheader->sh_type == SHT_NOBITS |
|| iheader->sh_type == oheader->sh_type) |
&& iheader->sh_flags == oheader->sh_flags |
&& iheader->sh_addralign == oheader->sh_addralign |
&& iheader->sh_entsize == oheader->sh_entsize |
&& iheader->sh_size == oheader->sh_size |
&& iheader->sh_addr == oheader->sh_addr |
&& (iheader->sh_info != oheader->sh_info |
|| iheader->sh_link != oheader->sh_link)) |
{ |
/* Note: Strictly speaking these assignments are wrong. |
The sh_link and sh_info fields should point to the |
relevent sections in the output BFD, which may not be in |
the same location as they were in the input BFD. But the |
whole point of this action is to preserve the original |
values of the sh_link and sh_info fields, so that they |
can be matched up with the section headers in the |
original file. So strictly speaking we may be creating |
an invalid ELF file, but it is only for a file that just |
contains debug info and only for sections without any |
contents. */ |
if (oheader->sh_link == 0) |
oheader->sh_link = iheader->sh_link; |
if (oheader->sh_info == 0) |
oheader->sh_info = iheader->sh_info; |
break; |
} |
} |
} |
} |
return TRUE; |
} |
1396,13 → 1223,8 |
swap_dyn_in = get_elf_backend_data (abfd)->s->swap_dyn_in; |
extdyn = dynbuf; |
/* PR 17512: file: 6f427532. */ |
if (s->size < extdynsize) |
goto error_return; |
extdynend = extdyn + s->size; |
/* PR 17512: file: id:000006,sig:06,src:000000,op:flip4,pos:5664. |
Fix range check. */ |
for (; extdyn <= (extdynend - extdynsize); extdyn += extdynsize) |
for (; extdyn < extdynend; extdyn += extdynsize) |
{ |
Elf_Internal_Dyn dyn; |
const char *name = ""; |
1570,53 → 1392,6 |
return FALSE; |
} |
/* Get version string. */ |
const char * |
_bfd_elf_get_symbol_version_string (bfd *abfd, asymbol *symbol, |
bfd_boolean *hidden) |
{ |
const char *version_string = NULL; |
if (elf_dynversym (abfd) != 0 |
&& (elf_dynverdef (abfd) != 0 || elf_dynverref (abfd) != 0)) |
{ |
unsigned int vernum = ((elf_symbol_type *) symbol)->version; |
*hidden = (vernum & VERSYM_HIDDEN) != 0; |
vernum &= VERSYM_VERSION; |
if (vernum == 0) |
version_string = ""; |
else if (vernum == 1) |
version_string = "Base"; |
else if (vernum <= elf_tdata (abfd)->cverdefs) |
version_string = |
elf_tdata (abfd)->verdef[vernum - 1].vd_nodename; |
else |
{ |
Elf_Internal_Verneed *t; |
version_string = ""; |
for (t = elf_tdata (abfd)->verref; |
t != NULL; |
t = t->vn_nextref) |
{ |
Elf_Internal_Vernaux *a; |
for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr) |
{ |
if (a->vna_other == vernum) |
{ |
version_string = a->vna_nodename; |
break; |
} |
} |
} |
} |
} |
return version_string; |
} |
/* Display ELF-specific fields of a symbol. */ |
void |
1643,8 → 1418,6 |
const struct elf_backend_data *bed; |
unsigned char st_other; |
bfd_vma val; |
const char *version_string; |
bfd_boolean hidden; |
section_name = symbol->section ? symbol->section->name : "(*none*)"; |
1670,12 → 1443,45 |
bfd_fprintf_vma (abfd, file, val); |
/* If we have version information, print it. */ |
version_string = _bfd_elf_get_symbol_version_string (abfd, |
symbol, |
&hidden); |
if (version_string) |
if (elf_dynversym (abfd) != 0 |
&& (elf_dynverdef (abfd) != 0 |
|| elf_dynverref (abfd) != 0)) |
{ |
if (!hidden) |
unsigned int vernum; |
const char *version_string; |
vernum = ((elf_symbol_type *) symbol)->version & VERSYM_VERSION; |
if (vernum == 0) |
version_string = ""; |
else if (vernum == 1) |
version_string = "Base"; |
else if (vernum <= elf_tdata (abfd)->cverdefs) |
version_string = |
elf_tdata (abfd)->verdef[vernum - 1].vd_nodename; |
else |
{ |
Elf_Internal_Verneed *t; |
version_string = ""; |
for (t = elf_tdata (abfd)->verref; |
t != NULL; |
t = t->vn_nextref) |
{ |
Elf_Internal_Vernaux *a; |
for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr) |
{ |
if (a->vna_other == vernum) |
{ |
version_string = a->vna_nodename; |
break; |
} |
} |
} |
} |
if ((((elf_symbol_type *) symbol)->version & VERSYM_HIDDEN) == 0) |
fprintf (file, " %-11s", version_string); |
else |
{ |
1708,6 → 1514,29 |
} |
} |
/* Allocate an ELF string table--force the first byte to be zero. */ |
struct bfd_strtab_hash * |
_bfd_elf_stringtab_init (void) |
{ |
struct bfd_strtab_hash *ret; |
ret = _bfd_stringtab_init (); |
if (ret != NULL) |
{ |
bfd_size_type loc; |
loc = _bfd_stringtab_add (ret, "", TRUE, FALSE); |
BFD_ASSERT (loc == 0 || loc == (bfd_size_type) -1); |
if (loc == (bfd_size_type) -1) |
{ |
_bfd_stringtab_free (ret); |
ret = NULL; |
} |
} |
return ret; |
} |
/* ELF .o/exec file reading */ |
/* Create a new bfd section from an ELF section header. */ |
1719,50 → 1548,16 |
Elf_Internal_Ehdr *ehdr; |
const struct elf_backend_data *bed; |
const char *name; |
bfd_boolean ret = TRUE; |
static bfd_boolean * sections_being_created = NULL; |
static bfd * sections_being_created_abfd = NULL; |
static unsigned int nesting = 0; |
if (shindex >= elf_numsections (abfd)) |
return FALSE; |
if (++ nesting > 3) |
{ |
/* PR17512: A corrupt ELF binary might contain a recursive group of |
sections, with each the string indicies pointing to the next in the |
loop. Detect this here, by refusing to load a section that we are |
already in the process of loading. We only trigger this test if |
we have nested at least three sections deep as normal ELF binaries |
can expect to recurse at least once. |
FIXME: It would be better if this array was attached to the bfd, |
rather than being held in a static pointer. */ |
if (sections_being_created_abfd != abfd) |
sections_being_created = NULL; |
if (sections_being_created == NULL) |
{ |
/* FIXME: It would be more efficient to attach this array to the bfd somehow. */ |
sections_being_created = (bfd_boolean *) |
bfd_zalloc (abfd, elf_numsections (abfd) * sizeof (bfd_boolean)); |
sections_being_created_abfd = abfd; |
} |
if (sections_being_created [shindex]) |
{ |
(*_bfd_error_handler) |
(_("%B: warning: loop in section dependencies detected"), abfd); |
return FALSE; |
} |
sections_being_created [shindex] = TRUE; |
} |
hdr = elf_elfsections (abfd)[shindex]; |
ehdr = elf_elfheader (abfd); |
name = bfd_elf_string_from_elf_section (abfd, ehdr->e_shstrndx, |
hdr->sh_name); |
if (name == NULL) |
goto fail; |
return FALSE; |
bed = get_elf_backend_data (abfd); |
switch (hdr->sh_type) |
1769,7 → 1564,7 |
{ |
case SHT_NULL: |
/* Inactive section. Throw it away. */ |
goto success; |
return TRUE; |
case SHT_PROGBITS: /* Normal section with contents. */ |
case SHT_NOBITS: /* .bss section. */ |
1780,13 → 1575,11 |
case SHT_PREINIT_ARRAY: /* .preinit_array section. */ |
case SHT_GNU_LIBLIST: /* .gnu.liblist section. */ |
case SHT_GNU_HASH: /* .gnu.hash section. */ |
ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); |
goto success; |
return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); |
case SHT_DYNAMIC: /* Dynamic linking information. */ |
if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) |
goto fail; |
return FALSE; |
if (hdr->sh_link > elf_numsections (abfd)) |
{ |
/* PR 10478: Accept Solaris binaries with a sh_link |
1800,11 → 1593,11 |
break; |
/* Otherwise fall through. */ |
default: |
goto fail; |
return FALSE; |
} |
} |
else if (elf_elfsections (abfd)[hdr->sh_link] == NULL) |
goto fail; |
return FALSE; |
else if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_STRTAB) |
{ |
Elf_Internal_Shdr *dynsymhdr; |
1833,38 → 1626,28 |
} |
} |
} |
goto success; |
break; |
case SHT_SYMTAB: /* A symbol table. */ |
case SHT_SYMTAB: /* A symbol table */ |
if (elf_onesymtab (abfd) == shindex) |
goto success; |
return TRUE; |
if (hdr->sh_entsize != bed->s->sizeof_sym) |
goto fail; |
return FALSE; |
if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size) |
{ |
if (hdr->sh_size != 0) |
goto fail; |
return FALSE; |
/* Some assemblers erroneously set sh_info to one with a |
zero sh_size. ld sees this as a global symbol count |
of (unsigned) -1. Fix it here. */ |
hdr->sh_info = 0; |
goto success; |
return TRUE; |
} |
/* PR 18854: A binary might contain more than one symbol table. |
Unusual, but possible. Warn, but continue. */ |
if (elf_onesymtab (abfd) != 0) |
{ |
(*_bfd_error_handler) |
(_("%B: warning: multiple symbol tables detected - ignoring the table in section %u"), |
abfd, shindex); |
goto success; |
} |
BFD_ASSERT (elf_onesymtab (abfd) == 0); |
elf_onesymtab (abfd) = shindex; |
elf_symtab_hdr (abfd) = *hdr; |
elf_elfsections (abfd)[shindex] = hdr = & elf_symtab_hdr (abfd); |
elf_tdata (abfd)->symtab_hdr = *hdr; |
elf_elfsections (abfd)[shindex] = hdr = &elf_tdata (abfd)->symtab_hdr; |
abfd->flags |= HAS_SYMS; |
/* Sometimes a shared object will map in the symbol table. If |
1877,73 → 1660,53 |
&& (abfd->flags & DYNAMIC) != 0 |
&& ! _bfd_elf_make_section_from_shdr (abfd, hdr, name, |
shindex)) |
goto fail; |
return FALSE; |
/* Go looking for SHT_SYMTAB_SHNDX too, since if there is one we |
can't read symbols without that section loaded as well. It |
is most likely specified by the next section header. */ |
if (elf_elfsections (abfd)[elf_symtab_shndx (abfd)]->sh_link != shindex) |
{ |
elf_section_list * entry; |
unsigned int i, num_sec; |
for (entry = elf_symtab_shndx_list (abfd); entry != NULL; entry = entry->next) |
if (entry->hdr.sh_link == shindex) |
goto success; |
num_sec = elf_numsections (abfd); |
for (i = shindex + 1; i < num_sec; i++) |
{ |
Elf_Internal_Shdr *hdr2 = elf_elfsections (abfd)[i]; |
if (hdr2->sh_type == SHT_SYMTAB_SHNDX |
&& hdr2->sh_link == shindex) |
break; |
} |
if (i == num_sec) |
for (i = 1; i < shindex; i++) |
{ |
Elf_Internal_Shdr *hdr2 = elf_elfsections (abfd)[i]; |
if (hdr2->sh_type == SHT_SYMTAB_SHNDX |
&& hdr2->sh_link == shindex) |
break; |
} |
if (i != shindex) |
ret = bfd_section_from_shdr (abfd, i); |
/* else FIXME: we have failed to find the symbol table - should we issue an error ? */ |
goto success; |
return bfd_section_from_shdr (abfd, i); |
} |
return TRUE; |
case SHT_DYNSYM: /* A dynamic symbol table. */ |
case SHT_DYNSYM: /* A dynamic symbol table */ |
if (elf_dynsymtab (abfd) == shindex) |
goto success; |
return TRUE; |
if (hdr->sh_entsize != bed->s->sizeof_sym) |
goto fail; |
return FALSE; |
if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size) |
{ |
if (hdr->sh_size != 0) |
goto fail; |
return FALSE; |
/* Some linkers erroneously set sh_info to one with a |
zero sh_size. ld sees this as a global symbol count |
of (unsigned) -1. Fix it here. */ |
hdr->sh_info = 0; |
goto success; |
return TRUE; |
} |
/* PR 18854: A binary might contain more than one dynamic symbol table. |
Unusual, but possible. Warn, but continue. */ |
if (elf_dynsymtab (abfd) != 0) |
{ |
(*_bfd_error_handler) |
(_("%B: warning: multiple dynamic symbol tables detected - ignoring the table in section %u"), |
abfd, shindex); |
goto success; |
} |
BFD_ASSERT (elf_dynsymtab (abfd) == 0); |
elf_dynsymtab (abfd) = shindex; |
elf_tdata (abfd)->dynsymtab_hdr = *hdr; |
elf_elfsections (abfd)[shindex] = hdr = &elf_tdata (abfd)->dynsymtab_hdr; |
1951,47 → 1714,34 |
/* Besides being a symbol table, we also treat this as a regular |
section, so that objcopy can handle it. */ |
ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); |
goto success; |
return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); |
case SHT_SYMTAB_SHNDX: /* Symbol section indices when >64k sections. */ |
{ |
elf_section_list * entry; |
case SHT_SYMTAB_SHNDX: /* Symbol section indices when >64k sections */ |
if (elf_symtab_shndx (abfd) == shindex) |
return TRUE; |
for (entry = elf_symtab_shndx_list (abfd); entry != NULL; entry = entry->next) |
if (entry->ndx == shindex) |
goto success; |
BFD_ASSERT (elf_symtab_shndx (abfd) == 0); |
elf_symtab_shndx (abfd) = shindex; |
elf_tdata (abfd)->symtab_shndx_hdr = *hdr; |
elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->symtab_shndx_hdr; |
return TRUE; |
entry = bfd_alloc (abfd, sizeof * entry); |
if (entry == NULL) |
goto fail; |
entry->ndx = shindex; |
entry->hdr = * hdr; |
entry->next = elf_symtab_shndx_list (abfd); |
elf_symtab_shndx_list (abfd) = entry; |
elf_elfsections (abfd)[shindex] = & entry->hdr; |
goto success; |
} |
case SHT_STRTAB: /* A string table. */ |
case SHT_STRTAB: /* A string table */ |
if (hdr->bfd_section != NULL) |
goto success; |
return TRUE; |
if (ehdr->e_shstrndx == shindex) |
{ |
elf_tdata (abfd)->shstrtab_hdr = *hdr; |
elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->shstrtab_hdr; |
goto success; |
return TRUE; |
} |
if (elf_elfsections (abfd)[elf_onesymtab (abfd)]->sh_link == shindex) |
{ |
symtab_strtab: |
elf_tdata (abfd)->strtab_hdr = *hdr; |
elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->strtab_hdr; |
goto success; |
return TRUE; |
} |
if (elf_elfsections (abfd)[elf_dynsymtab (abfd)]->sh_link == shindex) |
{ |
dynsymtab_strtab: |
2000,9 → 1750,8 |
elf_elfsections (abfd)[shindex] = hdr; |
/* We also treat this as a regular section, so that objcopy |
can handle it. */ |
ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, |
return _bfd_elf_make_section_from_shdr (abfd, hdr, name, |
shindex); |
goto success; |
} |
/* If the string table isn't one of the above, then treat it as a |
2020,9 → 1769,9 |
{ |
/* Prevent endless recursion on broken objects. */ |
if (i == shindex) |
goto fail; |
return FALSE; |
if (! bfd_section_from_shdr (abfd, i)) |
goto fail; |
return FALSE; |
if (elf_onesymtab (abfd) == i) |
goto symtab_strtab; |
if (elf_dynsymtab (abfd) == i) |
2030,8 → 1779,7 |
} |
} |
} |
ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); |
goto success; |
return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); |
case SHT_REL: |
case SHT_RELA: |
2046,7 → 1794,7 |
if (hdr->sh_entsize |
!= (bfd_size_type) (hdr->sh_type == SHT_REL |
? bed->s->sizeof_rel : bed->s->sizeof_rela)) |
goto fail; |
return FALSE; |
/* Check for a bogus link to avoid crashing. */ |
if (hdr->sh_link >= num_sec) |
2054,9 → 1802,8 |
((*_bfd_error_handler) |
(_("%B: invalid link %lu for reloc section %s (index %u)"), |
abfd, hdr->sh_link, name, shindex)); |
ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, |
return _bfd_elf_make_section_from_shdr (abfd, hdr, name, |
shindex); |
goto success; |
} |
/* For some incomprehensible reason Oracle distributes |
2097,7 → 1844,7 |
if ((elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_SYMTAB |
|| elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_DYNSYM) |
&& ! bfd_section_from_shdr (abfd, hdr->sh_link)) |
goto fail; |
return FALSE; |
/* If this reloc section does not use the main symbol table we |
don't treat it as a reloc section. BFD can't adequately |
2112,18 → 1859,14 |
|| hdr->sh_info >= num_sec |
|| elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_REL |
|| elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_RELA) |
{ |
ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, |
return _bfd_elf_make_section_from_shdr (abfd, hdr, name, |
shindex); |
goto success; |
} |
if (! bfd_section_from_shdr (abfd, hdr->sh_info)) |
goto fail; |
return FALSE; |
target_sect = bfd_section_from_elf_index (abfd, hdr->sh_info); |
if (target_sect == NULL) |
goto fail; |
return FALSE; |
esdt = elf_section_data (target_sect); |
if (hdr->sh_type == SHT_RELA) |
2131,13 → 1874,11 |
else |
p_hdr = &esdt->rel.hdr; |
/* PR 17512: file: 0b4f81b7. */ |
if (*p_hdr != NULL) |
goto fail; |
BFD_ASSERT (*p_hdr == NULL); |
amt = sizeof (*hdr2); |
hdr2 = (Elf_Internal_Shdr *) bfd_alloc (abfd, amt); |
if (hdr2 == NULL) |
goto fail; |
return FALSE; |
*hdr2 = *hdr; |
*p_hdr = hdr2; |
elf_elfsections (abfd)[shindex] = hdr2; |
2153,48 → 1894,40 |
target_sect->use_rela_p = 1; |
} |
abfd->flags |= HAS_RELOC; |
goto success; |
return TRUE; |
} |
case SHT_GNU_verdef: |
elf_dynverdef (abfd) = shindex; |
elf_tdata (abfd)->dynverdef_hdr = *hdr; |
ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); |
goto success; |
return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); |
case SHT_GNU_versym: |
if (hdr->sh_entsize != sizeof (Elf_External_Versym)) |
goto fail; |
return FALSE; |
elf_dynversym (abfd) = shindex; |
elf_tdata (abfd)->dynversym_hdr = *hdr; |
ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); |
goto success; |
return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); |
case SHT_GNU_verneed: |
elf_dynverref (abfd) = shindex; |
elf_tdata (abfd)->dynverref_hdr = *hdr; |
ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); |
goto success; |
return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); |
case SHT_SHLIB: |
goto success; |
return TRUE; |
case SHT_GROUP: |
if (! IS_VALID_GROUP_SECTION_HEADER (hdr, GRP_ENTRY_SIZE)) |
goto fail; |
return FALSE; |
if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) |
goto fail; |
return FALSE; |
if (hdr->contents != NULL) |
{ |
Elf_Internal_Group *idx = (Elf_Internal_Group *) hdr->contents; |
unsigned int n_elt = hdr->sh_size / sizeof (* idx); |
unsigned int n_elt = hdr->sh_size / GRP_ENTRY_SIZE; |
asection *s; |
if (n_elt == 0) |
goto fail; |
if (idx->flags & GRP_COMDAT) |
hdr->bfd_section->flags |
|= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; |
2201,7 → 1934,6 |
/* We try to keep the same section order as it comes in. */ |
idx += n_elt; |
while (--n_elt != 0) |
{ |
--idx; |
2215,7 → 1947,7 |
} |
} |
} |
goto success; |
break; |
default: |
/* Possibly an attributes section. */ |
2223,14 → 1955,14 |
|| hdr->sh_type == bed->obj_attrs_section_type) |
{ |
if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) |
goto fail; |
return FALSE; |
_bfd_elf_parse_attributes (abfd, hdr); |
goto success; |
return TRUE; |
} |
/* Check for any processor-specific section types. */ |
if (bed->elf_backend_section_from_shdr (abfd, hdr, name, shindex)) |
goto success; |
return TRUE; |
if (hdr->sh_type >= SHT_LOUSER && hdr->sh_type <= SHT_HIUSER) |
{ |
2242,13 → 1974,10 |
"specific section `%s' [0x%8x]"), |
abfd, name, hdr->sh_type); |
else |
{ |
/* Allow sections reserved for applications. */ |
ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, |
return _bfd_elf_make_section_from_shdr (abfd, hdr, name, |
shindex); |
goto success; |
} |
} |
else if (hdr->sh_type >= SHT_LOPROC |
&& hdr->sh_type <= SHT_HIPROC) |
/* FIXME: We should handle this section. */ |
2268,12 → 1997,9 |
"`%s' [0x%8x]"), |
abfd, name, hdr->sh_type); |
else |
{ |
/* Otherwise it should be processed. */ |
ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); |
goto success; |
return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); |
} |
} |
else |
/* FIXME: We should handle this section. */ |
(*_bfd_error_handler) |
2280,21 → 2006,11 |
(_("%B: don't know how to handle section `%s' [0x%8x]"), |
abfd, name, hdr->sh_type); |
goto fail; |
return FALSE; |
} |
fail: |
ret = FALSE; |
success: |
if (sections_being_created && sections_being_created_abfd == abfd) |
sections_being_created [shindex] = FALSE; |
if (-- nesting == 0) |
{ |
sections_being_created = NULL; |
sections_being_created_abfd = abfd; |
return TRUE; |
} |
return ret; |
} |
/* Return the local symbol specified by ABFD, R_SYMNDX. */ |
2800,27 → 2516,6 |
return elf_section_data (sec)->rela.hdr; |
} |
static bfd_boolean |
_bfd_elf_set_reloc_sh_name (bfd *abfd, |
Elf_Internal_Shdr *rel_hdr, |
const char *sec_name, |
bfd_boolean use_rela_p) |
{ |
char *name = (char *) bfd_alloc (abfd, |
sizeof ".rela" + strlen (sec_name)); |
if (name == NULL) |
return FALSE; |
sprintf (name, "%s%s", use_rela_p ? ".rela" : ".rel", sec_name); |
rel_hdr->sh_name = |
(unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd), name, |
FALSE); |
if (rel_hdr->sh_name == (unsigned int) -1) |
return FALSE; |
return TRUE; |
} |
/* Allocate and initialize a section-header for a new reloc section, |
containing relocations against ASECT. It is stored in RELDATA. If |
USE_RELA_P is TRUE, we use RELA relocations; otherwise, we use REL |
2829,11 → 2524,11 |
static bfd_boolean |
_bfd_elf_init_reloc_shdr (bfd *abfd, |
struct bfd_elf_section_reloc_data *reldata, |
const char *sec_name, |
bfd_boolean use_rela_p, |
bfd_boolean delay_st_name_p) |
asection *asect, |
bfd_boolean use_rela_p) |
{ |
Elf_Internal_Shdr *rel_hdr; |
char *name; |
const struct elf_backend_data *bed = get_elf_backend_data (abfd); |
bfd_size_type amt; |
2842,11 → 2537,16 |
rel_hdr = bfd_zalloc (abfd, amt); |
reldata->hdr = rel_hdr; |
if (delay_st_name_p) |
rel_hdr->sh_name = (unsigned int) -1; |
else if (!_bfd_elf_set_reloc_sh_name (abfd, rel_hdr, sec_name, |
use_rela_p)) |
amt = sizeof ".rela" + strlen (asect->name); |
name = (char *) bfd_alloc (abfd, amt); |
if (name == NULL) |
return FALSE; |
sprintf (name, "%s%s", use_rela_p ? ".rela" : ".rel", asect->name); |
rel_hdr->sh_name = |
(unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd), name, |
FALSE); |
if (rel_hdr->sh_name == (unsigned int) -1) |
return FALSE; |
rel_hdr->sh_type = use_rela_p ? SHT_RELA : SHT_REL; |
rel_hdr->sh_entsize = (use_rela_p |
? bed->s->sizeof_rela |
2887,8 → 2587,6 |
struct bfd_elf_section_data *esd = elf_section_data (asect); |
Elf_Internal_Shdr *this_hdr; |
unsigned int sh_type; |
const char *name = asect->name; |
bfd_boolean delay_st_name_p = FALSE; |
if (arg->failed) |
{ |
2899,73 → 2597,13 |
this_hdr = &esd->this_hdr; |
if (arg->link_info) |
{ |
/* ld: compress DWARF debug sections with names: .debug_*. */ |
if ((arg->link_info->compress_debug & COMPRESS_DEBUG) |
&& (asect->flags & SEC_DEBUGGING) |
&& name[1] == 'd' |
&& name[6] == '_') |
{ |
/* Set SEC_ELF_COMPRESS to indicate this section should be |
compressed. */ |
asect->flags |= SEC_ELF_COMPRESS; |
/* If this section will be compressed, delay adding setion |
name to section name section after it is compressed in |
_bfd_elf_assign_file_positions_for_non_load. */ |
delay_st_name_p = TRUE; |
} |
} |
else if ((asect->flags & SEC_ELF_RENAME)) |
{ |
/* objcopy: rename output DWARF debug section. */ |
if ((abfd->flags & (BFD_DECOMPRESS | BFD_COMPRESS_GABI))) |
{ |
/* When we decompress or compress with SHF_COMPRESSED, |
convert section name from .zdebug_* to .debug_* if |
needed. */ |
if (name[1] == 'z') |
{ |
char *new_name = convert_zdebug_to_debug (abfd, name); |
if (new_name == NULL) |
{ |
arg->failed = TRUE; |
return; |
} |
name = new_name; |
} |
} |
else if (asect->compress_status == COMPRESS_SECTION_DONE) |
{ |
/* PR binutils/18087: Compression does not always make a |
section smaller. So only rename the section when |
compression has actually taken place. If input section |
name is .zdebug_*, we should never compress it again. */ |
char *new_name = convert_debug_to_zdebug (abfd, name); |
if (new_name == NULL) |
{ |
arg->failed = TRUE; |
return; |
} |
BFD_ASSERT (name[1] != 'z'); |
name = new_name; |
} |
} |
if (delay_st_name_p) |
this_hdr->sh_name = (unsigned int) -1; |
else |
{ |
this_hdr->sh_name |
= (unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd), |
name, FALSE); |
this_hdr->sh_name = (unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd), |
asect->name, FALSE); |
if (this_hdr->sh_name == (unsigned int) -1) |
{ |
arg->failed = TRUE; |
return; |
} |
} |
/* Don't clear sh_flags. Assembler may set additional bits. */ |
2978,15 → 2616,6 |
this_hdr->sh_offset = 0; |
this_hdr->sh_size = asect->size; |
this_hdr->sh_link = 0; |
/* PR 17512: file: 0eb809fe, 8b0535ee. */ |
if (asect->alignment_power >= (sizeof (bfd_vma) * 8) - 1) |
{ |
(*_bfd_error_handler) |
(_("%B: error: Alignment power %d of section `%A' is too big"), |
abfd, asect, asect->alignment_power); |
arg->failed = TRUE; |
return; |
} |
this_hdr->sh_addralign = (bfd_vma) 1 << asect->alignment_power; |
/* The sh_entsize and sh_info fields may have been set already by |
copy_private_section_data. */ |
3135,19 → 2764,16 |
if (arg->link_info |
/* Do the normal setup if we wouldn't create any sections here. */ |
&& esd->rel.count + esd->rela.count > 0 |
&& (bfd_link_relocatable (arg->link_info) |
|| arg->link_info->emitrelocations)) |
&& (arg->link_info->relocatable || arg->link_info->emitrelocations)) |
{ |
if (esd->rel.count && esd->rel.hdr == NULL |
&& !_bfd_elf_init_reloc_shdr (abfd, &esd->rel, name, FALSE, |
delay_st_name_p)) |
&& !_bfd_elf_init_reloc_shdr (abfd, &esd->rel, asect, FALSE)) |
{ |
arg->failed = TRUE; |
return; |
} |
if (esd->rela.count && esd->rela.hdr == NULL |
&& !_bfd_elf_init_reloc_shdr (abfd, &esd->rela, name, TRUE, |
delay_st_name_p)) |
&& !_bfd_elf_init_reloc_shdr (abfd, &esd->rela, asect, TRUE)) |
{ |
arg->failed = TRUE; |
return; |
3156,9 → 2782,8 |
else if (!_bfd_elf_init_reloc_shdr (abfd, |
(asect->use_rela_p |
? &esd->rela : &esd->rel), |
name, |
asect->use_rela_p, |
delay_st_name_p)) |
asect, |
asect->use_rela_p)) |
arg->failed = TRUE; |
} |
3292,48 → 2917,6 |
H_PUT_32 (abfd, sec->flags & SEC_LINK_ONCE ? GRP_COMDAT : 0, loc); |
} |
/* Return the section which RELOC_SEC applies to. */ |
asection * |
_bfd_elf_get_reloc_section (asection *reloc_sec) |
{ |
const char *name; |
unsigned int type; |
bfd *abfd; |
if (reloc_sec == NULL) |
return NULL; |
type = elf_section_data (reloc_sec)->this_hdr.sh_type; |
if (type != SHT_REL && type != SHT_RELA) |
return NULL; |
/* We look up the section the relocs apply to by name. */ |
name = reloc_sec->name; |
if (type == SHT_REL) |
name += 4; |
else |
name += 5; |
/* If a target needs .got.plt section, relocations in rela.plt/rel.plt |
section apply to .got.plt section. */ |
abfd = reloc_sec->owner; |
if (get_elf_backend_data (abfd)->want_got_plt |
&& strcmp (name, ".plt") == 0) |
{ |
/* .got.plt is a linker created input section. It may be mapped |
to some other output section. Try two likely sections. */ |
name = ".got.plt"; |
reloc_sec = bfd_get_section_by_name (abfd, name); |
if (reloc_sec != NULL) |
return reloc_sec; |
name = ".got"; |
} |
reloc_sec = bfd_get_section_by_name (abfd, name); |
return reloc_sec; |
} |
/* Assign all ELF section numbers. The dummy first section is handled here |
too. The link/info pointers for the standard section types are filled |
in here too, while we're at it. */ |
3343,7 → 2926,7 |
{ |
struct elf_obj_tdata *t = elf_tdata (abfd); |
asection *sec; |
unsigned int section_number; |
unsigned int section_number, secn; |
Elf_Internal_Shdr **i_shdrp; |
struct bfd_elf_section_data *d; |
bfd_boolean need_symtab; |
3353,7 → 2936,7 |
_bfd_elf_strtab_clear_all_refs (elf_shstrtab (abfd)); |
/* SHT_GROUP sections are in relocatable files only. */ |
if (link_info == NULL || bfd_link_relocatable (link_info)) |
if (link_info == NULL || link_info->relocatable) |
{ |
/* Put SHT_GROUP sections first. */ |
for (sec = abfd->sections; sec != NULL; sec = sec->next) |
3380,12 → 2963,10 |
if (d->this_hdr.sh_type != SHT_GROUP) |
d->this_idx = section_number++; |
if (d->this_hdr.sh_name != (unsigned int) -1) |
_bfd_elf_strtab_addref (elf_shstrtab (abfd), d->this_hdr.sh_name); |
if (d->rel.hdr) |
{ |
d->rel.idx = section_number++; |
if (d->rel.hdr->sh_name != (unsigned int) -1) |
_bfd_elf_strtab_addref (elf_shstrtab (abfd), d->rel.hdr->sh_name); |
} |
else |
3394,7 → 2975,6 |
if (d->rela.hdr) |
{ |
d->rela.idx = section_number++; |
if (d->rela.hdr->sh_name != (unsigned int) -1) |
_bfd_elf_strtab_addref (elf_shstrtab (abfd), d->rela.hdr->sh_name); |
} |
else |
3415,17 → 2995,11 |
_bfd_elf_strtab_addref (elf_shstrtab (abfd), t->symtab_hdr.sh_name); |
if (section_number > ((SHN_LORESERVE - 2) & 0xFFFF)) |
{ |
elf_section_list * entry; |
BFD_ASSERT (elf_symtab_shndx_list (abfd) == NULL); |
entry = bfd_zalloc (abfd, sizeof * entry); |
entry->ndx = section_number++; |
elf_symtab_shndx_list (abfd) = entry; |
entry->hdr.sh_name |
elf_symtab_shndx (abfd) = section_number++; |
t->symtab_shndx_hdr.sh_name |
= (unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd), |
".symtab_shndx", FALSE); |
if (entry->hdr.sh_name == (unsigned int) -1) |
if (t->symtab_shndx_hdr.sh_name == (unsigned int) -1) |
return FALSE; |
} |
elf_strtab_sec (abfd) = section_number++; |
3439,6 → 3013,9 |
return FALSE; |
} |
_bfd_elf_strtab_finalize (elf_shstrtab (abfd)); |
t->shstrtab_hdr.sh_size = _bfd_elf_strtab_size (elf_shstrtab (abfd)); |
elf_numsections (abfd) = section_number; |
elf_elfheader (abfd)->e_shnum = section_number; |
3465,10 → 3042,8 |
i_shdrp[elf_onesymtab (abfd)] = &t->symtab_hdr; |
if (elf_numsections (abfd) > (SHN_LORESERVE & 0xFFFF)) |
{ |
elf_section_list * entry = elf_symtab_shndx_list (abfd); |
BFD_ASSERT (entry != NULL); |
i_shdrp[entry->ndx] = & entry->hdr; |
entry->hdr.sh_link = elf_onesymtab (abfd); |
i_shdrp[elf_symtab_shndx (abfd)] = &t->symtab_shndx_hdr; |
t->symtab_shndx_hdr.sh_link = elf_onesymtab (abfd); |
} |
i_shdrp[elf_strtab_sec (abfd)] = &t->strtab_hdr; |
t->symtab_hdr.sh_link = elf_strtab_sec (abfd); |
3477,6 → 3052,7 |
for (sec = abfd->sections; sec; sec = sec->next) |
{ |
asection *s; |
const char *name; |
d = elf_section_data (sec); |
3495,13 → 3071,11 |
{ |
d->rel.hdr->sh_link = elf_onesymtab (abfd); |
d->rel.hdr->sh_info = d->this_idx; |
d->rel.hdr->sh_flags |= SHF_INFO_LINK; |
} |
if (d->rela.idx != 0) |
{ |
d->rela.hdr->sh_link = elf_onesymtab (abfd); |
d->rela.hdr->sh_info = d->this_idx; |
d->rela.hdr->sh_flags |= SHF_INFO_LINK; |
} |
/* We need to set up sh_link for SHF_LINK_ORDER. */ |
3580,12 → 3154,15 |
if (s != NULL) |
d->this_hdr.sh_link = elf_section_data (s)->this_idx; |
s = get_elf_backend_data (abfd)->get_reloc_section (sec); |
/* We look up the section the relocs apply to by name. */ |
name = sec->name; |
if (d->this_hdr.sh_type == SHT_REL) |
name += 4; |
else |
name += 5; |
s = bfd_get_section_by_name (abfd, name); |
if (s != NULL) |
{ |
d->this_hdr.sh_info = elf_section_data (s)->this_idx; |
d->this_hdr.sh_flags |= SHF_INFO_LINK; |
} |
break; |
case SHT_STRTAB: |
3656,10 → 3233,12 |
} |
} |
/* Delay setting sh_name to _bfd_elf_write_object_contents so that |
_bfd_elf_assign_file_positions_for_non_load can convert DWARF |
debug section name from .debug_* to .zdebug_* if needed. */ |
for (secn = 1; secn < section_number; ++secn) |
if (i_shdrp[secn] == NULL) |
i_shdrp[secn] = i_shdrp[0]; |
else |
i_shdrp[secn]->sh_name = _bfd_elf_strtab_offset (elf_shstrtab (abfd), |
i_shdrp[secn]->sh_name); |
return TRUE; |
} |
3710,7 → 3289,7 |
unsigned int num_globals = 0; |
unsigned int num_locals2 = 0; |
unsigned int num_globals2 = 0; |
unsigned int max_index = 0; |
int max_index = 0; |
unsigned int idx; |
asection *asect; |
asymbol **new_syms; |
3859,7 → 3438,7 |
const struct elf_backend_data *bed = get_elf_backend_data (abfd); |
struct fake_section_arg fsargs; |
bfd_boolean failed; |
struct elf_strtab_hash *strtab = NULL; |
struct bfd_strtab_hash *strtab = NULL; |
Elf_Internal_Shdr *shstrtab_hdr; |
bfd_boolean need_symtab; |
3874,6 → 3453,7 |
return FALSE; |
/* Post process the headers if necessary. */ |
if (bed->elf_backend_post_process_headers) |
(*bed->elf_backend_post_process_headers) (abfd, link_info); |
fsargs.failed = FALSE; |
3912,11 → 3492,11 |
shstrtab_hdr->sh_type = SHT_STRTAB; |
shstrtab_hdr->sh_flags = 0; |
shstrtab_hdr->sh_addr = 0; |
/* sh_size is set in _bfd_elf_assign_file_positions_for_non_load. */ |
shstrtab_hdr->sh_size = _bfd_elf_strtab_size (elf_shstrtab (abfd)); |
shstrtab_hdr->sh_entsize = 0; |
shstrtab_hdr->sh_link = 0; |
shstrtab_hdr->sh_info = 0; |
/* sh_offset is set in _bfd_elf_assign_file_positions_for_non_load. */ |
/* sh_offset is set in assign_file_positions_except_relocs. */ |
shstrtab_hdr->sh_addralign = 1; |
if (!assign_file_positions_except_relocs (abfd, link_info)) |
3929,16 → 3509,12 |
off = elf_next_file_pos (abfd); |
hdr = & elf_symtab_hdr (abfd); |
hdr = &elf_tdata (abfd)->symtab_hdr; |
off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE); |
if (elf_symtab_shndx_list (abfd) != NULL) |
{ |
hdr = & elf_symtab_shndx_list (abfd)->hdr; |
hdr = &elf_tdata (abfd)->symtab_shndx_hdr; |
if (hdr->sh_size != 0) |
off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE); |
/* FIXME: What about other symtab_shndx sections in the list ? */ |
} |
hdr = &elf_tdata (abfd)->strtab_hdr; |
off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE); |
3948,9 → 3524,9 |
/* Now that we know where the .strtab section goes, write it |
out. */ |
if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0 |
|| ! _bfd_elf_strtab_emit (abfd, strtab)) |
|| ! _bfd_stringtab_emit (abfd, strtab)) |
return FALSE; |
_bfd_elf_strtab_free (strtab); |
_bfd_stringtab_free (strtab); |
} |
abfd->output_has_begun = TRUE; |
4289,11 → 3865,6 |
last_size = 0; |
phdr_index = 0; |
maxpagesize = bed->maxpagesize; |
/* PR 17512: file: c8455299. |
Avoid divide-by-zero errors later on. |
FIXME: Should we abort if the maxpagesize is zero ? */ |
if (maxpagesize == 0) |
maxpagesize = 1; |
writable = FALSE; |
dynsec = bfd_get_section_by_name (abfd, ".dynamic"); |
if (dynsec != NULL |
4364,18 → 3935,11 |
new_segment = TRUE; |
} |
else if ((last_hdr->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) == 0 |
&& (hdr->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) != 0 |
&& ((abfd->flags & D_PAGED) == 0 |
|| (((last_hdr->lma + last_size - 1) & -maxpagesize) |
!= (hdr->lma & -maxpagesize)))) |
&& (hdr->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) != 0) |
{ |
/* We don't want to put a loaded section after a |
nonloaded (ie. bss style) section in the same segment |
as that will force the non-loaded section to be loaded. |
Consider .tbss sections as loaded for this purpose. |
However, like the writable/non-writable case below, |
if they are on the same page then they must be put |
in the same segment. */ |
/* We don't want to put a loadable section after a |
nonloadable section in the same segment. |
Consider .tbss sections as loadable for this purpose. */ |
new_segment = TRUE; |
} |
else if ((abfd->flags & D_PAGED) == 0) |
4545,32 → 4109,12 |
/* Mandated PF_R. */ |
m->p_flags = PF_R; |
m->p_flags_valid = 1; |
s = first_tls; |
for (i = 0; i < (unsigned int) tls_count; ++i) |
{ |
if ((s->flags & SEC_THREAD_LOCAL) == 0) |
{ |
_bfd_error_handler |
(_("%B: TLS sections are not adjacent:"), abfd); |
s = first_tls; |
i = 0; |
while (i < (unsigned int) tls_count) |
{ |
if ((s->flags & SEC_THREAD_LOCAL) != 0) |
{ |
_bfd_error_handler (_(" TLS: %A"), s); |
i++; |
BFD_ASSERT (first_tls->flags & SEC_THREAD_LOCAL); |
m->sections[i] = first_tls; |
first_tls = first_tls->next; |
} |
else |
_bfd_error_handler (_(" non-TLS: %A"), s); |
s = s->next; |
} |
bfd_set_error (bfd_error_bad_value); |
goto error_return; |
} |
m->sections[i] = s; |
s = s->next; |
} |
*pm = m; |
pm = &m->next; |
4632,7 → 4176,11 |
== (SEC_LOAD | SEC_HAS_CONTENTS)) |
break; |
if (i != (unsigned) -1) |
if (i == (unsigned) -1) |
continue; |
if (m->sections[i]->vma + m->sections[i]->size |
>= info->relro_end) |
break; |
} |
} |
4646,6 → 4194,9 |
goto error_return; |
m->next = NULL; |
m->p_type = PT_GNU_RELRO; |
m->p_flags = PF_R; |
m->p_flags_valid = 1; |
*pm = m; |
pm = &m->next; |
} |
4754,9 → 4305,6 |
static file_ptr |
vma_page_aligned_bias (bfd_vma vma, ufile_ptr off, bfd_vma maxpagesize) |
{ |
/* PR binutils/16199: Handle an alignment of zero. */ |
if (maxpagesize == 0) |
maxpagesize = 1; |
return ((vma - off) % maxpagesize); |
} |
5233,7 → 4781,6 |
p->p_flags |= PF_W; |
} |
} |
off -= off_adjust; |
/* Check that all sections are in a PT_LOAD segment. |
5285,7 → 4832,7 |
{ |
const struct elf_backend_data *bed = get_elf_backend_data (abfd); |
Elf_Internal_Shdr **i_shdrpp; |
Elf_Internal_Shdr **hdrpp, **end_hdrpp; |
Elf_Internal_Shdr **hdrpp; |
Elf_Internal_Phdr *phdrs; |
Elf_Internal_Phdr *p; |
struct elf_segment_map *m; |
5293,12 → 4840,14 |
bfd_vma filehdr_vaddr, filehdr_paddr; |
bfd_vma phdrs_vaddr, phdrs_paddr; |
file_ptr off; |
unsigned int num_sec; |
unsigned int i; |
unsigned int count; |
i_shdrpp = elf_elfsections (abfd); |
end_hdrpp = i_shdrpp + elf_numsections (abfd); |
num_sec = elf_numsections (abfd); |
off = elf_next_file_pos (abfd); |
for (hdrpp = i_shdrpp + 1; hdrpp < end_hdrpp; hdrpp++) |
for (i = 1, hdrpp = i_shdrpp + 1; i < num_sec; i++, hdrpp++) |
{ |
Elf_Internal_Shdr *hdr; |
5329,14 → 4878,9 |
} |
else if (((hdr->sh_type == SHT_REL || hdr->sh_type == SHT_RELA) |
&& hdr->bfd_section == NULL) |
|| (hdr->bfd_section != NULL |
&& (hdr->bfd_section->flags & SEC_ELF_COMPRESS)) |
/* Compress DWARF debug sections. */ |
|| hdr == i_shdrpp[elf_onesymtab (abfd)] |
|| (elf_symtab_shndx_list (abfd) != NULL |
&& hdr == i_shdrpp[elf_symtab_shndx_list (abfd)->ndx]) |
|| hdr == i_shdrpp[elf_strtab_sec (abfd)] |
|| hdr == i_shdrpp[elf_shstrtab_sec (abfd)]) |
|| hdr == i_shdrpp[elf_symtab_shndx (abfd)] |
|| hdr == i_shdrpp[elf_strtab_sec (abfd)]) |
hdr->sh_offset = -1; |
else |
off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE); |
5438,11 → 4982,14 |
{ |
if (lp->p_type == PT_LOAD |
&& lp->p_vaddr < link_info->relro_end |
&& lp->p_vaddr + lp->p_filesz >= link_info->relro_end |
&& lm->count != 0 |
&& lm->sections[0]->vma >= link_info->relro_start) |
break; |
} |
/* PR ld/14207. If the RELRO segment doesn't fit in the |
LOAD segment, it should be removed. */ |
BFD_ASSERT (lm != NULL); |
} |
else |
5477,7 → 5024,7 |
if (!m->p_align_valid) |
p->p_align = 1; |
if (!m->p_flags_valid) |
p->p_flags = PF_R; |
p->p_flags = (lp->p_flags & ~PF_W); |
} |
else |
{ |
5492,19 → 5039,11 |
} |
else if (m->count != 0) |
{ |
unsigned int i; |
if (p->p_type != PT_LOAD |
&& (p->p_type != PT_NOTE |
|| bfd_get_format (abfd) != bfd_core)) |
{ |
if (m->includes_filehdr || m->includes_phdrs) |
{ |
/* PR 17512: file: 2195325e. */ |
(*_bfd_error_handler) |
(_("%B: warning: non-load segment includes file header and/or program header"), |
abfd); |
return FALSE; |
} |
BFD_ASSERT (!m->includes_filehdr && !m->includes_phdrs); |
p->p_filesz = 0; |
p->p_offset = m->sections[0]->filepos; |
5540,15 → 5079,6 |
return TRUE; |
} |
static elf_section_list * |
find_section_in_list (unsigned int i, elf_section_list * list) |
{ |
for (;list != NULL; list = list->next) |
if (list->ndx == i) |
break; |
return list; |
} |
/* Work out the file positions of all the sections. This is called by |
_bfd_elf_compute_section_file_positions. All the section sizes and |
VMAs must be known before this is called. |
5569,6 → 5099,7 |
{ |
struct elf_obj_tdata *tdata = elf_tdata (abfd); |
Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd); |
file_ptr off; |
const struct elf_backend_data *bed = get_elf_backend_data (abfd); |
if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0 |
5578,7 → 5109,6 |
unsigned int num_sec = elf_numsections (abfd); |
Elf_Internal_Shdr **hdrpp; |
unsigned int i; |
file_ptr off; |
/* Start after the ELF header. */ |
off = i_ehdrp->e_ehsize; |
5593,14 → 5123,9 |
hdr = *hdrpp; |
if (((hdr->sh_type == SHT_REL || hdr->sh_type == SHT_RELA) |
&& hdr->bfd_section == NULL) |
|| (hdr->bfd_section != NULL |
&& (hdr->bfd_section->flags & SEC_ELF_COMPRESS)) |
/* Compress DWARF debug sections. */ |
|| i == elf_onesymtab (abfd) |
|| (elf_symtab_shndx_list (abfd) != NULL |
&& hdr == i_shdrpp[elf_symtab_shndx_list (abfd)->ndx]) |
|| i == elf_strtab_sec (abfd) |
|| i == elf_shstrtab_sec (abfd)) |
|| i == elf_symtab_shndx (abfd) |
|| i == elf_strtab_sec (abfd)) |
{ |
hdr->sh_offset = -1; |
} |
5607,8 → 5132,6 |
else |
off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE); |
} |
elf_next_file_pos (abfd) = off; |
} |
else |
{ |
5629,32 → 5152,22 |
return FALSE; |
} |
/* Set e_type in ELF header to ET_EXEC for -pie -Ttext-segment=. */ |
if (link_info != NULL && bfd_link_pie (link_info)) |
{ |
unsigned int num_segments = elf_elfheader (abfd)->e_phnum; |
Elf_Internal_Phdr *segment = elf_tdata (abfd)->phdr; |
Elf_Internal_Phdr *end_segment = &segment[num_segments]; |
/* Find the lowest p_vaddr in PT_LOAD segments. */ |
bfd_vma p_vaddr = (bfd_vma) -1; |
for (; segment < end_segment; segment++) |
if (segment->p_type == PT_LOAD && p_vaddr > segment->p_vaddr) |
p_vaddr = segment->p_vaddr; |
/* Set e_type to ET_EXEC if the lowest p_vaddr in PT_LOAD |
segments is non-zero. */ |
if (p_vaddr) |
i_ehdrp->e_type = ET_EXEC; |
} |
/* Write out the program headers. */ |
alloc = elf_program_header_size (abfd) / bed->s->sizeof_phdr; |
if (bfd_seek (abfd, (bfd_signed_vma) bed->s->sizeof_ehdr, SEEK_SET) != 0 |
|| bed->s->write_out_phdrs (abfd, tdata->phdr, alloc) != 0) |
return FALSE; |
off = elf_next_file_pos (abfd); |
} |
/* Place the section headers. */ |
off = align_file_position (off, 1 << bed->s->log_file_align); |
i_ehdrp->e_shoff = off; |
off += i_ehdrp->e_shnum * i_ehdrp->e_shentsize; |
elf_next_file_pos (abfd) = off; |
return TRUE; |
} |
5739,7 → 5252,7 |
elf_tdata (abfd)->shstrtab_hdr.sh_name = |
(unsigned int) _bfd_elf_strtab_add (shstrtab, ".shstrtab", FALSE); |
if (elf_tdata (abfd)->symtab_hdr.sh_name == (unsigned int) -1 |
|| elf_tdata (abfd)->strtab_hdr.sh_name == (unsigned int) -1 |
|| elf_tdata (abfd)->symtab_hdr.sh_name == (unsigned int) -1 |
|| elf_tdata (abfd)->shstrtab_hdr.sh_name == (unsigned int) -1) |
return FALSE; |
5747,101 → 5260,29 |
} |
/* Assign file positions for all the reloc sections which are not part |
of the loadable file image, and the file position of section headers. */ |
of the loadable file image. */ |
static bfd_boolean |
_bfd_elf_assign_file_positions_for_non_load (bfd *abfd) |
void |
_bfd_elf_assign_file_positions_for_relocs (bfd *abfd) |
{ |
file_ptr off; |
Elf_Internal_Shdr **shdrpp, **end_shdrpp; |
Elf_Internal_Shdr *shdrp; |
Elf_Internal_Ehdr *i_ehdrp; |
const struct elf_backend_data *bed; |
unsigned int i, num_sec; |
Elf_Internal_Shdr **shdrpp; |
off = elf_next_file_pos (abfd); |
shdrpp = elf_elfsections (abfd); |
end_shdrpp = shdrpp + elf_numsections (abfd); |
for (shdrpp++; shdrpp < end_shdrpp; shdrpp++) |
num_sec = elf_numsections (abfd); |
for (i = 1, shdrpp = elf_elfsections (abfd) + 1; i < num_sec; i++, shdrpp++) |
{ |
Elf_Internal_Shdr *shdrp; |
shdrp = *shdrpp; |
if (shdrp->sh_offset == -1) |
{ |
asection *sec = shdrp->bfd_section; |
bfd_boolean is_rel = (shdrp->sh_type == SHT_REL |
|| shdrp->sh_type == SHT_RELA); |
if (is_rel |
|| (sec != NULL && (sec->flags & SEC_ELF_COMPRESS))) |
{ |
if (!is_rel) |
{ |
const char *name = sec->name; |
struct bfd_elf_section_data *d; |
/* Compress DWARF debug sections. */ |
if (!bfd_compress_section (abfd, sec, |
shdrp->contents)) |
return FALSE; |
if (sec->compress_status == COMPRESS_SECTION_DONE |
&& (abfd->flags & BFD_COMPRESS_GABI) == 0) |
{ |
/* If section is compressed with zlib-gnu, convert |
section name from .debug_* to .zdebug_*. */ |
char *new_name |
= convert_debug_to_zdebug (abfd, name); |
if (new_name == NULL) |
return FALSE; |
name = new_name; |
if ((shdrp->sh_type == SHT_REL || shdrp->sh_type == SHT_RELA) |
&& shdrp->sh_offset == -1) |
off = _bfd_elf_assign_file_position_for_section (shdrp, off, TRUE); |
} |
/* Add setion name to section name section. */ |
if (shdrp->sh_name != (unsigned int) -1) |
abort (); |
shdrp->sh_name |
= (unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd), |
name, FALSE); |
d = elf_section_data (sec); |
/* Add reloc setion name to section name section. */ |
if (d->rel.hdr |
&& !_bfd_elf_set_reloc_sh_name (abfd, |
d->rel.hdr, |
name, FALSE)) |
return FALSE; |
if (d->rela.hdr |
&& !_bfd_elf_set_reloc_sh_name (abfd, |
d->rela.hdr, |
name, TRUE)) |
return FALSE; |
/* Update section size and contents. */ |
shdrp->sh_size = sec->size; |
shdrp->contents = sec->contents; |
shdrp->bfd_section->contents = NULL; |
} |
off = _bfd_elf_assign_file_position_for_section (shdrp, |
off, |
TRUE); |
} |
} |
} |
/* Place section name section after DWARF debug sections have been |
compressed. */ |
_bfd_elf_strtab_finalize (elf_shstrtab (abfd)); |
shdrp = &elf_tdata (abfd)->shstrtab_hdr; |
shdrp->sh_size = _bfd_elf_strtab_size (elf_shstrtab (abfd)); |
off = _bfd_elf_assign_file_position_for_section (shdrp, off, TRUE); |
/* Place the section headers. */ |
i_ehdrp = elf_elfheader (abfd); |
bed = get_elf_backend_data (abfd); |
off = align_file_position (off, 1 << bed->s->log_file_align); |
i_ehdrp->e_shoff = off; |
off += i_ehdrp->e_shnum * i_ehdrp->e_shentsize; |
elf_next_file_pos (abfd) = off; |
return TRUE; |
} |
bfd_boolean |
5864,16 → 5305,12 |
if (failed) |
return FALSE; |
if (!_bfd_elf_assign_file_positions_for_non_load (abfd)) |
return FALSE; |
_bfd_elf_assign_file_positions_for_relocs (abfd); |
/* After writing the headers, we need to write the sections too... */ |
num_sec = elf_numsections (abfd); |
for (count = 1; count < num_sec; count++) |
{ |
i_shdrp[count]->sh_name |
= _bfd_elf_strtab_offset (elf_shstrtab (abfd), |
i_shdrp[count]->sh_name); |
if (bed->elf_backend_section_processing) |
(*bed->elf_backend_section_processing) (abfd, i_shdrp[count]); |
if (i_shdrp[count]->contents) |
6325,8 → 5762,8 |
something. They are allowed by the ELF spec however, so only |
a warning is produced. */ |
if (segment->p_type == PT_LOAD) |
(*_bfd_error_handler) (_("\ |
%B: warning: Empty loadable segment detected, is this intentional ?"), |
(*_bfd_error_handler) (_("%B: warning: Empty loadable segment" |
" detected, is this intentional ?\n"), |
ibfd); |
map->count = 0; |
6776,7 → 6213,7 |
phdr_included = TRUE; |
} |
lowest_section = NULL; |
lowest_section = first_section; |
if (section_count != 0) |
{ |
unsigned int isec = 0; |
6793,8 → 6230,7 |
{ |
bfd_vma seg_off; |
if (lowest_section == NULL |
|| section->lma < lowest_section->lma) |
if (section->lma < lowest_section->lma) |
lowest_section = section; |
/* Section lmas are set up from PT_LOAD header |
6939,15 → 6375,7 |
i++, segment++) |
if (segment->p_type == PT_LOAD |
&& maxpagesize < segment->p_align) |
{ |
/* PR 17512: file: f17299af. */ |
if (segment->p_align > (bfd_vma) 1 << ((sizeof (bfd_vma) * 8) - 2)) |
(*_bfd_error_handler) (_("\ |
%B: warning: segment alignment of 0x%llx is too large"), |
ibfd, (long long) segment->p_align); |
else |
maxpagesize = segment->p_align; |
} |
if (maxpagesize != get_elf_backend_data (obfd)->maxpagesize) |
bfd_emul_set_maxpagesize (bfd_get_target (obfd), maxpagesize); |
6967,8 → 6395,7 |
{ |
Elf_Internal_Shdr *ihdr, *ohdr; |
bfd_boolean final_link = (link_info != NULL |
&& !bfd_link_relocatable (link_info)); |
bfd_boolean final_link = link_info != NULL && !link_info->relocatable; |
if (ibfd->xvec->flavour != bfd_target_elf_flavour |
|| obfd->xvec->flavour != bfd_target_elf_flavour) |
7005,11 → 6432,6 |
elf_next_in_group (osec) = elf_next_in_group (isec); |
elf_section_data (osec)->group = elf_section_data (isec)->group; |
} |
/* If not decompress, preserve SHF_COMPRESSED. */ |
if ((ibfd->flags & BFD_DECOMPRESS) == 0) |
elf_section_flags (osec) |= (elf_section_flags (isec) |
& SHF_COMPRESSED); |
} |
ihdr = &elf_section_data (isec)->this_hdr; |
7188,7 → 6610,7 |
shndx = MAP_STRTAB; |
else if (shndx == elf_shstrtab_sec (ibfd)) |
shndx = MAP_SHSTRTAB; |
else if (find_section_in_list (shndx, elf_symtab_shndx_list (ibfd))) |
else if (shndx == elf_symtab_shndx (ibfd)) |
shndx = MAP_SYM_SHNDX; |
osym->internal_elf_sym.st_shndx = shndx; |
} |
7200,21 → 6622,18 |
static bfd_boolean |
swap_out_syms (bfd *abfd, |
struct elf_strtab_hash **sttp, |
struct bfd_strtab_hash **sttp, |
int relocatable_p) |
{ |
const struct elf_backend_data *bed; |
int symcount; |
asymbol **syms; |
struct elf_strtab_hash *stt; |
struct bfd_strtab_hash *stt; |
Elf_Internal_Shdr *symtab_hdr; |
Elf_Internal_Shdr *symtab_shndx_hdr; |
Elf_Internal_Shdr *symstrtab_hdr; |
struct elf_sym_strtab *symstrtab; |
bfd_byte *outbound_syms; |
bfd_byte *outbound_shndx; |
unsigned long outbound_syms_index; |
unsigned long outbound_shndx_index; |
int idx; |
unsigned int num_locals; |
bfd_size_type amt; |
7224,7 → 6643,7 |
return FALSE; |
/* Dump out the symtabs. */ |
stt = _bfd_elf_strtab_init (); |
stt = _bfd_elf_stringtab_init (); |
if (stt == NULL) |
return FALSE; |
7240,33 → 6659,17 |
symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr; |
symstrtab_hdr->sh_type = SHT_STRTAB; |
/* Allocate buffer to swap out the .strtab section. */ |
symstrtab = (struct elf_sym_strtab *) bfd_malloc ((symcount + 1) |
* sizeof (*symstrtab)); |
if (symstrtab == NULL) |
{ |
_bfd_elf_strtab_free (stt); |
return FALSE; |
} |
outbound_syms = (bfd_byte *) bfd_alloc2 (abfd, 1 + symcount, |
bed->s->sizeof_sym); |
if (outbound_syms == NULL) |
{ |
error_return: |
_bfd_elf_strtab_free (stt); |
free (symstrtab); |
_bfd_stringtab_free (stt); |
return FALSE; |
} |
symtab_hdr->contents = outbound_syms; |
outbound_syms_index = 0; |
outbound_shndx = NULL; |
outbound_shndx_index = 0; |
if (elf_symtab_shndx_list (abfd)) |
{ |
symtab_shndx_hdr = & elf_symtab_shndx_list (abfd)->hdr; |
symtab_shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr; |
if (symtab_shndx_hdr->sh_name != 0) |
{ |
amt = (bfd_size_type) (1 + symcount) * sizeof (Elf_External_Sym_Shndx); |
7273,7 → 6676,10 |
outbound_shndx = (bfd_byte *) |
bfd_zalloc2 (abfd, 1 + symcount, sizeof (Elf_External_Sym_Shndx)); |
if (outbound_shndx == NULL) |
goto error_return; |
{ |
_bfd_stringtab_free (stt); |
return FALSE; |
} |
symtab_shndx_hdr->contents = outbound_shndx; |
symtab_shndx_hdr->sh_type = SHT_SYMTAB_SHNDX; |
7281,8 → 6687,6 |
symtab_shndx_hdr->sh_addralign = sizeof (Elf_External_Sym_Shndx); |
symtab_shndx_hdr->sh_entsize = sizeof (Elf_External_Sym_Shndx); |
} |
/* FIXME: What about any other headers in the list ? */ |
} |
/* Now generate the data (for "contents"). */ |
{ |
7295,12 → 6699,10 |
sym.st_other = 0; |
sym.st_shndx = SHN_UNDEF; |
sym.st_target_internal = 0; |
symstrtab[0].sym = sym; |
symstrtab[0].dest_index = outbound_syms_index; |
symstrtab[0].destshndx_index = outbound_shndx_index; |
outbound_syms_index++; |
bed->s->swap_symbol_out (abfd, &sym, outbound_syms, outbound_shndx); |
outbound_syms += bed->s->sizeof_sym; |
if (outbound_shndx != NULL) |
outbound_shndx_index++; |
outbound_shndx += sizeof (Elf_External_Sym_Shndx); |
} |
name_local_sections |
7308,7 → 6710,7 |
&& bed->elf_backend_name_local_section_symbols (abfd)); |
syms = bfd_get_outsymbols (abfd); |
for (idx = 0; idx < symcount;) |
for (idx = 0; idx < symcount; idx++) |
{ |
Elf_Internal_Sym sym; |
bfd_vma value = syms[idx]->value; |
7320,18 → 6722,19 |
&& (flags & (BSF_SECTION_SYM | BSF_GLOBAL)) == BSF_SECTION_SYM) |
{ |
/* Local section symbols have no name. */ |
sym.st_name = (unsigned long) -1; |
sym.st_name = 0; |
} |
else |
{ |
/* Call _bfd_elf_strtab_offset after _bfd_elf_strtab_finalize |
to get the final offset for st_name. */ |
sym.st_name |
= (unsigned long) _bfd_elf_strtab_add (stt, syms[idx]->name, |
FALSE); |
sym.st_name = (unsigned long) _bfd_stringtab_add (stt, |
syms[idx]->name, |
TRUE, FALSE); |
if (sym.st_name == (unsigned long) -1) |
goto error_return; |
{ |
_bfd_stringtab_free (stt); |
return FALSE; |
} |
} |
type_ptr = elf_symbol_from (abfd, syms[idx]); |
7390,8 → 6793,7 |
shndx = elf_shstrtab_sec (abfd); |
break; |
case MAP_SYM_SHNDX: |
if (elf_symtab_shndx_list (abfd)) |
shndx = elf_symtab_shndx_list (abfd)->ndx; |
shndx = elf_symtab_shndx (abfd); |
break; |
default: |
shndx = SHN_ABS; |
7421,7 → 6823,8 |
syms[idx]->name ? syms[idx]->name : "<Local sym>", |
sec->name); |
bfd_set_error (bfd_error_invalid_operation); |
goto error_return; |
_bfd_stringtab_free (stt); |
return FALSE; |
} |
shndx = _bfd_elf_section_from_bfd_section (abfd, sec2); |
7507,40 → 6910,14 |
sym.st_target_internal = 0; |
} |
idx++; |
symstrtab[idx].sym = sym; |
symstrtab[idx].dest_index = outbound_syms_index; |
symstrtab[idx].destshndx_index = outbound_shndx_index; |
outbound_syms_index++; |
bed->s->swap_symbol_out (abfd, &sym, outbound_syms, outbound_shndx); |
outbound_syms += bed->s->sizeof_sym; |
if (outbound_shndx != NULL) |
outbound_shndx_index++; |
outbound_shndx += sizeof (Elf_External_Sym_Shndx); |
} |
/* Finalize the .strtab section. */ |
_bfd_elf_strtab_finalize (stt); |
/* Swap out the .strtab section. */ |
for (idx = 0; idx <= symcount; idx++) |
{ |
struct elf_sym_strtab *elfsym = &symstrtab[idx]; |
if (elfsym->sym.st_name == (unsigned long) -1) |
elfsym->sym.st_name = 0; |
else |
elfsym->sym.st_name = _bfd_elf_strtab_offset (stt, |
elfsym->sym.st_name); |
bed->s->swap_symbol_out (abfd, &elfsym->sym, |
(outbound_syms |
+ (elfsym->dest_index |
* bed->s->sizeof_sym)), |
(outbound_shndx |
+ (elfsym->destshndx_index |
* sizeof (Elf_External_Sym_Shndx)))); |
} |
free (symstrtab); |
*sttp = stt; |
symstrtab_hdr->sh_size = _bfd_elf_strtab_size (stt); |
symstrtab_hdr->sh_size = _bfd_stringtab_size (stt); |
symstrtab_hdr->sh_type = SHT_STRTAB; |
symstrtab_hdr->sh_flags = 0; |
7744,30 → 7121,26 |
hdr = &elf_tdata (abfd)->dynverref_hdr; |
if (hdr->sh_info == 0 || hdr->sh_size < sizeof (Elf_External_Verneed)) |
elf_tdata (abfd)->verref = (Elf_Internal_Verneed *) |
bfd_zalloc2 (abfd, hdr->sh_info, sizeof (Elf_Internal_Verneed)); |
if (elf_tdata (abfd)->verref == NULL) |
goto error_return; |
elf_tdata (abfd)->cverrefs = hdr->sh_info; |
contents = (bfd_byte *) bfd_malloc (hdr->sh_size); |
if (contents == NULL) |
{ |
error_return_bad_verref: |
(*_bfd_error_handler) |
(_("%B: .gnu.version_r invalid entry"), abfd); |
bfd_set_error (bfd_error_bad_value); |
error_return_verref: |
elf_tdata (abfd)->verref = NULL; |
elf_tdata (abfd)->cverrefs = 0; |
goto error_return; |
} |
contents = (bfd_byte *) bfd_malloc (hdr->sh_size); |
if (contents == NULL) |
goto error_return_verref; |
if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0 |
|| bfd_bread (contents, hdr->sh_size, abfd) != hdr->sh_size) |
goto error_return_verref; |
elf_tdata (abfd)->verref = (Elf_Internal_Verneed *) |
bfd_zalloc2 (abfd, hdr->sh_info, sizeof (Elf_Internal_Verneed)); |
if (elf_tdata (abfd)->verref == NULL) |
if (hdr->sh_info && hdr->sh_size < sizeof (Elf_External_Verneed)) |
goto error_return_verref; |
BFD_ASSERT (sizeof (Elf_External_Verneed) |
7789,7 → 7162,7 |
bfd_elf_string_from_elf_section (abfd, hdr->sh_link, |
iverneed->vn_file); |
if (iverneed->vn_filename == NULL) |
goto error_return_bad_verref; |
goto error_return_verref; |
if (iverneed->vn_cnt == 0) |
iverneed->vn_auxptr = NULL; |
7804,7 → 7177,7 |
if (iverneed->vn_aux |
> (size_t) (contents_end - (bfd_byte *) everneed)) |
goto error_return_bad_verref; |
goto error_return_verref; |
evernaux = ((Elf_External_Vernaux *) |
((bfd_byte *) everneed + iverneed->vn_aux)); |
7817,42 → 7190,36 |
bfd_elf_string_from_elf_section (abfd, hdr->sh_link, |
ivernaux->vna_name); |
if (ivernaux->vna_nodename == NULL) |
goto error_return_bad_verref; |
goto error_return_verref; |
if (ivernaux->vna_other > freeidx) |
freeidx = ivernaux->vna_other; |
ivernaux->vna_nextptr = NULL; |
if (ivernaux->vna_next == 0) |
{ |
iverneed->vn_cnt = j + 1; |
break; |
} |
if (j + 1 < iverneed->vn_cnt) |
ivernaux->vna_nextptr = ivernaux + 1; |
else |
ivernaux->vna_nextptr = NULL; |
if (ivernaux->vna_next |
> (size_t) (contents_end - (bfd_byte *) evernaux)) |
goto error_return_bad_verref; |
goto error_return_verref; |
evernaux = ((Elf_External_Vernaux *) |
((bfd_byte *) evernaux + ivernaux->vna_next)); |
if (ivernaux->vna_other > freeidx) |
freeidx = ivernaux->vna_other; |
} |
iverneed->vn_nextref = NULL; |
if (iverneed->vn_next == 0) |
break; |
if (i + 1 < hdr->sh_info) |
iverneed->vn_nextref = iverneed + 1; |
else |
iverneed->vn_nextref = NULL; |
if (iverneed->vn_next |
> (size_t) (contents_end - (bfd_byte *) everneed)) |
goto error_return_bad_verref; |
goto error_return_verref; |
everneed = ((Elf_External_Verneed *) |
((bfd_byte *) everneed + iverneed->vn_next)); |
} |
elf_tdata (abfd)->cverrefs = i; |
free (contents); |
contents = NULL; |
7871,25 → 7238,16 |
hdr = &elf_tdata (abfd)->dynverdef_hdr; |
if (hdr->sh_info == 0 || hdr->sh_size < sizeof (Elf_External_Verdef)) |
{ |
error_return_bad_verdef: |
(*_bfd_error_handler) |
(_("%B: .gnu.version_d invalid entry"), abfd); |
bfd_set_error (bfd_error_bad_value); |
error_return_verdef: |
elf_tdata (abfd)->verdef = NULL; |
elf_tdata (abfd)->cverdefs = 0; |
goto error_return; |
} |
contents = (bfd_byte *) bfd_malloc (hdr->sh_size); |
if (contents == NULL) |
goto error_return_verdef; |
goto error_return; |
if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0 |
|| bfd_bread (contents, hdr->sh_size, abfd) != hdr->sh_size) |
goto error_return_verdef; |
goto error_return; |
if (hdr->sh_info && hdr->sh_size < sizeof (Elf_External_Verdef)) |
goto error_return; |
BFD_ASSERT (sizeof (Elf_External_Verdef) |
>= sizeof (Elf_External_Verdaux)); |
contents_end_def = contents + hdr->sh_size |
7906,17 → 7264,12 |
{ |
_bfd_elf_swap_verdef_in (abfd, everdef, &iverdefmem); |
if ((iverdefmem.vd_ndx & ((unsigned) VERSYM_VERSION)) == 0) |
goto error_return_bad_verdef; |
if ((iverdefmem.vd_ndx & ((unsigned) VERSYM_VERSION)) > maxidx) |
maxidx = iverdefmem.vd_ndx & ((unsigned) VERSYM_VERSION); |
if (iverdefmem.vd_next == 0) |
break; |
if (iverdefmem.vd_next |
> (size_t) (contents_end_def - (bfd_byte *) everdef)) |
goto error_return_bad_verdef; |
goto error_return; |
everdef = ((Elf_External_Verdef *) |
((bfd_byte *) everdef + iverdefmem.vd_next)); |
7929,11 → 7282,10 |
else |
freeidx = ++maxidx; |
} |
elf_tdata (abfd)->verdef = (Elf_Internal_Verdef *) |
bfd_zalloc2 (abfd, maxidx, sizeof (Elf_Internal_Verdef)); |
if (elf_tdata (abfd)->verdef == NULL) |
goto error_return_verdef; |
goto error_return; |
elf_tdata (abfd)->cverdefs = maxidx; |
7948,10 → 7300,15 |
_bfd_elf_swap_verdef_in (abfd, everdef, &iverdefmem); |
if ((iverdefmem.vd_ndx & VERSYM_VERSION) == 0) |
goto error_return_bad_verdef; |
{ |
error_return_verdef: |
elf_tdata (abfd)->verdef = NULL; |
elf_tdata (abfd)->cverdefs = 0; |
goto error_return; |
} |
iverdef = &iverdefarr[(iverdefmem.vd_ndx & VERSYM_VERSION) - 1]; |
memcpy (iverdef, &iverdefmem, offsetof (Elf_Internal_Verdef, vd_bfd)); |
memcpy (iverdef, &iverdefmem, sizeof (Elf_Internal_Verdef)); |
iverdef->vd_bfd = abfd; |
7968,7 → 7325,7 |
if (iverdef->vd_aux |
> (size_t) (contents_end_aux - (bfd_byte *) everdef)) |
goto error_return_bad_verdef; |
goto error_return_verdef; |
everdaux = ((Elf_External_Verdaux *) |
((bfd_byte *) everdef + iverdef->vd_aux)); |
7981,34 → 7338,28 |
bfd_elf_string_from_elf_section (abfd, hdr->sh_link, |
iverdaux->vda_name); |
if (iverdaux->vda_nodename == NULL) |
goto error_return_bad_verdef; |
goto error_return_verdef; |
iverdaux->vda_nextptr = NULL; |
if (iverdaux->vda_next == 0) |
{ |
iverdef->vd_cnt = j + 1; |
break; |
} |
if (j + 1 < iverdef->vd_cnt) |
iverdaux->vda_nextptr = iverdaux + 1; |
else |
iverdaux->vda_nextptr = NULL; |
if (iverdaux->vda_next |
> (size_t) (contents_end_aux - (bfd_byte *) everdaux)) |
goto error_return_bad_verdef; |
goto error_return_verdef; |
everdaux = ((Elf_External_Verdaux *) |
((bfd_byte *) everdaux + iverdaux->vda_next)); |
} |
iverdef->vd_nodename = NULL; |
if (iverdef->vd_cnt) |
iverdef->vd_nodename = iverdef->vd_auxptr->vda_nodename; |
iverdef->vd_nextdef = NULL; |
if (iverdef->vd_next == 0) |
break; |
if ((size_t) (iverdef - iverdefarr) + 1 < maxidx) |
iverdef->vd_nextdef = iverdef + 1; |
else |
iverdef->vd_nextdef = NULL; |
everdef = ((Elf_External_Verdef *) |
((bfd_byte *) everdef + iverdef->vd_next)); |
8051,13 → 7402,14 |
if (iverdef->vd_nodename == NULL) |
goto error_return_verdef; |
iverdef->vd_nextdef = NULL; |
iverdef->vd_auxptr = ((struct elf_internal_verdaux *) |
bfd_zalloc (abfd, sizeof (Elf_Internal_Verdaux))); |
iverdef->vd_auxptr = (struct elf_internal_verdaux *) |
bfd_alloc (abfd, sizeof (Elf_Internal_Verdaux)); |
if (iverdef->vd_auxptr == NULL) |
goto error_return_verdef; |
iverdaux = iverdef->vd_auxptr; |
iverdaux->vda_nodename = iverdef->vd_nodename; |
iverdaux->vda_nextptr = NULL; |
} |
return TRUE; |
8072,13 → 7424,17 |
_bfd_elf_make_empty_symbol (bfd *abfd) |
{ |
elf_symbol_type *newsym; |
bfd_size_type amt = sizeof (elf_symbol_type); |
newsym = (elf_symbol_type *) bfd_zalloc (abfd, sizeof * newsym); |
newsym = (elf_symbol_type *) bfd_zalloc (abfd, amt); |
if (!newsym) |
return NULL; |
else |
{ |
newsym->symbol.the_bfd = abfd; |
return &newsym->symbol; |
} |
} |
void |
_bfd_elf_get_symbol_info (bfd *abfd ATTRIBUTE_UNUSED, |
8114,47 → 7470,6 |
if (name[0] == '_' && name[1] == '.' && name[2] == 'L' && name[3] == '_') |
return TRUE; |
/* Treat assembler generated fake symbols, dollar local labels and |
forward-backward labels (aka local labels) as locals. |
These labels have the form: |
L0^A.* (fake symbols) |
[.]?L[0123456789]+{^A|^B}[0123456789]* (local labels) |
Versions which start with .L will have already been matched above, |
so we only need to match the rest. */ |
if (name[0] == 'L' && ISDIGIT (name[1])) |
{ |
bfd_boolean ret = FALSE; |
const char * p; |
char c; |
for (p = name + 2; (c = *p); p++) |
{ |
if (c == 1 || c == 2) |
{ |
if (c == 1 && p == name + 2) |
/* A fake symbol. */ |
return TRUE; |
/* FIXME: We are being paranoid here and treating symbols like |
L0^Bfoo as if there were non-local, on the grounds that the |
assembler will never generate them. But can any symbol |
containing an ASCII value in the range 1-31 ever be anything |
other than some kind of local ? */ |
ret = TRUE; |
} |
if (! ISDIGIT (c)) |
{ |
ret = FALSE; |
break; |
} |
} |
return ret; |
} |
return FALSE; |
} |
8181,13 → 7496,132 |
return bfd_default_set_arch_mach (abfd, arch, machine); |
} |
/* Find the function to a particular section and offset, |
for error reporting. */ |
static bfd_boolean |
elf_find_function (bfd *abfd, |
asection *section, |
asymbol **symbols, |
bfd_vma offset, |
const char **filename_ptr, |
const char **functionname_ptr) |
{ |
struct elf_find_function_cache |
{ |
asection *last_section; |
asymbol *func; |
const char *filename; |
bfd_size_type func_size; |
} *cache; |
if (symbols == NULL) |
return FALSE; |
cache = elf_tdata (abfd)->elf_find_function_cache; |
if (cache == NULL) |
{ |
cache = bfd_zalloc (abfd, sizeof (*cache)); |
elf_tdata (abfd)->elf_find_function_cache = cache; |
if (cache == NULL) |
return FALSE; |
} |
if (cache->last_section != section |
|| cache->func == NULL |
|| offset < cache->func->value |
|| offset >= cache->func->value + cache->func_size) |
{ |
asymbol *file; |
bfd_vma low_func; |
asymbol **p; |
/* ??? Given multiple file symbols, it is impossible to reliably |
choose the right file name for global symbols. File symbols are |
local symbols, and thus all file symbols must sort before any |
global symbols. The ELF spec may be interpreted to say that a |
file symbol must sort before other local symbols, but currently |
ld -r doesn't do this. So, for ld -r output, it is possible to |
make a better choice of file name for local symbols by ignoring |
file symbols appearing after a given local symbol. */ |
enum { nothing_seen, symbol_seen, file_after_symbol_seen } state; |
const struct elf_backend_data *bed = get_elf_backend_data (abfd); |
file = NULL; |
low_func = 0; |
state = nothing_seen; |
cache->filename = NULL; |
cache->func = NULL; |
cache->func_size = 0; |
cache->last_section = section; |
for (p = symbols; *p != NULL; p++) |
{ |
asymbol *sym = *p; |
bfd_vma code_off; |
bfd_size_type size; |
if ((sym->flags & BSF_FILE) != 0) |
{ |
file = sym; |
if (state == symbol_seen) |
state = file_after_symbol_seen; |
continue; |
} |
size = bed->maybe_function_sym (sym, section, &code_off); |
if (size != 0 |
&& code_off <= offset |
&& (code_off > low_func |
|| (code_off == low_func |
&& size > cache->func_size))) |
{ |
cache->func = sym; |
cache->func_size = size; |
cache->filename = NULL; |
low_func = code_off; |
if (file != NULL |
&& ((sym->flags & BSF_LOCAL) != 0 |
|| state != file_after_symbol_seen)) |
cache->filename = bfd_asymbol_name (file); |
} |
if (state == nothing_seen) |
state = symbol_seen; |
} |
} |
if (cache->func == NULL) |
return FALSE; |
if (filename_ptr) |
*filename_ptr = cache->filename; |
if (functionname_ptr) |
*functionname_ptr = bfd_asymbol_name (cache->func); |
return TRUE; |
} |
/* Find the nearest line to a particular section and offset, |
for error reporting. */ |
bfd_boolean |
_bfd_elf_find_nearest_line (bfd *abfd, |
asection *section, |
asymbol **symbols, |
bfd_vma offset, |
const char **filename_ptr, |
const char **functionname_ptr, |
unsigned int *line_ptr) |
{ |
return _bfd_elf_find_nearest_line_discriminator (abfd, section, symbols, |
offset, filename_ptr, |
functionname_ptr, |
line_ptr, |
NULL); |
} |
bfd_boolean |
_bfd_elf_find_nearest_line_discriminator (bfd *abfd, |
asection *section, |
asymbol **symbols, |
bfd_vma offset, |
const char **filename_ptr, |
const char **functionname_ptr, |
8196,22 → 7630,32 |
{ |
bfd_boolean found; |
if (_bfd_dwarf2_find_nearest_line (abfd, symbols, NULL, section, offset, |
if (_bfd_dwarf1_find_nearest_line (abfd, section, symbols, offset, |
filename_ptr, functionname_ptr, |
line_ptr, discriminator_ptr, |
dwarf_debug_sections, 0, |
&elf_tdata (abfd)->dwarf2_find_line_info) |
|| _bfd_dwarf1_find_nearest_line (abfd, symbols, section, offset, |
filename_ptr, functionname_ptr, |
line_ptr)) |
{ |
if (!*functionname_ptr) |
_bfd_elf_find_function (abfd, symbols, section, offset, |
elf_find_function (abfd, section, symbols, offset, |
*filename_ptr ? NULL : filename_ptr, |
functionname_ptr); |
return TRUE; |
} |
if (_bfd_dwarf2_find_nearest_line (abfd, dwarf_debug_sections, |
section, symbols, offset, |
filename_ptr, functionname_ptr, |
line_ptr, discriminator_ptr, 0, |
&elf_tdata (abfd)->dwarf2_find_line_info)) |
{ |
if (!*functionname_ptr) |
elf_find_function (abfd, section, symbols, offset, |
*filename_ptr ? NULL : filename_ptr, |
functionname_ptr); |
return TRUE; |
} |
if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, |
&found, filename_ptr, |
functionname_ptr, line_ptr, |
8223,7 → 7667,7 |
if (symbols == NULL) |
return FALSE; |
if (! _bfd_elf_find_function (abfd, symbols, section, offset, |
if (! elf_find_function (abfd, section, symbols, offset, |
filename_ptr, functionname_ptr)) |
return FALSE; |
8237,9 → 7681,19 |
_bfd_elf_find_line (bfd *abfd, asymbol **symbols, asymbol *symbol, |
const char **filename_ptr, unsigned int *line_ptr) |
{ |
return _bfd_dwarf2_find_nearest_line (abfd, symbols, symbol, NULL, 0, |
filename_ptr, NULL, line_ptr, NULL, |
dwarf_debug_sections, 0, |
return _bfd_elf_find_line_discriminator (abfd, symbols, symbol, |
filename_ptr, line_ptr, |
NULL); |
} |
bfd_boolean |
_bfd_elf_find_line_discriminator (bfd *abfd, asymbol **symbols, asymbol *symbol, |
const char **filename_ptr, |
unsigned int *line_ptr, |
unsigned int *discriminator_ptr) |
{ |
return _bfd_dwarf2_find_line (abfd, symbols, symbol, |
filename_ptr, line_ptr, discriminator_ptr, 0, |
&elf_tdata (abfd)->dwarf2_find_line_info); |
} |
8268,7 → 7722,7 |
const struct elf_backend_data *bed = get_elf_backend_data (abfd); |
int ret = bed->s->sizeof_ehdr; |
if (!bfd_link_relocatable (info)) |
if (!info->relocatable) |
{ |
bfd_size_type phdr_size = elf_program_header_size (abfd); |
8299,27 → 7753,13 |
bfd_size_type count) |
{ |
Elf_Internal_Shdr *hdr; |
file_ptr pos; |
bfd_signed_vma pos; |
if (! abfd->output_has_begun |
&& ! _bfd_elf_compute_section_file_positions (abfd, NULL)) |
return FALSE; |
if (!count) |
return TRUE; |
hdr = &elf_section_data (section)->this_hdr; |
if (hdr->sh_offset == (file_ptr) -1) |
{ |
/* We must compress this section. Write output to the buffer. */ |
unsigned char *contents = hdr->contents; |
if ((offset + count) > hdr->sh_size |
|| (section->flags & SEC_ELF_COMPRESS) == 0 |
|| contents == NULL) |
abort (); |
memcpy (contents + offset, location, count); |
return TRUE; |
} |
pos = hdr->sh_offset + offset; |
if (bfd_seek (abfd, pos, SEEK_SET) != 0 |
|| bfd_bwrite (location, count, abfd) != count) |
8739,18 → 8179,6 |
} |
static bfd_boolean |
elfcore_grok_s390_vxrs_low (bfd *abfd, Elf_Internal_Note *note) |
{ |
return elfcore_make_note_pseudosection (abfd, ".reg-s390-vxrs-low", note); |
} |
static bfd_boolean |
elfcore_grok_s390_vxrs_high (bfd *abfd, Elf_Internal_Note *note) |
{ |
return elfcore_make_note_pseudosection (abfd, ".reg-s390-vxrs-high", note); |
} |
static bfd_boolean |
elfcore_grok_arm_vfp (bfd *abfd, Elf_Internal_Note *note) |
{ |
return elfcore_make_note_pseudosection (abfd, ".reg-arm-vfp", note); |
9134,9 → 8562,6 |
if (note->namesz == 6 |
&& strcmp (note->namedata, "LINUX") == 0) |
return elfcore_grok_xstatereg (abfd, note); |
else if (note->namesz == 8 |
&& strcmp (note->namedata, "FreeBSD") == 0) |
return elfcore_grok_xstatereg (abfd, note); |
else |
return TRUE; |
9217,20 → 8642,6 |
else |
return TRUE; |
case NT_S390_VXRS_LOW: |
if (note->namesz == 6 |
&& strcmp (note->namedata, "LINUX") == 0) |
return elfcore_grok_s390_vxrs_low (abfd, note); |
else |
return TRUE; |
case NT_S390_VXRS_HIGH: |
if (note->namesz == 6 |
&& strcmp (note->namedata, "LINUX") == 0) |
return elfcore_grok_s390_vxrs_high (abfd, note); |
else |
return TRUE; |
case NT_ARM_VFP: |
if (note->namesz == 6 |
&& strcmp (note->namedata, "LINUX") == 0) |
9297,18 → 8708,18 |
static bfd_boolean |
elfobj_grok_gnu_build_id (bfd *abfd, Elf_Internal_Note *note) |
{ |
struct bfd_build_id* build_id; |
struct elf_obj_tdata *t; |
if (note->descsz == 0) |
return FALSE; |
build_id = bfd_alloc (abfd, sizeof (struct bfd_build_id) - 1 + note->descsz); |
if (build_id == NULL) |
t = elf_tdata (abfd); |
t->build_id = bfd_alloc (abfd, sizeof (*t->build_id) - 1 + note->descsz); |
if (t->build_id == NULL) |
return FALSE; |
build_id->size = note->descsz; |
memcpy (build_id->data, note->descdata, note->descsz); |
abfd->build_id = build_id; |
t->build_id->size = note->descsz; |
memcpy (t->build_id->data, note->descdata, note->descsz); |
return TRUE; |
} |
9876,7 → 9287,7 |
lwpstat.pr_lwpid = pid >> 16; |
lwpstat.pr_cursig = cursig; |
#if defined (HAVE_LWPSTATUS_T_PR_REG) |
memcpy (&lwpstat.pr_reg, gregs, sizeof (lwpstat.pr_reg)); |
memcpy (lwpstat.pr_reg, gregs, sizeof (lwpstat.pr_reg)); |
#elif defined (HAVE_LWPSTATUS_T_PR_CONTEXT) |
#if !defined(gregs) |
memcpy (lwpstat.pr_context.uc_mcontext.gregs, |
9956,11 → 9367,7 |
elfcore_write_xstatereg (bfd *abfd, char *buf, int *bufsiz, |
const void *xfpregs, int size) |
{ |
char *note_name; |
if (get_elf_backend_data (abfd)->elf_osabi == ELFOSABI_FREEBSD) |
note_name = "FreeBSD"; |
else |
note_name = "LINUX"; |
char *note_name = "LINUX"; |
return elfcore_write_note (abfd, buf, bufsiz, |
note_name, NT_X86_XSTATE, xfpregs, size); |
} |
10101,31 → 9508,6 |
} |
char * |
elfcore_write_s390_vxrs_low (bfd *abfd, |
char *buf, |
int *bufsiz, |
const void *s390_vxrs_low, |
int size) |
{ |
char *note_name = "LINUX"; |
return elfcore_write_note (abfd, buf, bufsiz, |
note_name, NT_S390_VXRS_LOW, s390_vxrs_low, size); |
} |
char * |
elfcore_write_s390_vxrs_high (bfd *abfd, |
char *buf, |
int *bufsiz, |
const void *s390_vxrs_high, |
int size) |
{ |
char *note_name = "LINUX"; |
return elfcore_write_note (abfd, buf, bufsiz, |
note_name, NT_S390_VXRS_HIGH, |
s390_vxrs_high, size); |
} |
char * |
elfcore_write_arm_vfp (bfd *abfd, |
char *buf, |
int *bufsiz, |
10209,10 → 9591,6 |
return elfcore_write_s390_system_call (abfd, buf, bufsiz, data, size); |
if (strcmp (section, ".reg-s390-tdb") == 0) |
return elfcore_write_s390_tdb (abfd, buf, bufsiz, data, size); |
if (strcmp (section, ".reg-s390-vxrs-low") == 0) |
return elfcore_write_s390_vxrs_low (abfd, buf, bufsiz, data, size); |
if (strcmp (section, ".reg-s390-vxrs-high") == 0) |
return elfcore_write_s390_vxrs_high (abfd, buf, bufsiz, data, size); |
if (strcmp (section, ".reg-arm-vfp") == 0) |
return elfcore_write_arm_vfp (abfd, buf, bufsiz, data, size); |
if (strcmp (section, ".reg-aarch-tls") == 0) |
10260,38 → 9638,32 |
return TRUE; |
case bfd_core: |
if (CONST_STRNEQ (in.namedata, "NetBSD-CORE")) |
{ |
#define GROKER_ELEMENT(S,F) {S, sizeof (S) - 1, F} |
struct |
if (! elfcore_grok_netbsd_note (abfd, &in)) |
return FALSE; |
} |
else if (CONST_STRNEQ (in.namedata, "OpenBSD")) |
{ |
const char * string; |
size_t len; |
bfd_boolean (* func)(bfd *, Elf_Internal_Note *); |
if (! elfcore_grok_openbsd_note (abfd, &in)) |
return FALSE; |
} |
grokers[] = |
else if (CONST_STRNEQ (in.namedata, "QNX")) |
{ |
GROKER_ELEMENT ("", elfcore_grok_note), |
GROKER_ELEMENT ("NetBSD-CORE", elfcore_grok_netbsd_note), |
GROKER_ELEMENT ( "OpenBSD", elfcore_grok_openbsd_note), |
GROKER_ELEMENT ("QNX", elfcore_grok_nto_note), |
GROKER_ELEMENT ("SPU/", elfcore_grok_spu_note) |
}; |
#undef GROKER_ELEMENT |
int i; |
for (i = ARRAY_SIZE (grokers); i--;) |
if (! elfcore_grok_nto_note (abfd, &in)) |
return FALSE; |
} |
else if (CONST_STRNEQ (in.namedata, "SPU/")) |
{ |
if (in.namesz >= grokers[i].len |
&& strncmp (in.namedata, grokers[i].string, |
grokers[i].len) == 0) |
if (! elfcore_grok_spu_note (abfd, &in)) |
return FALSE; |
} |
else |
{ |
if (! grokers[i].func (abfd, & in)) |
if (! elfcore_grok_note (abfd, &in)) |
return FALSE; |
break; |
} |
} |
break; |
} |
case bfd_object: |
if (in.namesz == sizeof "GNU" && strcmp (in.namedata, "GNU") == 0) |
10325,14 → 9697,10 |
if (bfd_seek (abfd, offset, SEEK_SET) != 0) |
return FALSE; |
buf = (char *) bfd_malloc (size + 1); |
buf = (char *) bfd_malloc (size); |
if (buf == NULL) |
return FALSE; |
/* PR 17512: file: ec08f814 |
0-termintate the buffer so that string searches will not overflow. */ |
buf[size] = 0; |
if (bfd_bread (buf, size, abfd) != size |
|| !elf_parse_notes (abfd, buf, size, offset)) |
{ |
10493,12 → 9861,11 |
bfd_elf_bfd_from_remote_memory |
(bfd *templ, |
bfd_vma ehdr_vma, |
bfd_size_type size, |
bfd_vma *loadbasep, |
int (*target_read_memory) (bfd_vma, bfd_byte *, bfd_size_type)) |
{ |
return (*get_elf_backend_data (templ)->elf_backend_bfd_from_remote_memory) |
(templ, ehdr_vma, size, loadbasep, target_read_memory); |
(templ, ehdr_vma, loadbasep, target_read_memory); |
} |
long |
10624,7 → 9991,7 |
SEC_IS_COMMON, NULL, "LARGE_COMMON", 0); |
void |
_bfd_elf_post_process_headers (bfd * abfd, |
_bfd_elf_set_osabi (bfd * abfd, |
struct bfd_link_info * link_info ATTRIBUTE_UNUSED) |
{ |
Elf_Internal_Ehdr * i_ehdrp; /* ELF file header, internal form. */ |
/contrib/toolchain/binutils/bfd/elf32-gen.c |
---|
1,5 → 1,6 |
/* Generic support for 32-bit ELF |
Copyright (C) 1993-2015 Free Software Foundation, Inc. |
Copyright 1993, 1995, 1998, 1999, 2001, 2002, 2004, 2005, 2007 |
Free Software Foundation, Inc. |
This file is part of BFD, the Binary File Descriptor library. |
86,9 → 87,9 |
return bfd_elf_link_add_symbols (abfd, info); |
} |
#define TARGET_LITTLE_SYM elf32_le_vec |
#define TARGET_LITTLE_SYM bfd_elf32_little_generic_vec |
#define TARGET_LITTLE_NAME "elf32-little" |
#define TARGET_BIG_SYM elf32_be_vec |
#define TARGET_BIG_SYM bfd_elf32_big_generic_vec |
#define TARGET_BIG_NAME "elf32-big" |
#define ELF_ARCH bfd_arch_unknown |
#define ELF_MACHINE_CODE EM_NONE |
/contrib/toolchain/binutils/bfd/elf32-i386.c |
---|
1,5 → 1,7 |
/* Intel 80386/80486-specific support for 32-bit ELF |
Copyright (C) 1993-2015 Free Software Foundation, Inc. |
Copyright 1993, 1994, 1995, 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 BFD, the Binary File Descriptor library. |
29,7 → 31,6 |
#include "objalloc.h" |
#include "hashtab.h" |
#include "dwarf2.h" |
#include "opcode/i386.h" |
/* 386 uses REL relocations instead of RELA. */ |
#define USE_REL 1 |
38,7 → 39,7 |
static reloc_howto_type elf_howto_table[]= |
{ |
HOWTO(R_386_NONE, 0, 3, 0, FALSE, 0, complain_overflow_dont, |
HOWTO(R_386_NONE, 0, 0, 0, FALSE, 0, complain_overflow_bitfield, |
bfd_elf_generic_reloc, "R_386_NONE", |
TRUE, 0x00000000, 0x00000000, FALSE), |
HOWTO(R_386_32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, |
147,13 → 148,10 |
HOWTO(R_386_IRELATIVE, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, |
bfd_elf_generic_reloc, "R_386_IRELATIVE", |
TRUE, 0xffffffff, 0xffffffff, FALSE), |
HOWTO(R_386_GOT32X, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, |
bfd_elf_generic_reloc, "R_386_GOT32X", |
TRUE, 0xffffffff, 0xffffffff, FALSE), |
/* Another gap. */ |
#define R_386_ext2 (R_386_GOT32X + 1 - R_386_tls_offset) |
#define R_386_vt_offset (R_386_GNU_VTINHERIT - R_386_ext2) |
#define R_386_irelative (R_386_IRELATIVE + 1 - R_386_tls_offset) |
#define R_386_vt_offset (R_386_GNU_VTINHERIT - R_386_irelative) |
/* GNU extension to record C++ vtable hierarchy. */ |
HOWTO (R_386_GNU_VTINHERIT, /* type */ |
336,10 → 334,6 |
TRACE ("BFD_RELOC_386_IRELATIVE"); |
return &elf_howto_table[R_386_IRELATIVE - R_386_tls_offset]; |
case BFD_RELOC_386_GOT32X: |
TRACE ("BFD_RELOC_386_GOT32X"); |
return &elf_howto_table[R_386_GOT32X - R_386_tls_offset]; |
case BFD_RELOC_VTABLE_INHERIT: |
TRACE ("BFD_RELOC_VTABLE_INHERIT"); |
return &elf_howto_table[R_386_GNU_VTINHERIT - R_386_vt_offset]; |
379,17 → 373,15 |
&& ((indx = r_type - R_386_ext_offset) - R_386_standard |
>= R_386_ext - R_386_standard) |
&& ((indx = r_type - R_386_tls_offset) - R_386_ext |
>= R_386_ext2 - R_386_ext) |
&& ((indx = r_type - R_386_vt_offset) - R_386_ext2 |
>= R_386_vt - R_386_ext2)) |
>= R_386_irelative - R_386_ext) |
&& ((indx = r_type - R_386_vt_offset) - R_386_irelative |
>= R_386_vt - R_386_irelative)) |
{ |
(*_bfd_error_handler) (_("%B: invalid relocation type %d"), |
abfd, (int) r_type); |
indx = R_386_NONE; |
} |
/* PR 17512: file: 0f67f69d. */ |
if (elf_howto_table [indx].type != r_type) |
return NULL; |
BFD_ASSERT (elf_howto_table [indx].type == r_type); |
return &elf_howto_table[indx]; |
} |
590,24 → 582,6 |
0, 0, 0, 0 /* replaced with offset to start of .plt. */ |
}; |
/* Entries in the GOT procedure linkage table look like this. */ |
static const bfd_byte elf_i386_got_plt_entry[8] = |
{ |
0xff, 0x25, /* jmp indirect */ |
0, 0, 0, 0, /* replaced with offset of this symbol in .got. */ |
0x66, 0x90 /* xchg %ax,%ax */ |
}; |
/* Entries in the PIC GOT procedure linkage table look like this. */ |
static const bfd_byte elf_i386_pic_got_plt_entry[8] = |
{ |
0xff, 0xa3, /* jmp *offset(%ebx) */ |
0, 0, 0, 0, /* replaced with offset of this symbol in .got. */ |
0x66, 0x90 /* xchg %ax,%ax */ |
}; |
/* .eh_frame covering the .plt section. */ |
static const bfd_byte elf_i386_eh_frame_plt[] = |
764,17 → 738,6 |
(GOT_TLS_GD_P (type) || GOT_TLS_GDESC_P (type)) |
unsigned char tls_type; |
/* Symbol is referenced by R_386_GOTOFF relocation. */ |
unsigned int gotoff_ref : 1; |
/* Reference count of C/C++ function pointer relocations in read-write |
section which can be resolved at run-time. */ |
bfd_signed_vma func_pointer_refcount; |
/* Information about the GOT PLT entry. Filled when there are both |
GOT and PLT relocations against the same function. */ |
union gotplt_union plt_got; |
/* Offset of the GOTPLT entry reserved for the TLS descriptor, |
starting at the end of the jump table. */ |
bfd_vma tlsdesc_got; |
824,7 → 787,6 |
asection *sdynbss; |
asection *srelbss; |
asection *plt_eh_frame; |
asection *plt_got; |
union |
{ |
866,7 → 828,7 |
== I386_ELF_DATA ? ((struct elf_i386_link_hash_table *) ((p)->hash)) : NULL) |
#define elf_i386_compute_jump_table_size(htab) \ |
((htab)->elf.srelplt->reloc_count * 4) |
((htab)->next_tls_desc_index * 4) |
/* Create an entry in an i386 ELF linker hash table. */ |
894,9 → 856,6 |
eh = (struct elf_i386_link_hash_entry *) entry; |
eh->dyn_relocs = NULL; |
eh->tls_type = GOT_UNKNOWN; |
eh->gotoff_ref = 0; |
eh->func_pointer_refcount = 0; |
eh->plt_got.offset = (bfd_vma) -1; |
eh->tlsdesc_got = (bfd_vma) -1; |
} |
965,28 → 924,11 |
ret->elf.indx = sec->id; |
ret->elf.dynstr_index = ELF32_R_SYM (rel->r_info); |
ret->elf.dynindx = -1; |
ret->func_pointer_refcount = 0; |
ret->plt_got.offset = (bfd_vma) -1; |
*slot = ret; |
} |
return &ret->elf; |
} |
/* Destroy an i386 ELF linker hash table. */ |
static void |
elf_i386_link_hash_table_free (bfd *obfd) |
{ |
struct elf_i386_link_hash_table *htab |
= (struct elf_i386_link_hash_table *) obfd->link.hash; |
if (htab->loc_hash_table) |
htab_delete (htab->loc_hash_table); |
if (htab->loc_hash_memory) |
objalloc_free ((struct objalloc *) htab->loc_hash_memory); |
_bfd_elf_link_hash_table_free (obfd); |
} |
/* Create an i386 ELF linker hash table. */ |
static struct bfd_link_hash_table * |
1015,14 → 957,28 |
ret->loc_hash_memory = objalloc_create (); |
if (!ret->loc_hash_table || !ret->loc_hash_memory) |
{ |
elf_i386_link_hash_table_free (abfd); |
free (ret); |
return NULL; |
} |
ret->elf.root.hash_table_free = elf_i386_link_hash_table_free; |
return &ret->elf.root; |
} |
/* Destroy an i386 ELF linker hash table. */ |
static void |
elf_i386_link_hash_table_free (struct bfd_link_hash_table *hash) |
{ |
struct elf_i386_link_hash_table *htab |
= (struct elf_i386_link_hash_table *) hash; |
if (htab->loc_hash_table) |
htab_delete (htab->loc_hash_table); |
if (htab->loc_hash_memory) |
objalloc_free ((struct objalloc *) htab->loc_hash_memory); |
_bfd_elf_link_hash_table_free (hash); |
} |
/* Create .plt, .rel.plt, .got, .got.plt, .rel.got, .dynbss, and |
.rel.bss sections in DYNOBJ, and set up shortcuts to them in our |
hash table. */ |
1040,28 → 996,13 |
return FALSE; |
htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss"); |
if (!htab->sdynbss) |
if (!info->shared) |
htab->srelbss = bfd_get_linker_section (dynobj, ".rel.bss"); |
if (!htab->sdynbss |
|| (!info->shared && !htab->srelbss)) |
abort (); |
if (bfd_link_executable (info)) |
{ |
/* Always allow copy relocs for building executables. */ |
asection *s = bfd_get_linker_section (dynobj, ".rel.bss"); |
if (s == NULL) |
{ |
const struct elf_backend_data *bed = get_elf_backend_data (dynobj); |
s = bfd_make_section_anyway_with_flags (dynobj, |
".rel.bss", |
(bed->dynamic_sec_flags |
| SEC_READONLY)); |
if (s == NULL |
|| ! bfd_set_section_alignment (dynobj, s, |
bed->s->log_file_align)) |
return FALSE; |
} |
htab->srelbss = s; |
} |
if (get_elf_i386_backend_data (dynobj)->is_vxworks |
&& !elf_vxworks_create_dynamic_sections (dynobj, info, |
&htab->srelplt2)) |
1134,10 → 1075,6 |
eind->tls_type = GOT_UNKNOWN; |
} |
/* Copy gotoff_ref so that elf_i386_adjust_dynamic_symbol will |
generate a R_386_COPY reloc. */ |
edir->gotoff_ref |= eind->gotoff_ref; |
if (ELIMINATE_COPY_RELOCS |
&& ind->root.type != bfd_link_hash_indirect |
&& dir->dynamic_adjusted) |
1152,16 → 1089,8 |
dir->pointer_equality_needed |= ind->pointer_equality_needed; |
} |
else |
{ |
if (eind->func_pointer_refcount > 0) |
{ |
edir->func_pointer_refcount += eind->func_pointer_refcount; |
eind->func_pointer_refcount = 0; |
} |
_bfd_elf_link_hash_copy_indirect (info, dir, ind); |
} |
} |
/* Return TRUE if the TLS access code sequence support transition |
from R_TYPE. */ |
1376,7 → 1305,7 |
case R_386_TLS_IE_32: |
case R_386_TLS_IE: |
case R_386_TLS_GOTIE: |
if (bfd_link_executable (info)) |
if (info->executable) |
{ |
if (h == NULL) |
to_type = R_386_TLS_LE_32; |
1392,7 → 1321,7 |
{ |
unsigned int new_to_type = to_type; |
if (bfd_link_executable (info) |
if (info->executable |
&& h != NULL |
&& h->dynindx == -1 |
&& (tls_type & GOT_TLS_IE)) |
1418,7 → 1347,7 |
break; |
case R_386_TLS_LDM: |
if (bfd_link_executable (info)) |
if (info->executable) |
to_type = R_386_TLS_LE_32; |
break; |
1474,10 → 1403,6 |
return TRUE; |
} |
/* Rename some of the generic section flags to better document how they |
are used here. */ |
#define need_convert_load sec_flg0 |
/* Look through the relocs for a section during the first phase, and |
calculate needed space in the global offset table, procedure linkage |
table, and dynamic reloc sections. */ |
1494,9 → 1419,8 |
const Elf_Internal_Rela *rel; |
const Elf_Internal_Rela *rel_end; |
asection *sreloc; |
bfd_boolean use_plt_got; |
if (bfd_link_relocatable (info)) |
if (info->relocatable) |
return TRUE; |
BFD_ASSERT (is_i386_elf (abfd)); |
1505,10 → 1429,6 |
if (htab == NULL) |
return FALSE; |
use_plt_got = (!get_elf_i386_backend_data (abfd)->is_vxworks |
&& (get_elf_i386_backend_data (abfd) |
== &elf_i386_arch_bed)); |
symtab_hdr = &elf_symtab_hdr (abfd); |
sym_hashes = elf_sym_hashes (abfd); |
1520,7 → 1440,6 |
unsigned int r_type; |
unsigned long r_symndx; |
struct elf_link_hash_entry *h; |
struct elf_i386_link_hash_entry *eh; |
Elf_Internal_Sym *isym; |
const char *name; |
bfd_boolean size_reloc; |
1570,7 → 1489,6 |
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
} |
eh = (struct elf_i386_link_hash_entry *) h; |
if (h != NULL) |
{ |
/* Create the ifunc sections for static executables. If we |
1582,13 → 1500,11 |
default: |
break; |
case R_386_GOTOFF: |
eh->gotoff_ref = 1; |
case R_386_32: |
case R_386_PC32: |
case R_386_PLT32: |
case R_386_GOT32: |
case R_386_GOT32X: |
case R_386_GOTOFF: |
if (htab->elf.dynobj == NULL) |
htab->elf.dynobj = abfd; |
if (!_bfd_elf_create_ifunc_sections (htab->elf.dynobj, info)) |
1599,10 → 1515,6 |
/* It is referenced by a non-shared object. */ |
h->ref_regular = 1; |
h->root.non_ir_ref = 1; |
if (h->type == STT_GNU_IFUNC) |
elf_tdata (info->output_bfd)->has_gnu_symbols |
|= elf_gnu_symbol_ifunc; |
} |
if (! elf_i386_tls_transition (info, abfd, sec, NULL, |
1641,12 → 1553,11 |
case R_386_TLS_IE_32: |
case R_386_TLS_IE: |
case R_386_TLS_GOTIE: |
if (!bfd_link_executable (info)) |
if (!info->executable) |
info->flags |= DF_STATIC_TLS; |
/* Fall through */ |
case R_386_GOT32: |
case R_386_GOT32X: |
case R_386_TLS_GD: |
case R_386_TLS_GOTDESC: |
case R_386_TLS_DESC_CALL: |
1657,10 → 1568,7 |
switch (r_type) |
{ |
default: |
case R_386_GOT32: |
case R_386_GOT32X: |
tls_type = GOT_NORMAL; |
break; |
case R_386_GOT32: tls_type = GOT_NORMAL; break; |
case R_386_TLS_GD: tls_type = GOT_TLS_GD; break; |
case R_386_TLS_GOTDESC: |
case R_386_TLS_DESC_CALL: |
1765,7 → 1673,7 |
case R_386_TLS_LE_32: |
case R_386_TLS_LE: |
if (bfd_link_executable (info)) |
if (info->executable) |
break; |
info->flags |= DF_STATIC_TLS; |
/* Fall through */ |
1772,7 → 1680,7 |
case R_386_32: |
case R_386_PC32: |
if (h != NULL && bfd_link_executable (info)) |
if (h != NULL && info->executable) |
{ |
/* If this reloc is in a read-only section, we might |
need a copy reloc. We can't check reliably at this |
1785,23 → 1693,9 |
/* We may need a .plt entry if the function this reloc |
refers to is in a shared lib. */ |
h->plt.refcount += 1; |
if (r_type == R_386_PC32) |
{ |
/* Since something like ".long foo - ." may be used |
as pointer, make sure that PLT is used if foo is |
a function defined in a shared library. */ |
if ((sec->flags & SEC_CODE) == 0) |
if (r_type != R_386_PC32) |
h->pointer_equality_needed = 1; |
} |
else |
{ |
h->pointer_equality_needed = 1; |
/* R_386_32 can be resolved at run-time. */ |
if (r_type == R_386_32 |
&& (sec->flags & SEC_READONLY) == 0) |
eh->func_pointer_refcount += 1; |
} |
} |
size_reloc = FALSE; |
do_size: |
1826,7 → 1720,7 |
may need to keep relocations for symbols satisfied by a |
dynamic library if we manage to avoid copy relocs for the |
symbol. */ |
if ((bfd_link_pic (info) |
if ((info->shared |
&& (sec->flags & SEC_ALLOC) != 0 |
&& (r_type != R_386_PC32 |
|| (h != NULL |
1834,7 → 1728,7 |
|| h->root.type == bfd_link_hash_defweak |
|| !h->def_regular)))) |
|| (ELIMINATE_COPY_RELOCS |
&& !bfd_link_pic (info) |
&& !info->shared |
&& (sec->flags & SEC_ALLOC) != 0 |
&& h != NULL |
&& (h->root.type == bfd_link_hash_defweak |
1862,7 → 1756,7 |
relocations we need for this symbol. */ |
if (h != NULL) |
{ |
head = &eh->dyn_relocs; |
head = &((struct elf_i386_link_hash_entry *) h)->dyn_relocs; |
} |
else |
{ |
1926,46 → 1820,8 |
default: |
break; |
} |
if (use_plt_got |
&& h != NULL |
&& h->plt.refcount > 0 |
&& (((info->flags & DF_BIND_NOW) && !h->pointer_equality_needed) |
|| h->got.refcount > 0) |
&& htab->plt_got == NULL) |
{ |
/* Create the GOT procedure linkage table. */ |
unsigned int plt_got_align; |
const struct elf_backend_data *bed; |
bed = get_elf_backend_data (info->output_bfd); |
BFD_ASSERT (sizeof (elf_i386_got_plt_entry) == 8 |
&& (sizeof (elf_i386_got_plt_entry) |
== sizeof (elf_i386_pic_got_plt_entry))); |
plt_got_align = 3; |
if (htab->elf.dynobj == NULL) |
htab->elf.dynobj = abfd; |
htab->plt_got |
= bfd_make_section_anyway_with_flags (htab->elf.dynobj, |
".plt.got", |
(bed->dynamic_sec_flags |
| SEC_ALLOC |
| SEC_CODE |
| SEC_LOAD |
| SEC_READONLY)); |
if (htab->plt_got == NULL |
|| !bfd_set_section_alignment (htab->elf.dynobj, |
htab->plt_got, |
plt_got_align)) |
return FALSE; |
} |
if ((r_type == R_386_GOT32 || r_type == R_386_GOT32X) |
&& (h == NULL || h->type != STT_GNU_IFUNC)) |
sec->need_convert_load = 1; |
} |
return TRUE; |
} |
2004,7 → 1860,7 |
bfd_signed_vma *local_got_refcounts; |
const Elf_Internal_Rela *rel, *relend; |
if (bfd_link_relocatable (info)) |
if (info->relocatable) |
return TRUE; |
htab = elf_i386_hash_table (info); |
2087,7 → 1943,6 |
case R_386_TLS_IE: |
case R_386_TLS_GOTIE: |
case R_386_GOT32: |
case R_386_GOT32X: |
if (h != NULL) |
{ |
if (h->got.refcount > 0) |
2108,7 → 1963,7 |
case R_386_32: |
case R_386_PC32: |
case R_386_SIZE32: |
if (bfd_link_pic (info) |
if (info->shared |
&& (h == NULL || h->type != STT_GNU_IFUNC)) |
break; |
/* Fall through */ |
2118,15 → 1973,7 |
{ |
if (h->plt.refcount > 0) |
h->plt.refcount -= 1; |
if (r_type == R_386_32 |
&& (sec->flags & SEC_READONLY) == 0) |
{ |
struct elf_i386_link_hash_entry *eh |
= (struct elf_i386_link_hash_entry *) h; |
if (eh->func_pointer_refcount > 0) |
eh->func_pointer_refcount -= 1; |
} |
} |
break; |
case R_386_GOTOFF: |
2256,14 → 2103,12 |
only references to the symbol are via the global offset table. |
For such cases we need not do anything here; the relocations will |
be handled correctly by relocate_section. */ |
if (!bfd_link_executable (info)) |
if (info->shared) |
return TRUE; |
/* If there are no references to this symbol that do not use the |
GOT nor R_386_GOTOFF relocation, we don't need to generate a copy |
reloc. */ |
eh = (struct elf_i386_link_hash_entry *) h; |
if (!h->non_got_ref && !eh->gotoff_ref) |
GOT, we don't need to generate a copy reloc. */ |
if (!h->non_got_ref) |
return TRUE; |
/* If -z nocopyreloc was given, we won't generate them either. */ |
2277,15 → 2122,14 |
if (htab == NULL) |
return FALSE; |
/* If there aren't any dynamic relocs in read-only sections nor |
R_386_GOTOFF relocation, then we can keep the dynamic relocs and |
avoid the copy reloc. This doesn't work on VxWorks, where we can |
not have dynamic relocations (other than copy and jump slot |
relocations) in an executable. */ |
/* If there aren't any dynamic relocs in read-only sections, then |
we can keep the dynamic relocs and avoid the copy reloc. This |
doesn't work on VxWorks, where we can not have dynamic relocations |
(other than copy and jump slot relocations) in an executable. */ |
if (ELIMINATE_COPY_RELOCS |
&& !eh->gotoff_ref |
&& !get_elf_i386_backend_data (info->output_bfd)->is_vxworks) |
{ |
eh = (struct elf_i386_link_hash_entry *) h; |
for (p = eh->dyn_relocs; p != NULL; p = p->next) |
{ |
s = p->sec->output_section; |
2321,7 → 2165,7 |
s = htab->sdynbss; |
return _bfd_elf_adjust_dynamic_copy (info, h, s); |
return _bfd_elf_adjust_dynamic_copy (h, s); |
} |
/* Allocate space in .plt, .got and associated reloc sections for |
2348,29 → 2192,6 |
plt_entry_size = GET_PLT_ENTRY_SIZE (info->output_bfd); |
/* Clear the reference count of function pointer relocations if |
symbol isn't a normal function. */ |
if (h->type != STT_FUNC) |
eh->func_pointer_refcount = 0; |
/* We can't use the GOT PLT if pointer equality is needed since |
finish_dynamic_symbol won't clear symbol value and the dynamic |
linker won't update the GOT slot. We will get into an infinite |
loop at run-time. */ |
if (htab->plt_got != NULL |
&& h->type != STT_GNU_IFUNC |
&& !h->pointer_equality_needed |
&& h->plt.refcount > 0 |
&& h->got.refcount > 0) |
{ |
/* Don't use the regular PLT if there are both GOT and GOTPLT |
reloctions. */ |
h->plt.offset = (bfd_vma) -1; |
/* Use the GOT PLT. */ |
eh->plt_got.refcount = 1; |
} |
/* Since STT_GNU_IFUNC symbol must go through PLT, we handle it |
here if it is defined and referenced in a non-shared object. */ |
if (h->type == STT_GNU_IFUNC |
2378,30 → 2199,9 |
return _bfd_elf_allocate_ifunc_dyn_relocs (info, h, &eh->dyn_relocs, |
plt_entry_size, |
plt_entry_size, 4); |
/* Don't create the PLT entry if there are only function pointer |
relocations which can be resolved at run-time. */ |
else if (htab->elf.dynamic_sections_created |
&& (h->plt.refcount > eh->func_pointer_refcount |
|| eh->plt_got.refcount > 0)) |
&& h->plt.refcount > 0) |
{ |
bfd_boolean use_plt_got; |
/* Clear the reference count of function pointer relocations |
if PLT is used. */ |
eh->func_pointer_refcount = 0; |
if ((info->flags & DF_BIND_NOW) && !h->pointer_equality_needed) |
{ |
/* Don't use the regular PLT for DF_BIND_NOW. */ |
h->plt.offset = (bfd_vma) -1; |
/* Use the GOT PLT. */ |
h->got.refcount = 1; |
eh->plt_got.refcount = 1; |
} |
use_plt_got = eh->plt_got.refcount > 0; |
/* Make sure this symbol is output as a dynamic symbol. |
Undefined weak syms won't yet be marked as dynamic. */ |
if (h->dynindx == -1 |
2411,21 → 2211,16 |
return FALSE; |
} |
if (bfd_link_pic (info) |
if (info->shared |
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h)) |
{ |
asection *s = htab->elf.splt; |
asection *got_s = htab->plt_got; |
/* If this is the first .plt entry, make room for the special |
first entry. The .plt section is used by prelink to undo |
prelinking for dynamic relocations. */ |
first entry. */ |
if (s->size == 0) |
s->size = plt_entry_size; |
s->size += plt_entry_size; |
if (use_plt_got) |
eh->plt_got.offset = got_s->size; |
else |
h->plt.offset = s->size; |
/* If this symbol is not defined in a regular file, and we are |
2433,42 → 2228,26 |
location in the .plt. This is required to make function |
pointers compare as equal between the normal executable and |
the shared library. */ |
if (! bfd_link_pic (info) |
if (! info->shared |
&& !h->def_regular) |
{ |
if (use_plt_got) |
{ |
/* We need to make a call to the entry of the GOT PLT |
instead of regular PLT entry. */ |
h->root.u.def.section = got_s; |
h->root.u.def.value = eh->plt_got.offset; |
} |
else |
{ |
h->root.u.def.section = s; |
h->root.u.def.value = h->plt.offset; |
} |
} |
/* Make room for this entry. */ |
if (use_plt_got) |
got_s->size += sizeof (elf_i386_got_plt_entry); |
else |
{ |
s->size += plt_entry_size; |
/* We also need to make an entry in the .got.plt section, |
which will be placed in the .got section by the linker |
script. */ |
/* We also need to make an entry in the .got.plt section, which |
will be placed in the .got section by the linker script. */ |
htab->elf.sgotplt->size += 4; |
/* We also need to make an entry in the .rel.plt section. */ |
htab->elf.srelplt->size += sizeof (Elf32_External_Rel); |
htab->elf.srelplt->reloc_count++; |
} |
if (get_elf_i386_backend_data (info->output_bfd)->is_vxworks |
&& !bfd_link_pic (info)) |
&& !info->shared) |
{ |
/* VxWorks has a second set of relocations for each PLT entry |
in executables. They go in a separate relocation section, |
2505,7 → 2284,7 |
/* If R_386_TLS_{IE_32,IE,GOTIE} symbol is now local to the binary, |
make it a R_386_TLS_LE_32 requiring no TLS entry. */ |
if (h->got.refcount > 0 |
&& bfd_link_executable (info) |
&& info->executable |
&& h->dynindx == -1 |
&& (elf_i386_hash_entry(h)->tls_type & GOT_TLS_IE)) |
h->got.offset = (bfd_vma) -1; |
2557,7 → 2336,7 |
else if (! GOT_TLS_GDESC_P (tls_type) |
&& (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT |
|| h->root.type != bfd_link_hash_undefweak) |
&& (bfd_link_pic (info) |
&& (info->shared |
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))) |
htab->elf.srelgot->size += sizeof (Elf32_External_Rel); |
if (GOT_TLS_GDESC_P (tls_type)) |
2575,7 → 2354,7 |
space for pc-relative relocs that have become local due to symbol |
visibility changes. */ |
if (bfd_link_pic (info)) |
if (info->shared) |
{ |
/* The only reloc that uses pc_count is R_386_PC32, which will |
appear on a call or on something like ".long foo - .". We |
2632,10 → 2411,9 |
{ |
/* For the non-shared case, discard space for relocs against |
symbols which turn out to need copy relocs or are not |
dynamic. Keep dynamic relocations for run-time function |
pointer initialization. */ |
dynamic. */ |
if ((!h->non_got_ref || eh->func_pointer_refcount > 0) |
if (!h->non_got_ref |
&& ((h->def_dynamic |
&& !h->def_regular) |
|| (htab->elf.dynamic_sections_created |
2658,7 → 2436,6 |
} |
eh->dyn_relocs = NULL; |
eh->func_pointer_refcount = 0; |
keep: ; |
} |
2719,9 → 2496,8 |
info->flags |= DF_TEXTREL; |
if ((info->warn_shared_textrel && bfd_link_pic (info)) |
|| info->error_textrel) |
info->callbacks->einfo (_("%P: %B: warning: relocation against `%s' in readonly section `%A'\n"), |
if (info->warn_shared_textrel && info->shared) |
info->callbacks->einfo (_("%P: %B: warning: relocation against `%s' in readonly section `%A'.\n"), |
p->sec->owner, h->root.root.string, |
p->sec); |
2732,27 → 2508,14 |
return TRUE; |
} |
/* With the local symbol, foo, we convert |
mov foo@GOT[(%reg1)], %reg2 |
/* Convert |
mov foo@GOT(%reg), %reg |
to |
lea foo[@GOTOFF(%reg1)], %reg2 |
and convert |
call/jmp *foo@GOT[(%reg)] |
to |
nop call foo/jmp foo nop |
When PIC is false, convert |
test %reg1, foo@GOT[(%reg2)] |
to |
test $foo, %reg1 |
and convert |
binop foo@GOT[(%reg1)], %reg2 |
to |
binop $foo, %reg2 |
where binop is one of adc, add, and, cmp, or, sbb, sub, xor |
instructions. */ |
lea foo@GOTOFF(%reg), %reg |
with the local symbol, foo. */ |
static bfd_boolean |
elf_i386_convert_load (bfd *abfd, asection *sec, |
elf_i386_convert_mov_to_lea (bfd *abfd, asection *sec, |
struct bfd_link_info *link_info) |
{ |
Elf_Internal_Shdr *symtab_hdr; |
2768,10 → 2531,10 |
if (!is_elf_hash_table (link_info->hash)) |
return FALSE; |
/* Nothing to do if there is no need or no output. */ |
/* Nothing to do if there are no codes, no relocations or no output. */ |
if ((sec->flags & (SEC_CODE | SEC_RELOC)) != (SEC_CODE | SEC_RELOC) |
|| sec->need_convert_load == 0 |
|| bfd_is_abs_section (sec->output_section)) |
|| sec->reloc_count == 0 |
|| discarded_section (sec)) |
return TRUE; |
symtab_hdr = &elf_tdata (abfd)->symtab_hdr; |
2804,97 → 2567,33 |
unsigned int r_symndx = ELF32_R_SYM (irel->r_info); |
unsigned int indx; |
struct elf_link_hash_entry *h; |
unsigned int opcode; |
unsigned int modrm; |
bfd_vma roff; |
bfd_boolean baseless; |
Elf_Internal_Sym *isym; |
unsigned int addend; |
unsigned int nop; |
bfd_vma nop_offset; |
if (r_type != R_386_GOT32 && r_type != R_386_GOT32X) |
if (r_type != R_386_GOT32) |
continue; |
roff = irel->r_offset; |
if (roff < 2) |
continue; |
/* Addend for R_386_GOT32 and R_386_GOT32X relocations must be 0. */ |
addend = bfd_get_32 (abfd, contents + roff); |
if (addend != 0) |
continue; |
modrm = bfd_get_8 (abfd, contents + roff - 1); |
baseless = (modrm & 0xc7) == 0x5; |
if (r_type == R_386_GOT32X |
&& baseless |
&& bfd_link_pic (link_info)) |
{ |
/* For PIC, disallow R_386_GOT32X without a base register |
since we don't know what the GOT base is. Allow |
R_386_GOT32 for existing object files. */ |
const char *name; |
/* Get the symbol referred to by the reloc. */ |
if (r_symndx < symtab_hdr->sh_info) |
{ |
isym = bfd_sym_from_r_symndx (&htab->sym_cache, abfd, |
r_symndx); |
name = bfd_elf_sym_name (abfd, symtab_hdr, isym, NULL); |
} |
else |
{ |
indx = r_symndx - symtab_hdr->sh_info; |
h = elf_sym_hashes (abfd)[indx]; |
BFD_ASSERT (h != NULL); |
name = h->root.root.string; |
} |
Elf_Internal_Sym *isym; |
(*_bfd_error_handler) |
(_("%B: direct GOT relocation R_386_GOT32X against `%s' without base register can not be used when making a shared object"), |
abfd, name); |
goto error_return; |
} |
isym = bfd_sym_from_r_symndx (&htab->sym_cache, |
abfd, r_symndx); |
opcode = bfd_get_8 (abfd, contents + roff - 2); |
/* It is OK to convert mov to lea. */ |
if (opcode != 0x8b) |
/* STT_GNU_IFUNC must keep R_386_GOT32 relocation. */ |
if (ELF_ST_TYPE (isym->st_info) != STT_GNU_IFUNC |
&& bfd_get_8 (input_bfd, |
contents + irel->r_offset - 2) == 0x8b) |
{ |
/* Only convert R_386_GOT32X relocation for call, jmp or |
one of adc, add, and, cmp, or, sbb, sub, test, xor |
instructions. */ |
if (r_type != R_386_GOT32X) |
continue; |
/* It is OK to convert indirect branch to direct branch. It |
is OK to convert adc, add, and, cmp, or, sbb, sub, test, |
xor only when PIC is false. */ |
if (opcode != 0xff && bfd_link_pic (link_info)) |
continue; |
bfd_put_8 (output_bfd, 0x8d, |
contents + irel->r_offset - 2); |
irel->r_info = ELF32_R_INFO (r_symndx, R_386_GOTOFF); |
if (local_got_refcounts != NULL |
&& local_got_refcounts[r_symndx] > 0) |
local_got_refcounts[r_symndx] -= 1; |
changed_contents = TRUE; |
changed_relocs = TRUE; |
} |
/* Try to convert R_386_GOT32 and R_386_GOT32X. Get the symbol |
referred to by the reloc. */ |
if (r_symndx < symtab_hdr->sh_info) |
{ |
isym = bfd_sym_from_r_symndx (&htab->sym_cache, |
abfd, r_symndx); |
/* STT_GNU_IFUNC must keep GOT32 relocations. */ |
if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC) |
continue; |
h = NULL; |
if (opcode == 0x0ff) |
/* Convert "call/jmp *foo@GOT[(%reg)]". */ |
goto convert_branch; |
else |
/* Convert "mov foo@GOT[(%reg1)], %reg2", |
"test %reg1, foo@GOT(%reg2)" and |
"binop foo@GOT[(%reg1)], %reg2". */ |
goto convert_load; |
} |
indx = r_symndx - symtab_hdr->sh_info; |
2905,149 → 2604,25 |
|| h->root.type == bfd_link_hash_warning) |
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
/* STT_GNU_IFUNC must keep GOT32 relocations. */ |
if (h->type == STT_GNU_IFUNC) |
continue; |
if (opcode == 0xff) |
/* STT_GNU_IFUNC must keep R_386_GOT32 relocation. We also avoid |
optimizing _DYNAMIC since ld.so may use its link-time address. */ |
if (h->def_regular |
&& h->type != STT_GNU_IFUNC |
&& h != htab->elf.hdynamic |
&& SYMBOL_REFERENCES_LOCAL (link_info, h) |
&& bfd_get_8 (input_bfd, |
contents + irel->r_offset - 2) == 0x8b) |
{ |
/* We have "call/jmp *foo@GOT[(%reg)]". */ |
if ((h->root.type == bfd_link_hash_defined |
|| h->root.type == bfd_link_hash_defweak) |
&& SYMBOL_REFERENCES_LOCAL (link_info, h)) |
{ |
/* The function is locally defined. */ |
convert_branch: |
/* Convert R_386_GOT32X to R_386_PC32. */ |
if (modrm == 0x15 || (modrm & 0xf8) == 0x90) |
{ |
/* Convert to "nop call foo". ADDR_PREFIX_OPCODE |
is a nop prefix. */ |
modrm = 0xe8; |
nop = link_info->call_nop_byte; |
if (link_info->call_nop_as_suffix) |
{ |
nop_offset = roff + 3; |
irel->r_offset -= 1; |
} |
else |
nop_offset = roff - 2; |
} |
else |
{ |
/* Convert to "jmp foo nop". */ |
modrm = 0xe9; |
nop = NOP_OPCODE; |
nop_offset = roff + 3; |
irel->r_offset -= 1; |
} |
bfd_put_8 (abfd, nop, contents + nop_offset); |
bfd_put_8 (abfd, modrm, contents + irel->r_offset - 1); |
/* When converting to PC-relative relocation, we |
need to adjust addend by -4. */ |
bfd_put_32 (abfd, -4, contents + irel->r_offset); |
irel->r_info = ELF32_R_INFO (r_symndx, R_386_PC32); |
if (h) |
{ |
bfd_put_8 (output_bfd, 0x8d, |
contents + irel->r_offset - 2); |
irel->r_info = ELF32_R_INFO (r_symndx, R_386_GOTOFF); |
if (h->got.refcount > 0) |
h->got.refcount -= 1; |
} |
else |
{ |
if (local_got_refcounts != NULL |
&& local_got_refcounts[r_symndx] > 0) |
local_got_refcounts[r_symndx] -= 1; |
} |
changed_contents = TRUE; |
changed_relocs = TRUE; |
} |
} |
else |
{ |
/* We have "mov foo@GOT[(%re1g)], %reg2", |
"test %reg1, foo@GOT(%reg2)" and |
"binop foo@GOT[(%reg1)], %reg2". |
Avoid optimizing _DYNAMIC since ld.so may use its |
link-time address. */ |
if (h == htab->elf.hdynamic) |
continue; |
/* def_regular is set by an assignment in a linker script in |
bfd_elf_record_link_assignment. */ |
if ((h->def_regular |
|| h->root.type == bfd_link_hash_defined |
|| h->root.type == bfd_link_hash_defweak) |
&& SYMBOL_REFERENCES_LOCAL (link_info, h)) |
{ |
convert_load: |
if (opcode == 0x8b) |
{ |
/* Convert "mov foo@GOT(%reg1), %reg2" to |
"lea foo@GOTOFF(%reg1), %reg2". */ |
if (r_type == R_386_GOT32X |
&& (baseless || !bfd_link_pic (link_info))) |
{ |
r_type = R_386_32; |
/* For R_386_32, convert |
"lea foo@GOTOFF(%reg1), %reg2" to |
"lea foo@GOT, %reg2". */ |
if (!baseless) |
{ |
modrm = 0x5 | (modrm & 0x38); |
bfd_put_8 (abfd, modrm, contents + roff - 1); |
} |
} |
else |
r_type = R_386_GOTOFF; |
opcode = 0x8d; |
} |
else |
{ |
if (opcode == 0x85) |
{ |
/* Convert "test %reg1, foo@GOT(%reg2)" to |
"test $foo, %reg1". */ |
modrm = 0xc0 | (modrm & 0x38) >> 3; |
opcode = 0xf7; |
} |
else |
{ |
/* Convert "binop foo@GOT(%reg1), %reg2" to |
"binop $foo, %reg2". */ |
modrm = (0xc0 |
| (modrm & 0x38) >> 3 |
| (opcode & 0x3c)); |
opcode = 0x81; |
} |
bfd_put_8 (abfd, modrm, contents + roff - 1); |
r_type = R_386_32; |
} |
bfd_put_8 (abfd, opcode, contents + roff - 2); |
irel->r_info = ELF32_R_INFO (r_symndx, r_type); |
if (h) |
{ |
if (h->got.refcount > 0) |
h->got.refcount -= 1; |
} |
else |
{ |
if (local_got_refcounts != NULL |
&& local_got_refcounts[r_symndx] > 0) |
local_got_refcounts[r_symndx] -= 1; |
} |
changed_contents = TRUE; |
changed_relocs = TRUE; |
} |
} |
} |
if (contents != NULL |
&& elf_section_data (sec)->this_hdr.contents != contents) |
{ |
3101,7 → 2676,7 |
if (htab->elf.dynamic_sections_created) |
{ |
/* Set the contents of the .interp section to the interpreter. */ |
if (bfd_link_executable (info) && !info->nointerp) |
if (info->executable) |
{ |
s = bfd_get_linker_section (dynobj, ".interp"); |
if (s == NULL) |
3113,7 → 2688,7 |
/* Set up .got offsets for local syms, and space for local dynamic |
relocs. */ |
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next) |
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next) |
{ |
bfd_signed_vma *local_got; |
bfd_signed_vma *end_local_got; |
3130,7 → 2705,7 |
{ |
struct elf_dyn_relocs *p; |
if (!elf_i386_convert_load (ibfd, s, info)) |
if (!elf_i386_convert_mov_to_lea (ibfd, s, info)) |
return FALSE; |
for (p = ((struct elf_dyn_relocs *) |
3161,9 → 2736,8 |
&& (info->flags & DF_TEXTREL) == 0) |
{ |
info->flags |= DF_TEXTREL; |
if ((info->warn_shared_textrel && bfd_link_pic (info)) |
|| info->error_textrel) |
info->callbacks->einfo (_("%P: %B: warning: relocation in readonly section `%A'\n"), |
if (info->warn_shared_textrel && info->shared) |
info->callbacks->einfo (_("%P: %B: warning: relocation in readonly section `%A'.\n"), |
p->sec->owner, p->sec); |
} |
} |
3203,7 → 2777,7 |
|| *local_tls_type == GOT_TLS_IE_BOTH) |
s->size += 4; |
} |
if (bfd_link_pic (info) |
if (info->shared |
|| GOT_TLS_GD_ANY_P (*local_tls_type) |
|| (*local_tls_type & GOT_TLS_IE)) |
{ |
3311,7 → 2885,6 |
else if (s == htab->elf.sgotplt |
|| s == htab->elf.iplt |
|| s == htab->elf.igotplt |
|| s == htab->plt_got |
|| s == htab->plt_eh_frame |
|| s == htab->sdynbss) |
{ |
3382,7 → 2955,7 |
#define add_dynamic_entry(TAG, VAL) \ |
_bfd_elf_add_dynamic_entry (info, TAG, VAL) |
if (bfd_link_executable (info)) |
if (info->executable) |
{ |
if (!add_dynamic_entry (DT_DEBUG, 0)) |
return FALSE; |
3390,19 → 2963,12 |
if (htab->elf.splt->size != 0) |
{ |
/* DT_PLTGOT is used by prelink even if there is no PLT |
relocation. */ |
if (!add_dynamic_entry (DT_PLTGOT, 0)) |
return FALSE; |
if (htab->elf.srelplt->size != 0) |
{ |
if (!add_dynamic_entry (DT_PLTRELSZ, 0) |
if (!add_dynamic_entry (DT_PLTGOT, 0) |
|| !add_dynamic_entry (DT_PLTRELSZ, 0) |
|| !add_dynamic_entry (DT_PLTREL, DT_REL) |
|| !add_dynamic_entry (DT_JMPREL, 0)) |
return FALSE; |
} |
} |
if (relocs) |
{ |
3419,15 → 2985,6 |
if ((info->flags & DF_TEXTREL) != 0) |
{ |
if ((elf_tdata (output_bfd)->has_gnu_symbols |
& elf_gnu_symbol_ifunc) == elf_gnu_symbol_ifunc) |
{ |
info->callbacks->einfo |
(_("%P%X: read-only segment has dynamic IFUNC relocations; recompile with -fPIC\n")); |
bfd_set_error (bfd_error_bad_value); |
return FALSE; |
} |
if (!add_dynamic_entry (DT_TEXTREL, 0)) |
return FALSE; |
} |
3477,7 → 3034,6 |
tlsbase = (struct elf_link_hash_entry *)bh; |
tlsbase->def_regular = 1; |
tlsbase->other = STV_HIDDEN; |
tlsbase->root.linker_def = 1; |
(*bed->elf_backend_hide_symbol) (info, tlsbase, TRUE); |
} |
} |
3530,7 → 3086,7 |
struct elf_i386_link_hash_table *htab; |
struct bfd_link_hash_entry *base; |
if (!bfd_link_executable (info)) |
if (!info->executable) |
return; |
htab = elf_i386_hash_table (info); |
3594,7 → 3150,6 |
bfd_vma *local_got_offsets; |
bfd_vma *local_tlsdesc_gotents; |
Elf_Internal_Rela *rel; |
Elf_Internal_Rela *wrel; |
Elf_Internal_Rela *relend; |
bfd_boolean is_vxworks_tls; |
unsigned plt_entry_size; |
3611,7 → 3166,7 |
/* We have to handle relocations in vxworks .tls_vars sections |
specially, because the dynamic loader is 'weird'. */ |
is_vxworks_tls = (get_elf_i386_backend_data (output_bfd)->is_vxworks |
&& bfd_link_pic (info) |
&& info->shared |
&& !strcmp (input_section->output_section->name, |
".tls_vars")); |
3619,18 → 3174,17 |
plt_entry_size = GET_PLT_ENTRY_SIZE (output_bfd); |
rel = wrel = relocs; |
rel = relocs; |
relend = relocs + input_section->reloc_count; |
for (; rel < relend; wrel++, rel++) |
for (; rel < relend; rel++) |
{ |
unsigned int r_type; |
reloc_howto_type *howto; |
unsigned long r_symndx; |
struct elf_link_hash_entry *h; |
struct elf_i386_link_hash_entry *eh; |
Elf_Internal_Sym *sym; |
asection *sec; |
bfd_vma off, offplt, plt_offset; |
bfd_vma off, offplt; |
bfd_vma relocation; |
bfd_boolean unresolved_reloc; |
bfd_reloc_status_type r; |
3637,22 → 3191,17 |
unsigned int indx; |
int tls_type; |
bfd_vma st_size; |
asection *resolved_plt; |
r_type = ELF32_R_TYPE (rel->r_info); |
if (r_type == R_386_GNU_VTINHERIT |
|| r_type == R_386_GNU_VTENTRY) |
{ |
if (wrel != rel) |
*wrel = *rel; |
continue; |
} |
if ((indx = r_type) >= R_386_standard |
&& ((indx = r_type - R_386_ext_offset) - R_386_standard |
>= R_386_ext - R_386_standard) |
&& ((indx = r_type - R_386_tls_offset) - R_386_ext |
>= R_386_ext2 - R_386_ext)) |
>= R_386_irelative - R_386_ext)) |
{ |
(*_bfd_error_handler) |
(_("%B: unrecognized relocation (0x%x) in section `%A'"), |
3678,7 → 3227,7 |
if (ELF_ST_TYPE (sym->st_info) == STT_SECTION |
&& ((sec->flags & SEC_MERGE) != 0 |
|| (bfd_link_relocatable (info) |
|| (info->relocatable |
&& sec->output_offset != 0))) |
{ |
bfd_vma addend; |
3714,7 → 3263,7 |
abort (); |
} |
if (bfd_link_relocatable (info)) |
if (info->relocatable) |
addend += sec->output_offset; |
else |
{ |
3745,7 → 3294,7 |
break; |
} |
} |
else if (!bfd_link_relocatable (info) |
else if (!info->relocatable |
&& ELF32_ST_TYPE (sym->st_info) == STT_GNU_IFUNC) |
{ |
/* Relocate against local STT_GNU_IFUNC symbol. */ |
3762,40 → 3311,21 |
else |
{ |
bfd_boolean warned ATTRIBUTE_UNUSED; |
bfd_boolean ignored ATTRIBUTE_UNUSED; |
RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, |
r_symndx, symtab_hdr, sym_hashes, |
h, sec, relocation, |
unresolved_reloc, warned, ignored); |
unresolved_reloc, warned); |
st_size = h->size; |
} |
if (sec != NULL && discarded_section (sec)) |
{ |
_bfd_clear_contents (howto, input_bfd, input_section, |
contents + rel->r_offset); |
wrel->r_offset = rel->r_offset; |
wrel->r_info = 0; |
wrel->r_addend = 0; |
RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, |
rel, 1, relend, howto, 0, contents); |
/* For ld -r, remove relocations in debug sections against |
sections defined in discarded sections. Not done for |
eh_frame editing code expects to be present. */ |
if (bfd_link_relocatable (info) |
&& (input_section->flags & SEC_DEBUGGING)) |
wrel--; |
if (info->relocatable) |
continue; |
} |
if (bfd_link_relocatable (info)) |
{ |
if (wrel != rel) |
*wrel = *rel; |
continue; |
} |
/* Since STT_GNU_IFUNC symbol must go through PLT, we handle |
it here if it is defined in a non-shared object. */ |
if (h != NULL |
3806,17 → 3336,9 |
bfd_vma plt_index; |
const char *name; |
if ((input_section->flags & SEC_ALLOC) == 0) |
{ |
/* Dynamic relocs are not propagated for SEC_DEBUGGING |
sections because such sections are not SEC_ALLOC and |
thus ld.so will not process them. */ |
if ((input_section->flags & SEC_DEBUGGING) != 0) |
continue; |
if ((input_section->flags & SEC_ALLOC) == 0 |
|| h->plt.offset == (bfd_vma) -1) |
abort (); |
} |
else if (h->plt.offset == (bfd_vma) -1) |
abort (); |
/* STT_GNU_IFUNC symbol must go through PLT. */ |
if (htab->elf.splt != NULL) |
3852,7 → 3374,7 |
case R_386_32: |
/* Generate dynamic relcoation only when there is a |
non-GOT reference in a shared object. */ |
if (bfd_link_pic (info) && h->non_got_ref) |
if (info->shared && h->non_got_ref) |
{ |
Elf_Internal_Rela outrel; |
asection *sreloc; |
3874,7 → 3396,7 |
if (h->dynindx == -1 |
|| h->forced_local |
|| bfd_link_executable (info)) |
|| info->executable) |
{ |
/* This symbol is resolved locally. */ |
outrel.r_info = ELF32_R_INFO (0, R_386_IRELATIVE); |
3903,7 → 3425,6 |
goto do_relocation; |
case R_386_GOT32: |
case R_386_GOT32X: |
base_got = htab->elf.sgot; |
off = h->got.offset; |
3978,67 → 3499,9 |
} |
} |
eh = (struct elf_i386_link_hash_entry *) h; |
switch (r_type) |
{ |
case R_386_GOT32X: |
/* Avoid optimizing _DYNAMIC since ld.so may use its |
link-time address. */ |
if (h == htab->elf.hdynamic) |
goto r_386_got32; |
if (bfd_link_pic (info)) |
{ |
/* It is OK to convert mov to lea and convert indirect |
branch to direct branch. It is OK to convert adc, |
add, and, cmp, or, sbb, sub, test, xor only when PIC |
is false. */ |
unsigned int opcode, addend; |
addend = bfd_get_32 (input_bfd, contents + rel->r_offset); |
if (addend != 0) |
goto r_386_got32; |
opcode = bfd_get_8 (input_bfd, contents + rel->r_offset - 2); |
if (opcode != 0x8b && opcode != 0xff) |
goto r_386_got32; |
} |
/* Resolve "mov GOT[(%reg)], %reg", |
"call/jmp *GOT[(%reg)]", "test %reg, foo@GOT[(%reg)]" |
and "binop foo@GOT[(%reg)], %reg". */ |
if (h == NULL |
|| (h->plt.offset == (bfd_vma) -1 |
&& h->got.offset == (bfd_vma) -1) |
|| htab->elf.sgotplt == NULL) |
abort (); |
offplt = (htab->elf.sgotplt->output_section->vma |
+ htab->elf.sgotplt->output_offset); |
/* It is relative to .got.plt section. */ |
if (h->got.offset != (bfd_vma) -1) |
/* Use GOT entry. */ |
relocation = (htab->elf.sgot->output_section->vma |
+ htab->elf.sgot->output_offset |
+ h->got.offset - offplt); |
else |
/* Use GOTPLT entry. */ |
relocation = (h->plt.offset / plt_entry_size - 1 + 3) * 4; |
if (!bfd_link_pic (info)) |
{ |
/* If not PIC, add the .got.plt section address for |
baseless addressing. */ |
unsigned int modrm; |
modrm = bfd_get_8 (input_bfd, contents + rel->r_offset - 1); |
if ((modrm & 0xc7) == 0x5) |
relocation += offplt; |
} |
unresolved_reloc = FALSE; |
break; |
case R_386_GOT32: |
r_386_got32: |
/* Relocation is to the entry for this symbol in the global |
offset table. */ |
if (htab->elf.sgot == NULL) |
4050,10 → 3513,8 |
off = h->got.offset; |
dyn = htab->elf.dynamic_sections_created; |
if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, |
bfd_link_pic (info), |
h) |
|| (bfd_link_pic (info) |
if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h) |
|| (info->shared |
&& SYMBOL_REFERENCES_LOCAL (info, h)) |
|| (ELF_ST_VISIBILITY (h->other) |
&& h->root.type == bfd_link_hash_undefweak)) |
4099,7 → 3560,7 |
bfd_put_32 (output_bfd, relocation, |
htab->elf.sgot->contents + off); |
if (bfd_link_pic (info)) |
if (info->shared) |
{ |
asection *s; |
Elf_Internal_Rela outrel; |
4132,11 → 3593,11 |
/* Relocation is relative to the start of the global offset |
table. */ |
/* Check to make sure it isn't a protected function or data |
symbol for shared library since it may not be local when |
used as function address or with copy relocation. We also |
need to make sure that a symbol is referenced locally. */ |
if (!bfd_link_executable (info) && h) |
/* Check to make sure it isn't a protected function symbol |
for shared library since it may not be local when used |
as function address. We also need to make sure that a |
symbol is defined locally. */ |
if (info->shared && h) |
{ |
if (!h->def_regular) |
{ |
4164,16 → 3625,14 |
bfd_set_error (bfd_error_bad_value); |
return FALSE; |
} |
else if (!SYMBOL_REFERENCES_LOCAL (info, h) |
&& (h->type == STT_FUNC |
|| h->type == STT_OBJECT) |
else if (!info->executable |
&& !SYMBOLIC_BIND (info, h) |
&& h->type == STT_FUNC |
&& ELF_ST_VISIBILITY (h->other) == STV_PROTECTED) |
{ |
(*_bfd_error_handler) |
(_("%B: relocation R_386_GOTOFF against protected %s `%s' can not be used when making a shared object"), |
input_bfd, |
h->type == STT_FUNC ? "function" : "data", |
h->root.root.string); |
(_("%B: relocation R_386_GOTOFF against protected function `%s' can not be used when making a shared object"), |
input_bfd, h->root.root.string); |
bfd_set_error (bfd_error_bad_value); |
return FALSE; |
} |
4204,8 → 3663,7 |
if (h == NULL) |
break; |
if ((h->plt.offset == (bfd_vma) -1 |
&& eh->plt_got.offset == (bfd_vma) -1) |
if (h->plt.offset == (bfd_vma) -1 |
|| htab->elf.splt == NULL) |
{ |
/* We didn't make a PLT entry for this symbol. This |
4214,20 → 3672,9 |
break; |
} |
if (h->plt.offset != (bfd_vma) -1) |
{ |
resolved_plt = htab->elf.splt; |
plt_offset = h->plt.offset; |
} |
else |
{ |
resolved_plt = htab->plt_got; |
plt_offset = eh->plt_got.offset; |
} |
relocation = (resolved_plt->output_section->vma |
+ resolved_plt->output_offset |
+ plt_offset); |
relocation = (htab->elf.splt->output_section->vma |
+ htab->elf.splt->output_offset |
+ h->plt.offset); |
unresolved_reloc = FALSE; |
break; |
4242,8 → 3689,7 |
|| is_vxworks_tls) |
break; |
/* Copy dynamic function pointer relocations. */ |
if ((bfd_link_pic (info) |
if ((info->shared |
&& (h == NULL |
|| ELF_ST_VISIBILITY (h->other) == STV_DEFAULT |
|| h->root.type != bfd_link_hash_undefweak) |
4250,10 → 3696,10 |
&& ((r_type != R_386_PC32 && r_type != R_386_SIZE32) |
|| !SYMBOL_CALLS_LOCAL (info, h))) |
|| (ELIMINATE_COPY_RELOCS |
&& !bfd_link_pic (info) |
&& !info->shared |
&& h != NULL |
&& h->dynindx != -1 |
&& (!h->non_got_ref || eh->func_pointer_refcount > 0) |
&& !h->non_got_ref |
&& ((h->def_dynamic |
&& !h->def_regular) |
|| h->root.type == bfd_link_hash_undefweak |
4285,7 → 3731,7 |
else if (h != NULL |
&& h->dynindx != -1 |
&& (r_type == R_386_PC32 |
|| !bfd_link_pic (info) |
|| !info->shared |
|| !SYMBOLIC_BIND (info, h) |
|| !h->def_regular)) |
outrel.r_info = ELF32_R_INFO (h->dynindx, r_type); |
4316,7 → 3762,7 |
break; |
case R_386_TLS_IE: |
if (!bfd_link_executable (info)) |
if (!info->executable) |
{ |
Elf_Internal_Rela outrel; |
asection *sreloc; |
4386,7 → 3832,6 |
contents + roff); |
/* Skip R_386_PC32/R_386_PLT32. */ |
rel++; |
wrel++; |
continue; |
} |
else if (ELF32_R_TYPE (rel->r_info) == R_386_TLS_GOTDESC) |
4726,7 → 4171,6 |
contents + roff + 8); |
/* Skip R_386_PLT32. */ |
rel++; |
wrel++; |
continue; |
} |
else if (ELF32_R_TYPE (rel->r_info) == R_386_TLS_GOTDESC) |
4824,7 → 4268,6 |
"\x65\xa1\0\0\0\0\x90\x8d\x74\x26", 11); |
/* Skip R_386_PC32/R_386_PLT32. */ |
rel++; |
wrel++; |
continue; |
} |
4860,8 → 4303,7 |
break; |
case R_386_TLS_LDO_32: |
if (!bfd_link_executable (info) |
|| (input_section->flags & SEC_CODE) == 0) |
if (!info->executable || (input_section->flags & SEC_CODE) == 0) |
relocation -= elf_i386_dtpoff_base (info); |
else |
/* When converting LDO to LE, we must negate. */ |
4870,7 → 4312,7 |
case R_386_TLS_LE_32: |
case R_386_TLS_LE: |
if (!bfd_link_executable (info)) |
if (!info->executable) |
{ |
Elf_Internal_Rela outrel; |
asection *sreloc; |
4966,31 → 4408,8 |
return FALSE; |
} |
} |
if (wrel != rel) |
*wrel = *rel; |
} |
if (wrel != rel) |
{ |
Elf_Internal_Shdr *rel_hdr; |
size_t deleted = rel - wrel; |
rel_hdr = _bfd_elf_single_rel_hdr (input_section->output_section); |
rel_hdr->sh_size -= rel_hdr->sh_entsize * deleted; |
if (rel_hdr->sh_size == 0) |
{ |
/* It is too late to remove an empty reloc section. Leave |
one NONE reloc. |
??? What is wrong with an empty section??? */ |
rel_hdr->sh_size = rel_hdr->sh_entsize; |
deleted -= 1; |
} |
rel_hdr = _bfd_elf_single_rel_hdr (input_section); |
rel_hdr->sh_size -= rel_hdr->sh_entsize * deleted; |
input_section->reloc_count -= deleted; |
} |
return TRUE; |
} |
5006,7 → 4425,6 |
struct elf_i386_link_hash_table *htab; |
unsigned plt_entry_size; |
const struct elf_i386_backend_data *abed; |
struct elf_i386_link_hash_entry *eh; |
htab = elf_i386_hash_table (info); |
if (htab == NULL) |
5015,8 → 4433,6 |
abed = get_elf_i386_backend_data (output_bfd); |
plt_entry_size = GET_PLT_ENTRY_SIZE (output_bfd); |
eh = (struct elf_i386_link_hash_entry *) h; |
if (h->plt.offset != (bfd_vma) -1) |
{ |
bfd_vma plt_index; |
5044,7 → 4460,7 |
it up. */ |
if ((h->dynindx == -1 |
&& !((h->forced_local || bfd_link_executable (info)) |
&& !((h->forced_local || info->executable) |
&& h->def_regular |
&& h->type == STT_GNU_IFUNC)) |
|| plt == NULL |
5075,7 → 4491,7 |
} |
/* Fill in the entry in the procedure linkage table. */ |
if (! bfd_link_pic (info)) |
if (! info->shared) |
{ |
memcpy (plt->contents + h->plt.offset, abed->plt->plt_entry, |
abed->plt->plt_entry_size); |
5097,7 → 4513,7 |
s = ((h->plt.offset - abed->plt->plt_entry_size) |
/ abed->plt->plt_entry_size); |
/* K: Number of relocations for PLTResolve. */ |
if (bfd_link_pic (info)) |
if (info->shared) |
k = PLTRESOLVE_RELOCS_SHLIB; |
else |
k = PLTRESOLVE_RELOCS; |
5145,7 → 4561,7 |
+ gotplt->output_offset |
+ got_offset); |
if (h->dynindx == -1 |
|| ((bfd_link_executable (info) |
|| ((info->executable |
|| ELF_ST_VISIBILITY (h->other) != STV_DEFAULT) |
&& h->def_regular |
&& h->type == STT_GNU_IFUNC)) |
5181,54 → 4597,9 |
plt->contents + h->plt.offset |
+ abed->plt->plt_plt_offset); |
} |
} |
else if (eh->plt_got.offset != (bfd_vma) -1) |
{ |
bfd_vma got_offset, plt_offset; |
asection *plt, *got, *gotplt; |
const bfd_byte *got_plt_entry; |
/* Offset of displacement of the indirect jump. */ |
bfd_vma plt_got_offset = 2; |
/* Set the entry in the GOT procedure linkage table. */ |
plt = htab->plt_got; |
got = htab->elf.sgot; |
gotplt = htab->elf.sgotplt; |
got_offset = h->got.offset; |
if (got_offset == (bfd_vma) -1 |
|| plt == NULL |
|| got == NULL |
|| gotplt == NULL) |
abort (); |
/* Fill in the entry in the GOT procedure linkage table. */ |
if (! bfd_link_pic (info)) |
if (!h->def_regular) |
{ |
got_plt_entry = elf_i386_got_plt_entry; |
got_offset += got->output_section->vma + got->output_offset; |
} |
else |
{ |
got_plt_entry = elf_i386_pic_got_plt_entry; |
got_offset += (got->output_section->vma |
+ got->output_offset |
- gotplt->output_section->vma |
- gotplt->output_offset); |
} |
plt_offset = eh->plt_got.offset; |
memcpy (plt->contents + plt_offset, got_plt_entry, |
sizeof (elf_i386_got_plt_entry)); |
bfd_put_32 (output_bfd, got_offset, |
plt->contents + plt_offset + plt_got_offset); |
} |
if (!h->def_regular |
&& (h->plt.offset != (bfd_vma) -1 |
|| eh->plt_got.offset != (bfd_vma) -1)) |
{ |
/* Mark the symbol as undefined, rather than as defined in |
the .plt section. Leave the value if there were any |
relocations where pointer equality matters (this is a clue |
5241,6 → 4612,7 |
if (!h->pointer_equality_needed) |
sym->st_value = 0; |
} |
} |
if (h->got.offset != (bfd_vma) -1 |
&& ! GOT_TLS_GD_ANY_P (elf_i386_hash_entry(h)->tls_type) |
5266,7 → 4638,7 |
if (h->def_regular |
&& h->type == STT_GNU_IFUNC) |
{ |
if (bfd_link_pic (info)) |
if (info->shared) |
{ |
/* Generate R_386_GLOB_DAT. */ |
goto do_glob_dat; |
5289,7 → 4661,7 |
return TRUE; |
} |
} |
else if (bfd_link_pic (info) |
else if (info->shared |
&& SYMBOL_REFERENCES_LOCAL (info, h)) |
{ |
BFD_ASSERT((h->got.offset & 1) != 0); |
5348,27 → 4720,10 |
dynamic linker, before writing them out. */ |
static enum elf_reloc_type_class |
elf_i386_reloc_type_class (const struct bfd_link_info *info, |
elf_i386_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED, |
const asection *rel_sec ATTRIBUTE_UNUSED, |
const Elf_Internal_Rela *rela) |
{ |
bfd *abfd = info->output_bfd; |
const struct elf_backend_data *bed = get_elf_backend_data (abfd); |
struct elf_link_hash_table *htab = elf_hash_table (info); |
unsigned long r_symndx = ELF32_R_SYM (rela->r_info); |
Elf_Internal_Sym sym; |
if (htab->dynsym == NULL |
|| !bed->s->swap_symbol_in (abfd, |
(htab->dynsym->contents |
+ r_symndx * sizeof (Elf32_External_Sym)), |
0, &sym)) |
abort (); |
/* Check relocation against STT_GNU_IFUNC symbol. */ |
if (ELF32_ST_TYPE (sym.st_info) == STT_GNU_IFUNC) |
return reloc_class_ifunc; |
switch (ELF32_R_TYPE (rela->r_info)) |
{ |
case R_386_RELATIVE: |
5472,7 → 4827,7 |
/* Fill in the first entry in the procedure linkage table. */ |
if (htab->elf.splt && htab->elf.splt->size > 0) |
{ |
if (bfd_link_pic (info)) |
if (info->shared) |
{ |
memcpy (htab->elf.splt->contents, abed->plt->pic_plt0_entry, |
abed->plt->plt0_entry_size); |
5530,7 → 4885,7 |
->this_hdr.sh_entsize = 4; |
/* Correct the .rel.plt.unloaded relocations. */ |
if (abed->is_vxworks && !bfd_link_pic (info)) |
if (abed->is_vxworks && !info->shared) |
{ |
int num_plts = (htab->elf.splt->size |
/ abed->plt->plt_entry_size) - 1; |
5537,7 → 4892,7 |
unsigned char *p; |
p = htab->srelplt2->contents; |
if (bfd_link_pic (info)) |
if (info->shared) |
p += PLTRESOLVE_RELOCS_SHLIB * sizeof (Elf32_External_Rel); |
else |
p += PLTRESOLVE_RELOCS * sizeof (Elf32_External_Rel); |
5621,98 → 4976,16 |
return TRUE; |
} |
/* Return an array of PLT entry symbol values. */ |
/* Return address for Ith PLT stub in section PLT, for relocation REL |
or (bfd_vma) -1 if it should not be included. */ |
static bfd_vma * |
elf_i386_get_plt_sym_val (bfd *abfd, asymbol **dynsyms, asection *plt, |
asection *relplt) |
static bfd_vma |
elf_i386_plt_sym_val (bfd_vma i, const asection *plt, |
const arelent *rel ATTRIBUTE_UNUSED) |
{ |
bfd_boolean (*slurp_relocs) (bfd *, asection *, asymbol **, bfd_boolean); |
arelent *p; |
long count, i; |
bfd_vma *plt_sym_val; |
bfd_vma plt_offset; |
bfd_byte *plt_contents; |
const struct elf_i386_backend_data *bed |
= get_elf_i386_backend_data (abfd); |
Elf_Internal_Shdr *hdr; |
/* Get the .plt section contents. */ |
plt_contents = (bfd_byte *) bfd_malloc (plt->size); |
if (plt_contents == NULL) |
return NULL; |
if (!bfd_get_section_contents (abfd, (asection *) plt, |
plt_contents, 0, plt->size)) |
{ |
bad_return: |
free (plt_contents); |
return NULL; |
return plt->vma + (i + 1) * GET_PLT_ENTRY_SIZE (plt->owner); |
} |
slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table; |
if (! (*slurp_relocs) (abfd, relplt, dynsyms, TRUE)) |
goto bad_return; |
hdr = &elf_section_data (relplt)->this_hdr; |
count = relplt->size / hdr->sh_entsize; |
plt_sym_val = (bfd_vma *) bfd_malloc (sizeof (bfd_vma) * count); |
if (plt_sym_val == NULL) |
goto bad_return; |
for (i = 0; i < count; i++) |
plt_sym_val[i] = -1; |
plt_offset = bed->plt->plt_entry_size; |
p = relplt->relocation; |
for (i = 0; i < count; i++, p++) |
{ |
long reloc_index; |
/* Skip unknown relocation. PR 17512: file: bc9d6cf5. */ |
if (p->howto == NULL) |
continue; |
if (p->howto->type != R_386_JUMP_SLOT |
&& p->howto->type != R_386_IRELATIVE) |
continue; |
reloc_index = H_GET_32 (abfd, (plt_contents + plt_offset |
+ bed->plt->plt_reloc_offset)); |
reloc_index /= sizeof (Elf32_External_Rel); |
if (reloc_index >= count) |
abort (); |
plt_sym_val[reloc_index] = plt->vma + plt_offset; |
plt_offset += bed->plt->plt_entry_size; |
/* PR binutils/18437: Skip extra relocations in the .rel.plt |
section. */ |
if (plt_offset >= plt->size) |
break; |
} |
free (plt_contents); |
return plt_sym_val; |
} |
/* Similar to _bfd_elf_get_synthetic_symtab. */ |
static long |
elf_i386_get_synthetic_symtab (bfd *abfd, |
long symcount, |
asymbol **syms, |
long dynsymcount, |
asymbol **dynsyms, |
asymbol **ret) |
{ |
asection *plt = bfd_get_section_by_name (abfd, ".plt"); |
return _bfd_elf_ifunc_get_synthetic_symtab (abfd, symcount, syms, |
dynsymcount, dynsyms, ret, |
plt, |
elf_i386_get_plt_sym_val); |
} |
/* Return TRUE if symbol should be hashed in the `.gnu.hash' section. */ |
static bfd_boolean |
5731,7 → 5004,7 |
static bfd_boolean |
elf_i386_add_symbol_hook (bfd * abfd, |
struct bfd_link_info * info, |
struct bfd_link_info * info ATTRIBUTE_UNUSED, |
Elf_Internal_Sym * sym, |
const char ** namep ATTRIBUTE_UNUSED, |
flagword * flagsp ATTRIBUTE_UNUSED, |
5738,16 → 5011,15 |
asection ** secp ATTRIBUTE_UNUSED, |
bfd_vma * valp ATTRIBUTE_UNUSED) |
{ |
if (ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE |
&& (abfd->flags & DYNAMIC) == 0 |
&& bfd_get_flavour (info->output_bfd) == bfd_target_elf_flavour) |
elf_tdata (info->output_bfd)->has_gnu_symbols |
|= elf_gnu_symbol_unique; |
if ((abfd->flags & DYNAMIC) == 0 |
&& (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC |
|| ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE)) |
elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE; |
return TRUE; |
} |
#define TARGET_LITTLE_SYM i386_elf32_vec |
#define TARGET_LITTLE_SYM bfd_elf32_i386_vec |
#define TARGET_LITTLE_NAME "elf32-i386" |
#define ELF_ARCH bfd_arch_i386 |
#define ELF_TARGET_ID I386_ELF_DATA |
5761,7 → 5033,6 |
#define elf_backend_want_plt_sym 0 |
#define elf_backend_got_header_size 12 |
#define elf_backend_plt_alignment 4 |
#define elf_backend_extern_protected_data 1 |
/* Support RELA for objdump of prelink objects. */ |
#define elf_info_to_howto elf_i386_info_to_howto_rel |
5771,9 → 5042,9 |
#define bfd_elf32_bfd_is_local_label_name elf_i386_is_local_label_name |
#define bfd_elf32_bfd_link_hash_table_create elf_i386_link_hash_table_create |
#define bfd_elf32_bfd_link_hash_table_free elf_i386_link_hash_table_free |
#define bfd_elf32_bfd_reloc_type_lookup elf_i386_reloc_type_lookup |
#define bfd_elf32_bfd_reloc_name_lookup elf_i386_reloc_name_lookup |
#define bfd_elf32_get_synthetic_symtab elf_i386_get_synthetic_symtab |
#define elf_backend_adjust_dynamic_symbol elf_i386_adjust_dynamic_symbol |
#define elf_backend_relocs_compatible _bfd_elf_relocs_compatible |
5793,8 → 5064,11 |
#define elf_backend_always_size_sections elf_i386_always_size_sections |
#define elf_backend_omit_section_dynsym \ |
((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true) |
#define elf_backend_plt_sym_val elf_i386_plt_sym_val |
#define elf_backend_hash_symbol elf_i386_hash_symbol |
#define elf_backend_add_symbol_hook elf_i386_add_symbol_hook |
#undef elf_backend_post_process_headers |
#define elf_backend_post_process_headers _bfd_elf_set_osabi |
#include "elf32-target.h" |
5801,7 → 5075,7 |
/* FreeBSD support. */ |
#undef TARGET_LITTLE_SYM |
#define TARGET_LITTLE_SYM i386_elf32_fbsd_vec |
#define TARGET_LITTLE_SYM bfd_elf32_i386_freebsd_vec |
#undef TARGET_LITTLE_NAME |
#define TARGET_LITTLE_NAME "elf32-i386-freebsd" |
#undef ELF_OSABI |
5814,14 → 5088,11 |
static void |
elf_i386_fbsd_post_process_headers (bfd *abfd, struct bfd_link_info *info) |
{ |
_bfd_elf_post_process_headers (abfd, info); |
_bfd_elf_set_osabi (abfd, info); |
#ifdef OLD_FREEBSD_ABI_LABEL |
{ |
/* The ABI label supported by FreeBSD <= 4.0 is quite nonstandard. */ |
Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd); |
memcpy (&i_ehdrp->e_ident[EI_ABIVERSION], "FreeBSD", 8); |
} |
#endif |
} |
5837,12 → 5108,10 |
/* Solaris 2. */ |
#undef TARGET_LITTLE_SYM |
#define TARGET_LITTLE_SYM i386_elf32_sol2_vec |
#define TARGET_LITTLE_SYM bfd_elf32_i386_sol2_vec |
#undef TARGET_LITTLE_NAME |
#define TARGET_LITTLE_NAME "elf32-i386-sol2" |
#undef elf_backend_post_process_headers |
/* Restore default: we cannot use ELFOSABI_SOLARIS, otherwise ELFOSABI_NONE |
objects won't be recognized. */ |
#undef ELF_OSABI |
5864,51 → 5133,10 |
#include "elf32-target.h" |
/* Intel MCU support. */ |
static bfd_boolean |
elf32_iamcu_elf_object_p (bfd *abfd) |
{ |
/* Set the right machine number for an IAMCU elf32 file. */ |
bfd_default_set_arch_mach (abfd, bfd_arch_iamcu, bfd_mach_i386_iamcu); |
return TRUE; |
} |
#undef TARGET_LITTLE_SYM |
#define TARGET_LITTLE_SYM iamcu_elf32_vec |
#undef TARGET_LITTLE_NAME |
#define TARGET_LITTLE_NAME "elf32-iamcu" |
#undef ELF_ARCH |
#define ELF_ARCH bfd_arch_iamcu |
#undef ELF_MACHINE_CODE |
#define ELF_MACHINE_CODE EM_IAMCU |
#undef ELF_OSABI |
#undef elf32_bed |
#define elf32_bed elf32_iamcu_bed |
#undef elf_backend_object_p |
#define elf_backend_object_p elf32_iamcu_elf_object_p |
#undef elf_backend_static_tls_alignment |
#undef elf_backend_want_plt_sym |
#define elf_backend_want_plt_sym 0 |
#include "elf32-target.h" |
/* Restore defaults. */ |
#undef ELF_ARCH |
#define ELF_ARCH bfd_arch_i386 |
#undef ELF_MACHINE_CODE |
#define ELF_MACHINE_CODE EM_386 |
/* Native Client support. */ |
#undef TARGET_LITTLE_SYM |
#define TARGET_LITTLE_SYM i386_elf32_nacl_vec |
#define TARGET_LITTLE_SYM bfd_elf32_i386_nacl_vec |
#undef TARGET_LITTLE_NAME |
#define TARGET_LITTLE_NAME "elf32-i386-nacl" |
#undef elf32_bed |
5922,6 → 5150,7 |
#undef elf_backend_want_plt_sym |
#define elf_backend_want_plt_sym 0 |
#undef elf_backend_post_process_headers |
#define elf_backend_post_process_headers _bfd_elf_set_osabi |
#undef elf_backend_static_tls_alignment |
/* NaCl uses substantially different PLT entries for the same effects. */ |
6097,7 → 5326,7 |
/* VxWorks support. */ |
#undef TARGET_LITTLE_SYM |
#define TARGET_LITTLE_SYM i386_elf32_vxworks_vec |
#define TARGET_LITTLE_SYM bfd_elf32_i386_vxworks_vec |
#undef TARGET_LITTLE_NAME |
#define TARGET_LITTLE_NAME "elf32-i386-vxworks" |
#undef ELF_OSABI |
6115,6 → 5344,7 |
#define elf_backend_arch_data &elf_i386_vxworks_arch_bed |
#undef elf_backend_relocs_compatible |
#undef elf_backend_post_process_headers |
#undef elf_backend_add_symbol_hook |
#define elf_backend_add_symbol_hook \ |
elf_vxworks_add_symbol_hook |
/contrib/toolchain/binutils/bfd/elf32-target.h |
---|
1,5 → 1,7 |
/* Target definitions for 32-bit ELF |
Copyright (C) 1993-2015 Free Software Foundation, Inc. |
Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, |
2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 |
Free Software Foundation, Inc. |
This file is part of BFD, the Binary File Descriptor library. |
49,9 → 51,6 |
#ifndef bfd_elf32_find_nearest_line |
#define bfd_elf32_find_nearest_line _bfd_elf_find_nearest_line |
#endif |
#ifndef bfd_elf32_find_line |
#define bfd_elf32_find_line _bfd_elf_find_line |
#endif |
#ifndef bfd_elf32_find_inliner_info |
#define bfd_elf32_find_inliner_info _bfd_elf_find_inliner_info |
#endif |
66,10 → 65,6 |
#ifndef bfd_elf32_get_symbol_info |
#define bfd_elf32_get_symbol_info _bfd_elf_get_symbol_info |
#endif |
#ifndef bfd_elf32_get_symbol_version_string |
#define bfd_elf32_get_symbol_version_string \ |
_bfd_elf_get_symbol_version_string |
#endif |
#define bfd_elf32_canonicalize_symtab _bfd_elf_canonicalize_symtab |
#define bfd_elf32_get_symtab_upper_bound _bfd_elf_get_symtab_upper_bound |
#define bfd_elf32_make_empty_symbol _bfd_elf_make_empty_symbol |
114,12 → 109,6 |
#ifndef elf_backend_default_execstack |
#define elf_backend_default_execstack 1 |
#endif |
#ifndef elf_backend_caches_rawsize |
#define elf_backend_caches_rawsize 0 |
#endif |
#ifndef elf_backend_extern_protected_data |
#define elf_backend_extern_protected_data 0 |
#endif |
#ifndef elf_backend_stack_align |
#define elf_backend_stack_align 16 |
#endif |
247,6 → 236,9 |
#ifndef bfd_elf32_bfd_link_hash_table_create |
#define bfd_elf32_bfd_link_hash_table_create _bfd_elf_link_hash_table_create |
#endif |
#ifndef bfd_elf32_bfd_link_hash_table_free |
#define bfd_elf32_bfd_link_hash_table_free _bfd_elf_link_hash_table_free |
#endif |
#ifndef bfd_elf32_bfd_link_add_symbols |
#define bfd_elf32_bfd_link_add_symbols bfd_elf_link_add_symbols |
#endif |
263,6 → 255,9 |
#define bfd_elf32_bfd_link_hash_table_create \ |
_bfd_generic_link_hash_table_create |
#endif |
#ifndef bfd_elf32_bfd_link_hash_table_free |
#define bfd_elf32_bfd_link_hash_table_free _bfd_generic_link_hash_table_free |
#endif |
#ifndef bfd_elf32_bfd_link_add_symbols |
#define bfd_elf32_bfd_link_add_symbols _bfd_generic_link_add_symbols |
#endif |
503,7 → 498,7 |
#define elf_backend_static_tls_alignment 1 |
#endif |
#ifndef elf_backend_post_process_headers |
#define elf_backend_post_process_headers _bfd_elf_post_process_headers |
#define elf_backend_post_process_headers NULL |
#endif |
#ifndef elf_backend_print_symbol_all |
#define elf_backend_print_symbol_all NULL |
538,9 → 533,6 |
#ifndef elf_backend_count_relocs |
#define elf_backend_count_relocs NULL |
#endif |
#ifndef elf_backend_sort_relocs_p |
#define elf_backend_sort_relocs_p NULL |
#endif |
#ifndef elf_backend_grok_prstatus |
#define elf_backend_grok_prstatus NULL |
#endif |
672,18 → 664,6 |
#define elf_backend_maybe_function_sym _bfd_elf_maybe_function_sym |
#endif |
#ifndef elf_backend_get_reloc_section |
#define elf_backend_get_reloc_section _bfd_elf_get_reloc_section |
#endif |
#ifndef elf_backend_compact_eh_encoding |
#define elf_backend_compact_eh_encoding NULL |
#endif |
#ifndef elf_backend_cant_unwind_opcode |
#define elf_backend_cant_unwind_opcode 0 |
#endif |
#ifndef elf_match_priority |
#define elf_match_priority \ |
(ELF_ARCH == bfd_arch_unknown ? 2 : ELF_OSABI == ELFOSABI_NONE ? 1 : 0) |
755,7 → 735,6 |
elf_backend_ignore_undef_symbol, |
elf_backend_emit_relocs, |
elf_backend_count_relocs, |
elf_backend_sort_relocs_p, |
elf_backend_grok_prstatus, |
elf_backend_grok_psinfo, |
elf_backend_write_core_note, |
781,7 → 760,6 |
elf_backend_hash_symbol, |
elf_backend_is_function_type, |
elf_backend_maybe_function_sym, |
elf_backend_get_reloc_section, |
elf_backend_link_order_error_handler, |
elf_backend_relplt_name, |
ELF_MACHINE_ALT1, |
796,8 → 774,6 |
elf_backend_obj_attrs_section_type, |
elf_backend_obj_attrs_order, |
elf_backend_obj_attrs_handle_unknown, |
elf_backend_compact_eh_encoding, |
elf_backend_cant_unwind_opcode, |
elf_backend_static_tls_alignment, |
elf_backend_stack_align, |
elf_backend_collect, |
818,9 → 794,7 |
elf_backend_want_got_sym, |
elf_backend_want_dynbss, |
elf_backend_want_p_paddr_set_to_zero, |
elf_backend_default_execstack, |
elf_backend_caches_rawsize, |
elf_backend_extern_protected_data |
elf_backend_default_execstack |
}; |
/* Forward declaration for use when initialising alternative_target field. */ |
845,8 → 819,7 |
/* object_flags: mask of all file flags */ |
(HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
| DYNAMIC | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS |
| BFD_COMPRESS_GABI), |
| DYNAMIC | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS), |
/* section_flags: mask of all section flags */ |
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
944,8 → 917,7 |
/* object_flags: mask of all file flags */ |
(HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
| DYNAMIC | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS |
| BFD_COMPRESS_GABI), |
| DYNAMIC | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS), |
/* section_flags: mask of all section flags */ |
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
/contrib/toolchain/binutils/bfd/elf32.c |
---|
1,5 → 1,6 |
/* ELF 32-bit executable support for BFD. |
Copyright (C) 1993-2015 Free Software Foundation, Inc. |
Copyright 1993, 2001, 2004, 2005, 2006, 2007, 2008, 2009 |
Free Software Foundation, Inc. |
This file is part of BFD, the Binary File Descriptor library. |
/contrib/toolchain/binutils/bfd/elf64-target.h |
---|
1,5 → 1,7 |
/* Target definitions for 64-bit ELF |
Copyright (C) 1993-2015 Free Software Foundation, Inc. |
Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, |
2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 |
Free Software Foundation, Inc. |
This file is part of BFD, the Binary File Descriptor library. |
49,9 → 51,6 |
#ifndef bfd_elf64_find_nearest_line |
#define bfd_elf64_find_nearest_line _bfd_elf_find_nearest_line |
#endif |
#ifndef bfd_elf64_find_line |
#define bfd_elf64_find_line _bfd_elf_find_line |
#endif |
#ifndef bfd_elf64_find_inliner_info |
#define bfd_elf64_find_inliner_info _bfd_elf_find_inliner_info |
#endif |
66,10 → 65,6 |
#ifndef bfd_elf64_get_symbol_info |
#define bfd_elf64_get_symbol_info _bfd_elf_get_symbol_info |
#endif |
#ifndef bfd_elf64_get_symbol_version_string |
#define bfd_elf64_get_symbol_version_string \ |
_bfd_elf_get_symbol_version_string |
#endif |
#define bfd_elf64_canonicalize_symtab _bfd_elf_canonicalize_symtab |
#define bfd_elf64_get_symtab_upper_bound _bfd_elf_get_symtab_upper_bound |
#define bfd_elf64_make_empty_symbol _bfd_elf_make_empty_symbol |
114,12 → 109,6 |
#ifndef elf_backend_default_execstack |
#define elf_backend_default_execstack 1 |
#endif |
#ifndef elf_backend_caches_rawsize |
#define elf_backend_caches_rawsize 0 |
#endif |
#ifndef elf_backend_extern_protected_data |
#define elf_backend_extern_protected_data 0 |
#endif |
#ifndef elf_backend_stack_align |
#define elf_backend_stack_align 16 |
#endif |
247,6 → 236,9 |
#ifndef bfd_elf64_bfd_link_hash_table_create |
#define bfd_elf64_bfd_link_hash_table_create _bfd_elf_link_hash_table_create |
#endif |
#ifndef bfd_elf64_bfd_link_hash_table_free |
#define bfd_elf64_bfd_link_hash_table_free _bfd_elf_link_hash_table_free |
#endif |
#ifndef bfd_elf64_bfd_link_add_symbols |
#define bfd_elf64_bfd_link_add_symbols bfd_elf_link_add_symbols |
#endif |
263,6 → 255,9 |
#define bfd_elf64_bfd_link_hash_table_create \ |
_bfd_generic_link_hash_table_create |
#endif |
#ifndef bfd_elf64_bfd_link_hash_table_free |
#define bfd_elf64_bfd_link_hash_table_free _bfd_generic_link_hash_table_free |
#endif |
#ifndef bfd_elf64_bfd_link_add_symbols |
#define bfd_elf64_bfd_link_add_symbols _bfd_generic_link_add_symbols |
#endif |
503,7 → 498,7 |
#define elf_backend_static_tls_alignment 1 |
#endif |
#ifndef elf_backend_post_process_headers |
#define elf_backend_post_process_headers _bfd_elf_post_process_headers |
#define elf_backend_post_process_headers NULL |
#endif |
#ifndef elf_backend_print_symbol_all |
#define elf_backend_print_symbol_all NULL |
538,9 → 533,6 |
#ifndef elf_backend_count_relocs |
#define elf_backend_count_relocs NULL |
#endif |
#ifndef elf_backend_sort_relocs_p |
#define elf_backend_sort_relocs_p NULL |
#endif |
#ifndef elf_backend_grok_prstatus |
#define elf_backend_grok_prstatus NULL |
#endif |
672,18 → 664,6 |
#define elf_backend_maybe_function_sym _bfd_elf_maybe_function_sym |
#endif |
#ifndef elf_backend_get_reloc_section |
#define elf_backend_get_reloc_section _bfd_elf_get_reloc_section |
#endif |
#ifndef elf_backend_compact_eh_encoding |
#define elf_backend_compact_eh_encoding NULL |
#endif |
#ifndef elf_backend_cant_unwind_opcode |
#define elf_backend_cant_unwind_opcode 0 |
#endif |
#ifndef elf_match_priority |
#define elf_match_priority \ |
(ELF_ARCH == bfd_arch_unknown ? 2 : ELF_OSABI == ELFOSABI_NONE ? 1 : 0) |
755,7 → 735,6 |
elf_backend_ignore_undef_symbol, |
elf_backend_emit_relocs, |
elf_backend_count_relocs, |
elf_backend_sort_relocs_p, |
elf_backend_grok_prstatus, |
elf_backend_grok_psinfo, |
elf_backend_write_core_note, |
781,7 → 760,6 |
elf_backend_hash_symbol, |
elf_backend_is_function_type, |
elf_backend_maybe_function_sym, |
elf_backend_get_reloc_section, |
elf_backend_link_order_error_handler, |
elf_backend_relplt_name, |
ELF_MACHINE_ALT1, |
796,8 → 774,6 |
elf_backend_obj_attrs_section_type, |
elf_backend_obj_attrs_order, |
elf_backend_obj_attrs_handle_unknown, |
elf_backend_compact_eh_encoding, |
elf_backend_cant_unwind_opcode, |
elf_backend_static_tls_alignment, |
elf_backend_stack_align, |
elf_backend_collect, |
818,9 → 794,7 |
elf_backend_want_got_sym, |
elf_backend_want_dynbss, |
elf_backend_want_p_paddr_set_to_zero, |
elf_backend_default_execstack, |
elf_backend_caches_rawsize, |
elf_backend_extern_protected_data |
elf_backend_default_execstack |
}; |
/* Forward declaration for use when initialising alternative_target field. */ |
845,8 → 819,7 |
/* object_flags: mask of all file flags */ |
(HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
| DYNAMIC | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS |
| BFD_COMPRESS_GABI), |
| DYNAMIC | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS), |
/* section_flags: mask of all section flags */ |
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
944,8 → 917,7 |
/* object_flags: mask of all file flags */ |
(HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
| DYNAMIC | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS |
| BFD_COMPRESS_GABI), |
| DYNAMIC | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS), |
/* section_flags: mask of all section flags */ |
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
/contrib/toolchain/binutils/bfd/elfcode.h |
---|
1,5 → 1,7 |
/* ELF executable support for BFD. |
Copyright (C) 1991-2015 Free Software Foundation, Inc. |
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, |
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 |
Free Software Foundation, Inc. |
Written by Fred Fish @ Cygnus Support, from information published |
in "UNIX System V Release 4, Programmers Guide: ANSI C and |
71,7 → 73,6 |
#include "bfdlink.h" |
#include "libbfd.h" |
#include "elf-bfd.h" |
#include "libiberty.h" |
/* Renaming structures, typedefs, macros and functions to be size-specific. */ |
#define Elf_External_Ehdr NAME(Elf,External_Ehdr) |
605,10 → 606,13 |
if (i_ehdrp->e_shoff != 0) |
{ |
file_ptr where = (file_ptr) i_ehdrp->e_shoff; |
bfd_signed_vma where = i_ehdrp->e_shoff; |
if (where != (file_ptr) where) |
goto got_wrong_format_error; |
/* Seek to the section header table in the file. */ |
if (bfd_seek (abfd, where, SEEK_SET) != 0) |
if (bfd_seek (abfd, (file_ptr) where, SEEK_SET) != 0) |
goto got_no_match; |
/* Read the first section header at index 0, and convert to internal |
654,10 → 658,12 |
goto got_wrong_format_error; |
where += (i_ehdrp->e_shnum - 1) * sizeof (x_shdr); |
if (where != (file_ptr) where) |
goto got_wrong_format_error; |
if ((bfd_size_type) where <= i_ehdrp->e_shoff) |
goto got_wrong_format_error; |
if (bfd_seek (abfd, where, SEEK_SET) != 0) |
if (bfd_seek (abfd, (file_ptr) where, SEEK_SET) != 0) |
goto got_no_match; |
if (bfd_bread (&x_shdr, sizeof x_shdr, abfd) != sizeof (x_shdr)) |
goto got_no_match; |
664,7 → 670,7 |
/* Back to where we were. */ |
where = i_ehdrp->e_shoff + sizeof (x_shdr); |
if (bfd_seek (abfd, where, SEEK_SET) != 0) |
if (bfd_seek (abfd, (file_ptr) where, SEEK_SET) != 0) |
goto got_no_match; |
} |
} |
676,10 → 682,6 |
Elf_Internal_Shdr *shdrp; |
unsigned int num_sec; |
#ifndef BFD64 |
if (i_ehdrp->e_shnum > ((bfd_size_type) -1) / sizeof (*i_shdrp)) |
goto got_wrong_format_error; |
#endif |
amt = sizeof (*i_shdrp) * i_ehdrp->e_shnum; |
i_shdrp = (Elf_Internal_Shdr *) bfd_alloc (abfd, amt); |
if (!i_shdrp) |
711,7 → 713,7 |
switch (ebd->elf_machine_code) |
{ |
case EM_386: |
case EM_IAMCU: |
case EM_486: |
case EM_X86_64: |
case EM_OLD_SPARCV9: |
case EM_SPARC32PLUS: |
770,11 → 772,7 |
Elf_Internal_Phdr *i_phdr; |
unsigned int i; |
#ifndef BFD64 |
if (i_ehdrp->e_phnum > ((bfd_size_type) -1) / sizeof (*i_phdr)) |
goto got_wrong_format_error; |
#endif |
amt = i_ehdrp->e_phnum * sizeof (*i_phdr); |
amt = i_ehdrp->e_phnum * sizeof (Elf_Internal_Phdr); |
elf_tdata (abfd)->phdr = (Elf_Internal_Phdr *) bfd_alloc (abfd, amt); |
if (elf_tdata (abfd)->phdr == NULL) |
goto got_no_match; |
1217,9 → 1215,10 |
for (isym = isymbuf + 1, sym = symbase; isym < isymend; isym++, sym++) |
{ |
memcpy (&sym->internal_elf_sym, isym, sizeof (Elf_Internal_Sym)); |
sym->symbol.the_bfd = abfd; |
sym->symbol.the_bfd = abfd; |
sym->symbol.name = bfd_elf_sym_name (abfd, hdr, isym, NULL); |
sym->symbol.value = isym->st_value; |
if (isym->st_shndx == SHN_UNDEF) |
1503,9 → 1502,7 |
rel_hdr2 = d->rela.hdr; |
reloc_count2 = rel_hdr2 ? NUM_SHDR_ENTRIES (rel_hdr2) : 0; |
/* PR 17512: file: 0b4f81b7. */ |
if (asect->reloc_count != reloc_count + reloc_count2) |
return FALSE; |
BFD_ASSERT (asect->reloc_count == reloc_count + reloc_count2); |
BFD_ASSERT ((rel_hdr && asect->rel_filepos == rel_hdr->sh_offset) |
|| (rel_hdr2 && asect->rel_filepos == rel_hdr2->sh_offset)); |
1591,25 → 1588,22 |
#endif |
/* Create a new BFD as if by bfd_openr. Rather than opening a file, |
reconstruct an ELF file by reading the segments out of remote |
memory based on the ELF file header at EHDR_VMA and the ELF program |
headers it points to. If non-zero, SIZE is the known extent of the |
object. If not null, *LOADBASEP is filled in with the difference |
between the VMAs from which the segments were read, and the VMAs |
the file headers (and hence BFD's idea of each section's VMA) put |
them at. |
reconstruct an ELF file by reading the segments out of remote memory |
based on the ELF file header at EHDR_VMA and the ELF program headers it |
points to. If not null, *LOADBASEP is filled in with the difference |
between the VMAs from which the segments were read, and the VMAs the |
file headers (and hence BFD's idea of each section's VMA) put them at. |
The function TARGET_READ_MEMORY is called to copy LEN bytes from |
the remote memory at target address VMA into the local buffer at |
MYADDR; it should return zero on success or an `errno' code on |
failure. TEMPL must be a BFD for a target with the word size and |
byte order found in the remote memory. */ |
The function TARGET_READ_MEMORY is called to copy LEN bytes from the |
remote memory at target address VMA into the local buffer at MYADDR; it |
should return zero on success or an `errno' code on failure. TEMPL must |
be a BFD for a target with the word size and byte order found in the |
remote memory. */ |
bfd * |
NAME(_bfd_elf,bfd_from_remote_memory) |
(bfd *templ, |
bfd_vma ehdr_vma, |
bfd_size_type size, |
bfd_vma *loadbasep, |
int (*target_read_memory) (bfd_vma, bfd_byte *, bfd_size_type)) |
{ |
1616,15 → 1610,15 |
Elf_External_Ehdr x_ehdr; /* Elf file header, external form */ |
Elf_Internal_Ehdr i_ehdr; /* Elf file header, internal form */ |
Elf_External_Phdr *x_phdrs; |
Elf_Internal_Phdr *i_phdrs, *last_phdr, *first_phdr; |
Elf_Internal_Phdr *i_phdrs, *last_phdr; |
bfd *nbfd; |
struct bfd_in_memory *bim; |
int contents_size; |
bfd_byte *contents; |
int err; |
unsigned int i; |
bfd_vma high_offset; |
bfd_vma shdr_end; |
bfd_vma loadbase; |
bfd_boolean loadbase_set; |
/* Read in the ELF header in external format. */ |
err = target_read_memory (ehdr_vma, (bfd_byte *) &x_ehdr, sizeof x_ehdr); |
1684,7 → 1678,10 |
x_phdrs = (Elf_External_Phdr *) |
bfd_malloc (i_ehdr.e_phnum * (sizeof *x_phdrs + sizeof *i_phdrs)); |
if (x_phdrs == NULL) |
{ |
bfd_set_error (bfd_error_no_memory); |
return NULL; |
} |
err = target_read_memory (ehdr_vma + i_ehdr.e_phoff, (bfd_byte *) x_phdrs, |
i_ehdr.e_phnum * sizeof x_phdrs[0]); |
if (err) |
1696,44 → 1693,34 |
} |
i_phdrs = (Elf_Internal_Phdr *) &x_phdrs[i_ehdr.e_phnum]; |
high_offset = 0; |
loadbase = 0; |
first_phdr = NULL; |
contents_size = 0; |
last_phdr = NULL; |
loadbase = ehdr_vma; |
loadbase_set = FALSE; |
for (i = 0; i < i_ehdr.e_phnum; ++i) |
{ |
elf_swap_phdr_in (templ, &x_phdrs[i], &i_phdrs[i]); |
if (i_phdrs[i].p_type == PT_LOAD) |
{ |
bfd_vma segment_end = i_phdrs[i].p_offset + i_phdrs[i].p_filesz; |
bfd_vma segment_end; |
segment_end = (i_phdrs[i].p_offset + i_phdrs[i].p_filesz |
+ i_phdrs[i].p_align - 1) & -i_phdrs[i].p_align; |
if (segment_end > (bfd_vma) contents_size) |
contents_size = segment_end; |
if (segment_end > high_offset) |
/* LOADADDR is the `Base address' from the gELF specification: |
`lowest p_vaddr value for a PT_LOAD segment' is P_VADDR from the |
first PT_LOAD as PT_LOADs are ordered by P_VADDR. */ |
if (!loadbase_set && (i_phdrs[i].p_offset & -i_phdrs[i].p_align) == 0) |
{ |
high_offset = segment_end; |
last_phdr = &i_phdrs[i]; |
loadbase = ehdr_vma - (i_phdrs[i].p_vaddr & -i_phdrs[i].p_align); |
loadbase_set = TRUE; |
} |
/* If this program header covers offset zero, where the file |
header sits, then we can figure out the loadbase. */ |
if (first_phdr == NULL) |
{ |
bfd_vma p_offset = i_phdrs[i].p_offset; |
bfd_vma p_vaddr = i_phdrs[i].p_vaddr; |
if (i_phdrs[i].p_align > 1) |
{ |
p_offset &= -i_phdrs[i].p_align; |
p_vaddr &= -i_phdrs[i].p_align; |
last_phdr = &i_phdrs[i]; |
} |
if (p_offset == 0) |
{ |
loadbase = ehdr_vma - p_vaddr; |
first_phdr = &i_phdrs[i]; |
} |
} |
} |
} |
if (high_offset == 0) |
if (last_phdr == NULL) |
{ |
/* There were no PT_LOAD segments, so we don't have anything to read. */ |
free (x_phdrs); |
1741,42 → 1728,27 |
return NULL; |
} |
shdr_end = 0; |
if (i_ehdr.e_shoff != 0 && i_ehdr.e_shnum != 0 && i_ehdr.e_shentsize != 0) |
/* Trim the last segment so we don't bother with zeros in the last page |
that are off the end of the file. However, if the extra bit in that |
page includes the section headers, keep them. */ |
if ((bfd_vma) contents_size > last_phdr->p_offset + last_phdr->p_filesz |
&& (bfd_vma) contents_size >= (i_ehdr.e_shoff |
+ i_ehdr.e_shnum * i_ehdr.e_shentsize)) |
{ |
shdr_end = i_ehdr.e_shoff + i_ehdr.e_shnum * i_ehdr.e_shentsize; |
if (last_phdr->p_filesz != last_phdr->p_memsz) |
{ |
/* If the last PT_LOAD header has a bss area then ld.so will |
have cleared anything past p_filesz, zapping the section |
headers. */ |
contents_size = last_phdr->p_offset + last_phdr->p_filesz; |
if ((bfd_vma) contents_size < (i_ehdr.e_shoff |
+ i_ehdr.e_shnum * i_ehdr.e_shentsize)) |
contents_size = i_ehdr.e_shoff + i_ehdr.e_shnum * i_ehdr.e_shentsize; |
} |
else if (size >= shdr_end) |
high_offset = size; |
else |
{ |
bfd_vma page_size = get_elf_backend_data (templ)->minpagesize; |
bfd_vma segment_end = last_phdr->p_offset + last_phdr->p_filesz; |
contents_size = last_phdr->p_offset + last_phdr->p_filesz; |
/* Assume we loaded full pages, allowing us to sometimes see |
section headers. */ |
if (page_size > 1 && shdr_end > segment_end) |
{ |
bfd_vma page_end = (segment_end + page_size - 1) & -page_size; |
if (page_end >= shdr_end) |
/* Whee, section headers covered. */ |
high_offset = shdr_end; |
} |
} |
} |
/* Now we know the size of the whole image we want read in. */ |
contents = (bfd_byte *) bfd_zmalloc (high_offset); |
contents = (bfd_byte *) bfd_zmalloc (contents_size); |
if (contents == NULL) |
{ |
free (x_phdrs); |
bfd_set_error (bfd_error_no_memory); |
return NULL; |
} |
1783,22 → 1755,13 |
for (i = 0; i < i_ehdr.e_phnum; ++i) |
if (i_phdrs[i].p_type == PT_LOAD) |
{ |
bfd_vma start = i_phdrs[i].p_offset; |
bfd_vma end = start + i_phdrs[i].p_filesz; |
bfd_vma vaddr = i_phdrs[i].p_vaddr; |
/* Extend the beginning of the first pt_load to cover file |
header and program headers, if we proved earlier that its |
aligned offset is 0. */ |
if (first_phdr == &i_phdrs[i]) |
{ |
vaddr -= start; |
start = 0; |
} |
/* Extend the end of the last pt_load to cover section headers. */ |
if (last_phdr == &i_phdrs[i]) |
end = high_offset; |
err = target_read_memory (loadbase + vaddr, |
bfd_vma start = i_phdrs[i].p_offset & -i_phdrs[i].p_align; |
bfd_vma end = (i_phdrs[i].p_offset + i_phdrs[i].p_filesz |
+ i_phdrs[i].p_align - 1) & -i_phdrs[i].p_align; |
if (end > (bfd_vma) contents_size) |
end = contents_size; |
err = target_read_memory ((loadbase + i_phdrs[i].p_vaddr) |
& -i_phdrs[i].p_align, |
contents + start, end - start); |
if (err) |
{ |
1813,7 → 1776,8 |
/* If the segments visible in memory didn't include the section headers, |
then clear them from the file header. */ |
if (high_offset < shdr_end) |
if ((bfd_vma) contents_size < (i_ehdr.e_shoff |
+ i_ehdr.e_shnum * i_ehdr.e_shentsize)) |
{ |
memset (&x_ehdr.e_shoff, 0, sizeof x_ehdr.e_shoff); |
memset (&x_ehdr.e_shnum, 0, sizeof x_ehdr.e_shnum); |
1829,6 → 1793,7 |
if (bim == NULL) |
{ |
free (contents); |
bfd_set_error (bfd_error_no_memory); |
return NULL; |
} |
nbfd = _bfd_new_bfd (); |
1836,11 → 1801,12 |
{ |
free (bim); |
free (contents); |
bfd_set_error (bfd_error_no_memory); |
return NULL; |
} |
nbfd->filename = xstrdup ("<in-memory>"); |
nbfd->filename = "<in-memory>"; |
nbfd->xvec = templ->xvec; |
bim->size = high_offset; |
bim->size = contents_size; |
bim->buffer = contents; |
nbfd->iostream = bim; |
nbfd->flags = BFD_IN_MEMORY; |
/contrib/toolchain/binutils/bfd/elfcore.h |
---|
1,5 → 1,6 |
/* ELF core file support for BFD. |
Copyright (C) 1995-2015 Free Software Foundation, Inc. |
Copyright 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2005, 2007, |
2008, 2010 Free Software Foundation, Inc. |
This file is part of BFD, the Binary File Descriptor library. |
188,10 → 189,13 |
{ |
Elf_External_Shdr x_shdr; |
Elf_Internal_Shdr i_shdr; |
file_ptr where = (file_ptr) i_ehdrp->e_shoff; |
bfd_signed_vma where = i_ehdrp->e_shoff; |
if (where != (file_ptr) where) |
goto wrong; |
/* Seek to the section header table in the file. */ |
if (bfd_seek (abfd, where, SEEK_SET) != 0) |
if (bfd_seek (abfd, (file_ptr) where, SEEK_SET) != 0) |
goto fail; |
/* Read the first section header at index 0, and convert to internal |
214,7 → 218,7 |
{ |
Elf_External_Phdr x_phdr; |
Elf_Internal_Phdr i_phdr; |
file_ptr where; |
bfd_signed_vma where; |
/* Check that we don't have a totally silly number of |
program headers. */ |
222,11 → 226,13 |
|| i_ehdrp->e_phnum > (unsigned int) -1 / sizeof (i_phdr)) |
goto wrong; |
where = (file_ptr)(i_ehdrp->e_phoff + (i_ehdrp->e_phnum - 1) * sizeof (x_phdr)); |
where = i_ehdrp->e_phoff + (i_ehdrp->e_phnum - 1) * sizeof (x_phdr); |
if (where != (file_ptr) where) |
goto wrong; |
if ((bfd_size_type) where <= i_ehdrp->e_phoff) |
goto wrong; |
if (bfd_seek (abfd, where, SEEK_SET) != 0) |
if (bfd_seek (abfd, (file_ptr) where, SEEK_SET) != 0) |
goto fail; |
if (bfd_bread (&x_phdr, sizeof (x_phdr), abfd) != sizeof (x_phdr)) |
goto fail; |
/contrib/toolchain/binutils/bfd/elflink.c |
---|
1,5 → 1,5 |
/* ELF linking support for BFD. |
Copyright (C) 1995-2015 Free Software Foundation, Inc. |
Copyright 1995-2013 Free Software Foundation, Inc. |
This file is part of BFD, the Binary File Descriptor library. |
20,7 → 20,6 |
#include "sysdep.h" |
#include "bfd.h" |
#include "bfd_stdint.h" |
#include "bfdlink.h" |
#include "libbfd.h" |
#define ARCH_SIZE 0 |
54,47 → 53,6 |
static bfd_boolean _bfd_elf_fix_symbol_flags |
(struct elf_link_hash_entry *, struct elf_info_failed *); |
asection * |
_bfd_elf_section_for_symbol (struct elf_reloc_cookie *cookie, |
unsigned long r_symndx, |
bfd_boolean discard) |
{ |
if (r_symndx >= cookie->locsymcount |
|| ELF_ST_BIND (cookie->locsyms[r_symndx].st_info) != STB_LOCAL) |
{ |
struct elf_link_hash_entry *h; |
h = cookie->sym_hashes[r_symndx - cookie->extsymoff]; |
while (h->root.type == bfd_link_hash_indirect |
|| h->root.type == bfd_link_hash_warning) |
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
if ((h->root.type == bfd_link_hash_defined |
|| h->root.type == bfd_link_hash_defweak) |
&& discarded_section (h->root.u.def.section)) |
return h->root.u.def.section; |
else |
return NULL; |
} |
else |
{ |
/* It's not a relocation against a global symbol, |
but it could be a relocation against a local |
symbol for a discarded section. */ |
asection *isec; |
Elf_Internal_Sym *isym; |
/* Need to: get the symbol; get the section. */ |
isym = &cookie->locsyms[r_symndx]; |
isec = bfd_section_from_elf_index (cookie->abfd, isym->st_shndx); |
if (isec != NULL |
&& discard ? discarded_section (isec) : 1) |
return isec; |
} |
return NULL; |
} |
/* Define a symbol in a dynamic linkage section. */ |
struct elf_link_hash_entry * |
118,19 → 76,19 |
} |
bh = &h->root; |
bed = get_elf_backend_data (abfd); |
if (!_bfd_generic_link_add_one_symbol (info, abfd, name, BSF_GLOBAL, |
sec, 0, NULL, FALSE, bed->collect, |
sec, 0, NULL, FALSE, |
get_elf_backend_data (abfd)->collect, |
&bh)) |
return NULL; |
h = (struct elf_link_hash_entry *) bh; |
h->def_regular = 1; |
h->non_elf = 0; |
h->root.linker_def = 1; |
h->type = STT_OBJECT; |
if (ELF_ST_VISIBILITY (h->other) != STV_INTERNAL) |
h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_HIDDEN; |
bed = get_elf_backend_data (abfd); |
(*bed->elf_backend_hide_symbol) (info, h, TRUE); |
return h; |
} |
246,7 → 204,7 |
/* A dynamically linked executable has a .interp section, but a |
shared library does not. */ |
if (bfd_link_executable (info) && !info->nointerp) |
if (info->executable) |
{ |
s = bfd_make_section_anyway_with_flags (abfd, ".interp", |
flags | SEC_READONLY); |
279,7 → 237,6 |
if (s == NULL |
|| ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align)) |
return FALSE; |
elf_hash_table (info)->dynsym = s; |
s = bfd_make_section_anyway_with_flags (abfd, ".dynstr", |
flags | SEC_READONLY); |
419,7 → 376,7 |
be needed, we can discard it later. We will never need this |
section when generating a shared object, since they do not use |
copy relocs. */ |
if (! bfd_link_pic (info)) |
if (! info->shared) |
{ |
s = bfd_make_section_anyway_with_flags (abfd, |
(bed->rela_plts_and_copies_p |
520,7 → 477,7 |
struct bfd_elf_dynamic_list *d = info->dynamic_list; |
/* It may be called more than once on the same H. */ |
if(h->dynamic || bfd_link_relocatable (info)) |
if(h->dynamic || info->relocatable) |
return; |
if ((info->dynamic_data |
624,7 → 581,7 |
/* STV_HIDDEN and STV_INTERNAL symbols must be STB_LOCAL in shared objects |
and executables. */ |
if (!bfd_link_relocatable (info) |
if (!info->relocatable |
&& h->dynindx != -1 |
&& (ELF_ST_VISIBILITY (h->other) == STV_HIDDEN |
|| ELF_ST_VISIBILITY (h->other) == STV_INTERNAL)) |
632,9 → 589,8 |
if ((h->def_dynamic |
|| h->ref_dynamic |
|| bfd_link_pic (info) |
|| (bfd_link_pde (info) |
&& elf_hash_table (info)->is_relocatable_executable)) |
|| info->shared |
|| (info->executable && elf_hash_table (info)->is_relocatable_executable)) |
&& h->dynindx == -1) |
{ |
if (! bfd_elf_link_record_dynamic_symbol (info, h)) |
804,7 → 760,6 |
asection *p) |
{ |
struct elf_link_hash_table *htab; |
asection *ip; |
switch (elf_section_data (p)->this_hdr.sh_type) |
{ |
820,9 → 775,18 |
if (htab->text_index_section != NULL) |
return p != htab->text_index_section && p != htab->data_index_section; |
return (htab->dynobj != NULL |
if (strcmp (p->name, ".got") == 0 |
|| strcmp (p->name, ".got.plt") == 0 |
|| strcmp (p->name, ".plt") == 0) |
{ |
asection *ip; |
if (htab->dynobj != NULL |
&& (ip = bfd_get_linker_section (htab->dynobj, p->name)) != NULL |
&& ip->output_section == p); |
&& ip->output_section == p) |
return TRUE; |
} |
return FALSE; |
/* There shouldn't be section relative relocations |
against any other section. */ |
844,8 → 808,7 |
{ |
unsigned long dynsymcount = 0; |
if (bfd_link_pic (info) |
|| elf_hash_table (info)->is_relocatable_executable) |
if (info->shared || elf_hash_table (info)->is_relocatable_executable) |
{ |
const struct elf_backend_data *bed = get_elf_backend_data (output_bfd); |
asection *p; |
888,31 → 851,48 |
static void |
elf_merge_st_other (bfd *abfd, struct elf_link_hash_entry *h, |
const Elf_Internal_Sym *isym, asection *sec, |
bfd_boolean definition, bfd_boolean dynamic) |
Elf_Internal_Sym *isym, bfd_boolean definition, |
bfd_boolean dynamic) |
{ |
const struct elf_backend_data *bed = get_elf_backend_data (abfd); |
/* If st_other has a processor-specific meaning, specific |
code might be needed here. */ |
code might be needed here. We never merge the visibility |
attribute with the one from a dynamic object. */ |
if (bed->elf_backend_merge_symbol_attribute) |
(*bed->elf_backend_merge_symbol_attribute) (h, isym, definition, |
dynamic); |
if (!dynamic) |
/* If this symbol has default visibility and the user has requested |
we not re-export it, then mark it as hidden. */ |
if (definition |
&& !dynamic |
&& (abfd->no_export |
|| (abfd->my_archive && abfd->my_archive->no_export)) |
&& ELF_ST_VISIBILITY (isym->st_other) != STV_INTERNAL) |
isym->st_other = (STV_HIDDEN |
| (isym->st_other & ~ELF_ST_VISIBILITY (-1))); |
if (!dynamic && ELF_ST_VISIBILITY (isym->st_other) != 0) |
{ |
unsigned symvis = ELF_ST_VISIBILITY (isym->st_other); |
unsigned hvis = ELF_ST_VISIBILITY (h->other); |
unsigned char hvis, symvis, other, nvis; |
/* Keep the most constraining visibility. Leave the remainder |
of the st_other field to elf_backend_merge_symbol_attribute. */ |
if (symvis - 1 < hvis - 1) |
h->other = symvis | (h->other & ~ELF_ST_VISIBILITY (-1)); |
/* Only merge the visibility. Leave the remainder of the |
st_other field to elf_backend_merge_symbol_attribute. */ |
other = h->other & ~ELF_ST_VISIBILITY (-1); |
/* Combine visibilities, using the most constraining one. */ |
hvis = ELF_ST_VISIBILITY (h->other); |
symvis = ELF_ST_VISIBILITY (isym->st_other); |
if (! hvis) |
nvis = symvis; |
else if (! symvis) |
nvis = hvis; |
else |
nvis = hvis < symvis ? hvis : symvis; |
h->other = other | nvis; |
} |
else if (definition |
&& ELF_ST_VISIBILITY (isym->st_other) != STV_DEFAULT |
&& (sec->flags & SEC_READONLY) == 0) |
h->protected_def = 1; |
} |
/* This function is called when we want to merge a new symbol with an |
942,8 → 922,7 |
bfd_boolean *skip, |
bfd_boolean *override, |
bfd_boolean *type_change_ok, |
bfd_boolean *size_change_ok, |
bfd_boolean *matched) |
bfd_boolean *size_change_ok) |
{ |
asection *sec, *oldsec; |
struct elf_link_hash_entry *h; |
954,7 → 933,6 |
bfd_boolean newdyn, olddyn, olddef, newdef, newdyncommon, olddyncommon; |
bfd_boolean newweak, oldweak, newfunc, oldfunc; |
const struct elf_backend_data *bed; |
char *new_version; |
*skip = FALSE; |
*override = FALSE; |
973,30 → 951,6 |
bed = get_elf_backend_data (abfd); |
/* NEW_VERSION is the symbol version of the new symbol. */ |
if (h->versioned != unversioned) |
{ |
/* Symbol version is unknown or versioned. */ |
new_version = strrchr (name, ELF_VER_CHR); |
if (new_version) |
{ |
if (h->versioned == unknown) |
{ |
if (new_version > name && new_version[-1] != ELF_VER_CHR) |
h->versioned = versioned_hidden; |
else |
h->versioned = versioned; |
} |
new_version += 1; |
if (new_version[0] == '\0') |
new_version = NULL; |
} |
else |
h->versioned = unversioned; |
} |
else |
new_version = NULL; |
/* For merging, we only care about real symbols. But we need to make |
sure that indirect symbol dynamic flags are updated. */ |
hi = h; |
1004,44 → 958,6 |
|| h->root.type == bfd_link_hash_warning) |
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
if (!*matched) |
{ |
if (hi == h || h->root.type == bfd_link_hash_new) |
*matched = TRUE; |
else |
{ |
/* OLD_HIDDEN is true if the existing symbol is only visible |
to the symbol with the same symbol version. NEW_HIDDEN is |
true if the new symbol is only visible to the symbol with |
the same symbol version. */ |
bfd_boolean old_hidden = h->versioned == versioned_hidden; |
bfd_boolean new_hidden = hi->versioned == versioned_hidden; |
if (!old_hidden && !new_hidden) |
/* The new symbol matches the existing symbol if both |
aren't hidden. */ |
*matched = TRUE; |
else |
{ |
/* OLD_VERSION is the symbol version of the existing |
symbol. */ |
char *old_version; |
if (h->versioned >= versioned) |
old_version = strrchr (h->root.root.string, |
ELF_VER_CHR) + 1; |
else |
old_version = NULL; |
/* The new symbol matches the existing symbol if they |
have the same symbol version. */ |
*matched = (old_version == new_version |
|| (old_version != NULL |
&& new_version != NULL |
&& strcmp (old_version, new_version) == 0)); |
} |
} |
} |
/* OLDBFD and OLDSEC are a BFD and an ASECTION associated with the |
existing symbol. */ |
1114,8 → 1030,6 |
} |
else |
{ |
/* Update the existing symbol only if they match. */ |
if (*matched) |
h->dynamic_def = 1; |
hi->dynamic_def = 1; |
} |
1173,30 → 1087,32 |
/* When we try to create a default indirect symbol from the dynamic |
definition with the default version, we skip it if its type and |
the type of existing regular definition mismatch. */ |
the type of existing regular definition mismatch. We only do it |
if the existing regular definition won't be dynamic. */ |
if (pold_alignment == NULL |
&& !info->shared |
&& !info->export_dynamic |
&& !h->ref_dynamic |
&& newdyn |
&& newdef |
&& !olddyn |
&& (((olddef || h->root.type == bfd_link_hash_common) |
&& (olddef || h->root.type == bfd_link_hash_common) |
&& ELF_ST_TYPE (sym->st_info) != h->type |
&& ELF_ST_TYPE (sym->st_info) != STT_NOTYPE |
&& h->type != STT_NOTYPE |
&& !(newfunc && oldfunc)) |
|| (olddef |
&& ((h->type == STT_GNU_IFUNC) |
!= (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC))))) |
{ |
*skip = TRUE; |
return TRUE; |
} |
/* Check TLS symbols. We don't check undefined symbols introduced |
by "ld -u" which have no type (and oldbfd NULL), and we don't |
check symbols from plugins because they also have no type. */ |
if (oldbfd != NULL |
&& (oldbfd->flags & BFD_PLUGIN) == 0 |
&& (abfd->flags & BFD_PLUGIN) == 0 |
/* Plugin symbol type isn't currently set. Stop bogus errors. */ |
if (oldbfd != NULL && (oldbfd->flags & BFD_PLUGIN) != 0) |
*type_change_ok = TRUE; |
/* Check TLS symbol. We don't check undefined symbol introduced by |
"ld -u". */ |
else if (oldbfd != NULL |
&& ELF_ST_TYPE (sym->st_info) != h->type |
&& (ELF_ST_TYPE (sym->st_info) == STT_TLS || h->type == STT_TLS)) |
{ |
1521,15 → 1437,12 |
if (!(oldbfd != NULL |
&& (oldbfd->flags & BFD_PLUGIN) != 0 |
&& (abfd->flags & BFD_PLUGIN) == 0)) |
{ |
newdef = FALSE; |
*skip = TRUE; |
} |
/* Merge st_other. If the symbol already has a dynamic index, |
but visibility says it should not be visible, turn it into a |
local symbol. */ |
elf_merge_st_other (abfd, h, sym, sec, newdef, newdyn); |
elf_merge_st_other (abfd, h, sym, newdef, newdyn); |
if (h->dynindx != -1) |
switch (ELF_ST_VISIBILITY (h->other)) |
{ |
1687,41 → 1600,14 |
char *p; |
size_t len, shortlen; |
asection *tmp_sec; |
bfd_boolean matched; |
if (h->versioned == unversioned || h->versioned == versioned_hidden) |
return TRUE; |
/* If this symbol has a version, and it is the default version, we |
create an indirect symbol from the default name to the fully |
decorated name. This will cause external references which do not |
specify a version to be bound to this version of the symbol. */ |
p = strchr (name, ELF_VER_CHR); |
if (h->versioned == unknown) |
{ |
if (p == NULL) |
{ |
h->versioned = unversioned; |
if (p == NULL || p[1] != ELF_VER_CHR) |
return TRUE; |
} |
else |
{ |
if (p[1] != ELF_VER_CHR) |
{ |
h->versioned = versioned_hidden; |
return TRUE; |
} |
else |
h->versioned = versioned; |
} |
} |
else |
{ |
/* PR ld/19073: We may see an unversioned definition after the |
default version. */ |
if (p == NULL) |
return TRUE; |
} |
bed = get_elf_backend_data (abfd); |
collect = bed->collect; |
1740,11 → 1626,10 |
actually going to define an indirect symbol. */ |
type_change_ok = FALSE; |
size_change_ok = FALSE; |
matched = TRUE; |
tmp_sec = sec; |
if (!_bfd_elf_merge_symbol (abfd, info, shortname, sym, &tmp_sec, &value, |
&hi, poldbfd, NULL, NULL, &skip, &override, |
&type_change_ok, &size_change_ok, &matched)) |
&type_change_ok, &size_change_ok)) |
return FALSE; |
if (skip) |
1752,18 → 1637,13 |
if (! override) |
{ |
/* Add the default symbol if not performing a relocatable link. */ |
if (! bfd_link_relocatable (info)) |
{ |
bh = &hi->root; |
if (! (_bfd_generic_link_add_one_symbol |
(info, abfd, shortname, BSF_INDIRECT, |
bfd_ind_section_ptr, |
(info, abfd, shortname, BSF_INDIRECT, bfd_ind_section_ptr, |
0, name, FALSE, collect, &bh))) |
return FALSE; |
hi = (struct elf_link_hash_entry *) bh; |
} |
} |
else |
{ |
/* In this case the symbol named SHORTNAME is overriding the |
1822,12 → 1702,6 |
ht = (struct elf_link_hash_entry *) hi->root.u.i.link; |
(*bed->elf_backend_copy_indirect_symbol) (info, ht, hi); |
/* A reference to the SHORTNAME symbol from a dynamic library |
will be satisfied by the versioned symbol at runtime. In |
effect, we have a reference to the versioned symbol. */ |
ht->ref_dynamic_nonweak |= hi->ref_dynamic_nonweak; |
hi->dynamic_def |= ht->dynamic_def; |
/* See if the new flags lead us to realize that the symbol must |
be dynamic. */ |
if (! *dynsym) |
1834,7 → 1708,7 |
{ |
if (! dynamic) |
{ |
if (! bfd_link_executable (info) |
if (! info->executable |
|| hi->def_dynamic |
|| hi->ref_dynamic) |
*dynsym = TRUE; |
1863,8 → 1737,8 |
size_change_ok = FALSE; |
tmp_sec = sec; |
if (!_bfd_elf_merge_symbol (abfd, info, shortname, sym, &tmp_sec, &value, |
&hi, poldbfd, NULL, NULL, &skip, &override, |
&type_change_ok, &size_change_ok, &matched)) |
&hi, NULL, NULL, NULL, &skip, &override, |
&type_change_ok, &size_change_ok)) |
return FALSE; |
if (skip) |
1897,8 → 1771,6 |
if (hi->root.type == bfd_link_hash_indirect) |
{ |
(*bed->elf_backend_copy_indirect_symbol) (info, h, hi); |
h->ref_dynamic_nonweak |= hi->ref_dynamic_nonweak; |
hi->dynamic_def |= h->dynamic_def; |
/* See if the new flags lead us to realize that the symbol |
must be dynamic. */ |
1906,7 → 1778,7 |
{ |
if (! dynamic) |
{ |
if (! bfd_link_executable (info) |
if (! info->executable |
|| hi->ref_dynamic) |
*dynsym = TRUE; |
} |
1972,9 → 1844,7 |
if (!h->def_dynamic |
|| h->def_regular |
|| h->dynindx == -1 |
|| h->verinfo.verdef == NULL |
|| (elf_dyn_lib_class (h->verinfo.verdef->vd_bfd) |
& (DYN_AS_NEEDED | DYN_DT_NEEDED | DYN_NO_NEEDED))) |
|| h->verinfo.verdef == NULL) |
return TRUE; |
/* See if we already know about this version. */ |
2074,14 → 1944,26 |
if (p != NULL && h->verinfo.vertree == NULL) |
{ |
struct bfd_elf_version_tree *t; |
bfd_boolean hidden; |
hidden = TRUE; |
/* There are two consecutive ELF_VER_CHR characters if this is |
not a hidden symbol. */ |
++p; |
if (*p == ELF_VER_CHR) |
{ |
hidden = FALSE; |
++p; |
} |
/* If there is no version string, we can just return out. */ |
if (*p == '\0') |
{ |
if (hidden) |
h->hidden = 1; |
return TRUE; |
} |
/* Look for the version. If we find it, it is no longer weak. */ |
for (t = sinfo->info->version_info; t != NULL; t = t->next) |
2129,7 → 2011,7 |
/* If we are building an application, we need to create a |
version node for this version. */ |
if (t == NULL && bfd_link_executable (info)) |
if (t == NULL && info->executable) |
{ |
struct bfd_elf_version_tree **pp; |
int version_index; |
2177,6 → 2059,9 |
sinfo->failed = TRUE; |
return FALSE; |
} |
if (hidden) |
h->hidden = 1; |
} |
/* If we don't have a version for this symbol, see if we can find |
2410,8 → 2295,8 |
{ |
struct elf_link_hash_entry **p; |
p = ((struct elf_link_hash_entry **) |
bfd_zmalloc (reldata->count * sizeof (*p))); |
p = (struct elf_link_hash_entry **) |
bfd_zmalloc (reldata->count * sizeof (struct elf_link_hash_entry *)); |
if (p == NULL) |
return FALSE; |
2491,7 → 2376,7 |
_bfd_elf_link_hash_fixup_symbol (struct bfd_link_info *info, |
struct elf_link_hash_entry *h) |
{ |
if (bfd_link_pie (info) |
if (info->pie |
&& h->dynindx == -1 |
&& h->root.type == bfd_link_hash_undefweak) |
return bfd_elf_link_record_dynamic_symbol (info, h); |
2594,7 → 2479,7 |
visibility. If the symbol has hidden or internal visibility, we |
will force it local. */ |
if (h->needs_plt |
&& bfd_link_pic (eif->info) |
&& eif->info->shared |
&& is_elf_hash_table (eif->info->hash) |
&& (SYMBOLIC_BIND (eif->info, h) |
|| ELF_ST_VISIBILITY (h->other) != STV_DEFAULT) |
2761,8 → 2646,7 |
DYNBSS. */ |
bfd_boolean |
_bfd_elf_adjust_dynamic_copy (struct bfd_link_info *info, |
struct elf_link_hash_entry *h, |
_bfd_elf_adjust_dynamic_copy (struct elf_link_hash_entry *h, |
asection *dynbss) |
{ |
unsigned int power_of_two; |
2801,15 → 2685,6 |
/* Increment the size of DYNBSS to make room for the symbol. */ |
dynbss->size += h->size; |
/* No error if extern_protected_data is true. */ |
if (h->protected_def |
&& (!info->extern_protected_data |
|| (info->extern_protected_data < 0 |
&& !get_elf_backend_data (dynbss->owner)->extern_protected_data))) |
info->callbacks->einfo |
(_("%P: copy reloc against protected `%T' is dangerous\n"), |
h->root.root.string); |
return TRUE; |
} |
2866,8 → 2741,7 |
/* Identify the cases where name binding rules say that a |
visible symbol resolves locally. */ |
binding_stays_local_p = (bfd_link_executable (info) |
|| SYMBOLIC_BIND (info, h)); |
binding_stays_local_p = info->executable || SYMBOLIC_BIND (info, h); |
switch (ELF_ST_VISIBILITY (h->other)) |
{ |
2952,7 → 2826,7 |
/* At this point, we know the symbol is defined and dynamic. In an |
executable it must resolve locally, likewise when building symbolic |
shared libraries. */ |
if (bfd_link_executable (info) || SYMBOLIC_BIND (info, h)) |
if (info->executable || SYMBOLIC_BIND (info, h)) |
return TRUE; |
/* Now deal with defined dynamic symbols in shared libraries. Ones |
2966,12 → 2840,8 |
bed = get_elf_backend_data (hash_table->dynobj); |
/* If extern_protected_data is false, STV_PROTECTED non-function |
symbols are local. */ |
if ((!info->extern_protected_data |
|| (info->extern_protected_data < 0 |
&& !bed->extern_protected_data)) |
&& !bed->is_function_type (h->type)) |
/* STV_PROTECTED non-function symbols are local. */ |
if (!bed->is_function_type (h->type)) |
return TRUE; |
/* Function pointer equality tests may require that STV_PROTECTED |
3070,11 → 2940,14 |
if (abfd == NULL) |
return FALSE; |
/* Return FALSE if the object has been claimed by plugin. */ |
if (abfd->plugin_format == bfd_plugin_yes) |
if (! bfd_check_format (abfd, bfd_object)) |
return FALSE; |
if (! bfd_check_format (abfd, bfd_object)) |
/* If we have already included the element containing this symbol in the |
link then we do not need to include it again. Just claim that any symbol |
it contains is not a definition, so that our caller will not decide to |
(re)include this element. */ |
if (abfd->archive_pass) |
return FALSE; |
/* Select the appropriate symbol table. */ |
3232,8 → 3105,7 |
on_needed_list (const char *soname, struct bfd_link_needed_list *needed) |
{ |
for (; needed != NULL; needed = needed->next) |
if ((elf_dyn_lib_class (needed->by) & DYN_AS_NEEDED) == 0 |
&& strcmp (soname, needed->name) == 0) |
if (strcmp (soname, needed->name) == 0) |
return TRUE; |
return FALSE; |
3254,7 → 3126,7 |
return vdiff > 0 ? 1 : -1; |
else |
{ |
int sdiff = h1->root.u.def.section->id - h2->root.u.def.section->id; |
long sdiff = h1->root.u.def.section->id - h2->root.u.def.section->id; |
if (sdiff != 0) |
return sdiff > 0 ? 1 : -1; |
} |
3446,7 → 3318,7 |
struct bfd_link_info *info, |
enum notice_asneeded_action act) |
{ |
return (*info->callbacks->notice) (info, NULL, NULL, ibfd, NULL, act, 0); |
return (*info->callbacks->notice) (info, NULL, ibfd, NULL, act, 0, NULL); |
} |
/* Add symbols from an ELF object file to the linker hash table. */ |
3485,7 → 3357,6 |
bfd_size_type old_dynstr_size = 0; |
size_t tabsize = 0; |
asection *s; |
bfd_boolean just_syms; |
htab = elf_hash_table (info); |
bed = get_elf_backend_data (abfd); |
3499,11 → 3370,11 |
/* You can't use -r against a dynamic object. Also, there's no |
hope of using a dynamic object which does not exactly match |
the format of the output file. */ |
if (bfd_link_relocatable (info) |
if (info->relocatable |
|| !is_elf_hash_table (htab) |
|| info->output_bfd->xvec != abfd->xvec) |
{ |
if (bfd_link_relocatable (info)) |
if (info->relocatable) |
bfd_set_error (bfd_error_invalid_operation); |
else |
bfd_set_error (bfd_error_wrong_format); |
3576,7 → 3447,7 |
FALSE, bed->collect, NULL))) |
goto error_return; |
if (bfd_link_executable (info)) |
if (!info->relocatable && info->executable) |
{ |
/* Clobber the section size so that the warning does |
not get copied into the output file. */ |
3589,9 → 3460,6 |
} |
} |
just_syms = ((s = abfd->sections) != NULL |
&& s->sec_info_type == SEC_INFO_TYPE_JUST_SYMS); |
add_needed = TRUE; |
if (! dynamic) |
{ |
3598,11 → 3466,9 |
/* If we are creating a shared library, create all the dynamic |
sections immediately. We need to attach them to something, |
so we attach them to this BFD, provided it is the right |
format and is not from ld --just-symbols. FIXME: If there |
are no input BFD's of the same format as the output, we can't |
make a shared library. */ |
if (!just_syms |
&& bfd_link_pic (info) |
format. FIXME: If there are no input BFD's of the same |
format as the output, we can't make a shared library. */ |
if (info->shared |
&& is_elf_hash_table (htab) |
&& info->output_bfd->xvec == abfd->xvec |
&& !htab->dynamic_sections_created) |
3622,7 → 3488,8 |
/* ld --just-symbols and dynamic objects don't mix very well. |
ld shouldn't allow it. */ |
if (just_syms) |
if ((s = abfd->sections) != NULL |
&& s->sec_info_type == SEC_INFO_TYPE_JUST_SYMS) |
abort (); |
/* If this dynamic lib was specified on the command line with |
3968,7 → 3835,6 |
bfd_boolean common; |
unsigned int old_alignment; |
bfd *old_bfd; |
bfd_boolean matched; |
override = FALSE; |
4054,7 → 3920,7 |
} |
else if (isym->st_shndx == SHN_COMMON |
&& ELF_ST_TYPE (isym->st_info) == STT_TLS |
&& !bfd_link_relocatable (info)) |
&& !info->relocatable) |
{ |
asection *tcomm = bfd_get_section_by_name (abfd, ".tcommon"); |
4103,7 → 3969,6 |
size_change_ok = FALSE; |
type_change_ok = bed->type_change_ok; |
old_weak = FALSE; |
matched = FALSE; |
old_alignment = 0; |
old_bfd = NULL; |
new_sec = sec; |
4221,28 → 4086,16 |
name = newname; |
} |
/* If this symbol has default visibility and the user has |
requested we not re-export it, then mark it as hidden. */ |
if (!bfd_is_und_section (sec) |
&& !dynamic |
&& abfd->no_export |
&& ELF_ST_VISIBILITY (isym->st_other) != STV_INTERNAL) |
isym->st_other = (STV_HIDDEN |
| (isym->st_other & ~ELF_ST_VISIBILITY (-1))); |
if (!_bfd_elf_merge_symbol (abfd, info, name, isym, &sec, &value, |
sym_hash, &old_bfd, &old_weak, |
&old_alignment, &skip, &override, |
&type_change_ok, &size_change_ok, |
&matched)) |
&type_change_ok, &size_change_ok)) |
goto error_free_vers; |
if (skip) |
continue; |
/* Override a definition only if the new symbol matches the |
existing one. */ |
if (override && matched) |
if (override) |
definition = FALSE; |
h = *sym_hash; |
4350,7 → 4203,7 |
/* If the indirect symbol has been forced local, don't |
make the real symbol dynamic. */ |
if ((h == hi || !hi->forced_local) |
&& (bfd_link_dll (info) |
&& (! info->executable |
|| h->def_dynamic |
|| h->ref_dynamic)) |
dynsym = TRUE; |
4499,12 → 4352,10 |
} |
/* Merge st_other field. */ |
elf_merge_st_other (abfd, h, isym, sec, definition, dynamic); |
elf_merge_st_other (abfd, h, isym, definition, dynamic); |
/* We don't want to make debug symbol dynamic. */ |
if (definition |
&& (sec->flags & SEC_DEBUGGING) |
&& !bfd_link_relocatable (info)) |
if (definition && (sec->flags & SEC_DEBUGGING) && !info->relocatable) |
dynsym = FALSE; |
/* Nor should we make plugin symbols dynamic. */ |
4528,8 → 4379,8 |
{ |
amt = ((isymend - isym + 1) |
* sizeof (struct elf_link_hash_entry *)); |
nondeflt_vers |
= (struct elf_link_hash_entry **) bfd_malloc (amt); |
nondeflt_vers = |
(struct elf_link_hash_entry **) bfd_malloc (amt); |
if (!nondeflt_vers) |
goto error_free_vers; |
} |
4576,9 → 4427,6 |
int ret; |
const char *soname = elf_dt_name (abfd); |
info->callbacks->minfo ("%!", soname, old_bfd, |
h->root.root.string); |
/* A symbol from a library loaded via DT_NEEDED of some |
other library is referenced by a regular object. |
Add a DT_NEEDED entry for it. Issue an error if |
4704,10 → 4552,9 |
old_tab = NULL; |
} |
/* Now that all the symbols from this input file are created, if |
not performing a relocatable link, handle .symver foo, foo@BAR |
such that any relocs against foo become foo@BAR. */ |
if (!bfd_link_relocatable (info) && nondeflt_vers != NULL) |
/* Now that all the symbols from this input file are created, handle |
.symver foo, foo@BAR such that any relocs against foo become foo@BAR. */ |
if (nondeflt_vers != NULL) |
{ |
bfd_size_type cnt, symidx; |
4837,7 → 4684,7 |
i = idx + 1; |
else |
{ |
int sdiff = slook->id - h->root.u.def.section->id; |
long sdiff = slook->id - h->root.u.def.section->id; |
if (sdiff < 0) |
j = idx; |
else if (sdiff > 0) |
5005,7 → 4852,8 |
/* Add this bfd to the loaded list. */ |
struct elf_link_loaded_list *n; |
n = (struct elf_link_loaded_list *) bfd_alloc (abfd, sizeof (*n)); |
n = (struct elf_link_loaded_list *) |
bfd_alloc (abfd, sizeof (struct elf_link_loaded_list)); |
if (n == NULL) |
goto error_return; |
n->abfd = abfd; |
5079,8 → 4927,20 |
} |
/* Add symbols from an ELF archive file to the linker hash table. We |
don't use _bfd_generic_link_add_archive_symbols because we need to |
handle versioned symbols. |
don't use _bfd_generic_link_add_archive_symbols because of a |
problem which arises on UnixWare. The UnixWare libc.so is an |
archive which includes an entry libc.so.1 which defines a bunch of |
symbols. The libc.so archive also includes a number of other |
object files, which also define symbols, some of which are the same |
as those defined in libc.so.1. Correct linking requires that we |
consider each object file in turn, and include it if it defines any |
symbols we need. _bfd_generic_link_add_archive_symbols does not do |
this; it looks through the list of undefined symbols, and includes |
any object file which defines them. When this algorithm is used on |
UnixWare, it winds up pulling in libc.so.1 early and defining a |
bunch of symbols. This means that some of the other objects in the |
archive are not included in the link, which is incorrect since they |
precede libc.so.1 in the archive. |
Fortunately, ELF archive handling is simpler than that done by |
_bfd_generic_link_add_archive_symbols, which has to allow for a.out |
5095,7 → 4955,8 |
elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info) |
{ |
symindex c; |
unsigned char *included = NULL; |
bfd_boolean *defined = NULL; |
bfd_boolean *included = NULL; |
carsym *symdefs; |
bfd_boolean loop; |
bfd_size_type amt; |
5119,10 → 4980,11 |
if (c == 0) |
return TRUE; |
amt = c; |
amt *= sizeof (*included); |
included = (unsigned char *) bfd_zmalloc (amt); |
if (included == NULL) |
return FALSE; |
amt *= sizeof (bfd_boolean); |
defined = (bfd_boolean *) bfd_zmalloc (amt); |
included = (bfd_boolean *) bfd_zmalloc (amt); |
if (defined == NULL || included == NULL) |
goto error_return; |
symdefs = bfd_ardata (abfd)->symdefs; |
bed = get_elf_backend_data (abfd); |
5147,7 → 5009,7 |
struct bfd_link_hash_entry *undefs_tail; |
symindex mark; |
if (included[i]) |
if (defined[i] || included[i]) |
continue; |
if (symdef->file_offset == last) |
{ |
5182,8 → 5044,7 |
else if (h->root.type != bfd_link_hash_undefined) |
{ |
if (h->root.type != bfd_link_hash_undefweak) |
/* Symbol must be defined. Don't check it again. */ |
included[i] = TRUE; |
defined[i] = TRUE; |
continue; |
} |
5195,6 → 5056,16 |
if (! bfd_check_format (element, bfd_object)) |
goto error_return; |
/* Doublecheck that we have not included this object |
already--it should be impossible, but there may be |
something wrong with the archive. */ |
if (element->archive_pass != 0) |
{ |
bfd_set_error (bfd_error_bad_value); |
goto error_return; |
} |
element->archive_pass = 1; |
undefs_tail = info->hash->undefs_tail; |
if (!(*info->callbacks |
5232,11 → 5103,14 |
} |
while (loop); |
free (defined); |
free (included); |
return TRUE; |
error_return: |
if (defined != NULL) |
free (defined); |
if (included != NULL) |
free (included); |
return FALSE; |
5274,6 → 5148,7 |
{ |
struct hash_codes_info *inf = (struct hash_codes_info *) data; |
const char *name; |
char *p; |
unsigned long ha; |
char *alc = NULL; |
5282,9 → 5157,7 |
return TRUE; |
name = h->root.root.string; |
if (h->versioned >= versioned) |
{ |
char *p = strchr (name, ELF_VER_CHR); |
p = strchr (name, ELF_VER_CHR); |
if (p != NULL) |
{ |
alc = (char *) bfd_malloc (p - name + 1); |
5297,7 → 5170,6 |
alc[p - name] = '\0'; |
name = alc; |
} |
} |
/* Compute the hash value. */ |
ha = bfd_elf_hash (name); |
5344,6 → 5216,7 |
{ |
struct collect_gnu_hash_codes *s = (struct collect_gnu_hash_codes *) data; |
const char *name; |
char *p; |
unsigned long ha; |
char *alc = NULL; |
5356,9 → 5229,7 |
return TRUE; |
name = h->root.root.string; |
if (h->versioned >= versioned) |
{ |
char *p = strchr (name, ELF_VER_CHR); |
p = strchr (name, ELF_VER_CHR); |
if (p != NULL) |
{ |
alc = (char *) bfd_malloc (p - name + 1); |
5371,7 → 5242,6 |
alc[p - name] = '\0'; |
name = alc; |
} |
} |
/* Compute the hash value. */ |
ha = bfd_elf_gnu_hash (name); |
5606,7 → 5476,7 |
{ |
bfd *ibfd; |
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next) |
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next) |
if (bfd_get_flavour (ibfd) == bfd_target_elf_flavour |
&& !_bfd_elf_fixup_group_sections (ibfd, bfd_abs_section_ptr)) |
return FALSE; |
5709,7 → 5579,7 |
elf_hash_table (info)->init_plt_refcount |
= elf_hash_table (info)->init_plt_offset; |
if (bfd_link_relocatable (info) |
if (info->relocatable |
&& !_bfd_elf_size_group_sections (info)) |
return FALSE; |
5733,7 → 5603,7 |
for (inputobj = info->input_bfds; |
inputobj; |
inputobj = inputobj->link.next) |
inputobj = inputobj->link_next) |
{ |
asection *s; |
5752,7 → 5622,7 |
} |
if (notesec || info->stacksize > 0) |
elf_stack_flags (output_bfd) = PF_R | PF_W | exec; |
if (notesec && exec && bfd_link_relocatable (info) |
if (notesec && exec && info->relocatable |
&& notesec->output_section != bfd_abs_section_ptr) |
notesec->output_section->flags |= SEC_CODE; |
} |
5770,7 → 5640,7 |
bfd_boolean all_defined; |
*sinterpptr = bfd_get_linker_section (dynobj, ".interp"); |
BFD_ASSERT (*sinterpptr != NULL || !bfd_link_executable (info) || info->nointerp); |
BFD_ASSERT (*sinterpptr != NULL || !info->executable); |
if (soname != NULL) |
{ |
5858,7 → 5728,7 |
/* If we are supposed to export all symbols into the dynamic symbol |
table (this is not the normal case), then do so. */ |
if (info->export_dynamic |
|| (bfd_link_executable (info) && info->dynamic)) |
|| (info->executable && info->dynamic)) |
{ |
elf_link_hash_traverse (elf_hash_table (info), |
_bfd_elf_export_symbol, |
5993,13 → 5863,13 |
if (s != NULL && s->linker_has_input) |
{ |
/* DT_PREINIT_ARRAY is not allowed in shared library. */ |
if (! bfd_link_executable (info)) |
if (! info->executable) |
{ |
bfd *sub; |
asection *o; |
for (sub = info->input_bfds; sub != NULL; |
sub = sub->link.next) |
sub = sub->link_next) |
if (bfd_get_flavour (sub) == bfd_target_elf_flavour) |
for (o = sub->sections; o != NULL; o = o->next) |
if (elf_section_data (o)->this_hdr.sh_type |
6057,9 → 5927,6 |
} |
} |
if (! _bfd_elf_maybe_strip_eh_frame_hdr (info)) |
return FALSE; |
/* The backend must work out the sizes of all the other dynamic |
sections. */ |
if (dynobj != NULL |
6067,6 → 5934,9 |
&& ! (*bed->elf_backend_size_dynamic_sections) (output_bfd, info)) |
return FALSE; |
if (! _bfd_elf_maybe_strip_eh_frame_hdr (info)) |
return FALSE; |
if (dynobj != NULL && elf_hash_table (info)->dynamic_sections_created) |
{ |
unsigned long section_sym_count; |
6327,7 → 6197,7 |
if (info->flags_1) |
{ |
if (bfd_link_executable (info)) |
if (info->executable) |
info->flags_1 &= ~ (DF_1_INITFIRST |
| DF_1_NODELETE |
| DF_1_NOOPEN); |
6553,7 → 6423,7 |
the final symbol table, because until then we do not know the |
correct value to give the symbols. We built the .dynstr |
section as we went along in elf_link_add_object_symbols. */ |
s = elf_hash_table (info)->dynsym; |
s = bfd_get_linker_section (dynobj, ".dynsym"); |
BFD_ASSERT (s != NULL); |
s->size = dynsymcount * bed->s->sizeof_sym; |
6821,7 → 6691,7 |
/* Finish SHF_MERGE section merging. */ |
bfd_boolean |
_bfd_elf_merge_sections (bfd *obfd, struct bfd_link_info *info) |
_bfd_elf_merge_sections (bfd *abfd, struct bfd_link_info *info) |
{ |
bfd *ibfd; |
asection *sec; |
6829,11 → 6699,8 |
if (!is_elf_hash_table (info->hash)) |
return FALSE; |
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next) |
if ((ibfd->flags & DYNAMIC) == 0 |
&& bfd_get_flavour (ibfd) == bfd_target_elf_flavour |
&& (elf_elfheader (ibfd)->e_ident[EI_CLASS] |
== get_elf_backend_data (obfd)->s->elfclass)) |
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next) |
if ((ibfd->flags & DYNAMIC) == 0) |
for (sec = ibfd->sections; sec != NULL; sec = sec->next) |
if ((sec->flags & SEC_MERGE) != 0 |
&& !bfd_is_abs_section (sec->output_section)) |
6841,7 → 6708,7 |
struct bfd_elf_section_data *secdata; |
secdata = elf_section_data (sec); |
if (! _bfd_add_merge_section (obfd, |
if (! _bfd_add_merge_section (abfd, |
&elf_hash_table (info)->merge_info, |
sec, &secdata->sec_info)) |
return FALSE; |
6850,7 → 6717,7 |
} |
if (elf_hash_table (info)->merge_info != NULL) |
_bfd_merge_sections (obfd, info, elf_hash_table (info)->merge_info, |
_bfd_merge_sections (abfd, info, elf_hash_table (info)->merge_info, |
merge_sections_remove_hook); |
return TRUE; |
} |
6907,11 → 6774,8 |
struct elf_link_hash_table *htab; |
/* Copy down any references that we may have already seen to the |
symbol which just became indirect if DIR isn't a hidden versioned |
symbol. */ |
symbol which just became indirect. */ |
if (dir->versioned != versioned_hidden) |
{ |
dir->ref_dynamic |= ind->ref_dynamic; |
dir->ref_regular |= ind->ref_regular; |
dir->ref_regular_nonweak |= ind->ref_regular_nonweak; |
6918,7 → 6782,6 |
dir->non_got_ref |= ind->non_got_ref; |
dir->needs_plt |= ind->needs_plt; |
dir->pointer_equality_needed |= ind->pointer_equality_needed; |
} |
if (ind->root.type != bfd_link_hash_indirect) |
return; |
7026,7 → 6889,6 |
free (ret); |
return NULL; |
} |
ret->root.hash_table_free = _bfd_elf_link_hash_table_free; |
return &ret->root; |
} |
7034,15 → 6896,13 |
/* Destroy an ELF linker hash table. */ |
void |
_bfd_elf_link_hash_table_free (bfd *obfd) |
_bfd_elf_link_hash_table_free (struct bfd_link_hash_table *hash) |
{ |
struct elf_link_hash_table *htab; |
htab = (struct elf_link_hash_table *) obfd->link.hash; |
struct elf_link_hash_table *htab = (struct elf_link_hash_table *) hash; |
if (htab->dynstr != NULL) |
_bfd_elf_strtab_free (htab->dynstr); |
_bfd_merge_sections_free (htab->merge_info); |
_bfd_generic_link_hash_table_free (obfd); |
_bfd_generic_link_hash_table_free (hash); |
} |
/* This is a hook for the ELF emulation code in the generic linker to |
7422,10 → 7282,10 |
if (count1 == 0 || count2 == 0 || count1 != count2) |
goto done; |
symtable1 |
= (struct elf_symbol *) bfd_malloc (count1 * sizeof (*symtable1)); |
symtable2 |
= (struct elf_symbol *) bfd_malloc (count2 * sizeof (*symtable2)); |
symtable1 = (struct elf_symbol *) |
bfd_malloc (count1 * sizeof (struct elf_symbol)); |
symtable2 = (struct elf_symbol *) |
bfd_malloc (count2 * sizeof (struct elf_symbol)); |
if (symtable1 == NULL || symtable2 == NULL) |
goto done; |
7551,7 → 7411,9 |
/* Output BFD. */ |
bfd *output_bfd; |
/* Symbol string table. */ |
struct elf_strtab_hash *symstrtab; |
struct bfd_strtab_hash *symstrtab; |
/* .dynsym section. */ |
asection *dynsym_sec; |
/* .hash section. */ |
asection *hash_sec; |
/* symbol version section (.gnu.version). */ |
7576,8 → 7438,16 |
/* Array large enough to hold a section pointer for each local |
symbol of any input BFD. */ |
asection **sections; |
/* Buffer for SHT_SYMTAB_SHNDX section. */ |
/* Buffer to hold swapped out symbols. */ |
bfd_byte *symbuf; |
/* And one for symbol section indices. */ |
Elf_External_Sym_Shndx *symshndxbuf; |
/* Number of swapped out symbols in buffer. */ |
size_t symbuf_count; |
/* Number of symbols which fit in symbuf. */ |
size_t symbuf_size; |
/* And same for symshndxbuf. */ |
size_t shndxbuf_size; |
/* Number of STT_FILE syms seen. */ |
size_t filesym_count; |
}; |
7588,7 → 7458,8 |
{ |
bfd_boolean failed; |
bfd_boolean localsyms; |
bfd_boolean file_sym_done; |
bfd_boolean need_second_pass; |
bfd_boolean second_pass; |
struct elf_final_link_info *flinfo; |
}; |
7938,34 → 7809,28 |
{ |
location += (size - chunksz); |
for (; size; size -= chunksz, location -= chunksz) |
for (; size; size -= chunksz, location -= chunksz, x >>= (chunksz * 8)) |
{ |
switch (chunksz) |
{ |
default: |
case 0: |
abort (); |
case 1: |
bfd_put_8 (input_bfd, x, location); |
x >>= 8; |
break; |
case 2: |
bfd_put_16 (input_bfd, x, location); |
x >>= 16; |
break; |
case 4: |
bfd_put_32 (input_bfd, x, location); |
/* Computed this way because x >>= 32 is undefined if x is a 32-bit value. */ |
x >>= 16; |
x >>= 16; |
break; |
case 8: |
#ifdef BFD64 |
case 8: |
bfd_put_64 (input_bfd, x, location); |
/* Computed this way because x >>= 64 is undefined if x is a 64-bit value. */ |
x >>= 32; |
x >>= 32; |
break; |
#else |
abort (); |
#endif |
default: |
abort (); |
break; |
} |
} |
8112,101 → 7977,14 |
return r; |
} |
/* Functions to read r_offset from external (target order) reloc |
entry. Faster than bfd_getl32 et al, because we let the compiler |
know the value is aligned. */ |
static bfd_vma |
ext32l_r_offset (const void *p) |
{ |
union aligned32 |
{ |
uint32_t v; |
unsigned char c[4]; |
}; |
const union aligned32 *a |
= (const union aligned32 *) &((const Elf32_External_Rel *) p)->r_offset; |
uint32_t aval = ( (uint32_t) a->c[0] |
| (uint32_t) a->c[1] << 8 |
| (uint32_t) a->c[2] << 16 |
| (uint32_t) a->c[3] << 24); |
return aval; |
} |
static bfd_vma |
ext32b_r_offset (const void *p) |
{ |
union aligned32 |
{ |
uint32_t v; |
unsigned char c[4]; |
}; |
const union aligned32 *a |
= (const union aligned32 *) &((const Elf32_External_Rel *) p)->r_offset; |
uint32_t aval = ( (uint32_t) a->c[0] << 24 |
| (uint32_t) a->c[1] << 16 |
| (uint32_t) a->c[2] << 8 |
| (uint32_t) a->c[3]); |
return aval; |
} |
#ifdef BFD_HOST_64_BIT |
static bfd_vma |
ext64l_r_offset (const void *p) |
{ |
union aligned64 |
{ |
uint64_t v; |
unsigned char c[8]; |
}; |
const union aligned64 *a |
= (const union aligned64 *) &((const Elf64_External_Rel *) p)->r_offset; |
uint64_t aval = ( (uint64_t) a->c[0] |
| (uint64_t) a->c[1] << 8 |
| (uint64_t) a->c[2] << 16 |
| (uint64_t) a->c[3] << 24 |
| (uint64_t) a->c[4] << 32 |
| (uint64_t) a->c[5] << 40 |
| (uint64_t) a->c[6] << 48 |
| (uint64_t) a->c[7] << 56); |
return aval; |
} |
static bfd_vma |
ext64b_r_offset (const void *p) |
{ |
union aligned64 |
{ |
uint64_t v; |
unsigned char c[8]; |
}; |
const union aligned64 *a |
= (const union aligned64 *) &((const Elf64_External_Rel *) p)->r_offset; |
uint64_t aval = ( (uint64_t) a->c[0] << 56 |
| (uint64_t) a->c[1] << 48 |
| (uint64_t) a->c[2] << 40 |
| (uint64_t) a->c[3] << 32 |
| (uint64_t) a->c[4] << 24 |
| (uint64_t) a->c[5] << 16 |
| (uint64_t) a->c[6] << 8 |
| (uint64_t) a->c[7]); |
return aval; |
} |
#endif |
/* When performing a relocatable link, the input relocations are |
preserved. But, if they reference global symbols, the indices |
referenced must be updated. Update all the relocations found in |
RELDATA. */ |
static bfd_boolean |
static void |
elf_link_adjust_relocs (bfd *abfd, |
struct bfd_elf_section_reloc_data *reldata, |
bfd_boolean sort) |
struct bfd_elf_section_reloc_data *reldata) |
{ |
unsigned int i; |
const struct elf_backend_data *bed = get_elf_backend_data (abfd); |
8262,120 → 8040,8 |
| (irela[j].r_info & r_type_mask)); |
(*swap_out) (abfd, irela, erela); |
} |
if (sort && count != 0) |
{ |
bfd_vma (*ext_r_off) (const void *); |
bfd_vma r_off; |
size_t elt_size; |
bfd_byte *base, *end, *p, *loc; |
bfd_byte *buf = NULL; |
if (bed->s->arch_size == 32) |
{ |
if (abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE) |
ext_r_off = ext32l_r_offset; |
else if (abfd->xvec->header_byteorder == BFD_ENDIAN_BIG) |
ext_r_off = ext32b_r_offset; |
else |
abort (); |
} |
else |
{ |
#ifdef BFD_HOST_64_BIT |
if (abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE) |
ext_r_off = ext64l_r_offset; |
else if (abfd->xvec->header_byteorder == BFD_ENDIAN_BIG) |
ext_r_off = ext64b_r_offset; |
else |
#endif |
abort (); |
} |
/* Must use a stable sort here. A modified insertion sort, |
since the relocs are mostly sorted already. */ |
elt_size = reldata->hdr->sh_entsize; |
base = reldata->hdr->contents; |
end = base + count * elt_size; |
if (elt_size > sizeof (Elf64_External_Rela)) |
abort (); |
/* Ensure the first element is lowest. This acts as a sentinel, |
speeding the main loop below. */ |
r_off = (*ext_r_off) (base); |
for (p = loc = base; (p += elt_size) < end; ) |
{ |
bfd_vma r_off2 = (*ext_r_off) (p); |
if (r_off > r_off2) |
{ |
r_off = r_off2; |
loc = p; |
} |
} |
if (loc != base) |
{ |
/* Don't just swap *base and *loc as that changes the order |
of the original base[0] and base[1] if they happen to |
have the same r_offset. */ |
bfd_byte onebuf[sizeof (Elf64_External_Rela)]; |
memcpy (onebuf, loc, elt_size); |
memmove (base + elt_size, base, loc - base); |
memcpy (base, onebuf, elt_size); |
} |
for (p = base + elt_size; (p += elt_size) < end; ) |
{ |
/* base to p is sorted, *p is next to insert. */ |
r_off = (*ext_r_off) (p); |
/* Search the sorted region for location to insert. */ |
loc = p - elt_size; |
while (r_off < (*ext_r_off) (loc)) |
loc -= elt_size; |
loc += elt_size; |
if (loc != p) |
{ |
/* Chances are there is a run of relocs to insert here, |
from one of more input files. Files are not always |
linked in order due to the way elf_link_input_bfd is |
called. See pr17666. */ |
size_t sortlen = p - loc; |
bfd_vma r_off2 = (*ext_r_off) (loc); |
size_t runlen = elt_size; |
size_t buf_size = 96 * 1024; |
while (p + runlen < end |
&& (sortlen <= buf_size |
|| runlen + elt_size <= buf_size) |
&& r_off2 > (*ext_r_off) (p + runlen)) |
runlen += elt_size; |
if (buf == NULL) |
{ |
buf = bfd_malloc (buf_size); |
if (buf == NULL) |
return FALSE; |
} |
if (runlen < sortlen) |
{ |
memcpy (buf, p, runlen); |
memmove (loc + runlen, loc, sortlen); |
memcpy (loc, buf, runlen); |
} |
else |
{ |
memcpy (buf, loc, sortlen); |
memmove (loc, p, runlen); |
memcpy (loc + runlen, buf, sortlen); |
} |
p += runlen - elt_size; |
} |
} |
/* Hashes are no longer valid. */ |
free (reldata->hashes); |
reldata->hashes = NULL; |
free (buf); |
} |
return TRUE; |
} |
struct elf_link_sort_rela |
{ |
union { |
8704,24 → 8370,48 |
return ret; |
} |
/* Add a symbol to the output symbol string table. */ |
/* Flush the output symbols to the file. */ |
static bfd_boolean |
elf_link_flush_output_syms (struct elf_final_link_info *flinfo, |
const struct elf_backend_data *bed) |
{ |
if (flinfo->symbuf_count > 0) |
{ |
Elf_Internal_Shdr *hdr; |
file_ptr pos; |
bfd_size_type amt; |
hdr = &elf_tdata (flinfo->output_bfd)->symtab_hdr; |
pos = hdr->sh_offset + hdr->sh_size; |
amt = flinfo->symbuf_count * bed->s->sizeof_sym; |
if (bfd_seek (flinfo->output_bfd, pos, SEEK_SET) != 0 |
|| bfd_bwrite (flinfo->symbuf, amt, flinfo->output_bfd) != amt) |
return FALSE; |
hdr->sh_size += amt; |
flinfo->symbuf_count = 0; |
} |
return TRUE; |
} |
/* Add a symbol to the output symbol table. */ |
static int |
elf_link_output_symstrtab (struct elf_final_link_info *flinfo, |
elf_link_output_sym (struct elf_final_link_info *flinfo, |
const char *name, |
Elf_Internal_Sym *elfsym, |
asection *input_sec, |
struct elf_link_hash_entry *h) |
{ |
bfd_byte *dest; |
Elf_External_Sym_Shndx *destshndx; |
int (*output_symbol_hook) |
(struct bfd_link_info *, const char *, Elf_Internal_Sym *, asection *, |
struct elf_link_hash_entry *); |
struct elf_link_hash_table *hash_table; |
const struct elf_backend_data *bed; |
bfd_size_type strtabsize; |
BFD_ASSERT (elf_onesymtab (flinfo->output_bfd)); |
bed = get_elf_backend_data (flinfo->output_bfd); |
output_symbol_hook = bed->elf_backend_link_output_symbol_hook; |
if (output_symbol_hook != NULL) |
8731,119 → 8421,49 |
return ret; |
} |
if (name == NULL |
|| *name == '\0' |
|| (input_sec->flags & SEC_EXCLUDE)) |
elfsym->st_name = (unsigned long) -1; |
if (name == NULL || *name == '\0') |
elfsym->st_name = 0; |
else if (input_sec->flags & SEC_EXCLUDE) |
elfsym->st_name = 0; |
else |
{ |
/* Call _bfd_elf_strtab_offset after _bfd_elf_strtab_finalize |
to get the final offset for st_name. */ |
elfsym->st_name |
= (unsigned long) _bfd_elf_strtab_add (flinfo->symstrtab, |
name, FALSE); |
elfsym->st_name = (unsigned long) _bfd_stringtab_add (flinfo->symstrtab, |
name, TRUE, FALSE); |
if (elfsym->st_name == (unsigned long) -1) |
return 0; |
} |
hash_table = elf_hash_table (flinfo->info); |
strtabsize = hash_table->strtabsize; |
if (strtabsize <= hash_table->strtabcount) |
if (flinfo->symbuf_count >= flinfo->symbuf_size) |
{ |
strtabsize += strtabsize; |
hash_table->strtabsize = strtabsize; |
strtabsize *= sizeof (*hash_table->strtab); |
hash_table->strtab |
= (struct elf_sym_strtab *) bfd_realloc (hash_table->strtab, |
strtabsize); |
if (hash_table->strtab == NULL) |
if (! elf_link_flush_output_syms (flinfo, bed)) |
return 0; |
} |
hash_table->strtab[hash_table->strtabcount].sym = *elfsym; |
hash_table->strtab[hash_table->strtabcount].dest_index |
= hash_table->strtabcount; |
hash_table->strtab[hash_table->strtabcount].destshndx_index |
= flinfo->symshndxbuf ? bfd_get_symcount (flinfo->output_bfd) : 0; |
bfd_get_symcount (flinfo->output_bfd) += 1; |
hash_table->strtabcount += 1; |
return 1; |
} |
/* Swap symbols out to the symbol table and flush the output symbols to |
the file. */ |
static bfd_boolean |
elf_link_swap_symbols_out (struct elf_final_link_info *flinfo) |
dest = flinfo->symbuf + flinfo->symbuf_count * bed->s->sizeof_sym; |
destshndx = flinfo->symshndxbuf; |
if (destshndx != NULL) |
{ |
struct elf_link_hash_table *hash_table = elf_hash_table (flinfo->info); |
bfd_size_type amt, i; |
const struct elf_backend_data *bed; |
bfd_byte *symbuf; |
Elf_Internal_Shdr *hdr; |
file_ptr pos; |
bfd_boolean ret; |
if (!hash_table->strtabcount) |
return TRUE; |
BFD_ASSERT (elf_onesymtab (flinfo->output_bfd)); |
bed = get_elf_backend_data (flinfo->output_bfd); |
amt = bed->s->sizeof_sym * hash_table->strtabcount; |
symbuf = (bfd_byte *) bfd_malloc (amt); |
if (symbuf == NULL) |
return FALSE; |
if (flinfo->symshndxbuf) |
if (bfd_get_symcount (flinfo->output_bfd) >= flinfo->shndxbuf_size) |
{ |
amt = (sizeof (Elf_External_Sym_Shndx) |
* (bfd_get_symcount (flinfo->output_bfd))); |
flinfo->symshndxbuf = (Elf_External_Sym_Shndx *) bfd_zmalloc (amt); |
if (flinfo->symshndxbuf == NULL) |
{ |
free (symbuf); |
return FALSE; |
} |
} |
bfd_size_type amt; |
for (i = 0; i < hash_table->strtabcount; i++) |
{ |
struct elf_sym_strtab *elfsym = &hash_table->strtab[i]; |
if (elfsym->sym.st_name == (unsigned long) -1) |
elfsym->sym.st_name = 0; |
else |
elfsym->sym.st_name |
= (unsigned long) _bfd_elf_strtab_offset (flinfo->symstrtab, |
elfsym->sym.st_name); |
bed->s->swap_symbol_out (flinfo->output_bfd, &elfsym->sym, |
((bfd_byte *) symbuf |
+ (elfsym->dest_index |
* bed->s->sizeof_sym)), |
(flinfo->symshndxbuf |
+ elfsym->destshndx_index)); |
amt = flinfo->shndxbuf_size * sizeof (Elf_External_Sym_Shndx); |
destshndx = (Elf_External_Sym_Shndx *) bfd_realloc (destshndx, |
amt * 2); |
if (destshndx == NULL) |
return 0; |
flinfo->symshndxbuf = destshndx; |
memset ((char *) destshndx + amt, 0, amt); |
flinfo->shndxbuf_size *= 2; |
} |
hdr = &elf_tdata (flinfo->output_bfd)->symtab_hdr; |
pos = hdr->sh_offset + hdr->sh_size; |
amt = hash_table->strtabcount * bed->s->sizeof_sym; |
if (bfd_seek (flinfo->output_bfd, pos, SEEK_SET) == 0 |
&& bfd_bwrite (symbuf, amt, flinfo->output_bfd) == amt) |
{ |
hdr->sh_size += amt; |
ret = TRUE; |
destshndx += bfd_get_symcount (flinfo->output_bfd); |
} |
else |
ret = FALSE; |
free (symbuf); |
bed->s->swap_symbol_out (flinfo->output_bfd, elfsym, dest, destshndx); |
flinfo->symbuf_count += 1; |
bfd_get_symcount (flinfo->output_bfd) += 1; |
free (hash_table->strtab); |
hash_table->strtab = NULL; |
return ret; |
return 1; |
} |
/* Return TRUE if the dynamic symbol SYM in ABFD is supported. */ |
9040,16 → 8660,6 |
const struct elf_backend_data *bed; |
long indx; |
int ret; |
/* A symbol is bound locally if it is forced local or it is locally |
defined, hidden versioned, not referenced by shared library and |
not exported when linking executable. */ |
bfd_boolean local_bind = (h->forced_local |
|| (bfd_link_executable (flinfo->info) |
&& !flinfo->info->export_dynamic |
&& !h->dynamic |
&& !h->ref_dynamic |
&& h->def_regular |
&& h->versioned == versioned_hidden)); |
if (h->root.type == bfd_link_hash_warning) |
{ |
9061,12 → 8671,17 |
/* Decide whether to output this symbol in this pass. */ |
if (eoinfo->localsyms) |
{ |
if (!local_bind) |
if (!h->forced_local) |
return TRUE; |
if (eoinfo->second_pass |
&& !((h->root.type == bfd_link_hash_defined |
|| h->root.type == bfd_link_hash_defweak) |
&& h->root.u.def.section->output_section != NULL)) |
return TRUE; |
} |
else |
{ |
if (local_bind) |
if (h->forced_local) |
return TRUE; |
} |
9109,7 → 8724,8 |
/* We should also warn if a forced local symbol is referenced from |
shared libraries. */ |
if (bfd_link_executable (flinfo->info) |
if (!flinfo->info->relocatable |
&& flinfo->info->executable |
&& h->forced_local |
&& h->ref_dynamic |
&& h->def_regular |
9163,8 → 8779,7 |
|| h->root.type == bfd_link_hash_defweak) |
&& ((flinfo->info->strip_discarded |
&& discarded_section (h->root.u.def.section)) |
|| ((h->root.u.def.section->flags & SEC_LINKER_CREATED) == 0 |
&& h->root.u.def.section->owner != NULL |
|| (h->root.u.def.section->owner != NULL |
&& (h->root.u.def.section->owner->flags & BFD_PLUGIN) != 0))) |
strip = TRUE; |
else if ((h->root.type == bfd_link_hash_undefined |
9187,7 → 8802,7 |
sym.st_value = 0; |
sym.st_size = h->size; |
sym.st_other = h->other; |
if (local_bind) |
if (h->forced_local) |
{ |
sym.st_info = ELF_ST_INFO (STB_LOCAL, h->type); |
/* Turn off visibility on local symbol. */ |
9223,6 → 8838,19 |
input_sec = h->root.u.def.section; |
if (input_sec->output_section != NULL) |
{ |
if (eoinfo->localsyms && flinfo->filesym_count == 1) |
{ |
bfd_boolean second_pass_sym |
= (input_sec->owner == flinfo->output_bfd |
|| input_sec->owner == NULL |
|| (input_sec->flags & SEC_LINKER_CREATED) != 0 |
|| (input_sec->owner->flags & BFD_LINKER_CREATED) != 0); |
eoinfo->need_second_pass |= second_pass_sym; |
if (eoinfo->second_pass != second_pass_sym) |
return TRUE; |
} |
sym.st_shndx = |
_bfd_elf_section_from_bfd_section (flinfo->output_bfd, |
input_sec->output_section); |
9240,7 → 8868,7 |
but in nonrelocatable files they are virtual |
addresses. */ |
sym.st_value = h->root.u.def.value + input_sec->output_offset; |
if (!bfd_link_relocatable (flinfo->info)) |
if (!flinfo->info->relocatable) |
{ |
sym.st_value += input_sec->output_section->vma; |
if (h->type == STT_TLS) |
9248,9 → 8876,15 |
asection *tls_sec = elf_hash_table (flinfo->info)->tls_sec; |
if (tls_sec != NULL) |
sym.st_value -= tls_sec->vma; |
else |
{ |
/* The TLS section may have been garbage collected. */ |
BFD_ASSERT (flinfo->info->gc_sections |
&& !input_sec->gc_mark); |
} |
} |
} |
} |
else |
{ |
BFD_ASSERT (input_sec->owner == NULL |
9284,10 → 8918,10 |
STT_GNU_IFUNC symbol must go through PLT. */ |
if ((h->type == STT_GNU_IFUNC |
&& h->def_regular |
&& !bfd_link_relocatable (flinfo->info)) |
&& !flinfo->info->relocatable) |
|| ((h->dynindx != -1 |
|| h->forced_local) |
&& ((bfd_link_pic (flinfo->info) |
&& ((flinfo->info->shared |
&& (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT |
|| h->root.type != bfd_link_hash_undefweak)) |
|| !h->forced_local) |
9337,7 → 8971,7 |
/* If a non-weak symbol with non-default visibility is not defined |
locally, it is a fatal error. */ |
if (!bfd_link_relocatable (flinfo->info) |
if (!flinfo->info->relocatable |
&& ELF_ST_VISIBILITY (sym.st_other) != STV_DEFAULT |
&& ELF_ST_BIND (sym.st_info) != STB_WEAK |
&& h->root.type == bfd_link_hash_undefined |
9360,7 → 8994,7 |
/* If this symbol should be put in the .dynsym section, then put it |
there now. We already know the symbol index. We also fill in |
the entry in the .hash section. */ |
if (elf_hash_table (flinfo->info)->dynsym != NULL |
if (flinfo->dynsym_sec != NULL |
&& h->dynindx != -1 |
&& elf_hash_table (flinfo->info)->dynamic_sections_created) |
{ |
9368,14 → 9002,8 |
/* Since there is no version information in the dynamic string, |
if there is no version info in symbol version section, we will |
have a run-time problem if not linking executable, referenced |
by shared library, not locally defined, or not bound locally. |
*/ |
if (h->verinfo.verdef == NULL |
&& !local_bind |
&& (!bfd_link_executable (flinfo->info) |
|| h->ref_dynamic |
|| !h->def_regular)) |
have a run-time problem. */ |
if (h->verinfo.verdef == NULL) |
{ |
char *p = strrchr (h->root.root.string, ELF_VER_CHR); |
9390,8 → 9018,7 |
} |
sym.st_name = h->dynstr_index; |
esym = (elf_hash_table (flinfo->info)->dynsym->contents |
+ h->dynindx * bed->s->sizeof_sym); |
esym = flinfo->dynsym_sec->contents + h->dynindx * bed->s->sizeof_sym; |
if (!check_dynsym (flinfo->output_bfd, &sym)) |
{ |
eoinfo->failed = TRUE; |
9429,9 → 9056,7 |
if (!h->def_regular) |
{ |
if (h->verinfo.verdef == NULL |
|| (elf_dyn_lib_class (h->verinfo.verdef->vd_bfd) |
& (DYN_AS_NEEDED | DYN_DT_NEEDED | DYN_NO_NEEDED))) |
if (h->verinfo.verdef == NULL) |
iversym.vs_vers = 0; |
else |
iversym.vs_vers = h->verinfo.verdef->vd_exp_refno + 1; |
9446,9 → 9071,7 |
iversym.vs_vers++; |
} |
/* Turn on VERSYM_HIDDEN only if the hidden versioned symbol is |
defined locally. */ |
if (h->versioned == versioned_hidden && h->def_regular) |
if (h->hidden) |
iversym.vs_vers |= VERSYM_HIDDEN; |
eversym = (Elf_External_Versym *) flinfo->symver_sec->contents; |
9462,32 → 9085,8 |
if (strip || (input_sec->flags & SEC_EXCLUDE) != 0) |
return TRUE; |
/* Output a FILE symbol so that following locals are not associated |
with the wrong input file. We need one for forced local symbols |
if we've seen more than one FILE symbol or when we have exactly |
one FILE symbol but global symbols are present in a file other |
than the one with the FILE symbol. We also need one if linker |
defined symbols are present. In practice these conditions are |
always met, so just emit the FILE symbol unconditionally. */ |
if (eoinfo->localsyms |
&& !eoinfo->file_sym_done |
&& eoinfo->flinfo->filesym_count != 0) |
{ |
Elf_Internal_Sym fsym; |
memset (&fsym, 0, sizeof (fsym)); |
fsym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FILE); |
fsym.st_shndx = SHN_ABS; |
if (!elf_link_output_symstrtab (eoinfo->flinfo, NULL, &fsym, |
bfd_und_section_ptr, NULL)) |
return FALSE; |
eoinfo->file_sym_done = TRUE; |
} |
indx = bfd_get_symcount (flinfo->output_bfd); |
ret = elf_link_output_symstrtab (flinfo, h->root.root.string, &sym, |
input_sec, h); |
ret = elf_link_output_sym (flinfo, h->root.root.string, &sym, input_sec, h); |
if (ret == 0) |
{ |
eoinfo->failed = TRUE; |
9513,7 → 9112,6 |
{ |
case SEC_INFO_TYPE_STABS: |
case SEC_INFO_TYPE_EH_FRAME: |
case SEC_INFO_TYPE_EH_FRAME_ENTRY: |
return TRUE; |
default: |
break; |
9753,8 → 9351,7 |
&& (bfd_hash_lookup (flinfo->info->keep_hash, name, FALSE, FALSE) |
== NULL)) |
|| (((flinfo->info->discard == discard_sec_merge |
&& (isec->flags & SEC_MERGE) |
&& !bfd_link_relocatable (flinfo->info)) |
&& (isec->flags & SEC_MERGE) && !flinfo->info->relocatable) |
|| flinfo->info->discard == discard_l) |
&& bfd_is_local_label_name (input_bfd, name))) |
continue; |
9761,10 → 9358,6 |
if (ELF_ST_TYPE (isym->st_info) == STT_FILE) |
{ |
if (input_bfd->lto_output) |
/* -flto puts a temp file name here. This means builds |
are not reproducible. Discard the symbol. */ |
continue; |
have_file_sym = TRUE; |
flinfo->filesym_count += 1; |
} |
9781,11 → 9374,8 |
memset (&osym, 0, sizeof (osym)); |
osym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FILE); |
osym.st_shndx = SHN_ABS; |
if (!elf_link_output_symstrtab (flinfo, |
(input_bfd->lto_output ? NULL |
: input_bfd->filename), |
&osym, bfd_abs_section_ptr, |
NULL)) |
if (!elf_link_output_sym (flinfo, input_bfd->filename, &osym, |
bfd_abs_section_ptr, NULL)) |
return FALSE; |
} |
9805,7 → 9395,7 |
output_section. Any special sections must be set up to meet |
these requirements. */ |
osym.st_value += isec->output_offset; |
if (!bfd_link_relocatable (flinfo->info)) |
if (!flinfo->info->relocatable) |
{ |
osym.st_value += isec->output_section->vma; |
if (ELF_ST_TYPE (osym.st_info) == STT_TLS) |
9817,7 → 9407,7 |
} |
indx = bfd_get_symcount (output_bfd); |
ret = elf_link_output_symstrtab (flinfo, name, &osym, isec, NULL); |
ret = elf_link_output_sym (flinfo, name, &osym, isec, NULL); |
if (ret == 0) |
return FALSE; |
else if (ret == 1) |
9849,7 → 9439,7 |
continue; |
} |
if (bfd_link_relocatable (flinfo->info) |
if (flinfo->info->relocatable |
&& (o->flags & (SEC_LINKER_CREATED | SEC_GROUP)) == SEC_GROUP) |
{ |
/* Deal with the group signature symbol. */ |
9900,8 → 9490,7 |
sym.st_value += o->output_offset; |
indx = bfd_get_symcount (output_bfd); |
ret = elf_link_output_symstrtab (flinfo, name, &sym, o, |
NULL); |
ret = elf_link_output_sym (flinfo, name, &sym, o, NULL); |
if (ret == 0) |
return FALSE; |
else if (ret == 1) |
9930,16 → 9519,7 |
file, so the contents field will not have been set by any of |
the routines which work on output files. */ |
if (elf_section_data (o)->this_hdr.contents != NULL) |
{ |
contents = elf_section_data (o)->this_hdr.contents; |
if (bed->caches_rawsize |
&& o->rawsize != 0 |
&& o->rawsize < o->size) |
{ |
memcpy (flinfo->contents, contents, o->rawsize); |
contents = flinfo->contents; |
} |
} |
else |
{ |
contents = flinfo->contents; |
10036,24 → 9616,6 |
s_type = h->type; |
/* If a plugin symbol is referenced from a non-IR file, |
mark the symbol as undefined. Note that the |
linker may attach linker created dynamic sections |
to the plugin bfd. Symbols defined in linker |
created sections are not plugin symbols. */ |
if (h->root.non_ir_ref |
&& (h->root.type == bfd_link_hash_defined |
|| h->root.type == bfd_link_hash_defweak) |
&& (h->root.u.def.section->flags |
& SEC_LINKER_CREATED) == 0 |
&& h->root.u.def.section->owner != NULL |
&& (h->root.u.def.section->owner->flags |
& BFD_PLUGIN) != 0) |
{ |
h->root.type = bfd_link_hash_undefined; |
h->root.u.undef.abfd = h->root.u.def.section->owner; |
} |
ps = NULL; |
if (h->root.type == bfd_link_hash_defined |
|| h->root.type == bfd_link_hash_defweak) |
10072,7 → 9634,7 |
} |
if ((s_type == STT_RELC || s_type == STT_SRELC) |
&& !bfd_link_relocatable (flinfo->info)) |
&& !flinfo->info->relocatable) |
{ |
bfd_vma val; |
bfd_vma dot = (rel->r_offset |
10162,7 → 9724,7 |
return FALSE; |
if (ret == 2 |
|| bfd_link_relocatable (flinfo->info) |
|| flinfo->info->relocatable |
|| flinfo->info->emitrelocations) |
{ |
Elf_Internal_Rela *irela; |
10193,7 → 9755,7 |
rel_hash_list = rel_hash; |
rela_hash_list = NULL; |
last_offset = o->output_offset; |
if (!bfd_link_relocatable (flinfo->info)) |
if (!flinfo->info->relocatable) |
last_offset += o->output_section->vma; |
for (next_erel = 0; irela < irelaend; irela++, next_erel++) |
{ |
10233,7 → 9795,7 |
irela->r_offset += o->output_offset; |
/* Relocs in an executable have to be virtual addresses. */ |
if (!bfd_link_relocatable (flinfo->info)) |
if (!flinfo->info->relocatable) |
irela->r_offset += o->output_section->vma; |
last_offset = irela->r_offset; |
10361,7 → 9923,7 |
return FALSE; |
sym.st_value += sec->output_offset; |
if (!bfd_link_relocatable (flinfo->info)) |
if (!flinfo->info->relocatable) |
{ |
sym.st_value += osec->vma; |
if (ELF_ST_TYPE (sym.st_info) == STT_TLS) |
10376,8 → 9938,7 |
} |
indx = bfd_get_symcount (output_bfd); |
ret = elf_link_output_symstrtab (flinfo, name, |
&sym, sec, |
ret = elf_link_output_sym (flinfo, name, &sym, sec, |
NULL); |
if (ret == 0) |
return FALSE; |
10448,14 → 10009,6 |
return FALSE; |
} |
break; |
case SEC_INFO_TYPE_EH_FRAME_ENTRY: |
{ |
if (! _bfd_elf_write_section_eh_frame_entry (output_bfd, |
flinfo->info, |
o, contents)) |
return FALSE; |
} |
break; |
default: |
{ |
/* FIXME: octets_per_byte. */ |
10599,7 → 10152,7 |
size = (bfd_size_type) bfd_get_reloc_size (howto); |
buf = (bfd_byte *) bfd_zmalloc (size); |
if (buf == NULL && size != 0) |
if (buf == NULL) |
return FALSE; |
rstat = _bfd_relocate_contents (howto, output_bfd, addend, buf); |
switch (rstat) |
10637,7 → 10190,7 |
relocatable file, and is a virtual address in an executable |
file. */ |
offset = link_order->offset; |
if (! bfd_link_relocatable (info)) |
if (! info->relocatable) |
offset += output_section->vma; |
for (i = 0; i < bed->s->int_rels_per_ext_rel; i++) |
10825,7 → 10378,7 |
asection *o; |
if (flinfo->symstrtab != NULL) |
_bfd_elf_strtab_free (flinfo->symstrtab); |
_bfd_stringtab_free (flinfo->symstrtab); |
if (flinfo->contents != NULL) |
free (flinfo->contents); |
if (flinfo->external_relocs != NULL) |
10842,6 → 10395,8 |
free (flinfo->indices); |
if (flinfo->sections != NULL) |
free (flinfo->sections); |
if (flinfo->symbuf != NULL) |
free (flinfo->symbuf); |
if (flinfo->symshndxbuf != NULL) |
free (flinfo->symshndxbuf); |
for (o = obfd->sections; o != NULL; o = o->next) |
10871,10 → 10426,12 |
bfd_size_type max_internal_reloc_count; |
bfd_size_type max_sym_count; |
bfd_size_type max_sym_shndx_count; |
file_ptr off; |
Elf_Internal_Sym elfsym; |
unsigned int i; |
Elf_Internal_Shdr *symtab_hdr; |
Elf_Internal_Shdr *symtab_shndx_hdr; |
Elf_Internal_Shdr *symstrtab_hdr; |
const struct elf_backend_data *bed = get_elf_backend_data (abfd); |
struct elf_outext_info eoinfo; |
bfd_boolean merged; |
10888,28 → 10445,30 |
if (! is_elf_hash_table (info->hash)) |
return FALSE; |
if (bfd_link_pic (info)) |
if (info->shared) |
abfd->flags |= DYNAMIC; |
dynamic = elf_hash_table (info)->dynamic_sections_created; |
dynobj = elf_hash_table (info)->dynobj; |
emit_relocs = (bfd_link_relocatable (info) |
emit_relocs = (info->relocatable |
|| info->emitrelocations); |
flinfo.info = info; |
flinfo.output_bfd = abfd; |
flinfo.symstrtab = _bfd_elf_strtab_init (); |
flinfo.symstrtab = _bfd_elf_stringtab_init (); |
if (flinfo.symstrtab == NULL) |
return FALSE; |
if (! dynamic) |
{ |
flinfo.dynsym_sec = NULL; |
flinfo.hash_sec = NULL; |
flinfo.symver_sec = NULL; |
} |
else |
{ |
flinfo.dynsym_sec = bfd_get_linker_section (dynobj, ".dynsym"); |
flinfo.hash_sec = bfd_get_linker_section (dynobj, ".hash"); |
/* Note that dynsym_sec can be NULL (on VMS). */ |
flinfo.symver_sec = bfd_get_linker_section (dynobj, ".gnu.version"); |
10924,7 → 10483,10 |
flinfo.internal_syms = NULL; |
flinfo.indices = NULL; |
flinfo.sections = NULL; |
flinfo.symbuf = NULL; |
flinfo.symshndxbuf = NULL; |
flinfo.symbuf_count = 0; |
flinfo.shndxbuf_size = 0; |
flinfo.filesym_count = 0; |
/* The object attributes have been merged. Remove the input |
11005,7 → 10567,7 |
to count particular types of relocs. Of course, |
reloc sections themselves can't have relocations. */ |
reloc_count = 0; |
else if (emit_relocs) |
else if (info->relocatable || info->emitrelocations) |
reloc_count = sec->reloc_count; |
else if (bed->elf_backend_count_relocs) |
reloc_count = (*bed->elf_backend_count_relocs) (info, sec); |
11032,7 → 10594,7 |
max_sym_count = sym_count; |
if (sym_count > max_sym_shndx_count |
&& elf_symtab_shndx_list (sec->owner) != NULL) |
&& elf_symtab_shndx (sec->owner) != 0) |
max_sym_shndx_count = sym_count; |
if ((sec->flags & SEC_RELOC) != 0) |
11057,7 → 10619,8 |
o->reloc_count += reloc_count; |
if (p->type == bfd_indirect_link_order && emit_relocs) |
if (p->type == bfd_indirect_link_order |
&& (info->relocatable || info->emitrelocations)) |
{ |
if (esdi->rel.hdr) |
esdo->rel.count += NUM_SHDR_ENTRIES (esdi->rel.hdr); |
11092,7 → 10655,7 |
o->vma = 0; |
} |
if (! bfd_link_relocatable (info) && merged) |
if (! info->relocatable && merged) |
elf_link_hash_traverse (elf_hash_table (info), |
_bfd_elf_link_sec_merge_syms, abfd); |
11099,7 → 10662,7 |
/* Figure out the file positions for everything but the symbol table |
and the relocs. We set symcount to force assign_section_numbers |
to create a symbol table. */ |
bfd_get_symcount (abfd) = info->strip != strip_all || emit_relocs; |
bfd_get_symcount (abfd) = info->strip == strip_all ? 0 : 1; |
BFD_ASSERT (! abfd->output_has_begun); |
if (! _bfd_elf_compute_section_file_positions (abfd, info)) |
goto error_return; |
11123,27 → 10686,14 |
to count upwards while actually outputting the relocations. */ |
esdo->rel.count = 0; |
esdo->rela.count = 0; |
if (esdo->this_hdr.sh_offset == (file_ptr) -1) |
{ |
/* Cache the section contents so that they can be compressed |
later. Use bfd_malloc since it will be freed by |
bfd_compress_section_contents. */ |
unsigned char *contents = esdo->this_hdr.contents; |
if ((o->flags & SEC_ELF_COMPRESS) == 0 || contents != NULL) |
abort (); |
contents |
= (unsigned char *) bfd_malloc (esdo->this_hdr.sh_size); |
if (contents == NULL) |
goto error_return; |
esdo->this_hdr.contents = contents; |
} |
} |
_bfd_elf_assign_file_positions_for_relocs (abfd); |
/* We have now assigned file positions for all the sections except |
.symtab, .strtab, and non-loaded reloc sections. We start the |
.symtab section at the current file position, and write directly |
to it. We build the .strtab section in memory. */ |
.symtab and .strtab. We start the .symtab section at the current |
file position, and write directly to it. We build the .strtab |
section in memory. */ |
bfd_get_symcount (abfd) = 0; |
symtab_hdr = &elf_tdata (abfd)->symtab_hdr; |
/* sh_name is set in prep_headers. */ |
11155,31 → 10705,40 |
/* sh_offset is set just below. */ |
symtab_hdr->sh_addralign = (bfd_vma) 1 << bed->s->log_file_align; |
if (max_sym_count < 20) |
max_sym_count = 20; |
elf_hash_table (info)->strtabsize = max_sym_count; |
amt = max_sym_count * sizeof (struct elf_sym_strtab); |
elf_hash_table (info)->strtab |
= (struct elf_sym_strtab *) bfd_malloc (amt); |
if (elf_hash_table (info)->strtab == NULL) |
goto error_return; |
/* The real buffer will be allocated in elf_link_swap_symbols_out. */ |
flinfo.symshndxbuf |
= (elf_numsections (abfd) > (SHN_LORESERVE & 0xFFFF) |
? (Elf_External_Sym_Shndx *) -1 : NULL); |
off = elf_next_file_pos (abfd); |
off = _bfd_elf_assign_file_position_for_section (symtab_hdr, off, TRUE); |
if (info->strip != strip_all || emit_relocs) |
{ |
file_ptr off = elf_next_file_pos (abfd); |
_bfd_elf_assign_file_position_for_section (symtab_hdr, off, TRUE); |
/* Note that at this point elf_next_file_pos (abfd) is |
incorrect. We do not yet know the size of the .symtab section. |
We correct next_file_pos below, after we do know the size. */ |
/* Allocate a buffer to hold swapped out symbols. This is to avoid |
continuously seeking to the right position in the file. */ |
if (! info->keep_memory || max_sym_count < 20) |
flinfo.symbuf_size = 20; |
else |
flinfo.symbuf_size = max_sym_count; |
amt = flinfo.symbuf_size; |
amt *= bed->s->sizeof_sym; |
flinfo.symbuf = (bfd_byte *) bfd_malloc (amt); |
if (flinfo.symbuf == NULL) |
goto error_return; |
if (elf_numsections (abfd) > (SHN_LORESERVE & 0xFFFF)) |
{ |
/* Wild guess at number of output symbols. realloc'd as needed. */ |
amt = 2 * max_sym_count + elf_numsections (abfd) + 1000; |
flinfo.shndxbuf_size = amt; |
amt *= sizeof (Elf_External_Sym_Shndx); |
flinfo.symshndxbuf = (Elf_External_Sym_Shndx *) bfd_zmalloc (amt); |
if (flinfo.symshndxbuf == NULL) |
goto error_return; |
} |
/* Start writing out the symbol table. The first symbol is always a |
dummy symbol. */ |
if (info->strip != strip_all |
|| emit_relocs) |
{ |
elfsym.st_value = 0; |
elfsym.st_size = 0; |
elfsym.st_info = 0; |
11186,9 → 10745,10 |
elfsym.st_other = 0; |
elfsym.st_shndx = SHN_UNDEF; |
elfsym.st_target_internal = 0; |
if (elf_link_output_symstrtab (&flinfo, NULL, &elfsym, |
bfd_und_section_ptr, NULL) != 1) |
if (elf_link_output_sym (&flinfo, NULL, &elfsym, bfd_und_section_ptr, |
NULL) != 1) |
goto error_return; |
} |
/* Output a symbol for each section. We output these even if we are |
discarding local symbols, since they are used for relocs. These |
11195,7 → 10755,9 |
symbols have no names. We store the index of each one in the |
index field of the section, so that we can find it again when |
outputting relocs. */ |
if (info->strip != strip_all |
|| emit_relocs) |
{ |
elfsym.st_size = 0; |
elfsym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION); |
elfsym.st_other = 0; |
11208,10 → 10770,9 |
{ |
o->target_index = bfd_get_symcount (abfd); |
elfsym.st_shndx = i; |
if (!bfd_link_relocatable (info)) |
if (!info->relocatable) |
elfsym.st_value = o->vma; |
if (elf_link_output_symstrtab (&flinfo, NULL, &elfsym, o, |
NULL) != 1) |
if (elf_link_output_sym (&flinfo, NULL, &elfsym, o, NULL) != 1) |
goto error_return; |
} |
} |
11310,9 → 10871,6 |
return FALSE; |
} |
if (!_bfd_elf_fixup_eh_frame_hdr (info)) |
return FALSE; |
/* Since ELF permits relocations to be against local symbols, we |
must have the local symbols available when we do the relocations. |
Since we would rather only read the local symbols once, and we |
11333,7 → 10891,7 |
we could write the relocs out and then read them again; I don't |
know how bad the memory loss will be. */ |
for (sub = info->input_bfds; sub != NULL; sub = sub->link.next) |
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next) |
sub->output_has_begun = FALSE; |
for (o = abfd->sections; o != NULL; o = o->next) |
{ |
11395,7 → 10953,7 |
/* Free symbol buffer if needed. */ |
if (!info->reduce_memory_overheads) |
{ |
for (sub = info->input_bfds; sub != NULL; sub = sub->link.next) |
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next) |
if (bfd_get_flavour (sub) == bfd_target_elf_flavour |
&& elf_tdata (sub)->symbuf) |
{ |
11404,6 → 10962,17 |
} |
} |
/* Output a FILE symbol so that following locals are not associated |
with the wrong input file. */ |
memset (&elfsym, 0, sizeof (elfsym)); |
elfsym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FILE); |
elfsym.st_shndx = SHN_ABS; |
if (flinfo.filesym_count > 1 |
&& !elf_link_output_sym (&flinfo, NULL, &elfsym, |
bfd_und_section_ptr, NULL)) |
return FALSE; |
/* Output any global symbols that got converted to local in a |
version script or due to symbol visibility. We do this in a |
separate step since ELF requires all local symbols to appear |
11413,15 → 10982,28 |
eoinfo.failed = FALSE; |
eoinfo.flinfo = &flinfo; |
eoinfo.localsyms = TRUE; |
eoinfo.file_sym_done = FALSE; |
eoinfo.need_second_pass = FALSE; |
eoinfo.second_pass = FALSE; |
bfd_hash_traverse (&info->hash->table, elf_link_output_extsym, &eoinfo); |
if (eoinfo.failed) |
return FALSE; |
if (flinfo.filesym_count == 1 |
&& !elf_link_output_sym (&flinfo, NULL, &elfsym, |
bfd_und_section_ptr, NULL)) |
return FALSE; |
if (eoinfo.need_second_pass) |
{ |
eoinfo.second_pass = TRUE; |
bfd_hash_traverse (&info->hash->table, elf_link_output_extsym, &eoinfo); |
if (eoinfo.failed) |
return FALSE; |
} |
/* If backend needs to output some local symbols not present in the hash |
table, do it now. */ |
if (bed->elf_backend_output_arch_local_syms |
&& (info->strip != strip_all || emit_relocs)) |
if (bed->elf_backend_output_arch_local_syms) |
{ |
typedef int (*out_sym_func) |
(void *, const char *, Elf_Internal_Sym *, asection *, |
11428,8 → 11010,7 |
struct elf_link_hash_entry *); |
if (! ((*bed->elf_backend_output_arch_local_syms) |
(abfd, info, &flinfo, |
(out_sym_func) elf_link_output_symstrtab))) |
(abfd, info, &flinfo, (out_sym_func) elf_link_output_sym))) |
return FALSE; |
} |
11442,17 → 11023,15 |
symtab_hdr->sh_info = bfd_get_symcount (abfd); |
if (dynamic |
&& elf_hash_table (info)->dynsym != NULL |
&& (elf_hash_table (info)->dynsym->output_section |
!= bfd_abs_section_ptr)) |
&& flinfo.dynsym_sec != NULL |
&& flinfo.dynsym_sec->output_section != bfd_abs_section_ptr) |
{ |
Elf_Internal_Sym sym; |
bfd_byte *dynsym = elf_hash_table (info)->dynsym->contents; |
bfd_byte *dynsym = flinfo.dynsym_sec->contents; |
long last_local = 0; |
/* Write out the section symbols for the output sections. */ |
if (bfd_link_pic (info) |
|| elf_hash_table (info)->is_relocatable_executable) |
if (info->shared || elf_hash_table (info)->is_relocatable_executable) |
{ |
asection *s; |
11520,7 → 11099,7 |
} |
} |
elf_section_data (elf_hash_table (info)->dynsym->output_section)->this_hdr.sh_info = |
elf_section_data (flinfo.dynsym_sec->output_section)->this_hdr.sh_info = |
last_local + 1; |
} |
11534,8 → 11113,7 |
/* If backend needs to output some symbols not present in the hash |
table, do it now. */ |
if (bed->elf_backend_output_arch_syms |
&& (info->strip != strip_all || emit_relocs)) |
if (bed->elf_backend_output_arch_syms) |
{ |
typedef int (*out_sym_func) |
(void *, const char *, Elf_Internal_Sym *, asection *, |
11542,28 → 11120,19 |
struct elf_link_hash_entry *); |
if (! ((*bed->elf_backend_output_arch_syms) |
(abfd, info, &flinfo, |
(out_sym_func) elf_link_output_symstrtab))) |
(abfd, info, &flinfo, (out_sym_func) elf_link_output_sym))) |
return FALSE; |
} |
/* Finalize the .strtab section. */ |
_bfd_elf_strtab_finalize (flinfo.symstrtab); |
/* Swap out the .strtab section. */ |
if (!elf_link_swap_symbols_out (&flinfo)) |
/* Flush all symbols to the file. */ |
if (! elf_link_flush_output_syms (&flinfo, bed)) |
return FALSE; |
/* Now we know the size of the symtab section. */ |
if (bfd_get_symcount (abfd) > 0) |
{ |
/* Finish up and write out the symbol string table (.strtab) |
section. */ |
Elf_Internal_Shdr *symstrtab_hdr; |
file_ptr off = symtab_hdr->sh_offset + symtab_hdr->sh_size; |
off += symtab_hdr->sh_size; |
symtab_shndx_hdr = & elf_symtab_shndx_list (abfd)->hdr; |
if (symtab_shndx_hdr != NULL && symtab_shndx_hdr->sh_name != 0) |
symtab_shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr; |
if (symtab_shndx_hdr->sh_name != 0) |
{ |
symtab_shndx_hdr->sh_type = SHT_SYMTAB_SHNDX; |
symtab_shndx_hdr->sh_entsize = sizeof (Elf_External_Sym_Shndx); |
11579,12 → 11148,15 |
return FALSE; |
} |
/* Finish up and write out the symbol string table (.strtab) |
section. */ |
symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr; |
/* sh_name was set in prep_headers. */ |
symstrtab_hdr->sh_type = SHT_STRTAB; |
symstrtab_hdr->sh_flags = 0; |
symstrtab_hdr->sh_addr = 0; |
symstrtab_hdr->sh_size = _bfd_elf_strtab_size (flinfo.symstrtab); |
symstrtab_hdr->sh_size = _bfd_stringtab_size (flinfo.symstrtab); |
symstrtab_hdr->sh_entsize = 0; |
symstrtab_hdr->sh_link = 0; |
symstrtab_hdr->sh_info = 0; |
11591,12 → 11163,13 |
/* sh_offset is set just below. */ |
symstrtab_hdr->sh_addralign = 1; |
off = _bfd_elf_assign_file_position_for_section (symstrtab_hdr, |
off, TRUE); |
off = _bfd_elf_assign_file_position_for_section (symstrtab_hdr, off, TRUE); |
elf_next_file_pos (abfd) = off; |
if (bfd_get_symcount (abfd) > 0) |
{ |
if (bfd_seek (abfd, symstrtab_hdr->sh_offset, SEEK_SET) != 0 |
|| ! _bfd_elf_strtab_emit (abfd, flinfo.symstrtab)) |
|| ! _bfd_stringtab_emit (abfd, flinfo.symstrtab)) |
return FALSE; |
} |
11604,17 → 11177,13 |
for (o = abfd->sections; o != NULL; o = o->next) |
{ |
struct bfd_elf_section_data *esdo = elf_section_data (o); |
bfd_boolean sort; |
if ((o->flags & SEC_RELOC) == 0) |
continue; |
sort = bed->sort_relocs_p == NULL || (*bed->sort_relocs_p) (o); |
if (esdo->rel.hdr != NULL |
&& !elf_link_adjust_relocs (abfd, &esdo->rel, sort)) |
return FALSE; |
if (esdo->rela.hdr != NULL |
&& !elf_link_adjust_relocs (abfd, &esdo->rela, sort)) |
return FALSE; |
if (esdo->rel.hdr != NULL) |
elf_link_adjust_relocs (abfd, &esdo->rel); |
if (esdo->rela.hdr != NULL) |
elf_link_adjust_relocs (abfd, &esdo->rela); |
/* Set the reloc_count field to 0 to prevent write_relocs from |
trying to swap the relocs out itself. */ |
11805,7 → 11374,7 |
goto error_return; |
/* Check for DT_TEXTREL (late, in case the backend removes it). */ |
if (((info->warn_shared_textrel && bfd_link_pic (info)) |
if (((info->warn_shared_textrel && info->shared) |
|| info->error_textrel) |
&& (o = bfd_get_linker_section (dynobj, ".dynamic")) != NULL) |
{ |
11861,8 → 11430,6 |
{ |
/* The contents of the .dynstr section are actually in a |
stringtab. */ |
file_ptr off; |
off = elf_section_data (o->output_section)->this_hdr.sh_offset; |
if (bfd_seek (abfd, off, SEEK_SET) != 0 |
|| ! _bfd_elf_strtab_emit (abfd, |
11872,7 → 11439,7 |
} |
} |
if (bfd_link_relocatable (info)) |
if (info->relocatable) |
{ |
bfd_boolean failed = FALSE; |
12056,6 → 11623,8 |
struct elf_link_hash_entry *h, |
Elf_Internal_Sym *sym) |
{ |
const char *sec_name; |
if (h != NULL) |
{ |
switch (h->root.type) |
12067,6 → 11636,33 |
case bfd_link_hash_common: |
return h->root.u.c.p->section; |
case bfd_link_hash_undefined: |
case bfd_link_hash_undefweak: |
/* To work around a glibc bug, keep all XXX input sections |
when there is an as yet undefined reference to __start_XXX |
or __stop_XXX symbols. The linker will later define such |
symbols for orphan input sections that have a name |
representable as a C identifier. */ |
if (strncmp (h->root.root.string, "__start_", 8) == 0) |
sec_name = h->root.root.string + 8; |
else if (strncmp (h->root.root.string, "__stop_", 7) == 0) |
sec_name = h->root.root.string + 7; |
else |
sec_name = NULL; |
if (sec_name && *sec_name != '\0') |
{ |
bfd *i; |
for (i = info->input_bfds; i; i = i->link_next) |
{ |
sec = bfd_get_section_by_name (i, sec_name); |
if (sec) |
sec->flags |= SEC_KEEP; |
} |
} |
break; |
default: |
break; |
} |
12084,8 → 11680,7 |
asection * |
_bfd_elf_gc_mark_rsec (struct bfd_link_info *info, asection *sec, |
elf_gc_mark_hook_fn gc_mark_hook, |
struct elf_reloc_cookie *cookie, |
bfd_boolean *start_stop) |
struct elf_reloc_cookie *cookie) |
{ |
unsigned long r_symndx; |
struct elf_link_hash_entry *h; |
12098,12 → 11693,6 |
|| ELF_ST_BIND (cookie->locsyms[r_symndx].st_info) != STB_LOCAL) |
{ |
h = cookie->sym_hashes[r_symndx - cookie->extsymoff]; |
if (h == NULL) |
{ |
info->callbacks->einfo (_("%F%P: corrupt input: %B\n"), |
sec->owner); |
return NULL; |
} |
while (h->root.type == bfd_link_hash_indirect |
|| h->root.type == bfd_link_hash_warning) |
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
12114,38 → 11703,6 |
handling copy relocs. */ |
if (h->u.weakdef != NULL) |
h->u.weakdef->mark = 1; |
if (start_stop != NULL |
&& (h->root.type == bfd_link_hash_undefined |
|| h->root.type == bfd_link_hash_undefweak)) |
{ |
/* To work around a glibc bug, mark all XXX input sections |
when there is an as yet undefined reference to __start_XXX |
or __stop_XXX symbols. The linker will later define such |
symbols for orphan input sections that have a name |
representable as a C identifier. */ |
const char *sec_name = NULL; |
if (strncmp (h->root.root.string, "__start_", 8) == 0) |
sec_name = h->root.root.string + 8; |
else if (strncmp (h->root.root.string, "__stop_", 7) == 0) |
sec_name = h->root.root.string + 7; |
if (sec_name != NULL && *sec_name != '\0') |
{ |
bfd *i; |
for (i = info->input_bfds; i != NULL; i = i->link.next) |
{ |
asection *s = bfd_get_section_by_name (i, sec_name); |
if (s != NULL && !s->gc_mark) |
{ |
*start_stop = TRUE; |
return s; |
} |
} |
} |
} |
return (*gc_mark_hook) (sec, info, cookie->rel, h, NULL); |
} |
12164,13 → 11721,10 |
struct elf_reloc_cookie *cookie) |
{ |
asection *rsec; |
bfd_boolean start_stop = FALSE; |
rsec = _bfd_elf_gc_mark_rsec (info, sec, gc_mark_hook, cookie, &start_stop); |
while (rsec != NULL) |
rsec = _bfd_elf_gc_mark_rsec (info, sec, gc_mark_hook, cookie); |
if (rsec && !rsec->gc_mark) |
{ |
if (!rsec->gc_mark) |
{ |
if (bfd_get_flavour (rsec->owner) != bfd_target_elf_flavour |
|| (rsec->owner->flags & DYNAMIC) != 0) |
rsec->gc_mark = 1; |
12177,10 → 11731,6 |
else if (!_bfd_elf_gc_mark (info, rsec, gc_mark_hook)) |
return FALSE; |
} |
if (!start_stop) |
break; |
rsec = bfd_get_next_section_by_name (rsec->owner, rsec); |
} |
return TRUE; |
} |
12242,55 → 11792,9 |
} |
} |
eh_frame = elf_section_eh_frame_entry (sec); |
if (ret && eh_frame && !eh_frame->gc_mark) |
if (!_bfd_elf_gc_mark (info, eh_frame, gc_mark_hook)) |
ret = FALSE; |
return ret; |
} |
/* Scan and mark sections in a special or debug section group. */ |
static void |
_bfd_elf_gc_mark_debug_special_section_group (asection *grp) |
{ |
/* Point to first section of section group. */ |
asection *ssec; |
/* Used to iterate the section group. */ |
asection *msec; |
bfd_boolean is_special_grp = TRUE; |
bfd_boolean is_debug_grp = TRUE; |
/* First scan to see if group contains any section other than debug |
and special section. */ |
ssec = msec = elf_next_in_group (grp); |
do |
{ |
if ((msec->flags & SEC_DEBUGGING) == 0) |
is_debug_grp = FALSE; |
if ((msec->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) != 0) |
is_special_grp = FALSE; |
msec = elf_next_in_group (msec); |
} |
while (msec != ssec); |
/* If this is a pure debug section group or pure special section group, |
keep all sections in this group. */ |
if (is_debug_grp || is_special_grp) |
{ |
do |
{ |
msec->gc_mark = 1; |
msec = elf_next_in_group (msec); |
} |
while (msec != ssec); |
} |
} |
/* Keep debug and special sections. */ |
bfd_boolean |
12299,7 → 11803,7 |
{ |
bfd *ibfd; |
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next) |
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next) |
{ |
asection *isec; |
bfd_boolean some_kept; |
12331,17 → 11835,13 |
continue; |
/* Keep debug and special sections like .comment when they are |
not part of a group. Also keep section groups that contain |
just debug sections or special sections. */ |
not part of a group, or when we have single-member groups. */ |
for (isec = ibfd->sections; isec != NULL; isec = isec->next) |
{ |
if ((isec->flags & SEC_GROUP) != 0) |
_bfd_elf_gc_mark_debug_special_section_group (isec); |
else if (((isec->flags & SEC_DEBUGGING) != 0 |
|| (isec->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0) |
&& elf_next_in_group (isec) == NULL) |
if ((elf_next_in_group (isec) == NULL |
|| elf_next_in_group (isec) == isec) |
&& ((isec->flags & SEC_DEBUGGING) != 0 |
|| (isec->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0)) |
isec->gc_mark = 1; |
} |
if (! debug_frag_seen) |
continue; |
12377,6 → 11877,7 |
isec->name, ilen) == 0) |
{ |
dsec->gc_mark = 0; |
break; |
} |
} |
} |
12399,7 → 11900,7 |
if (!h->mark |
&& (((h->root.type == bfd_link_hash_defined |
|| h->root.type == bfd_link_hash_defweak) |
&& !((h->def_regular || ELF_COMMON_DEF_P (h)) |
&& !(h->def_regular |
&& h->root.u.def.section->gc_mark)) |
|| h->root.type == bfd_link_hash_undefined |
|| h->root.type == bfd_link_hash_undefweak)) |
12430,12 → 11931,11 |
unsigned long section_sym_count; |
struct elf_gc_sweep_symbol_info sweep_info; |
for (sub = info->input_bfds; sub != NULL; sub = sub->link.next) |
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next) |
{ |
asection *o; |
if (bfd_get_flavour (sub) != bfd_target_elf_flavour |
|| !(*bed->relocs_compatible) (sub->xvec, abfd->xvec)) |
if (bfd_get_flavour (sub) != bfd_target_elf_flavour) |
continue; |
for (o = sub->sections; o != NULL; o = o->next) |
12468,9 → 11968,7 |
info we collected before. */ |
if (gc_sweep_hook |
&& (o->flags & SEC_RELOC) != 0 |
&& o->reloc_count != 0 |
&& !((info->strip == strip_all || info->strip == strip_debugger) |
&& (o->flags & SEC_DEBUGGING) != 0) |
&& o->reloc_count > 0 |
&& !bfd_is_abs_section (o->output_section)) |
{ |
Elf_Internal_Rela *internal_relocs; |
12618,20 → 12116,15 |
bfd_elf_gc_mark_dynamic_ref_symbol (struct elf_link_hash_entry *h, void *inf) |
{ |
struct bfd_link_info *info = (struct bfd_link_info *) inf; |
struct bfd_elf_dynamic_list *d = info->dynamic_list; |
if ((h->root.type == bfd_link_hash_defined |
|| h->root.type == bfd_link_hash_defweak) |
&& (h->ref_dynamic |
|| ((h->def_regular || ELF_COMMON_DEF_P (h)) |
|| ((!info->executable || info->export_dynamic) |
&& h->def_regular |
&& ELF_ST_VISIBILITY (h->other) != STV_INTERNAL |
&& ELF_ST_VISIBILITY (h->other) != STV_HIDDEN |
&& (!bfd_link_executable (info) |
|| info->export_dynamic |
|| (h->dynamic |
&& d != NULL |
&& (*d->match) (&d->head, NULL, h->root.root.string))) |
&& (h->versioned >= versioned |
&& (strchr (h->root.root.string, ELF_VER_CHR) != NULL |
|| !bfd_hide_sym_by_version (info->version_info, |
h->root.root.string))))) |
h->root.u.def.section->flags |= SEC_KEEP; |
12662,36 → 12155,6 |
} |
} |
bfd_boolean |
bfd_elf_parse_eh_frame_entries (bfd *abfd ATTRIBUTE_UNUSED, |
struct bfd_link_info *info) |
{ |
bfd *ibfd = info->input_bfds; |
for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next) |
{ |
asection *sec; |
struct elf_reloc_cookie cookie; |
if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour) |
continue; |
if (!init_reloc_cookie (&cookie, info, ibfd)) |
return FALSE; |
for (sec = ibfd->sections; sec; sec = sec->next) |
{ |
if (CONST_STRNEQ (bfd_section_name (ibfd, sec), ".eh_frame_entry") |
&& init_reloc_cookie_rels (&cookie, info, ibfd, sec)) |
{ |
_bfd_elf_parse_eh_frame_entry (info, sec, &cookie); |
fini_reloc_cookie_rels (&cookie, sec); |
} |
} |
} |
return TRUE; |
} |
/* Do mark and sweep of unused sections. */ |
bfd_boolean |
12701,7 → 12164,6 |
bfd *sub; |
elf_gc_mark_hook_fn gc_mark_hook; |
const struct elf_backend_data *bed = get_elf_backend_data (abfd); |
struct elf_link_hash_table *htab; |
if (!bed->can_gc_sections |
|| !is_elf_hash_table (info->hash)) |
12711,13 → 12173,11 |
} |
bed->gc_keep (info); |
htab = elf_hash_table (info); |
/* Try to parse each bfd's .eh_frame section. Point elf_eh_frame_section |
at the .eh_frame section if we can mark the FDEs individually. */ |
for (sub = info->input_bfds; |
info->eh_frame_hdr_type != COMPACT_EH_HDR && sub != NULL; |
sub = sub->link.next) |
_bfd_elf_begin_eh_frame_parsing (info); |
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next) |
{ |
asection *sec; |
struct elf_reloc_cookie cookie; |
12730,32 → 12190,38 |
&& (sec->flags & SEC_LINKER_CREATED) == 0) |
elf_eh_frame_section (sub) = sec; |
fini_reloc_cookie_for_section (&cookie, sec); |
sec = bfd_get_next_section_by_name (NULL, sec); |
sec = bfd_get_next_section_by_name (sec); |
} |
} |
_bfd_elf_end_eh_frame_parsing (info); |
/* Apply transitive closure to the vtable entry usage info. */ |
elf_link_hash_traverse (htab, elf_gc_propagate_vtable_entries_used, &ok); |
elf_link_hash_traverse (elf_hash_table (info), |
elf_gc_propagate_vtable_entries_used, |
&ok); |
if (!ok) |
return FALSE; |
/* Kill the vtable relocations that were not used. */ |
elf_link_hash_traverse (htab, elf_gc_smash_unused_vtentry_relocs, &ok); |
elf_link_hash_traverse (elf_hash_table (info), |
elf_gc_smash_unused_vtentry_relocs, |
&ok); |
if (!ok) |
return FALSE; |
/* Mark dynamically referenced symbols. */ |
if (htab->dynamic_sections_created) |
elf_link_hash_traverse (htab, bed->gc_mark_dynamic_ref, info); |
if (elf_hash_table (info)->dynamic_sections_created) |
elf_link_hash_traverse (elf_hash_table (info), |
bed->gc_mark_dynamic_ref, |
info); |
/* Grovel through relocs to find out who stays ... */ |
gc_mark_hook = bed->gc_mark_hook; |
for (sub = info->input_bfds; sub != NULL; sub = sub->link.next) |
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next) |
{ |
asection *o; |
if (bfd_get_flavour (sub) != bfd_target_elf_flavour |
|| !(*bed->relocs_compatible) (sub->xvec, abfd->xvec)) |
if (bfd_get_flavour (sub) != bfd_target_elf_flavour) |
continue; |
/* Start at sections marked with SEC_KEEP (ref _bfd_elf_gc_keep). |
12823,8 → 12289,8 |
win: |
if (!child->vtable) |
{ |
child->vtable = ((struct elf_link_virtual_table_entry *) |
bfd_zalloc (abfd, sizeof (*child->vtable))); |
child->vtable = (struct elf_link_virtual_table_entry *) |
bfd_zalloc (abfd, sizeof (*child->vtable)); |
if (!child->vtable) |
return FALSE; |
} |
12856,8 → 12322,8 |
if (!h->vtable) |
{ |
h->vtable = ((struct elf_link_virtual_table_entry *) |
bfd_zalloc (abfd, sizeof (*h->vtable))); |
h->vtable = (struct elf_link_virtual_table_entry *) |
bfd_zalloc (abfd, sizeof (*h->vtable)); |
if (!h->vtable) |
return FALSE; |
} |
13060,7 → 12526,7 |
gotoff = bed->got_header_size; |
/* Do the local .got entries first. */ |
for (i = info->input_bfds; i; i = i->link.next) |
for (i = info->input_bfds; i; i = i->link_next) |
{ |
bfd_signed_vma *local_got; |
bfd_size_type j, locsymcount; |
13149,10 → 12615,10 |
if ((h->root.type == bfd_link_hash_defined |
|| h->root.type == bfd_link_hash_defweak) |
&& (h->root.u.def.section->owner != rcookie->abfd |
|| h->root.u.def.section->kept_section != NULL |
|| discarded_section (h->root.u.def.section))) |
&& discarded_section (h->root.u.def.section)) |
return TRUE; |
else |
return FALSE; |
} |
else |
{ |
13165,9 → 12631,7 |
/* Need to: get the symbol; get the section. */ |
isym = &rcookie->locsyms[r_symndx]; |
isec = bfd_section_from_elf_index (rcookie->abfd, isym->st_shndx); |
if (isec != NULL |
&& (isec->kept_section != NULL |
|| discarded_section (isec))) |
if (isec != NULL && discarded_section (isec)) |
return TRUE; |
} |
return FALSE; |
13176,110 → 12640,94 |
} |
/* Discard unneeded references to discarded sections. |
Returns -1 on error, 1 if any section's size was changed, 0 if |
nothing changed. This function assumes that the relocations are in |
sorted order, which is true for all known assemblers. */ |
Returns TRUE if any section's size was changed. */ |
/* This function assumes that the relocations are in sorted order, |
which is true for all known assemblers. */ |
int |
bfd_boolean |
bfd_elf_discard_info (bfd *output_bfd, struct bfd_link_info *info) |
{ |
struct elf_reloc_cookie cookie; |
asection *o; |
asection *stab, *eh; |
const struct elf_backend_data *bed; |
bfd *abfd; |
int changed = 0; |
bfd_boolean ret = FALSE; |
if (info->traditional_format |
|| !is_elf_hash_table (info->hash)) |
return 0; |
return FALSE; |
o = bfd_get_section_by_name (output_bfd, ".stab"); |
if (o != NULL) |
_bfd_elf_begin_eh_frame_parsing (info); |
for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link_next) |
{ |
asection *i; |
for (i = o->map_head.s; i != NULL; i = i->map_head.s) |
{ |
if (i->size == 0 |
|| i->reloc_count == 0 |
|| i->sec_info_type != SEC_INFO_TYPE_STABS) |
continue; |
abfd = i->owner; |
if (bfd_get_flavour (abfd) != bfd_target_elf_flavour) |
continue; |
if (!init_reloc_cookie_for_section (&cookie, info, i)) |
return -1; |
bed = get_elf_backend_data (abfd); |
if (_bfd_discard_section_stabs (abfd, i, |
elf_section_data (i)->sec_info, |
bfd_elf_reloc_symbol_deleted_p, |
&cookie)) |
changed = 1; |
fini_reloc_cookie_for_section (&cookie, i); |
eh = NULL; |
if (!info->relocatable) |
{ |
eh = bfd_get_section_by_name (abfd, ".eh_frame"); |
while (eh != NULL |
&& (eh->size == 0 |
|| bfd_is_abs_section (eh->output_section))) |
eh = bfd_get_next_section_by_name (eh); |
} |
} |
o = NULL; |
if (info->eh_frame_hdr_type != COMPACT_EH_HDR) |
o = bfd_get_section_by_name (output_bfd, ".eh_frame"); |
if (o != NULL) |
{ |
asection *i; |
stab = bfd_get_section_by_name (abfd, ".stab"); |
if (stab != NULL |
&& (stab->size == 0 |
|| bfd_is_abs_section (stab->output_section) |
|| stab->sec_info_type != SEC_INFO_TYPE_STABS)) |
stab = NULL; |
for (i = o->map_head.s; i != NULL; i = i->map_head.s) |
{ |
if (i->size == 0) |
if (stab == NULL |
&& eh == NULL |
&& bed->elf_backend_discard_info == NULL) |
continue; |
abfd = i->owner; |
if (bfd_get_flavour (abfd) != bfd_target_elf_flavour) |
continue; |
if (!init_reloc_cookie (&cookie, info, abfd)) |
return FALSE; |
if (!init_reloc_cookie_for_section (&cookie, info, i)) |
return -1; |
_bfd_elf_parse_eh_frame (abfd, info, i, &cookie); |
if (_bfd_elf_discard_section_eh_frame (abfd, info, i, |
if (stab != NULL |
&& stab->reloc_count > 0 |
&& init_reloc_cookie_rels (&cookie, info, abfd, stab)) |
{ |
if (_bfd_discard_section_stabs (abfd, stab, |
elf_section_data (stab)->sec_info, |
bfd_elf_reloc_symbol_deleted_p, |
&cookie)) |
changed = 1; |
fini_reloc_cookie_for_section (&cookie, i); |
ret = TRUE; |
fini_reloc_cookie_rels (&cookie, stab); |
} |
} |
for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link.next) |
while (eh != NULL |
&& init_reloc_cookie_rels (&cookie, info, abfd, eh)) |
{ |
const struct elf_backend_data *bed; |
_bfd_elf_parse_eh_frame (abfd, info, eh, &cookie); |
if (_bfd_elf_discard_section_eh_frame (abfd, info, eh, |
bfd_elf_reloc_symbol_deleted_p, |
&cookie)) |
ret = TRUE; |
fini_reloc_cookie_rels (&cookie, eh); |
eh = bfd_get_next_section_by_name (eh); |
} |
if (bfd_get_flavour (abfd) != bfd_target_elf_flavour) |
continue; |
if (bed->elf_backend_discard_info != NULL |
&& (*bed->elf_backend_discard_info) (abfd, &cookie, info)) |
ret = TRUE; |
bed = get_elf_backend_data (abfd); |
if (bed->elf_backend_discard_info != NULL) |
{ |
if (!init_reloc_cookie (&cookie, info, abfd)) |
return -1; |
if ((*bed->elf_backend_discard_info) (abfd, &cookie, info)) |
changed = 1; |
fini_reloc_cookie (&cookie, abfd); |
} |
} |
if (info->eh_frame_hdr_type == COMPACT_EH_HDR) |
_bfd_elf_end_eh_frame_parsing (info); |
if (info->eh_frame_hdr_type |
&& !bfd_link_relocatable (info) |
if (info->eh_frame_hdr |
&& !info->relocatable |
&& _bfd_elf_discard_section_eh_frame_hdr (output_bfd, info)) |
changed = 1; |
ret = TRUE; |
return changed; |
return ret; |
} |
bfd_boolean |
13563,24 → 13011,17 |
return reloc_sec; |
} |
/* Copy the ELF symbol type and other attributes for a linker script |
assignment from HSRC to HDEST. Generally this should be treated as |
if we found a strong non-dynamic definition for HDEST (except that |
ld ignores multiple definition errors). */ |
/* Copy the ELF symbol type associated with a linker hash entry. */ |
void |
_bfd_elf_copy_link_hash_symbol_type (bfd *abfd, |
_bfd_elf_copy_link_hash_symbol_type (bfd *abfd ATTRIBUTE_UNUSED, |
struct bfd_link_hash_entry *hdest, |
struct bfd_link_hash_entry *hsrc) |
{ |
struct elf_link_hash_entry *ehdest = (struct elf_link_hash_entry *) hdest; |
struct elf_link_hash_entry *ehsrc = (struct elf_link_hash_entry *) hsrc; |
Elf_Internal_Sym isym; |
ehdest->type = ehsrc->type; |
ehdest->target_internal = ehsrc->target_internal; |
isym.st_other = ehsrc->other; |
elf_merge_st_other (abfd, ehdest, &isym, NULL, TRUE, FALSE); |
} |
/* Append a RELA relocation REL to section S in BFD. */ |
/contrib/toolchain/binutils/bfd/format.c |
---|
1,5 → 1,6 |
/* Generic BFD support for file formats. |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1999, 2000, 2001, 2002, |
2003, 2005, 2007, 2008, 2009 Free Software Foundation, Inc. |
Written by Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
402,7 → 403,7 |
/* We still have more than one equally good match, and at least some |
of the targets support match priority. Choose the first of the |
best matches. */ |
if (matching_vector && match_count > 1 && best_count != match_count) |
if (match_count > 1 && best_count != match_count) |
{ |
int i; |
/contrib/toolchain/binutils/bfd/genlink.h |
---|
1,5 → 1,5 |
/* genlink.h -- interface to the BFD generic linker |
Copyright (C) 1993-2015 Free Software Foundation, Inc. |
Copyright 1993, 1994, 1996, 2002, 2005, 2007 Free Software Foundation, Inc. |
Written by Ian Lance Taylor, Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
/contrib/toolchain/binutils/bfd/hash.c |
---|
1,5 → 1,6 |
/* hash.c -- hash table routines for BFD |
Copyright (C) 1993-2015 Free Software Foundation, Inc. |
Copyright 1993, 1994, 1995, 1997, 1999, 2001, 2002, 2003, 2004, 2005, |
2006, 2007, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. |
Written by Steve Chamberlain <sac@cygnus.com> |
This file is part of BFD, the Binary File Descriptor library. |
392,7 → 393,6 |
objalloc_alloc ((struct objalloc *) table->memory, alloc); |
if (table->table == NULL) |
{ |
bfd_hash_table_free (table); |
bfd_set_error (bfd_error_no_memory); |
return FALSE; |
} |
/contrib/toolchain/binutils/bfd/ihex.c |
---|
1,5 → 1,6 |
/* BFD back-end for Intel Hex objects. |
Copyright (C) 1995-2015 Free Software Foundation, Inc. |
Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, |
2006, 2007, 2009, 2011 Free Software Foundation, Inc. |
Written by Ian Lance Taylor of Cygnus Support <ian@cygnus.com>. |
This file is part of BFD, the Binary File Descriptor library. |
219,7 → 220,7 |
char buf[10]; |
if (! ISPRINT (c)) |
sprintf (buf, "\\%03o", (unsigned int) c & 0xff); |
sprintf (buf, "\\%03o", (unsigned int) c); |
else |
{ |
buf[0] = c; |
276,7 → 277,7 |
else |
{ |
file_ptr pos; |
unsigned char hdr[8]; |
char hdr[8]; |
unsigned int i; |
unsigned int len; |
bfd_vma addr; |
321,7 → 322,7 |
{ |
if (! ISHEX (buf[i])) |
{ |
ihex_bad_byte (abfd, lineno, buf[i], error); |
ihex_bad_byte (abfd, lineno, hdr[i], error); |
goto error_return; |
} |
} |
553,7 → 554,7 |
error = FALSE; |
while ((c = ihex_get_byte (abfd, &error)) != EOF) |
{ |
unsigned char hdr[8]; |
char hdr[8]; |
unsigned int len; |
unsigned int type; |
unsigned int i; |
918,12 → 919,10 |
#define ihex_make_empty_symbol _bfd_generic_make_empty_symbol |
#define ihex_print_symbol _bfd_nosymbols_print_symbol |
#define ihex_get_symbol_info _bfd_nosymbols_get_symbol_info |
#define ihex_get_symbol_version_string _bfd_nosymbols_get_symbol_version_string |
#define ihex_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false) |
#define ihex_bfd_is_local_label_name _bfd_nosymbols_bfd_is_local_label_name |
#define ihex_get_lineno _bfd_nosymbols_get_lineno |
#define ihex_find_nearest_line _bfd_nosymbols_find_nearest_line |
#define ihex_find_line _bfd_nosymbols_find_line |
#define ihex_find_inliner_info _bfd_nosymbols_find_inliner_info |
#define ihex_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol |
#define ihex_read_minisymbols _bfd_nosymbols_read_minisymbols |
938,6 → 937,7 |
#define ihex_section_already_linked _bfd_generic_section_already_linked |
#define ihex_bfd_define_common_symbol bfd_generic_define_common_symbol |
#define ihex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create |
#define ihex_bfd_link_hash_table_free _bfd_generic_link_hash_table_free |
#define ihex_bfd_link_add_symbols _bfd_generic_link_add_symbols |
#define ihex_bfd_link_just_syms _bfd_generic_link_just_syms |
#define ihex_bfd_copy_link_hash_symbol_type \ |
/contrib/toolchain/binutils/bfd/init.c |
---|
1,5 → 1,6 |
/* bfd initialization stuff |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 2003, 2005, 2007 |
Free Software Foundation, Inc. |
Written by Steve Chamberlain of Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
/contrib/toolchain/binutils/bfd/libaout.h |
---|
1,5 → 1,7 |
/* BFD back-end data structures for a.out (and similar) files. |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 |
Free Software Foundation, Inc. |
Written by Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
551,8 → 553,8 |
(bfd *, asymbol *, symbol_info *); |
extern bfd_boolean NAME (aout, find_nearest_line) |
(bfd *, asymbol **, asection *, bfd_vma, |
const char **, const char **, unsigned int *, unsigned int *); |
(bfd *, asection *, asymbol **, bfd_vma, const char **, |
const char **, unsigned int *); |
extern long NAME (aout, read_minisymbols) |
(bfd *, bfd_boolean, void * *, unsigned int *); |
/contrib/toolchain/binutils/bfd/libbfd.c |
---|
1,5 → 1,7 |
/* Assorted BFD support routines, only used internally. |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011 |
Free Software Foundation, Inc. |
Written by Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
171,18 → 173,15 |
bfd_malloc (bfd_size_type size) |
{ |
void *ptr; |
size_t sz = (size_t) size; |
if (size != sz |
/* This is to pacify memory checkers like valgrind. */ |
|| ((signed long) sz) < 0) |
if (size != (size_t) size) |
{ |
bfd_set_error (bfd_error_no_memory); |
return NULL; |
} |
ptr = malloc (sz); |
if (ptr == NULL && sz != 0) |
ptr = malloc ((size_t) size); |
if (ptr == NULL && (size_t) size != 0) |
bfd_set_error (bfd_error_no_memory); |
return ptr; |
193,6 → 192,8 |
void * |
bfd_malloc2 (bfd_size_type nmemb, bfd_size_type size) |
{ |
void *ptr; |
if ((nmemb | size) >= HALF_BFD_SIZE_TYPE |
&& size != 0 |
&& nmemb > ~(bfd_size_type) 0 / size) |
201,9 → 202,21 |
return NULL; |
} |
return bfd_malloc (size * nmemb); |
size *= nmemb; |
if (size != (size_t) size) |
{ |
bfd_set_error (bfd_error_no_memory); |
return NULL; |
} |
ptr = malloc ((size_t) size); |
if (ptr == NULL && (size_t) size != 0) |
bfd_set_error (bfd_error_no_memory); |
return ptr; |
} |
/* Reallocate memory using realloc. */ |
void * |
210,22 → 223,19 |
bfd_realloc (void *ptr, bfd_size_type size) |
{ |
void *ret; |
size_t sz = (size_t) size; |
if (ptr == NULL) |
return bfd_malloc (size); |
if (size != sz |
/* This is to pacify memory checkers like valgrind. */ |
|| ((signed long) sz) < 0) |
if (size != (size_t) size) |
{ |
bfd_set_error (bfd_error_no_memory); |
return NULL; |
} |
ret = realloc (ptr, sz); |
if (ptr == NULL) |
ret = malloc ((size_t) size); |
else |
ret = realloc (ptr, (size_t) size); |
if (ret == NULL && sz != 0) |
if (ret == NULL && (size_t) size != 0) |
bfd_set_error (bfd_error_no_memory); |
return ret; |
236,6 → 246,8 |
void * |
bfd_realloc2 (void *ptr, bfd_size_type nmemb, bfd_size_type size) |
{ |
void *ret; |
if ((nmemb | size) >= HALF_BFD_SIZE_TYPE |
&& size != 0 |
&& nmemb > ~(bfd_size_type) 0 / size) |
244,9 → 256,25 |
return NULL; |
} |
return bfd_realloc (ptr, size * nmemb); |
size *= nmemb; |
if (size != (size_t) size) |
{ |
bfd_set_error (bfd_error_no_memory); |
return NULL; |
} |
if (ptr == NULL) |
ret = malloc ((size_t) size); |
else |
ret = realloc (ptr, (size_t) size); |
if (ret == NULL && (size_t) size != 0) |
bfd_set_error (bfd_error_no_memory); |
return ret; |
} |
/* Reallocate memory using realloc. |
If this fails the pointer is freed before returning. */ |
253,10 → 281,24 |
void * |
bfd_realloc_or_free (void *ptr, bfd_size_type size) |
{ |
void *ret = bfd_realloc (ptr, size); |
size_t amount = (size_t) size; |
void *ret; |
if (ret == NULL && ptr != NULL) |
if (size != amount) |
ret = NULL; |
else if (ptr == NULL) |
ret = malloc (amount); |
else |
ret = realloc (ptr, amount); |
if (ret == NULL) |
{ |
if (amount > 0) |
bfd_set_error (bfd_error_no_memory); |
if (ptr != NULL) |
free (ptr); |
} |
return ret; |
} |
266,10 → 308,23 |
void * |
bfd_zmalloc (bfd_size_type size) |
{ |
void *ptr = bfd_malloc (size); |
void *ptr; |
if (ptr != NULL && size > 0) |
if (size != (size_t) size) |
{ |
bfd_set_error (bfd_error_no_memory); |
return NULL; |
} |
ptr = malloc ((size_t) size); |
if ((size_t) size != 0) |
{ |
if (ptr == NULL) |
bfd_set_error (bfd_error_no_memory); |
else |
memset (ptr, 0, (size_t) size); |
} |
return ptr; |
} |
280,16 → 335,34 |
void * |
bfd_zmalloc2 (bfd_size_type nmemb, bfd_size_type size) |
{ |
void *ptr = bfd_malloc2 (nmemb, size); |
void *ptr; |
if (ptr != NULL) |
if ((nmemb | size) >= HALF_BFD_SIZE_TYPE |
&& size != 0 |
&& nmemb > ~(bfd_size_type) 0 / size) |
{ |
size_t sz = nmemb * size; |
bfd_set_error (bfd_error_no_memory); |
return NULL; |
} |
if (sz > 0) |
memset (ptr, 0, sz); |
size *= nmemb; |
if (size != (size_t) size) |
{ |
bfd_set_error (bfd_error_no_memory); |
return NULL; |
} |
ptr = malloc ((size_t) size); |
if ((size_t) size != 0) |
{ |
if (ptr == NULL) |
bfd_set_error (bfd_error_no_memory); |
else |
memset (ptr, 0, (size_t) size); |
} |
return ptr; |
} |
477,10 → 550,11 |
.*/ |
/* Sign extension to bfd_signed_vma. */ |
#define COERCE16(x) (((bfd_vma) (x) ^ 0x8000) - 0x8000) |
#define COERCE32(x) (((bfd_vma) (x) ^ 0x80000000) - 0x80000000) |
#define COERCE16(x) (((bfd_signed_vma) (x) ^ 0x8000) - 0x8000) |
#define COERCE32(x) (((bfd_signed_vma) (x) ^ 0x80000000) - 0x80000000) |
#define EIGHT_GAZILLION ((bfd_int64_t) 1 << 63) |
#define COERCE64(x) \ |
(((bfd_uint64_t) (x) ^ ((bfd_uint64_t) 1 << 63)) - ((bfd_uint64_t) 1 << 63)) |
(((bfd_int64_t) (x) ^ EIGHT_GAZILLION) - EIGHT_GAZILLION) |
bfd_vma |
bfd_getb16 (const void *p) |
1003,45 → 1077,6 |
return result; |
} |
/* Read in a LEB128 encoded value from ABFD starting at DATA. |
If SIGN is true, return a signed LEB128 value. |
If LENGTH_RETURN is not NULL, return in it the number of bytes read. |
No bytes will be read at address END or beyond. */ |
bfd_vma |
safe_read_leb128 (bfd *abfd ATTRIBUTE_UNUSED, |
bfd_byte *data, |
unsigned int *length_return, |
bfd_boolean sign, |
const bfd_byte * const end) |
{ |
bfd_vma result = 0; |
unsigned int num_read = 0; |
unsigned int shift = 0; |
unsigned char byte = 0; |
while (data < end) |
{ |
byte = bfd_get_8 (abfd, data); |
data++; |
num_read++; |
result |= ((bfd_vma) (byte & 0x7f)) << shift; |
shift += 7; |
if ((byte & 0x80) == 0) |
break; |
} |
if (length_return != NULL) |
*length_return = num_read; |
if (sign && (shift < 8 * sizeof (result)) && (byte & 0x40)) |
result |= -((bfd_vma) 1 << shift); |
return result; |
} |
/* Helper function for reading sleb128 encoded data. */ |
bfd_signed_vma |
1073,6 → 1108,29 |
} |
bfd_boolean |
_bfd_generic_find_line (bfd *abfd ATTRIBUTE_UNUSED, |
asymbol **symbols ATTRIBUTE_UNUSED, |
asymbol *symbol ATTRIBUTE_UNUSED, |
const char **filename_ptr ATTRIBUTE_UNUSED, |
unsigned int *linenumber_ptr ATTRIBUTE_UNUSED) |
{ |
return FALSE; |
} |
bfd_boolean |
_bfd_generic_find_nearest_line_discriminator (bfd *abfd ATTRIBUTE_UNUSED, |
asection *section ATTRIBUTE_UNUSED, |
asymbol **symbols ATTRIBUTE_UNUSED, |
bfd_vma offset ATTRIBUTE_UNUSED, |
const char **filename_ptr ATTRIBUTE_UNUSED, |
const char **functionname_ptr ATTRIBUTE_UNUSED, |
unsigned int *line_ptr ATTRIBUTE_UNUSED, |
unsigned int *discriminator_ptr ATTRIBUTE_UNUSED) |
{ |
return FALSE; |
} |
bfd_boolean |
_bfd_generic_init_private_section_data (bfd *ibfd ATTRIBUTE_UNUSED, |
asection *isec ATTRIBUTE_UNUSED, |
bfd *obfd ATTRIBUTE_UNUSED, |
/contrib/toolchain/binutils/bfd/libbfd.h |
---|
6,7 → 6,10 |
/* libbfd.h -- Declarations used by bfd library *implementation*. |
(This include file is not for users of the library.) |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, |
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, |
2010, 2011, 2012 |
Free Software Foundation, Inc. |
Written by Cygnus Support. |
29,10 → 32,6 |
#include "hashtab.h" |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* Align an address upward to a boundary, expressed as a number of bytes. |
E.g. align to an 8-byte boundary with argument of 8. Take care never |
to wrap around if the address is within boundary-1 of the end of the |
401,8 → 400,6 |
((void (*) (bfd *, void *, asymbol *, bfd_print_symbol_type)) bfd_void) |
#define _bfd_nosymbols_get_symbol_info \ |
((void (*) (bfd *, asymbol *, symbol_info *)) bfd_void) |
#define _bfd_nosymbols_get_symbol_version_string \ |
((const char *(*) (bfd *, asymbol *, bfd_boolean *)) bfd_nullvoidptr) |
#define _bfd_nosymbols_bfd_is_local_label_name \ |
((bfd_boolean (*) (bfd *, const char *)) bfd_false) |
#define _bfd_nosymbols_bfd_is_target_special_symbol \ |
410,12 → 407,7 |
#define _bfd_nosymbols_get_lineno \ |
((alent *(*) (bfd *, asymbol *)) bfd_nullvoidptr) |
#define _bfd_nosymbols_find_nearest_line \ |
((bfd_boolean (*) (bfd *, asymbol **, asection *, bfd_vma, \ |
const char **, const char **, unsigned int *, \ |
unsigned int *)) \ |
bfd_false) |
#define _bfd_nosymbols_find_line \ |
((bfd_boolean (*) (bfd *, asymbol **, asymbol *, \ |
((bfd_boolean (*) (bfd *, asection *, asymbol **, bfd_vma, const char **, \ |
const char **, unsigned int *)) \ |
bfd_false) |
#define _bfd_nosymbols_find_inliner_info \ |
487,6 → 479,8 |
bfd_false) |
#define _bfd_nolink_bfd_link_hash_table_create \ |
((struct bfd_link_hash_table *(*) (bfd *)) bfd_nullvoidptr) |
#define _bfd_nolink_bfd_link_hash_table_free \ |
((void (*) (struct bfd_link_hash_table *)) bfd_void) |
#define _bfd_nolink_bfd_link_add_symbols \ |
((bfd_boolean (*) (bfd *, struct bfd_link_info *)) bfd_false) |
#define _bfd_nolink_bfd_link_just_syms \ |
536,8 → 530,8 |
/* Find the nearest line using DWARF 1 debugging information. */ |
extern bfd_boolean _bfd_dwarf1_find_nearest_line |
(bfd *, asymbol **, asection *, bfd_vma, |
const char **, const char **, unsigned int *); |
(bfd *, asection *, asymbol **, bfd_vma, const char **, |
const char **, unsigned int *); |
struct dwarf_debug_section |
{ |
552,14 → 546,22 |
/* Find the nearest line using DWARF 2 debugging information. */ |
extern bfd_boolean _bfd_dwarf2_find_nearest_line |
(bfd *, asymbol **, asymbol *, asection *, bfd_vma, |
const char **, const char **, unsigned int *, unsigned int *, |
const struct dwarf_debug_section *, unsigned int, void **); |
(bfd *, const struct dwarf_debug_section *, asection *, asymbol **, bfd_vma, |
const char **, const char **, unsigned int *, unsigned int *, unsigned int, |
void **); |
/* Find the bias between DWARF addresses and real addresses. */ |
extern bfd_signed_vma _bfd_dwarf2_find_symbol_bias |
(asymbol **, void **); |
/* Find the line using DWARF 2 debugging information. */ |
extern bfd_boolean _bfd_dwarf2_find_line |
(bfd *, asymbol **, asymbol *, const char **, |
unsigned int *, unsigned int *, unsigned int, void **); |
bfd_boolean _bfd_generic_find_line |
(bfd *, asymbol **, asymbol *, const char **, unsigned int *); |
bfd_boolean _bfd_generic_find_nearest_line_discriminator |
(bfd *, asection *, asymbol **, bfd_vma, const char **, const char **, |
unsigned int *, unsigned int *); |
/* Find inliner info after calling bfd_find_nearest_line. */ |
extern bfd_boolean _bfd_dwarf2_find_inliner_info |
(bfd *, const char **, const char **, unsigned int *, void **); |
566,8 → 568,7 |
/* Read DWARF 2 debugging information. */ |
extern bfd_boolean _bfd_dwarf2_slurp_debug_info |
(bfd *, bfd *, const struct dwarf_debug_section *, asymbol **, void **, |
bfd_boolean); |
(bfd *, bfd *, const struct dwarf_debug_section *, asymbol **, void **); |
/* Clean up the data used to handle DWARF 2 debugging information. */ |
extern void _bfd_dwarf2_cleanup_debug_info |
596,7 → 597,7 |
/* Generic link hash table destruction routine. */ |
extern void _bfd_generic_link_hash_table_free |
(bfd *); |
(struct bfd_link_hash_table *); |
/* Generic add symbol routine. */ |
extern bfd_boolean _bfd_generic_link_add_symbols |
611,9 → 612,7 |
/* Generic archive add symbol routine. */ |
extern bfd_boolean _bfd_generic_link_add_archive_symbols |
(bfd *, struct bfd_link_info *, |
bfd_boolean (*) (bfd *, struct bfd_link_info *, |
struct bfd_link_hash_entry *, const char *, |
bfd_boolean *)); |
bfd_boolean (*) (bfd *, struct bfd_link_info *, bfd_boolean *)); |
/* Forward declaration to avoid prototype errors. */ |
typedef struct bfd_link_hash_entry _bfd_link_hash_entry; |
852,8 → 851,6 |
extern bfd_vma read_unsigned_leb128 (bfd *, bfd_byte *, unsigned int *); |
extern bfd_signed_vma read_signed_leb128 (bfd *, bfd_byte *, unsigned int *); |
extern bfd_vma safe_read_leb128 (bfd *, bfd_byte *, unsigned int *, |
bfd_boolean, const bfd_byte * const); |
/* Extracted from init.c. */ |
/* Extracted from libbfd.c. */ |
bfd_boolean bfd_write_bigendian_4byte_int (bfd *, unsigned int); |
1131,10 → 1128,6 |
"BFD_RELOC_MICROMIPS_7_PCREL_S1", |
"BFD_RELOC_MICROMIPS_10_PCREL_S1", |
"BFD_RELOC_MICROMIPS_16_PCREL_S1", |
"BFD_RELOC_MIPS_21_PCREL_S2", |
"BFD_RELOC_MIPS_26_PCREL_S2", |
"BFD_RELOC_MIPS_18_PCREL_S3", |
"BFD_RELOC_MIPS_19_PCREL_S2", |
"BFD_RELOC_MICROMIPS_GPREL16", |
"BFD_RELOC_MICROMIPS_HI16", |
"BFD_RELOC_MICROMIPS_HI16_S", |
1201,11 → 1194,6 |
"BFD_RELOC_MOXIE_10_PCREL", |
"BFD_RELOC_FT32_10", |
"BFD_RELOC_FT32_20", |
"BFD_RELOC_FT32_17", |
"BFD_RELOC_FT32_18", |
"BFD_RELOC_FRV_LABEL16", |
"BFD_RELOC_FRV_LABEL24", |
"BFD_RELOC_FRV_LO16", |
1292,7 → 1280,6 |
"BFD_RELOC_386_TLS_DESC_CALL", |
"BFD_RELOC_386_TLS_DESC", |
"BFD_RELOC_386_IRELATIVE", |
"BFD_RELOC_386_GOT32X", |
"BFD_RELOC_X86_64_GOT32", |
"BFD_RELOC_X86_64_PLT32", |
"BFD_RELOC_X86_64_COPY", |
1322,8 → 1309,6 |
"BFD_RELOC_X86_64_IRELATIVE", |
"BFD_RELOC_X86_64_PC32_BND", |
"BFD_RELOC_X86_64_PLT32_BND", |
"BFD_RELOC_X86_64_GOTPCRELX", |
"BFD_RELOC_X86_64_REX_GOTPCRELX", |
"BFD_RELOC_NS32K_IMM_8", |
"BFD_RELOC_NS32K_IMM_16", |
"BFD_RELOC_NS32K_IMM_32", |
1391,7 → 1376,6 |
"BFD_RELOC_PPC_VLE_SDAREL_HI16D", |
"BFD_RELOC_PPC_VLE_SDAREL_HA16A", |
"BFD_RELOC_PPC_VLE_SDAREL_HA16D", |
"BFD_RELOC_PPC_REL16DX_HA", |
"BFD_RELOC_PPC64_HIGHER", |
"BFD_RELOC_PPC64_HIGHER_S", |
"BFD_RELOC_PPC64_HIGHEST", |
1417,8 → 1401,6 |
"BFD_RELOC_PPC64_PLTGOT16_LO_DS", |
"BFD_RELOC_PPC64_ADDR16_HIGH", |
"BFD_RELOC_PPC64_ADDR16_HIGHA", |
"BFD_RELOC_PPC64_ADDR64_LOCAL", |
"BFD_RELOC_PPC64_ENTRY", |
"BFD_RELOC_PPC_TLS", |
"BFD_RELOC_PPC_TLSGD", |
"BFD_RELOC_PPC_TLSLD", |
1668,72 → 1650,8 |
"BFD_RELOC_SH_GOTOFFFUNCDESC", |
"BFD_RELOC_SH_GOTOFFFUNCDESC20", |
"BFD_RELOC_SH_FUNCDESC", |
"BFD_RELOC_ARC_NONE", |
"BFD_RELOC_ARC_8", |
"BFD_RELOC_ARC_16", |
"BFD_RELOC_ARC_24", |
"BFD_RELOC_ARC_32", |
"BFD_RELOC_ARC_N8", |
"BFD_RELOC_ARC_N16", |
"BFD_RELOC_ARC_N24", |
"BFD_RELOC_ARC_N32", |
"BFD_RELOC_ARC_SDA", |
"BFD_RELOC_ARC_SECTOFF", |
"BFD_RELOC_ARC_S21H_PCREL", |
"BFD_RELOC_ARC_S21W_PCREL", |
"BFD_RELOC_ARC_S25H_PCREL", |
"BFD_RELOC_ARC_S25W_PCREL", |
"BFD_RELOC_ARC_SDA32", |
"BFD_RELOC_ARC_SDA_LDST", |
"BFD_RELOC_ARC_SDA_LDST1", |
"BFD_RELOC_ARC_SDA_LDST2", |
"BFD_RELOC_ARC_SDA16_LD", |
"BFD_RELOC_ARC_SDA16_LD1", |
"BFD_RELOC_ARC_SDA16_LD2", |
"BFD_RELOC_ARC_S13_PCREL", |
"BFD_RELOC_ARC_W", |
"BFD_RELOC_ARC_32_ME", |
"BFD_RELOC_ARC_32_ME_S", |
"BFD_RELOC_ARC_N32_ME", |
"BFD_RELOC_ARC_SECTOFF_ME", |
"BFD_RELOC_ARC_SDA32_ME", |
"BFD_RELOC_ARC_W_ME", |
"BFD_RELOC_AC_SECTOFF_U8", |
"BFD_RELOC_AC_SECTOFF_U8_1", |
"BFD_RELOC_AC_SECTOFF_U8_2", |
"BFD_RELOC_AC_SECTFOFF_S9", |
"BFD_RELOC_AC_SECTFOFF_S9_1", |
"BFD_RELOC_AC_SECTFOFF_S9_2", |
"BFD_RELOC_ARC_SECTOFF_ME_1", |
"BFD_RELOC_ARC_SECTOFF_ME_2", |
"BFD_RELOC_ARC_SECTOFF_1", |
"BFD_RELOC_ARC_SECTOFF_2", |
"BFD_RELOC_ARC_SDA16_ST2", |
"BFD_RELOC_ARC_32_PCREL", |
"BFD_RELOC_ARC_PC32", |
"BFD_RELOC_ARC_GOT32", |
"BFD_RELOC_ARC_GOTPC32", |
"BFD_RELOC_ARC_PLT32", |
"BFD_RELOC_ARC_COPY", |
"BFD_RELOC_ARC_GLOB_DAT", |
"BFD_RELOC_ARC_JMP_SLOT", |
"BFD_RELOC_ARC_RELATIVE", |
"BFD_RELOC_ARC_GOTOFF", |
"BFD_RELOC_ARC_GOTPC", |
"BFD_RELOC_ARC_S21W_PCREL_PLT", |
"BFD_RELOC_ARC_S25H_PCREL_PLT", |
"BFD_RELOC_ARC_TLS_DTPMOD", |
"BFD_RELOC_ARC_TLS_TPOFF", |
"BFD_RELOC_ARC_TLS_GD_GOT", |
"BFD_RELOC_ARC_TLS_GD_LD", |
"BFD_RELOC_ARC_TLS_GD_CALL", |
"BFD_RELOC_ARC_TLS_IE_GOT", |
"BFD_RELOC_ARC_TLS_DTPOFF", |
"BFD_RELOC_ARC_TLS_DTPOFF_S9", |
"BFD_RELOC_ARC_TLS_LE_S9", |
"BFD_RELOC_ARC_TLS_LE_32", |
"BFD_RELOC_ARC_S25W_PCREL_PLT", |
"BFD_RELOC_ARC_S21H_PCREL_PLT", |
"BFD_RELOC_ARC_B22_PCREL", |
"BFD_RELOC_ARC_B26", |
"BFD_RELOC_BFIN_16_IMM", |
"BFD_RELOC_BFIN_16_HIGH", |
"BFD_RELOC_BFIN_4_PCREL", |
1828,121 → 1746,6 |
"BFD_RELOC_M32R_GOTPC_HI_ULO", |
"BFD_RELOC_M32R_GOTPC_HI_SLO", |
"BFD_RELOC_M32R_GOTPC_LO", |
"BFD_RELOC_NDS32_20", |
"BFD_RELOC_NDS32_9_PCREL", |
"BFD_RELOC_NDS32_WORD_9_PCREL", |
"BFD_RELOC_NDS32_15_PCREL", |
"BFD_RELOC_NDS32_17_PCREL", |
"BFD_RELOC_NDS32_25_PCREL", |
"BFD_RELOC_NDS32_HI20", |
"BFD_RELOC_NDS32_LO12S3", |
"BFD_RELOC_NDS32_LO12S2", |
"BFD_RELOC_NDS32_LO12S1", |
"BFD_RELOC_NDS32_LO12S0", |
"BFD_RELOC_NDS32_LO12S0_ORI", |
"BFD_RELOC_NDS32_SDA15S3", |
"BFD_RELOC_NDS32_SDA15S2", |
"BFD_RELOC_NDS32_SDA15S1", |
"BFD_RELOC_NDS32_SDA15S0", |
"BFD_RELOC_NDS32_SDA16S3", |
"BFD_RELOC_NDS32_SDA17S2", |
"BFD_RELOC_NDS32_SDA18S1", |
"BFD_RELOC_NDS32_SDA19S0", |
"BFD_RELOC_NDS32_GOT20", |
"BFD_RELOC_NDS32_9_PLTREL", |
"BFD_RELOC_NDS32_25_PLTREL", |
"BFD_RELOC_NDS32_COPY", |
"BFD_RELOC_NDS32_GLOB_DAT", |
"BFD_RELOC_NDS32_JMP_SLOT", |
"BFD_RELOC_NDS32_RELATIVE", |
"BFD_RELOC_NDS32_GOTOFF", |
"BFD_RELOC_NDS32_GOTOFF_HI20", |
"BFD_RELOC_NDS32_GOTOFF_LO12", |
"BFD_RELOC_NDS32_GOTPC20", |
"BFD_RELOC_NDS32_GOT_HI20", |
"BFD_RELOC_NDS32_GOT_LO12", |
"BFD_RELOC_NDS32_GOTPC_HI20", |
"BFD_RELOC_NDS32_GOTPC_LO12", |
"BFD_RELOC_NDS32_INSN16", |
"BFD_RELOC_NDS32_LABEL", |
"BFD_RELOC_NDS32_LONGCALL1", |
"BFD_RELOC_NDS32_LONGCALL2", |
"BFD_RELOC_NDS32_LONGCALL3", |
"BFD_RELOC_NDS32_LONGJUMP1", |
"BFD_RELOC_NDS32_LONGJUMP2", |
"BFD_RELOC_NDS32_LONGJUMP3", |
"BFD_RELOC_NDS32_LOADSTORE", |
"BFD_RELOC_NDS32_9_FIXED", |
"BFD_RELOC_NDS32_15_FIXED", |
"BFD_RELOC_NDS32_17_FIXED", |
"BFD_RELOC_NDS32_25_FIXED", |
"BFD_RELOC_NDS32_LONGCALL4", |
"BFD_RELOC_NDS32_LONGCALL5", |
"BFD_RELOC_NDS32_LONGCALL6", |
"BFD_RELOC_NDS32_LONGJUMP4", |
"BFD_RELOC_NDS32_LONGJUMP5", |
"BFD_RELOC_NDS32_LONGJUMP6", |
"BFD_RELOC_NDS32_LONGJUMP7", |
"BFD_RELOC_NDS32_PLTREL_HI20", |
"BFD_RELOC_NDS32_PLTREL_LO12", |
"BFD_RELOC_NDS32_PLT_GOTREL_HI20", |
"BFD_RELOC_NDS32_PLT_GOTREL_LO12", |
"BFD_RELOC_NDS32_SDA12S2_DP", |
"BFD_RELOC_NDS32_SDA12S2_SP", |
"BFD_RELOC_NDS32_LO12S2_DP", |
"BFD_RELOC_NDS32_LO12S2_SP", |
"BFD_RELOC_NDS32_DWARF2_OP1", |
"BFD_RELOC_NDS32_DWARF2_OP2", |
"BFD_RELOC_NDS32_DWARF2_LEB", |
"BFD_RELOC_NDS32_UPDATE_TA", |
"BFD_RELOC_NDS32_PLT_GOTREL_LO20", |
"BFD_RELOC_NDS32_PLT_GOTREL_LO15", |
"BFD_RELOC_NDS32_PLT_GOTREL_LO19", |
"BFD_RELOC_NDS32_GOT_LO15", |
"BFD_RELOC_NDS32_GOT_LO19", |
"BFD_RELOC_NDS32_GOTOFF_LO15", |
"BFD_RELOC_NDS32_GOTOFF_LO19", |
"BFD_RELOC_NDS32_GOT15S2", |
"BFD_RELOC_NDS32_GOT17S2", |
"BFD_RELOC_NDS32_5", |
"BFD_RELOC_NDS32_10_UPCREL", |
"BFD_RELOC_NDS32_SDA_FP7U2_RELA", |
"BFD_RELOC_NDS32_RELAX_ENTRY", |
"BFD_RELOC_NDS32_GOT_SUFF", |
"BFD_RELOC_NDS32_GOTOFF_SUFF", |
"BFD_RELOC_NDS32_PLT_GOT_SUFF", |
"BFD_RELOC_NDS32_MULCALL_SUFF", |
"BFD_RELOC_NDS32_PTR", |
"BFD_RELOC_NDS32_PTR_COUNT", |
"BFD_RELOC_NDS32_PTR_RESOLVED", |
"BFD_RELOC_NDS32_PLTBLOCK", |
"BFD_RELOC_NDS32_RELAX_REGION_BEGIN", |
"BFD_RELOC_NDS32_RELAX_REGION_END", |
"BFD_RELOC_NDS32_MINUEND", |
"BFD_RELOC_NDS32_SUBTRAHEND", |
"BFD_RELOC_NDS32_DIFF8", |
"BFD_RELOC_NDS32_DIFF16", |
"BFD_RELOC_NDS32_DIFF32", |
"BFD_RELOC_NDS32_DIFF_ULEB128", |
"BFD_RELOC_NDS32_EMPTY", |
"BFD_RELOC_NDS32_25_ABS", |
"BFD_RELOC_NDS32_DATA", |
"BFD_RELOC_NDS32_TRAN", |
"BFD_RELOC_NDS32_17IFC_PCREL", |
"BFD_RELOC_NDS32_10IFCU_PCREL", |
"BFD_RELOC_NDS32_TPOFF", |
"BFD_RELOC_NDS32_TLS_LE_HI20", |
"BFD_RELOC_NDS32_TLS_LE_LO12", |
"BFD_RELOC_NDS32_TLS_LE_ADD", |
"BFD_RELOC_NDS32_TLS_LE_LS", |
"BFD_RELOC_NDS32_GOTTPOFF", |
"BFD_RELOC_NDS32_TLS_IE_HI20", |
"BFD_RELOC_NDS32_TLS_IE_LO12S2", |
"BFD_RELOC_NDS32_TLS_TPOFF", |
"BFD_RELOC_NDS32_TLS_LE_20", |
"BFD_RELOC_NDS32_TLS_LE_15S0", |
"BFD_RELOC_NDS32_TLS_LE_15S1", |
"BFD_RELOC_NDS32_TLS_LE_15S2", |
"BFD_RELOC_V850_9_PCREL", |
"BFD_RELOC_V850_22_PCREL", |
"BFD_RELOC_V850_SDA_16_16_OFFSET", |
2144,12 → 1947,6 |
"BFD_RELOC_AVR_8_LO", |
"BFD_RELOC_AVR_8_HI", |
"BFD_RELOC_AVR_8_HLO", |
"BFD_RELOC_AVR_DIFF8", |
"BFD_RELOC_AVR_DIFF16", |
"BFD_RELOC_AVR_DIFF32", |
"BFD_RELOC_AVR_LDS_STS_16", |
"BFD_RELOC_AVR_PORT6", |
"BFD_RELOC_AVR_PORT5", |
"BFD_RELOC_RL78_NEG8", |
"BFD_RELOC_RL78_NEG16", |
"BFD_RELOC_RL78_NEG24", |
2183,7 → 1980,6 |
"BFD_RELOC_RL78_HI8", |
"BFD_RELOC_RL78_LO16", |
"BFD_RELOC_RL78_CODE", |
"BFD_RELOC_RL78_SADDR", |
"BFD_RELOC_RX_NEG8", |
"BFD_RELOC_RX_NEG16", |
"BFD_RELOC_RX_NEG24", |
2559,30 → 2355,8 |
"BFD_RELOC_860_HIGH", |
"BFD_RELOC_860_HIGOT", |
"BFD_RELOC_860_HIGOTOFF", |
"BFD_RELOC_OR1K_REL_26", |
"BFD_RELOC_OR1K_GOTPC_HI16", |
"BFD_RELOC_OR1K_GOTPC_LO16", |
"BFD_RELOC_OR1K_GOT16", |
"BFD_RELOC_OR1K_PLT26", |
"BFD_RELOC_OR1K_GOTOFF_HI16", |
"BFD_RELOC_OR1K_GOTOFF_LO16", |
"BFD_RELOC_OR1K_COPY", |
"BFD_RELOC_OR1K_GLOB_DAT", |
"BFD_RELOC_OR1K_JMP_SLOT", |
"BFD_RELOC_OR1K_RELATIVE", |
"BFD_RELOC_OR1K_TLS_GD_HI16", |
"BFD_RELOC_OR1K_TLS_GD_LO16", |
"BFD_RELOC_OR1K_TLS_LDM_HI16", |
"BFD_RELOC_OR1K_TLS_LDM_LO16", |
"BFD_RELOC_OR1K_TLS_LDO_HI16", |
"BFD_RELOC_OR1K_TLS_LDO_LO16", |
"BFD_RELOC_OR1K_TLS_IE_HI16", |
"BFD_RELOC_OR1K_TLS_IE_LO16", |
"BFD_RELOC_OR1K_TLS_LE_HI16", |
"BFD_RELOC_OR1K_TLS_LE_LO16", |
"BFD_RELOC_OR1K_TLS_TPOFF", |
"BFD_RELOC_OR1K_TLS_DTPOFF", |
"BFD_RELOC_OR1K_TLS_DTPMOD", |
"BFD_RELOC_OPENRISC_ABS_26", |
"BFD_RELOC_OPENRISC_REL_26", |
"BFD_RELOC_H8_DIR16A8", |
"BFD_RELOC_H8_DIR16R8", |
"BFD_RELOC_H8_DIR24A8", |
2664,24 → 2438,6 |
"BFD_RELOC_NIOS2_JUMP_SLOT", |
"BFD_RELOC_NIOS2_RELATIVE", |
"BFD_RELOC_NIOS2_GOTOFF", |
"BFD_RELOC_NIOS2_CALL26_NOAT", |
"BFD_RELOC_NIOS2_GOT_LO", |
"BFD_RELOC_NIOS2_GOT_HA", |
"BFD_RELOC_NIOS2_CALL_LO", |
"BFD_RELOC_NIOS2_CALL_HA", |
"BFD_RELOC_NIOS2_R2_S12", |
"BFD_RELOC_NIOS2_R2_I10_1_PCREL", |
"BFD_RELOC_NIOS2_R2_T1I7_1_PCREL", |
"BFD_RELOC_NIOS2_R2_T1I7_2", |
"BFD_RELOC_NIOS2_R2_T2I4", |
"BFD_RELOC_NIOS2_R2_T2I4_1", |
"BFD_RELOC_NIOS2_R2_T2I4_2", |
"BFD_RELOC_NIOS2_R2_X1I7_2", |
"BFD_RELOC_NIOS2_R2_X2L5", |
"BFD_RELOC_NIOS2_R2_F1I5_2", |
"BFD_RELOC_NIOS2_R2_L5I4X1", |
"BFD_RELOC_NIOS2_R2_T1X1I6", |
"BFD_RELOC_NIOS2_R2_T1X1I6_2", |
"BFD_RELOC_IQ2000_OFFSET_16", |
"BFD_RELOC_IQ2000_OFFSET_21", |
"BFD_RELOC_IQ2000_UHI16", |
2816,41 → 2572,14 |
"BFD_RELOC_AARCH64_ADR_GOT_PAGE", |
"BFD_RELOC_AARCH64_LD64_GOT_LO12_NC", |
"BFD_RELOC_AARCH64_LD32_GOT_LO12_NC", |
"BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC", |
"BFD_RELOC_AARCH64_MOVW_GOTOFF_G1", |
"BFD_RELOC_AARCH64_LD64_GOTOFF_LO15", |
"BFD_RELOC_AARCH64_LD32_GOTPAGE_LO14", |
"BFD_RELOC_AARCH64_LD64_GOTPAGE_LO15", |
"BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21", |
"BFD_RELOC_AARCH64_TLSGD_ADR_PREL21", |
"BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC", |
"BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC", |
"BFD_RELOC_AARCH64_TLSGD_MOVW_G1", |
"BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1", |
"BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC", |
"BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21", |
"BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC", |
"BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC", |
"BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19", |
"BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC", |
"BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1", |
"BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_HI12", |
"BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12", |
"BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC", |
"BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC", |
"BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21", |
"BFD_RELOC_AARCH64_TLSLD_ADR_PREL21", |
"BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12", |
"BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC", |
"BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12", |
"BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC", |
"BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12", |
"BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC", |
"BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12", |
"BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC", |
"BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0", |
"BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0_NC", |
"BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1", |
"BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1_NC", |
"BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G2", |
"BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2", |
"BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1", |
"BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC", |
2882,8 → 2611,6 |
"BFD_RELOC_AARCH64_RELOC_END", |
"BFD_RELOC_AARCH64_GAS_INTERNAL_FIXUP", |
"BFD_RELOC_AARCH64_LDST_LO12", |
"BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12", |
"BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12_NC", |
"BFD_RELOC_AARCH64_LD_GOT_LO12_NC", |
"BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC", |
"BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC", |
3082,13 → 2809,6 |
"BFD_RELOC_EPIPHANY_SIMM11", |
"BFD_RELOC_EPIPHANY_IMM11", |
"BFD_RELOC_EPIPHANY_IMM8", |
"BFD_RELOC_VISIUM_HI16", |
"BFD_RELOC_VISIUM_LO16", |
"BFD_RELOC_VISIUM_IM16", |
"BFD_RELOC_VISIUM_REL16", |
"BFD_RELOC_VISIUM_HI16_PCREL", |
"BFD_RELOC_VISIUM_LO16_PCREL", |
"BFD_RELOC_VISIUM_IM16_PCREL", |
"@@overflow: BFD_RELOC_UNUSED@@", |
}; |
#endif |
3135,6 → 2855,3 |
bfd_boolean code); |
/* Extracted from elf.c. */ |
#ifdef __cplusplus |
} |
#endif |
/contrib/toolchain/binutils/bfd/libcoff.h |
---|
3,7 → 3,7 |
Run "make headers" in your build bfd/ to regenerate. */ |
/* BFD COFF object file private structure. |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990-2013 Free Software Foundation, Inc. |
Written by Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
24,12 → 24,7 |
MA 02110-1301, USA. */ |
#include "bfdlink.h" |
#include "coff-bfd.h" |
#ifdef __cplusplus |
extern "C" { |
#endif |
/* Object file tdata; access macros. */ |
#define coff_data(bfd) ((bfd)->tdata.coff_obj_data) |
44,7 → 39,6 |
#define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms) |
#define obj_coff_keep_syms(bfd) (coff_data (bfd)->keep_syms) |
#define obj_coff_strings(bfd) (coff_data (bfd)->strings) |
#define obj_coff_strings_len(bfd) (coff_data (bfd)->strings_len) |
#define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings) |
#define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes) |
#define obj_coff_strings_written(bfd) (coff_data (bfd)->strings_written) |
63,7 → 57,7 |
unsigned long raw_syment_count; |
/* These are only valid once writing has begun. */ |
unsigned long int relocbase; |
long int relocbase; |
/* These members communicate important constants about the symbol table |
to GDB's symbol-reading code. These `constants' unfortunately vary |
85,8 → 79,6 |
/* The string table. May be NULL. Read by |
_bfd_coff_read_string_table. */ |
char *strings; |
/* The length of the strings table. For error checking. */ |
bfd_size_type strings_len; |
/* If this is TRUE, the strings may not be freed. */ |
bfd_boolean keep_strings; |
/* If this is TRUE, the strings have been written out already. */ |
131,14 → 123,6 |
bfd_boolean insert_timestamp; |
bfd_boolean (*in_reloc_p) (bfd *, reloc_howto_type *); |
flagword real_flags; |
/* Build-id info. */ |
struct |
{ |
bfd_boolean (*after_write_object_contents) (bfd *); |
const char *style; |
asection *sec; |
} build_id; |
} pe_data_type; |
#define pe_data(bfd) ((bfd)->tdata.pe_obj_data) |
196,6 → 180,36 |
macro is only ever applied to an asymbol. */ |
#define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd))) |
/* The used_by_bfd field of a section may be set to a pointer to this |
structure. */ |
struct coff_section_tdata |
{ |
/* The relocs, swapped into COFF internal form. This may be NULL. */ |
struct internal_reloc *relocs; |
/* If this is TRUE, the relocs entry may not be freed. */ |
bfd_boolean keep_relocs; |
/* The section contents. This may be NULL. */ |
bfd_byte *contents; |
/* If this is TRUE, the contents entry may not be freed. */ |
bfd_boolean keep_contents; |
/* Information cached by coff_find_nearest_line. */ |
bfd_vma offset; |
unsigned int i; |
const char *function; |
/* Optional information about a COMDAT entry; NULL if not COMDAT. */ |
struct coff_comdat_info *comdat; |
int line_base; |
/* A pointer used for .stab linking optimizations. */ |
void * stab_info; |
/* Available for individual backends. */ |
void * tdata; |
}; |
/* An accessor macro for the coff_section_tdata structure. */ |
#define coff_section_data(abfd, sec) \ |
((struct coff_section_tdata *) (sec)->used_by_bfd) |
/* Tdata for sections in XCOFF files. This is used by the linker. */ |
struct xcoff_section_tdata |
269,16 → 283,6 |
struct stab_info stab_info; |
}; |
struct coff_reloc_cookie |
{ |
struct internal_reloc * rels; |
struct internal_reloc * rel; |
struct internal_reloc * relend; |
struct coff_symbol_struct * symbols; /* Symtab for input bfd. */ |
bfd * abfd; |
struct coff_link_hash_entry ** sym_hashes; |
}; |
/* Look up an entry in a COFF linker hash table. */ |
#define coff_link_hash_lookup(table, string, create, copy, follow) \ |
309,6 → 313,8 |
(bfd *, asymbol **); |
extern int coff_count_linenumbers |
(bfd *); |
extern struct coff_symbol_struct *coff_symbol_from |
(bfd *, asymbol *); |
extern bfd_boolean coff_renumber_symbols |
(bfd *, int *); |
extern void coff_mangle_symbols |
340,20 → 346,20 |
(bfd *, void * filep, asymbol *, bfd_print_symbol_type); |
extern void coff_get_symbol_info |
(bfd *, asymbol *, symbol_info *ret); |
#define coff_get_symbol_version_string \ |
_bfd_nosymbols_get_symbol_version_string |
extern bfd_boolean _bfd_coff_is_local_label_name |
(bfd *, const char *); |
extern asymbol *coff_bfd_make_debug_symbol |
(bfd *, void *, unsigned long); |
extern bfd_boolean coff_find_nearest_line |
(bfd *, asymbol **, asection *, bfd_vma, |
const char **, const char **, unsigned int *, unsigned int *); |
#define coff_find_line _bfd_nosymbols_find_line |
(bfd *, asection *, asymbol **, bfd_vma, const char **, |
const char **, unsigned int *); |
extern bfd_boolean coff_find_nearest_line_discriminator |
(bfd *, asection *, asymbol **, bfd_vma, const char **, |
const char **, unsigned int *, unsigned int *); |
struct dwarf_debug_section; |
extern bfd_boolean coff_find_nearest_line_with_names |
(bfd *, asymbol **, asection *, bfd_vma, const char **, const char **, |
unsigned int *, const struct dwarf_debug_section *); |
(bfd *, const struct dwarf_debug_section *, asection *, asymbol **, |
bfd_vma, const char **, const char **, unsigned int *); |
extern bfd_boolean coff_find_inliner_info |
(bfd *, const char **, const char **, unsigned int *); |
extern int coff_sizeof_headers |
576,8 → 582,6 |
extern bfd_boolean _bfd_coff_reloc_link_order |
(bfd *, struct coff_final_link_info *, asection *, |
struct bfd_link_order *); |
extern bfd_boolean bfd_coff_gc_sections |
(bfd *, struct bfd_link_info *); |
#define coff_get_section_contents_in_window \ |
595,6 → 599,8 |
(bfd *, arelent **, asymbol **); |
extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create |
(bfd *); |
extern void _bfd_xcoff_bfd_link_hash_table_free |
(struct bfd_link_hash_table *); |
extern bfd_boolean _bfd_xcoff_bfd_link_add_symbols |
(bfd *, struct bfd_link_info *); |
extern bfd_boolean _bfd_xcoff_bfd_final_link |
613,7 → 619,6 |
extern bfd_boolean ppc_process_before_allocation |
(bfd *, struct bfd_link_info *); |
/* Extracted from coffcode.h. */ |
typedef struct coff_ptr_struct |
{ |
/* Remembers the offset from the first symbol in the file for |
647,9 → 652,6 |
union internal_auxent auxent; |
struct internal_syment syment; |
} u; |
/* Selector for the union above. */ |
bfd_boolean is_sym; |
} combined_entry_type; |
685,10 → 687,6 |
COFF_SYMBOL_PE_SECTION |
}; |
typedef asection * (*coff_gc_mark_hook_fn) |
(asection *, struct bfd_link_info *, struct internal_reloc *, |
struct coff_link_hash_entry *, struct internal_syment *); |
typedef struct |
{ |
void (*_bfd_coff_swap_aux_in) |
738,7 → 736,6 |
unsigned int _bfd_coff_default_section_alignment_power; |
bfd_boolean _bfd_coff_force_symnames_in_strings; |
unsigned int _bfd_coff_debug_string_prefix_length; |
unsigned int _bfd_coff_max_nscns; |
void (*_bfd_coff_swap_filehdr_in) |
(bfd *, void *, void *); |
876,9 → 873,6 |
((coff_backend_info (abfd)->_bfd_coff_set_long_section_names) (abfd, enable)) |
#define bfd_coff_default_section_alignment_power(abfd) \ |
(coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power) |
#define bfd_coff_max_nscns(abfd) \ |
(coff_backend_info (abfd)->_bfd_coff_max_nscns) |
#define bfd_coff_swap_filehdr_in(abfd, i,o) \ |
((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o)) |
971,6 → 965,3 |
PE object file. */ |
#define bfd_pei_p(abfd) \ |
(CONST_STRNEQ ((abfd)->xvec->name, "pei-")) |
#ifdef __cplusplus |
} |
#endif |
/contrib/toolchain/binutils/bfd/libecoff.h |
---|
1,5 → 1,7 |
/* BFD ECOFF object file private structure. |
Copyright (C) 1993-2015 Free Software Foundation, Inc. |
Copyright 1993, 1994, 1995, 1996, 1999, 2001, 2002, 2003, 2004, |
2005, 2006, 2007, 2008, 2009, 2010 |
Free Software Foundation, Inc. |
Written by Ian Lance Taylor, Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
285,15 → 287,12 |
(bfd *, void *, asymbol *, bfd_print_symbol_type); |
extern void _bfd_ecoff_get_symbol_info |
(bfd *, asymbol *, symbol_info *); |
#define _bfd_ecoff_get_symbol_version_string \ |
_bfd_nosymbols_get_symbol_version_string |
extern bfd_boolean _bfd_ecoff_bfd_is_local_label_name |
(bfd *, const char *); |
#define _bfd_ecoff_get_lineno _bfd_nosymbols_get_lineno |
extern bfd_boolean _bfd_ecoff_find_nearest_line |
(bfd *, asymbol **, asection *, bfd_vma, |
const char **, const char **, unsigned int *, unsigned int *); |
#define _bfd_ecoff_find_line _bfd_nosymbols_find_line |
(bfd *, asection *, asymbol **, bfd_vma, const char **, const char **, |
unsigned int *); |
#define _bfd_ecoff_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol |
#define _bfd_ecoff_read_minisymbols _bfd_generic_read_minisymbols |
#define _bfd_ecoff_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol |
314,6 → 313,7 |
/* ecoff_bfd_relax_section defined by backend. */ |
extern struct bfd_link_hash_table *_bfd_ecoff_bfd_link_hash_table_create |
(bfd *); |
#define _bfd_ecoff_bfd_link_hash_table_free _bfd_generic_link_hash_table_free |
extern bfd_boolean _bfd_ecoff_bfd_link_add_symbols |
(bfd *, struct bfd_link_info *); |
#define _bfd_ecoff_bfd_link_just_syms _bfd_generic_link_just_syms |
/contrib/toolchain/binutils/bfd/libpei.h |
---|
1,5 → 1,6 |
/* Support for the generic parts of PE/PEI; common header information. |
Copyright (C) 1995-2015 Free Software Foundation, Inc. |
Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, |
2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
Written by Cygnus Solutions. |
This file is part of BFD, the Binary File Descriptor library. |
235,10 → 236,6 |
#define _bfd_XXi_swap_scnhdr_out _bfd_pex64i_swap_scnhdr_out |
#define _bfd_XXi_swap_sym_in _bfd_pex64i_swap_sym_in |
#define _bfd_XXi_swap_sym_out _bfd_pex64i_swap_sym_out |
#define _bfd_XXi_swap_debugdir_in _bfd_pex64i_swap_debugdir_in |
#define _bfd_XXi_swap_debugdir_out _bfd_pex64i_swap_debugdir_out |
#define _bfd_XXi_write_codeview_record _bfd_pex64i_write_codeview_record |
#define _bfd_XXi_slurp_codeview_record _bfd_pex64i_slurp_codeview_record |
#elif defined COFF_WITH_pep |
270,10 → 267,6 |
#define _bfd_XXi_swap_scnhdr_out _bfd_pepi_swap_scnhdr_out |
#define _bfd_XXi_swap_sym_in _bfd_pepi_swap_sym_in |
#define _bfd_XXi_swap_sym_out _bfd_pepi_swap_sym_out |
#define _bfd_XXi_swap_debugdir_in _bfd_pepi_swap_debugdir_in |
#define _bfd_XXi_swap_debugdir_out _bfd_pepi_swap_debugdir_out |
#define _bfd_XXi_write_codeview_record _bfd_pepi_write_codeview_record |
#define _bfd_XXi_slurp_codeview_record _bfd_pepi_slurp_codeview_record |
#else /* !COFF_WITH_pep */ |
305,10 → 298,6 |
#define _bfd_XXi_swap_scnhdr_out _bfd_pei_swap_scnhdr_out |
#define _bfd_XXi_swap_sym_in _bfd_pei_swap_sym_in |
#define _bfd_XXi_swap_sym_out _bfd_pei_swap_sym_out |
#define _bfd_XXi_swap_debugdir_in _bfd_pei_swap_debugdir_in |
#define _bfd_XXi_swap_debugdir_out _bfd_pei_swap_debugdir_out |
#define _bfd_XXi_write_codeview_record _bfd_pei_write_codeview_record |
#define _bfd_XXi_slurp_codeview_record _bfd_pei_slurp_codeview_record |
#endif /* !COFF_WITH_pep */ |
351,10 → 340,6 |
bfd_boolean _bfd_XX_bfd_copy_private_bfd_data_common (bfd *, bfd *); |
void _bfd_XX_get_symbol_info (bfd *, asymbol *, symbol_info *); |
bfd_boolean _bfd_XXi_final_link_postscript (bfd *, struct coff_final_link_info *); |
void _bfd_XXi_swap_debugdir_in (bfd *, void *, void *); |
unsigned _bfd_XXi_swap_debugdir_out (bfd *, void *, void *); |
unsigned _bfd_XXi_write_codeview_record (bfd *, file_ptr, CODEVIEW_INFO *); |
CODEVIEW_INFO * _bfd_XXi_slurp_codeview_record (bfd * abfd, file_ptr where, unsigned long length, CODEVIEW_INFO *cvinfo); |
/* The following are needed only for ONE of pe or pei, but don't |
otherwise vary; peicode.h fixes up ifdefs but we provide the |
/contrib/toolchain/binutils/bfd/linker.c |
---|
1,5 → 1,7 |
/* linker.c -- BFD linker routines |
Copyright (C) 1993-2015 Free Software Foundation, Inc. |
Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, |
2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 |
Free Software Foundation, Inc. |
Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support |
This file is part of BFD, the Binary File Descriptor library. |
229,16 → 231,28 |
@findex _bfd_generic_link_add_archive_symbols |
In most cases the work of looking through the symbols in the |
archive should be done by the |
<<_bfd_generic_link_add_archive_symbols>> function. |
<<_bfd_generic_link_add_archive_symbols>> function. This |
function builds a hash table from the archive symbol table and |
looks through the list of undefined symbols to see which |
elements should be included. |
<<_bfd_generic_link_add_archive_symbols>> is passed a function |
to call to make the final decision about adding an archive |
element to the link and to do the actual work of adding the |
symbols to the linker hash table. If the element is to |
symbols to the linker hash table. |
The function passed to |
<<_bfd_generic_link_add_archive_symbols>> must read the |
symbols of the archive element and decide whether the archive |
element should be included in the link. If the element is to |
be included, the <<add_archive_element>> linker callback |
routine must be called with the element as an argument, and |
the element's symbols must be added to the linker hash table |
just as though the element had itself been passed to the |
<<_bfd_link_add_symbols>> function. |
<<_bfd_link_add_symbols>> function. The <<add_archive_element>> |
callback has the option to indicate that it would like to |
replace the element archive with a substitute BFD, in which |
case it is the symbols of that substitute BFD that must be |
added to the linker hash table instead. |
When the a.out <<_bfd_link_add_symbols>> function receives an |
archive, it calls <<_bfd_generic_link_add_archive_symbols>> |
301,7 → 315,7 |
The <<input_bfds>> field of the <<bfd_link_info>> structure |
will point to a list of all the input files included in the |
link. These files are linked through the <<link.next>> field |
link. These files are linked through the <<link_next>> field |
of the <<bfd>> structure. |
Each section in the output file will have a list of |
407,14 → 421,11 |
static bfd_boolean generic_link_add_symbols |
(bfd *, struct bfd_link_info *, bfd_boolean); |
static bfd_boolean generic_link_check_archive_element_no_collect |
(bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, const char *, |
bfd_boolean *); |
(bfd *, struct bfd_link_info *, bfd_boolean *); |
static bfd_boolean generic_link_check_archive_element_collect |
(bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, const char *, |
bfd_boolean *); |
(bfd *, struct bfd_link_info *, bfd_boolean *); |
static bfd_boolean generic_link_check_archive_element |
(bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, const char *, |
bfd_boolean *, bfd_boolean); |
(bfd *, struct bfd_link_info *, bfd_boolean *, bfd_boolean); |
static bfd_boolean generic_link_add_symbol_list |
(bfd *, struct bfd_link_info *, bfd_size_type count, asymbol **, |
bfd_boolean); |
473,23 → 484,12 |
const char *), |
unsigned int entsize) |
{ |
bfd_boolean ret; |
BFD_ASSERT (!abfd->is_linker_output && !abfd->link.hash); |
table->undefs = NULL; |
table->undefs_tail = NULL; |
table->type = bfd_link_generic_hash_table; |
ret = bfd_hash_table_init (&table->table, newfunc, entsize); |
if (ret) |
{ |
/* Arrange for destruction of this hash table on closing ABFD. */ |
table->hash_table_free = _bfd_generic_link_hash_table_free; |
abfd->link.hash = table; |
abfd->is_linker_output = TRUE; |
return bfd_hash_table_init (&table->table, newfunc, entsize); |
} |
return ret; |
} |
/* Look up a symbol in a link hash table. If follow is TRUE, we |
follow bfd_link_hash_indirect and bfd_link_hash_warning links to |
568,6 → 568,8 |
return h; |
} |
#undef WRAP |
#undef REAL |
#define REAL "__real_" |
602,42 → 604,6 |
return bfd_link_hash_lookup (info->hash, string, create, copy, follow); |
} |
/* If H is a wrapped symbol, ie. the symbol name starts with "__wrap_" |
and the remainder is found in wrap_hash, return the real symbol. */ |
struct bfd_link_hash_entry * |
unwrap_hash_lookup (struct bfd_link_info *info, |
bfd *input_bfd, |
struct bfd_link_hash_entry *h) |
{ |
const char *l = h->root.string; |
if (*l == bfd_get_symbol_leading_char (input_bfd) |
|| *l == info->wrap_char) |
++l; |
if (CONST_STRNEQ (l, WRAP)) |
{ |
l += sizeof WRAP - 1; |
if (bfd_hash_lookup (info->wrap_hash, l, FALSE, FALSE) != NULL) |
{ |
char save = 0; |
if (l - (sizeof WRAP - 1) != h->root.string) |
{ |
--l; |
save = *l; |
*(char *) l = *h->root.string; |
} |
h = bfd_link_hash_lookup (info->hash, l, FALSE, FALSE, FALSE); |
if (save) |
*(char *) l = save; |
} |
} |
return h; |
} |
#undef WRAP |
/* Traverse a generic link hash table. Differs from bfd_hash_traverse |
in the treatment of warning symbols. When warning symbols are |
created they replace the real symbol, so you don't get to see the |
773,16 → 739,13 |
} |
void |
_bfd_generic_link_hash_table_free (bfd *obfd) |
_bfd_generic_link_hash_table_free (struct bfd_link_hash_table *hash) |
{ |
struct generic_link_hash_table *ret; |
struct generic_link_hash_table *ret |
= (struct generic_link_hash_table *) hash; |
BFD_ASSERT (obfd->is_linker_output && obfd->link.hash); |
ret = (struct generic_link_hash_table *) obfd->link.hash; |
bfd_hash_table_free (&ret->root.table); |
free (ret); |
obfd->link.hash = NULL; |
obfd->is_linker_output = FALSE; |
} |
/* Grab the symbols for an object file when doing a generic link. We |
852,8 → 815,9 |
sec->output_offset = sec->vma; |
} |
/* Copy the symbol type and other attributes for a linker script |
assignment from HSRC to HDEST. |
/* Copy the type of a symbol assiciated with a linker hast table entry. |
Override this so that symbols created in linker scripts get their |
type from the RHS of the assignment. |
The default implementation does nothing. */ |
void |
_bfd_generic_copy_link_hash_symbol_type (bfd *abfd ATTRIBUTE_UNUSED, |
908,32 → 872,138 |
return generic_link_add_symbol_list (abfd, info, symcount, outsyms, collect); |
} |
/* We build a hash table of all symbols defined in an archive. */ |
/* An archive symbol may be defined by multiple archive elements. |
This linked list is used to hold the elements. */ |
struct archive_list |
{ |
struct archive_list *next; |
unsigned int indx; |
}; |
/* An entry in an archive hash table. */ |
struct archive_hash_entry |
{ |
struct bfd_hash_entry root; |
/* Where the symbol is defined. */ |
struct archive_list *defs; |
}; |
/* An archive hash table itself. */ |
struct archive_hash_table |
{ |
struct bfd_hash_table table; |
}; |
/* Create a new entry for an archive hash table. */ |
static struct bfd_hash_entry * |
archive_hash_newfunc (struct bfd_hash_entry *entry, |
struct bfd_hash_table *table, |
const char *string) |
{ |
struct archive_hash_entry *ret = (struct archive_hash_entry *) entry; |
/* Allocate the structure if it has not already been allocated by a |
subclass. */ |
if (ret == NULL) |
ret = (struct archive_hash_entry *) |
bfd_hash_allocate (table, sizeof (struct archive_hash_entry)); |
if (ret == NULL) |
return NULL; |
/* Call the allocation method of the superclass. */ |
ret = ((struct archive_hash_entry *) |
bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string)); |
if (ret) |
{ |
/* Initialize the local fields. */ |
ret->defs = NULL; |
} |
return &ret->root; |
} |
/* Initialize an archive hash table. */ |
static bfd_boolean |
archive_hash_table_init |
(struct archive_hash_table *table, |
struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *, |
struct bfd_hash_table *, |
const char *), |
unsigned int entsize) |
{ |
return bfd_hash_table_init (&table->table, newfunc, entsize); |
} |
/* Look up an entry in an archive hash table. */ |
#define archive_hash_lookup(t, string, create, copy) \ |
((struct archive_hash_entry *) \ |
bfd_hash_lookup (&(t)->table, (string), (create), (copy))) |
/* Allocate space in an archive hash table. */ |
#define archive_hash_allocate(t, size) bfd_hash_allocate (&(t)->table, (size)) |
/* Free an archive hash table. */ |
#define archive_hash_table_free(t) bfd_hash_table_free (&(t)->table) |
/* Generic function to add symbols from an archive file to the global |
hash file. This function presumes that the archive symbol table |
has already been read in (this is normally done by the |
bfd_check_format entry point). It looks through the archive symbol |
table for symbols that are undefined or common in the linker global |
symbol hash table. When one is found, the CHECKFN argument is used |
to see if an object file should be included. This allows targets |
to customize common symbol behaviour. CHECKFN should set *PNEEDED |
to TRUE if the object file should be included, and must also call |
the bfd_link_info add_archive_element callback function and handle |
adding the symbols to the global hash table. CHECKFN must notice |
if the callback indicates a substitute BFD, and arrange to add |
those symbols instead if it does so. CHECKFN should only return |
FALSE if some sort of error occurs. */ |
bfd_check_format entry point). It looks through the undefined and |
common symbols and searches the archive symbol table for them. If |
it finds an entry, it includes the associated object file in the |
link. |
The old linker looked through the archive symbol table for |
undefined symbols. We do it the other way around, looking through |
undefined symbols for symbols defined in the archive. The |
advantage of the newer scheme is that we only have to look through |
the list of undefined symbols once, whereas the old method had to |
re-search the symbol table each time a new object file was added. |
The CHECKFN argument is used to see if an object file should be |
included. CHECKFN should set *PNEEDED to TRUE if the object file |
should be included, and must also call the bfd_link_info |
add_archive_element callback function and handle adding the symbols |
to the global hash table. CHECKFN must notice if the callback |
indicates a substitute BFD, and arrange to add those symbols instead |
if it does so. CHECKFN should only return FALSE if some sort of |
error occurs. |
For some formats, such as a.out, it is possible to look through an |
object file but not actually include it in the link. The |
archive_pass field in a BFD is used to avoid checking the symbols |
of an object files too many times. When an object is included in |
the link, archive_pass is set to -1. If an object is scanned but |
not included, archive_pass is set to the pass number. The pass |
number is incremented each time a new object file is included. The |
pass number is used because when a new object file is included it |
may create new undefined symbols which cause a previously examined |
object file to be included. */ |
bfd_boolean |
_bfd_generic_link_add_archive_symbols |
(bfd *abfd, |
struct bfd_link_info *info, |
bfd_boolean (*checkfn) (bfd *, struct bfd_link_info *, |
struct bfd_link_hash_entry *, const char *, |
bfd_boolean *)) |
bfd_boolean (*checkfn) (bfd *, struct bfd_link_info *, bfd_boolean *)) |
{ |
bfd_boolean loop; |
bfd_size_type amt; |
unsigned char *included; |
carsym *arsyms; |
carsym *arsym_end; |
register carsym *arsym; |
int pass; |
struct archive_hash_table arsym_hash; |
unsigned int indx; |
struct bfd_link_hash_entry **pundef; |
if (! bfd_has_map (abfd)) |
{ |
944,103 → 1014,148 |
return FALSE; |
} |
amt = bfd_ardata (abfd)->symdef_count; |
if (amt == 0) |
return TRUE; |
amt *= sizeof (*included); |
included = (unsigned char *) bfd_zmalloc (amt); |
if (included == NULL) |
return FALSE; |
do |
{ |
carsym *arsyms; |
carsym *arsym_end; |
carsym *arsym; |
unsigned int indx; |
file_ptr last_ar_offset = -1; |
bfd_boolean needed = FALSE; |
bfd *element = NULL; |
loop = FALSE; |
arsyms = bfd_ardata (abfd)->symdefs; |
arsym_end = arsyms + bfd_ardata (abfd)->symdef_count; |
/* In order to quickly determine whether an symbol is defined in |
this archive, we build a hash table of the symbols. */ |
if (! archive_hash_table_init (&arsym_hash, archive_hash_newfunc, |
sizeof (struct archive_hash_entry))) |
return FALSE; |
for (arsym = arsyms, indx = 0; arsym < arsym_end; arsym++, indx++) |
{ |
struct archive_hash_entry *arh; |
struct archive_list *l, **pp; |
arh = archive_hash_lookup (&arsym_hash, arsym->name, TRUE, FALSE); |
if (arh == NULL) |
goto error_return; |
l = ((struct archive_list *) |
archive_hash_allocate (&arsym_hash, sizeof (struct archive_list))); |
if (l == NULL) |
goto error_return; |
l->indx = indx; |
for (pp = &arh->defs; *pp != NULL; pp = &(*pp)->next) |
; |
*pp = l; |
l->next = NULL; |
} |
/* The archive_pass field in the archive itself is used to |
initialize PASS, sine we may search the same archive multiple |
times. */ |
pass = abfd->archive_pass + 1; |
/* New undefined symbols are added to the end of the list, so we |
only need to look through it once. */ |
pundef = &info->hash->undefs; |
while (*pundef != NULL) |
{ |
struct bfd_link_hash_entry *h; |
struct bfd_link_hash_entry *undefs_tail; |
struct archive_hash_entry *arh; |
struct archive_list *l; |
if (included[indx]) |
continue; |
if (needed && arsym->file_offset == last_ar_offset) |
h = *pundef; |
/* When a symbol is defined, it is not necessarily removed from |
the list. */ |
if (h->type != bfd_link_hash_undefined |
&& h->type != bfd_link_hash_common) |
{ |
included[indx] = 1; |
/* Remove this entry from the list, for general cleanliness |
and because we are going to look through the list again |
if we search any more libraries. We can't remove the |
entry if it is the tail, because that would lose any |
entries we add to the list later on (it would also cause |
us to lose track of whether the symbol has been |
referenced). */ |
if (*pundef != info->hash->undefs_tail) |
*pundef = (*pundef)->u.undef.next; |
else |
pundef = &(*pundef)->u.undef.next; |
continue; |
} |
h = bfd_link_hash_lookup (info->hash, arsym->name, |
FALSE, FALSE, TRUE); |
/* Look for this symbol in the archive symbol map. */ |
arh = archive_hash_lookup (&arsym_hash, h->root.string, FALSE, FALSE); |
if (arh == NULL) |
{ |
/* If we haven't found the exact symbol we're looking for, |
let's look for its import thunk */ |
if (info->pei386_auto_import) |
{ |
bfd_size_type amt = strlen (h->root.string) + 10; |
char *buf = (char *) bfd_malloc (amt); |
if (buf == NULL) |
return FALSE; |
if (h == NULL |
&& info->pei386_auto_import |
&& CONST_STRNEQ (arsym->name, "__imp_")) |
h = bfd_link_hash_lookup (info->hash, arsym->name + 6, |
FALSE, FALSE, TRUE); |
if (h == NULL) |
sprintf (buf, "__imp_%s", h->root.string); |
arh = archive_hash_lookup (&arsym_hash, buf, FALSE, FALSE); |
free(buf); |
} |
if (arh == NULL) |
{ |
pundef = &(*pundef)->u.undef.next; |
continue; |
} |
} |
/* Look at all the objects which define this symbol. */ |
for (l = arh->defs; l != NULL; l = l->next) |
{ |
bfd *element; |
bfd_boolean needed; |
/* If the symbol has gotten defined along the way, quit. */ |
if (h->type != bfd_link_hash_undefined |
&& h->type != bfd_link_hash_common) |
{ |
if (h->type != bfd_link_hash_undefweak) |
/* Symbol must be defined. Don't check it again. */ |
included[indx] = 1; |
break; |
element = bfd_get_elt_at_index (abfd, l->indx); |
if (element == NULL) |
goto error_return; |
/* If we've already included this element, or if we've |
already checked it on this pass, continue. */ |
if (element->archive_pass == -1 |
|| element->archive_pass == pass) |
continue; |
} |
if (last_ar_offset != arsym->file_offset) |
/* If we can't figure this element out, just ignore it. */ |
if (! bfd_check_format (element, bfd_object)) |
{ |
last_ar_offset = arsym->file_offset; |
element = _bfd_get_elt_at_filepos (abfd, last_ar_offset); |
if (element == NULL |
|| !bfd_check_format (element, bfd_object)) |
goto error_return; |
element->archive_pass = -1; |
continue; |
} |
undefs_tail = info->hash->undefs_tail; |
/* CHECKFN will see if this element should be included, and |
go ahead and include it if appropriate. */ |
if (! (*checkfn) (element, info, h, arsym->name, &needed)) |
if (! (*checkfn) (element, info, &needed)) |
goto error_return; |
if (needed) |
if (! needed) |
element->archive_pass = pass; |
else |
{ |
unsigned int mark; |
element->archive_pass = -1; |
/* Look backward to mark all symbols from this object file |
which we have already seen in this pass. */ |
mark = indx; |
do |
{ |
included[mark] = 1; |
if (mark == 0) |
break; |
--mark; |
/* Increment the pass count to show that we may need to |
recheck object files which were already checked. */ |
++pass; |
} |
while (arsyms[mark].file_offset == last_ar_offset); |
} |
if (undefs_tail != info->hash->undefs_tail) |
loop = TRUE; |
pundef = &(*pundef)->u.undef.next; |
} |
} |
} while (loop); |
free (included); |
archive_hash_table_free (&arsym_hash); |
/* Save PASS in case we are called again. */ |
abfd->archive_pass = pass; |
return TRUE; |
error_return: |
free (included); |
archive_hash_table_free (&arsym_hash); |
return FALSE; |
} |
1050,14 → 1165,12 |
for finding them. */ |
static bfd_boolean |
generic_link_check_archive_element_no_collect (bfd *abfd, |
generic_link_check_archive_element_no_collect ( |
bfd *abfd, |
struct bfd_link_info *info, |
struct bfd_link_hash_entry *h, |
const char *name, |
bfd_boolean *pneeded) |
{ |
return generic_link_check_archive_element (abfd, info, h, name, pneeded, |
FALSE); |
return generic_link_check_archive_element (abfd, info, pneeded, FALSE); |
} |
/* See if we should include an archive element. This version is used |
1067,12 → 1180,9 |
static bfd_boolean |
generic_link_check_archive_element_collect (bfd *abfd, |
struct bfd_link_info *info, |
struct bfd_link_hash_entry *h, |
const char *name, |
bfd_boolean *pneeded) |
{ |
return generic_link_check_archive_element (abfd, info, h, name, pneeded, |
TRUE); |
return generic_link_check_archive_element (abfd, info, pneeded, TRUE); |
} |
/* See if we should include an archive element. Optionally collect |
1081,8 → 1191,6 |
static bfd_boolean |
generic_link_check_archive_element (bfd *abfd, |
struct bfd_link_info *info, |
struct bfd_link_hash_entry *h, |
const char *name ATTRIBUTE_UNUSED, |
bfd_boolean *pneeded, |
bfd_boolean collect) |
{ |
1098,6 → 1206,7 |
for (; pp < ppend; pp++) |
{ |
asymbol *p; |
struct bfd_link_hash_entry *h; |
p = *pp; |
1120,14 → 1229,13 |
/* P is a symbol we are looking for. */ |
if (! bfd_is_com_section (p->section) |
|| (h->type == bfd_link_hash_undefined |
&& h->u.undef.abfd == NULL)) |
if (! bfd_is_com_section (p->section)) |
{ |
/* P is not a common symbol, or an undefined reference was |
created from outside BFD such as from a linker -u option. |
This object file defines the symbol, so pull it in. */ |
*pneeded = TRUE; |
bfd_size_type symcount; |
asymbol **symbols; |
bfd *oldbfd = abfd; |
/* This object file defines this symbol, so pull it in. */ |
if (!(*info->callbacks |
->add_archive_element) (info, abfd, bfd_asymbol_name (p), |
&abfd)) |
1134,7 → 1242,16 |
return FALSE; |
/* Potentially, the add_archive_element hook may have set a |
substitute BFD for us. */ |
return generic_link_add_object_symbols (abfd, info, collect); |
if (abfd != oldbfd |
&& !bfd_generic_link_read_symbols (abfd)) |
return FALSE; |
symcount = _bfd_generic_link_get_symcount (abfd); |
symbols = _bfd_generic_link_get_symbols (abfd); |
if (! generic_link_add_symbol_list (abfd, info, symcount, |
symbols, collect)) |
return FALSE; |
*pneeded = TRUE; |
return TRUE; |
} |
/* P is a common symbol. */ |
1145,6 → 1262,23 |
bfd_vma size; |
unsigned int power; |
symbfd = h->u.undef.abfd; |
if (symbfd == NULL) |
{ |
/* This symbol was created as undefined from outside |
BFD. We assume that we should link in the object |
file. This is for the -u option in the linker. */ |
if (!(*info->callbacks |
->add_archive_element) (info, abfd, bfd_asymbol_name (p), |
&abfd)) |
return FALSE; |
/* Potentially, the add_archive_element hook may have set a |
substitute BFD for us. But no symbols are going to get |
registered by anything we're returning to from here. */ |
*pneeded = TRUE; |
return TRUE; |
} |
/* Turn the symbol into a common symbol but do not link in |
the object file. This is how a.out works. Object |
formats that require different semantics must implement |
1152,7 → 1286,6 |
undefs list. We add the section to a common section |
attached to symbfd to ensure that it is in a BFD which |
will be linked in. */ |
symbfd = h->u.undef.abfd; |
h->type = bfd_link_hash_common; |
h->u.c.p = (struct bfd_link_hash_common_entry *) |
bfd_hash_allocate (&info->hash->table, |
1342,7 → 1475,8 |
CIND, /* Make indirect symbol from existing common symbol. */ |
SET, /* Add value to set. */ |
MWARN, /* Make warning symbol. */ |
WARN, /* Warn if referenced, else MWARN. */ |
WARN, /* Issue warning. */ |
CWARN, /* Warn if referenced, else MWARN. */ |
CYCLE, /* Repeat with symbol pointed to. */ |
REFC, /* Mark indirect symbol referenced and then CYCLE. */ |
WARNC /* Issue warning and then CYCLE. */ |
1360,7 → 1494,7 |
/* DEFW_ROW */ {DEFW, DEFW, DEFW, NOACT, NOACT, NOACT, NOACT, CYCLE }, |
/* COMMON_ROW */ {COM, COM, COM, CREF, COM, BIG, REFC, WARNC }, |
/* INDR_ROW */ {IND, IND, IND, MDEF, IND, CIND, MIND, CYCLE }, |
/* WARN_ROW */ {MWARN, WARN, WARN, WARN, WARN, WARN, WARN, NOACT }, |
/* WARN_ROW */ {MWARN, WARN, WARN, CWARN, CWARN, WARN, CWARN, NOACT }, |
/* SET_ROW */ {SET, SET, SET, SET, SET, SET, CYCLE, CYCLE } |
}; |
1442,7 → 1576,6 |
{ |
enum link_row row; |
struct bfd_link_hash_entry *h; |
struct bfd_link_hash_entry *inh = NULL; |
bfd_boolean cycle; |
BFD_ASSERT (section != NULL); |
1449,16 → 1582,7 |
if (bfd_is_ind_section (section) |
|| (flags & BSF_INDIRECT) != 0) |
{ |
row = INDR_ROW; |
/* Create the indirect symbol here. This is for the benefit of |
the plugin "notice" function. |
STRING is the name of the symbol we want to indirect to. */ |
inh = bfd_wrapped_link_hash_lookup (abfd, info, string, TRUE, |
copy, FALSE); |
if (inh == NULL) |
return FALSE; |
} |
else if ((flags & BSF_WARNING) != 0) |
row = WARN_ROW; |
else if ((flags & BSF_CONSTRUCTOR) != 0) |
1473,13 → 1597,7 |
else if ((flags & BSF_WEAK) != 0) |
row = DEFW_ROW; |
else if (bfd_is_com_section (section)) |
{ |
row = COMMON_ROW; |
if (strcmp (name, "__gnu_lto_slim") == 0) |
(*_bfd_error_handler) |
(_("%s: plugin needed to handle lto object"), |
bfd_get_filename (abfd)); |
} |
else |
row = DEF_ROW; |
1503,8 → 1621,8 |
|| (info->notice_hash != NULL |
&& bfd_hash_lookup (info->notice_hash, name, FALSE, FALSE) != NULL)) |
{ |
if (! (*info->callbacks->notice) (info, h, inh, |
abfd, section, value, flags)) |
if (! (*info->callbacks->notice) (info, h, |
abfd, section, value, flags, string)) |
return FALSE; |
} |
1560,7 → 1678,6 |
h->type = bfd_link_hash_defined; |
h->u.def.section = section; |
h->u.def.value = value; |
h->linker_def = 0; |
/* If we have been asked to, we act like collect2 and |
identify all functions that might be global |
1660,7 → 1777,6 |
} |
else |
h->u.c.p->section = section; |
h->linker_def = 0; |
break; |
case REF: |
1740,6 → 1856,16 |
return FALSE; |
/* Fall through. */ |
case IND: |
/* Create an indirect symbol. */ |
{ |
struct bfd_link_hash_entry *inh; |
/* STRING is the name of the symbol we want to indirect |
to. */ |
inh = bfd_wrapped_link_hash_lookup (abfd, info, string, TRUE, |
copy, FALSE); |
if (inh == NULL) |
return FALSE; |
if (inh->type == bfd_link_hash_indirect |
&& inh->u.i.link == h) |
{ |
1757,11 → 1883,10 |
} |
/* If the indirect symbol has been referenced, we need to |
push the reference down to the symbol we are referencing. */ |
push the reference down to the symbol we are |
referencing. */ |
if (h->type != bfd_link_hash_new) |
{ |
/* ??? If inh->type == bfd_link_hash_undefweak this |
converts inh to bfd_link_hash_undefined. */ |
row = UNDEF_ROW; |
cycle = TRUE; |
} |
1768,12 → 1893,7 |
h->type = bfd_link_hash_indirect; |
h->u.i.link = inh; |
/* Not setting h = h->u.i.link here means that when cycle is |
set above we'll always go to REFC, and then cycle again |
to the indirected symbol. This means that any successful |
change of an existing symbol to indirect counts as a |
reference. ??? That may not be correct when the existing |
symbol was defweak. */ |
} |
break; |
case SET: |
1784,10 → 1904,8 |
break; |
case WARNC: |
/* Issue a warning and cycle, except when the reference is |
in LTO IR. */ |
if (h->u.i.warning != NULL |
&& (abfd->flags & BFD_PLUGIN) == 0) |
/* Issue a warning and cycle. */ |
if (h->u.i.warning != NULL) |
{ |
if (! (*info->callbacks->warning) (info, h->u.i.warning, |
h->root.string, abfd, |
1812,11 → 1930,19 |
break; |
case WARN: |
/* Warn if this symbol has been referenced already from non-IR, |
otherwise add a warning. */ |
if ((!info->lto_plugin_active |
&& (h->u.undef.next != NULL || info->hash->undefs_tail == h)) |
|| h->non_ir_ref) |
/* Issue a warning. */ |
if (! (*info->callbacks->warning) (info, string, h->root.string, |
hash_entry_bfd (h), NULL, 0)) |
return FALSE; |
break; |
case CWARN: |
/* Warn if this symbol has been referenced already, |
otherwise add a warning. A symbol has been referenced if |
the u.undef.next field is not NULL, or it is the tail of the |
undefined symbol list. The REF case above helps to |
ensure this. */ |
if (h->u.undef.next != NULL || info->hash->undefs_tail == h) |
{ |
if (! (*info->callbacks->warning) (info, string, h->root.string, |
hash_entry_bfd (h), NULL, 0)) |
1888,7 → 2014,7 |
p->u.indirect.section->linker_mark = TRUE; |
/* Build the output symbol table. */ |
for (sub = info->input_bfds; sub != NULL; sub = sub->link.next) |
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next) |
if (! _bfd_generic_link_output_symbols (abfd, sub, info, &outsymalloc)) |
return FALSE; |
1906,7 → 2032,7 |
if (! generic_add_output_symbol (abfd, &outsymalloc, NULL)) |
return FALSE; |
if (bfd_link_relocatable (info)) |
if (info->relocatable) |
{ |
/* Allocate space for the output relocs for each section. */ |
for (o = abfd->sections; o != NULL; o = o->next) |
2136,7 → 2262,7 |
/* fall through */ |
case bfd_link_hash_defined: |
sym->flags |= BSF_GLOBAL; |
sym->flags &=~ (BSF_WEAK | BSF_CONSTRUCTOR); |
sym->flags &=~ BSF_CONSTRUCTOR; |
sym->value = h->root.u.def.value; |
sym->section = h->root.u.def.section; |
break; |
2210,7 → 2336,7 |
break; |
case discard_sec_merge: |
output = TRUE; |
if (bfd_link_relocatable (info) |
if (info->relocatable |
|| ! (sym->section->flags & SEC_MERGE)) |
break; |
/* FALLTHROUGH */ |
2380,7 → 2506,7 |
{ |
arelent *r; |
if (! bfd_link_relocatable (info)) |
if (! info->relocatable) |
abort (); |
if (sec->orelocation == NULL) |
abort (); |
2434,7 → 2560,7 |
size = bfd_get_reloc_size (r->howto); |
buf = (bfd_byte *) bfd_zmalloc (size); |
if (buf == NULL && size != 0) |
if (buf == NULL) |
return FALSE; |
rstat = _bfd_relocate_contents (r->howto, abfd, |
(bfd_vma) link_order->u.reloc.p->addend, |
2611,7 → 2737,7 |
BFD_ASSERT (input_section->output_offset == link_order->offset); |
BFD_ASSERT (input_section->size == link_order->size); |
if (bfd_link_relocatable (info) |
if (info->relocatable |
&& input_section->reloc_count > 0 |
&& output_section->orelocation == NULL) |
{ |
2705,7 → 2831,7 |
goto error_return; |
new_contents = (bfd_get_relocated_section_contents |
(output_bfd, info, link_order, contents, |
bfd_link_relocatable (info), |
info->relocatable, |
_bfd_generic_link_get_symbols (input_bfd))); |
if (!new_contents) |
goto error_return; |
2896,7 → 3022,7 |
files over IR because the first pass may contain a |
mix of LTO and normal objects and we must keep the |
first match, be it IR or real. */ |
if (sec->owner->lto_output |
if (info->loading_lto_outputs |
&& (l->sec->owner->flags & BFD_PLUGIN) != 0) |
{ |
l->sec = sec; |
/contrib/toolchain/binutils/bfd/merge.c |
---|
1,5 → 1,6 |
/* SEC_MERGE support. |
Copyright (C) 2001-2015 Free Software Foundation, Inc. |
Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 |
Free Software Foundation, Inc. |
Written by Jakub Jelinek <jakub@redhat.com>. |
This file is part of BFD, the Binary File Descriptor library. |
25,7 → 26,6 |
#include "sysdep.h" |
#include "bfd.h" |
#include "elf-bfd.h" |
#include "libbfd.h" |
#include "hashtab.h" |
#include "libiberty.h" |
284,8 → 284,7 |
} |
static bfd_boolean |
sec_merge_emit (bfd *abfd, struct sec_merge_hash_entry *entry, |
unsigned char *contents, file_ptr offset) |
sec_merge_emit (bfd *abfd, struct sec_merge_hash_entry *entry) |
{ |
struct sec_merge_sec_info *secinfo = entry->secinfo; |
asection *sec = secinfo->sec; |
308,12 → 307,7 |
len = -off & (entry->alignment - 1); |
if (len != 0) |
{ |
if (contents) |
{ |
memcpy (contents + offset, pad, len); |
offset += len; |
} |
else if (bfd_bwrite (pad, len, abfd) != len) |
if (bfd_bwrite (pad, len, abfd) != len) |
goto err; |
off += len; |
} |
321,12 → 315,7 |
str = entry->root.string; |
len = entry->len; |
if (contents) |
{ |
memcpy (contents + offset, str, len); |
offset += len; |
} |
else if (bfd_bwrite (str, len, abfd) != len) |
if (bfd_bwrite (str, len, abfd) != len) |
goto err; |
off += len; |
334,13 → 323,9 |
/* Trailing alignment needed? */ |
off = sec->size - off; |
if (off != 0) |
{ |
if (contents) |
memcpy (contents + offset, pad, off); |
else if (bfd_bwrite (pad, off, abfd) != off) |
if (off != 0 |
&& bfd_bwrite (pad, off, abfd) != off) |
goto err; |
} |
if (pad != NULL) |
free (pad); |
801,8 → 786,6 |
{ |
struct sec_merge_sec_info *secinfo; |
file_ptr pos; |
unsigned char *contents; |
Elf_Internal_Shdr *hdr; |
secinfo = (struct sec_merge_sec_info *) psecinfo; |
813,26 → 796,11 |
return TRUE; |
/* FIXME: octets_per_byte. */ |
hdr = &elf_section_data (sec->output_section)->this_hdr; |
if (hdr->sh_offset == (file_ptr) -1) |
{ |
/* We must compress this section. Write output to the |
buffer. */ |
contents = hdr->contents; |
if ((sec->output_section->flags & SEC_ELF_COMPRESS) == 0 |
|| contents == NULL) |
abort (); |
} |
else |
{ |
contents = NULL; |
pos = sec->output_section->filepos + sec->output_offset; |
if (bfd_seek (output_bfd, pos, SEEK_SET) != 0) |
return FALSE; |
} |
if (! sec_merge_emit (output_bfd, secinfo->first_str, contents, |
sec->output_offset)) |
if (! sec_merge_emit (output_bfd, secinfo->first_str)) |
return FALSE; |
return TRUE; |
/contrib/toolchain/binutils/bfd/pe-i386.c |
---|
1,5 → 1,6 |
/* BFD back-end for Intel 386 PECOFF files. |
Copyright (C) 1995-2015 Free Software Foundation, Inc. |
Copyright 1995, 1996, 1999, 2001, 2002, 2004, 2005, 2006, 2007 |
Free Software Foundation, Inc. |
This file is part of BFD, the Binary File Descriptor library. |
21,7 → 22,7 |
#include "sysdep.h" |
#include "bfd.h" |
#define TARGET_SYM i386_pe_vec |
#define TARGET_SYM i386pe_vec |
#define TARGET_NAME "pe-i386" |
#define COFF_WITH_PE |
#define PCRELOFFSET TRUE |
/contrib/toolchain/binutils/bfd/peicode.h |
---|
1,5 → 1,5 |
/* Support for the generic parts of PE/PEI, for BFD. |
Copyright (C) 1995-2015 Free Software Foundation, Inc. |
Copyright 1995-2013 Free Software Foundation, Inc. |
Written by Cygnus Solutions. |
This file is part of BFD, the Binary File Descriptor library. |
271,7 → 271,6 |
/* in_reloc_p is architecture dependent. */ |
pe->in_reloc_p = in_reloc_p; |
memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); |
return TRUE; |
} |
568,7 → 567,6 |
ent->u.syment.n_sclass = sclass; |
ent->u.syment.n_scnum = section->target_index; |
ent->u.syment._n._n_n._n_offset = (bfd_hostptr_t) sym; |
ent->is_sym = TRUE; |
sym->symbol.the_bfd = vars->abfd; |
sym->symbol.name = vars->string_ptr; |
631,20 → 629,6 |
if (size & 1) |
vars->data --; |
# if (GCC_VERSION >= 3000) |
/* PR 18758: See note in pe_ILF_buid_a_bfd. We must make sure that we |
preserve host alignment requirements. We test 'size' rather than |
vars.data as we cannot perform binary arithmetic on pointers. We assume |
that vars.data was sufficiently aligned upon entry to this function. |
The BFD_ASSERTs in this functions will warn us if we run out of room, |
but we should already have enough padding built in to ILF_DATA_SIZE. */ |
{ |
unsigned int alignment = __alignof__ (struct coff_section_tdata); |
if (size & (alignment - 1)) |
vars->data += alignment - (size & (alignment - 1)); |
} |
#endif |
/* Create a coff_section_tdata structure for our use. */ |
sec->used_by_bfd = (struct coff_section_tdata *) vars->data; |
vars->data += sizeof (struct coff_section_tdata); |
850,24 → 834,6 |
/* The remaining space in bim->buffer is used |
by the pe_ILF_make_a_section() function. */ |
# if (GCC_VERSION >= 3000) |
/* PR 18758: Make sure that the data area is sufficiently aligned for |
pointers on the host. __alignof__ is a gcc extension, hence the test |
above. For other compilers we will have to assume that the alignment is |
unimportant, or else extra code can be added here and in |
pe_ILF_make_a_section. |
Note - we cannot test 'ptr' directly as it is illegal to perform binary |
arithmetic on pointers, but we know that the strings section is the only |
one that might end on an unaligned boundary. */ |
{ |
unsigned int alignment = __alignof__ (char *); |
if (SIZEOF_ILF_STRINGS & (alignment - 1)) |
ptr += alignment - (SIZEOF_ILF_STRINGS & (alignment - 1)); |
} |
#endif |
vars.data = ptr; |
vars.abfd = abfd; |
vars.sec_index = 0; |
1005,16 → 971,7 |
} |
else |
#endif |
#ifdef AMD64MAGIC |
if (magic == AMD64MAGIC) |
{ |
pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, |
BFD_RELOC_32_PCREL, (asymbol **) imp_sym, |
imp_index); |
} |
else |
#endif |
pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset, |
BFD_RELOC_32, (asymbol **) imp_sym, |
imp_index); |
1120,7 → 1077,7 |
static const bfd_target * |
pe_ILF_object_p (bfd * abfd) |
{ |
bfd_byte buffer[14]; |
bfd_byte buffer[16]; |
bfd_byte * ptr; |
char * symbol_name; |
char * source_dll; |
1130,13 → 1087,17 |
unsigned int types; |
unsigned int magic; |
/* Upon entry the first six bytes of the ILF header have |
/* Upon entry the first four buyes of the ILF header have |
already been read. Now read the rest of the header. */ |
if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14) |
if (bfd_bread (buffer, (bfd_size_type) 16, abfd) != 16) |
return NULL; |
ptr = buffer; |
/* We do not bother to check the version number. |
version = H_GET_16 (abfd, ptr); */ |
ptr += 2; |
machine = H_GET_16 (abfd, ptr); |
ptr += 2; |
1287,91 → 1248,10 |
return abfd->xvec; |
} |
static void |
pe_bfd_read_buildid(bfd *abfd) |
{ |
pe_data_type *pe = pe_data (abfd); |
struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; |
asection *section; |
bfd_byte *data = 0; |
bfd_size_type dataoff; |
unsigned int i; |
bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; |
bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; |
if (size == 0) |
return; |
addr += extra->ImageBase; |
/* Search for the section containing the DebugDirectory */ |
for (section = abfd->sections; section != NULL; section = section->next) |
{ |
if ((addr >= section->vma) && (addr < (section->vma + section->size))) |
break; |
} |
if (section == NULL) |
{ |
return; |
} |
else if (!(section->flags & SEC_HAS_CONTENTS)) |
{ |
return; |
} |
dataoff = addr - section->vma; |
/* Read the whole section. */ |
if (!bfd_malloc_and_get_section (abfd, section, &data)) |
{ |
if (data != NULL) |
free (data); |
return; |
} |
/* Search for a CodeView entry in the DebugDirectory */ |
for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) |
{ |
struct external_IMAGE_DEBUG_DIRECTORY *ext |
= &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; |
struct internal_IMAGE_DEBUG_DIRECTORY idd; |
_bfd_XXi_swap_debugdir_in (abfd, ext, &idd); |
if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) |
{ |
char buffer[256 + 1]; |
CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; |
/* |
The debug entry doesn't have to have to be in a section, in which |
case AddressOfRawData is 0, so always use PointerToRawData. |
*/ |
if (_bfd_XXi_slurp_codeview_record (abfd, |
(file_ptr) idd.PointerToRawData, |
idd.SizeOfData, cvinfo)) |
{ |
struct bfd_build_id* build_id = bfd_alloc(abfd, |
sizeof(struct bfd_build_id) + cvinfo->SignatureLength); |
if (build_id) |
{ |
build_id->size = cvinfo->SignatureLength; |
memcpy(build_id->data, cvinfo->Signature, |
cvinfo->SignatureLength); |
abfd->build_id = build_id; |
} |
} |
break; |
} |
} |
} |
static const bfd_target * |
pe_bfd_object_p (bfd * abfd) |
{ |
bfd_byte buffer[6]; |
bfd_byte buffer[4]; |
struct external_PEI_DOS_hdr dos_hdr; |
struct external_PEI_IMAGE_hdr image_hdr; |
struct internal_filehdr internal_f; |
1378,12 → 1258,10 |
struct internal_aouthdr internal_a; |
file_ptr opt_hdr_size; |
file_ptr offset; |
const bfd_target *result; |
/* Detect if this a Microsoft Import Library Format element. */ |
/* First read the beginning of the header. */ |
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 |
|| bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) |
|| bfd_bread (buffer, (bfd_size_type) 4, abfd) != 4) |
{ |
if (bfd_get_error () != bfd_error_system_call) |
bfd_set_error (bfd_error_wrong_format); |
1390,9 → 1268,7 |
return NULL; |
} |
/* Then check the magic and the version (only 0 is supported). */ |
if (H_GET_32 (abfd, buffer) == 0xffff0000 |
&& H_GET_16 (abfd, buffer + 4) == 0) |
if (H_GET_32 (abfd, buffer) == 0xffff0000) |
return pe_ILF_object_p (abfd); |
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 |
1438,7 → 1314,7 |
/* Swap file header, so that we get the location for calling |
real_object_p. */ |
bfd_coff_swap_filehdr_in (abfd, &image_hdr, &internal_f); |
bfd_coff_swap_filehdr_in (abfd, (PTR)&image_hdr, &internal_f); |
if (! bfd_coff_bad_format_hook (abfd, &internal_f) |
|| internal_f.f_opthdr > bfd_coff_aoutsz (abfd)) |
1452,14 → 1328,9 |
if (opt_hdr_size != 0) |
{ |
bfd_size_type amt = opt_hdr_size; |
void * opthdr; |
PTR opthdr; |
/* PR 17521 file: 230-131433-0.004. */ |
if (amt < sizeof (PEAOUTHDR)) |
amt = sizeof (PEAOUTHDR); |
opthdr = bfd_zalloc (abfd, amt); |
opthdr = bfd_alloc (abfd, opt_hdr_size); |
if (opthdr == NULL) |
return NULL; |
if (bfd_bread (opthdr, opt_hdr_size, abfd) |
1466,27 → 1337,14 |
!= (bfd_size_type) opt_hdr_size) |
return NULL; |
bfd_set_error (bfd_error_no_error); |
bfd_coff_swap_aouthdr_in (abfd, opthdr, & internal_a); |
if (bfd_get_error () != bfd_error_no_error) |
return NULL; |
bfd_coff_swap_aouthdr_in (abfd, opthdr, (PTR) & internal_a); |
} |
result = coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, |
return coff_real_object_p (abfd, internal_f.f_nscns, &internal_f, |
(opt_hdr_size != 0 |
? &internal_a |
: (struct internal_aouthdr *) NULL)); |
if (result) |
{ |
/* Now the whole header has been processed, see if there is a build-id */ |
pe_bfd_read_buildid(abfd); |
} |
return result; |
} |
#define coff_object_p pe_bfd_object_p |
#endif /* COFF_IMAGE_WITH_PE */ |
/contrib/toolchain/binutils/bfd/peigen.c |
---|
1,5 → 1,5 |
/* Support for the generic parts of PE/PEI; the common executable parts. |
Copyright (C) 1995-2015 Free Software Foundation, Inc. |
Copyright 1995-2013 Free Software Foundation, Inc. |
Written by Cygnus Solutions. |
This file is part of BFD, the Binary File Descriptor library. |
80,7 → 80,6 |
#include "coff/pe.h" |
#include "libcoff.h" |
#include "libpei.h" |
#include "safe-ctype.h" |
#if defined COFF_WITH_pep || defined COFF_WITH_pex64 |
# undef AOUTSZ |
88,10 → 87,6 |
# define PEAOUTHDR PEPAOUTHDR |
#endif |
#define HighBitSet(val) ((val) & 0x80000000) |
#define SetHighBit(val) ((val) | 0x80000000) |
#define WithoutHighBit(val) ((val) & 0x7fffffff) |
/* FIXME: This file has various tests of POWERPC_LE_PE. Those tests |
worked when the code was in peicode.h, but no longer work now that |
the code is in peigen.c. PowerPC NT is said to be dead. If |
146,13 → 141,8 |
name = _bfd_coff_internal_syment_name (abfd, in, namebuf); |
if (name == NULL) |
{ |
_bfd_error_handler (_("%B: unable to find name for empty section"), |
abfd); |
bfd_set_error (bfd_error_invalid_target); |
return; |
} |
/* FIXME: Return error. */ |
abort (); |
sec = bfd_get_section_by_name (abfd, name); |
if (sec != NULL) |
in->n_scnum = sec->target_index; |
172,22 → 162,15 |
{ |
name = (const char *) bfd_alloc (abfd, strlen (namebuf) + 1); |
if (name == NULL) |
{ |
_bfd_error_handler (_("%B: out of memory creating name for empty section"), |
abfd); |
return; |
} |
/* FIXME: Return error. */ |
abort (); |
strcpy ((char *) name, namebuf); |
} |
flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_DATA | SEC_LOAD; |
sec = bfd_make_section_anyway_with_flags (abfd, name, flags); |
if (sec == NULL) |
{ |
_bfd_error_handler (_("%B: unable to create fake empty section"), |
abfd); |
return; |
} |
/* FIXME: Return error. */ |
abort (); |
sec->vma = 0; |
sec->lma = 0; |
216,14 → 199,6 |
#endif |
} |
static bfd_boolean |
abs_finder (bfd * abfd ATTRIBUTE_UNUSED, asection * sec, void * data) |
{ |
bfd_vma abs_val = * (bfd_vma *) data; |
return (sec->vma <= abs_val) && ((sec->vma + (1ULL << 32)) > abs_val); |
} |
unsigned int |
_bfd_pei_swap_sym_out (bfd * abfd, void * inp, void * extp) |
{ |
238,34 → 213,6 |
else |
memcpy (ext->e.e_name, in->_n._n_name, SYMNMLEN); |
/* The PE32 and PE32+ formats only use 4 bytes to hold the value of a |
symbol. This is a problem on 64-bit targets where we can generate |
absolute symbols with values >= 1^32. We try to work around this |
problem by finding a section whose base address is sufficient to |
reduce the absolute value to < 1^32, and then transforming the |
symbol into a section relative symbol. This of course is a hack. */ |
if (sizeof (in->n_value) > 4 |
/* The strange computation of the shift amount is here in order to |
avoid a compile time warning about the comparison always being |
false. It does not matter if this test fails to work as expected |
as the worst that can happen is that some absolute symbols are |
needlessly converted into section relative symbols. */ |
&& in->n_value > ((1ULL << (sizeof (in->n_value) > 4 ? 32 : 31)) - 1) |
&& in->n_scnum == -1) |
{ |
asection * sec; |
sec = bfd_sections_find_if (abfd, abs_finder, & in->n_value); |
if (sec) |
{ |
in->n_value -= sec->vma; |
in->n_scnum = sec->target_index; |
} |
/* else: FIXME: The value is outside the range of any section. This |
happens for __image_base__ and __ImageBase and maybe some other |
symbols as well. We should find a way to handle these values. */ |
} |
H_PUT_32 (abfd, in->n_value, ext->e_value); |
H_PUT_16 (abfd, in->n_scnum, ext->e_scnum); |
292,9 → 239,6 |
AUXENT *ext = (AUXENT *) ext1; |
union internal_auxent *in = (union internal_auxent *) in1; |
/* PR 17521: Make sure that all fields in the aux structure |
are initialised. */ |
memset (in, 0, sizeof * in); |
switch (in_class) |
{ |
case C_FILE: |
470,7 → 414,6 |
aouthdr_int->entry = GET_AOUTHDR_ENTRY (abfd, aouthdr_ext->entry); |
aouthdr_int->text_start = |
GET_AOUTHDR_TEXT_START (abfd, aouthdr_ext->text_start); |
#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) |
/* PE32+ does not have data_start member! */ |
aouthdr_int->data_start = |
517,19 → 460,6 |
{ |
int idx; |
/* PR 17512: Corrupt PE binaries can cause seg-faults. */ |
if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) |
{ |
(*_bfd_error_handler) |
(_("%B: aout header specifies an invalid number of data-directory entries: %d"), |
abfd, a->NumberOfRvaAndSizes); |
bfd_set_error (bfd_error_bad_value); |
/* Paranoia: If the number is corrupt, then assume that the |
actual entries themselves might be corrupt as well. */ |
a->NumberOfRvaAndSizes = 0; |
} |
for (idx = 0; idx < a->NumberOfRvaAndSizes; idx++) |
{ |
/* If data directory is empty, rva also should be 0. */ |
544,14 → 474,7 |
else |
a->DataDirectory[idx].VirtualAddress = 0; |
} |
while (idx < IMAGE_NUMBEROF_DIRECTORY_ENTRIES) |
{ |
a->DataDirectory[idx].Size = 0; |
a->DataDirectory[idx].VirtualAddress = 0; |
idx ++; |
} |
} |
if (aouthdr_int->entry) |
{ |
794,7 → 717,7 |
{ |
int idx; |
for (idx = 0; idx < IMAGE_NUMBEROF_DIRECTORY_ENTRIES; idx++) |
for (idx = 0; idx < 16; idx++) |
{ |
H_PUT_32 (abfd, extra->DataDirectory[idx].VirtualAddress, |
aouthdr_out->DataDirectory[idx][0]); |
1054,8 → 977,8 |
} |
if (coff_data (abfd)->link_info |
&& ! bfd_link_relocatable (coff_data (abfd)->link_info) |
&& ! bfd_link_pic (coff_data (abfd)->link_info) |
&& ! coff_data (abfd)->link_info->relocatable |
&& ! coff_data (abfd)->link_info->shared |
&& strcmp (scnhdr_int->s_name, ".text") == 0) |
{ |
/* By inference from looking at MS output, the 32 bit field |
1100,121 → 1023,6 |
return ret; |
} |
void |
_bfd_pei_swap_debugdir_in (bfd * abfd, void * ext1, void * in1) |
{ |
struct external_IMAGE_DEBUG_DIRECTORY *ext = (struct external_IMAGE_DEBUG_DIRECTORY *) ext1; |
struct internal_IMAGE_DEBUG_DIRECTORY *in = (struct internal_IMAGE_DEBUG_DIRECTORY *) in1; |
in->Characteristics = H_GET_32(abfd, ext->Characteristics); |
in->TimeDateStamp = H_GET_32(abfd, ext->TimeDateStamp); |
in->MajorVersion = H_GET_16(abfd, ext->MajorVersion); |
in->MinorVersion = H_GET_16(abfd, ext->MinorVersion); |
in->Type = H_GET_32(abfd, ext->Type); |
in->SizeOfData = H_GET_32(abfd, ext->SizeOfData); |
in->AddressOfRawData = H_GET_32(abfd, ext->AddressOfRawData); |
in->PointerToRawData = H_GET_32(abfd, ext->PointerToRawData); |
} |
unsigned int |
_bfd_pei_swap_debugdir_out (bfd * abfd, void * inp, void * extp) |
{ |
struct external_IMAGE_DEBUG_DIRECTORY *ext = (struct external_IMAGE_DEBUG_DIRECTORY *) extp; |
struct internal_IMAGE_DEBUG_DIRECTORY *in = (struct internal_IMAGE_DEBUG_DIRECTORY *) inp; |
H_PUT_32(abfd, in->Characteristics, ext->Characteristics); |
H_PUT_32(abfd, in->TimeDateStamp, ext->TimeDateStamp); |
H_PUT_16(abfd, in->MajorVersion, ext->MajorVersion); |
H_PUT_16(abfd, in->MinorVersion, ext->MinorVersion); |
H_PUT_32(abfd, in->Type, ext->Type); |
H_PUT_32(abfd, in->SizeOfData, ext->SizeOfData); |
H_PUT_32(abfd, in->AddressOfRawData, ext->AddressOfRawData); |
H_PUT_32(abfd, in->PointerToRawData, ext->PointerToRawData); |
return sizeof (struct external_IMAGE_DEBUG_DIRECTORY); |
} |
CODEVIEW_INFO * |
_bfd_pei_slurp_codeview_record (bfd * abfd, file_ptr where, unsigned long length, CODEVIEW_INFO *cvinfo) |
{ |
char buffer[256+1]; |
if (bfd_seek (abfd, where, SEEK_SET) != 0) |
return NULL; |
if (bfd_bread (buffer, 256, abfd) < 4) |
return NULL; |
/* Ensure null termination of filename. */ |
buffer[256] = '\0'; |
cvinfo->CVSignature = H_GET_32 (abfd, buffer); |
cvinfo->Age = 0; |
if ((cvinfo->CVSignature == CVINFO_PDB70_CVSIGNATURE) |
&& (length > sizeof (CV_INFO_PDB70))) |
{ |
CV_INFO_PDB70 *cvinfo70 = (CV_INFO_PDB70 *)(buffer); |
cvinfo->Age = H_GET_32(abfd, cvinfo70->Age); |
/* A GUID consists of 4,2,2 byte values in little-endian order, followed |
by 8 single bytes. Byte swap them so we can conveniently treat the GUID |
as 16 bytes in big-endian order. */ |
bfd_putb32 (bfd_getl32 (cvinfo70->Signature), cvinfo->Signature); |
bfd_putb16 (bfd_getl16 (&(cvinfo70->Signature[4])), &(cvinfo->Signature[4])); |
bfd_putb16 (bfd_getl16 (&(cvinfo70->Signature[6])), &(cvinfo->Signature[6])); |
memcpy (&(cvinfo->Signature[8]), &(cvinfo70->Signature[8]), 8); |
cvinfo->SignatureLength = CV_INFO_SIGNATURE_LENGTH; |
// cvinfo->PdbFileName = cvinfo70->PdbFileName; |
return cvinfo; |
} |
else if ((cvinfo->CVSignature == CVINFO_PDB20_CVSIGNATURE) |
&& (length > sizeof (CV_INFO_PDB20))) |
{ |
CV_INFO_PDB20 *cvinfo20 = (CV_INFO_PDB20 *)(buffer); |
cvinfo->Age = H_GET_32(abfd, cvinfo20->Age); |
memcpy (cvinfo->Signature, cvinfo20->Signature, 4); |
cvinfo->SignatureLength = 4; |
// cvinfo->PdbFileName = cvinfo20->PdbFileName; |
return cvinfo; |
} |
return NULL; |
} |
unsigned int |
_bfd_pei_write_codeview_record (bfd * abfd, file_ptr where, CODEVIEW_INFO *cvinfo) |
{ |
unsigned int size = sizeof (CV_INFO_PDB70) + 1; |
CV_INFO_PDB70 *cvinfo70; |
char buffer[size]; |
if (bfd_seek (abfd, where, SEEK_SET) != 0) |
return 0; |
cvinfo70 = (CV_INFO_PDB70 *) buffer; |
H_PUT_32 (abfd, CVINFO_PDB70_CVSIGNATURE, cvinfo70->CvSignature); |
/* Byte swap the GUID from 16 bytes in big-endian order to 4,2,2 byte values |
in little-endian order, followed by 8 single bytes. */ |
bfd_putl32 (bfd_getb32 (cvinfo->Signature), cvinfo70->Signature); |
bfd_putl16 (bfd_getb16 (&(cvinfo->Signature[4])), &(cvinfo70->Signature[4])); |
bfd_putl16 (bfd_getb16 (&(cvinfo->Signature[6])), &(cvinfo70->Signature[6])); |
memcpy (&(cvinfo70->Signature[8]), &(cvinfo->Signature[8]), 8); |
H_PUT_32 (abfd, cvinfo->Age, cvinfo70->Age); |
cvinfo70->PdbFileName[0] = '\0'; |
if (bfd_bwrite (buffer, size, abfd) != size) |
return 0; |
return size; |
} |
static char * dir_names[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] = |
{ |
N_("Export Directory [.edata (or where ever we found it)]"), |
1295,14 → 1103,7 |
_("\nThere is an import table, but the section containing it could not be found\n")); |
return TRUE; |
} |
else if (!(section->flags & SEC_HAS_CONTENTS)) |
{ |
fprintf (file, |
_("\nThere is an import table in %s, but that section has no contents\n"), |
section->name); |
return TRUE; |
} |
} |
fprintf (file, _("\nThere is an import table in %s at 0x%lx\n"), |
section->name, (unsigned long) addr); |
1413,9 → 1214,7 |
break; |
dll = (char *) data + dll_name - adj; |
/* PR 17512 file: 078-12277-0.004. */ |
bfd_size_type maxlen = (char *)(data + datasize) - dll - 1; |
fprintf (file, _("\n\tDLL Name: %.*s\n"), (int) maxlen, dll); |
fprintf (file, _("\n\tDLL Name: %s\n"), dll); |
if (hint_addr != 0) |
{ |
1480,7 → 1279,6 |
#ifdef COFF_WITH_pex64 |
for (j = 0; idx + j + 8 <= datasize; j += 8) |
{ |
bfd_size_type amt; |
unsigned long member = bfd_get_32 (abfd, data + idx + j); |
unsigned long member_high = bfd_get_32 (abfd, data + idx + j + 4); |
1487,24 → 1285,17 |
if (!member && !member_high) |
break; |
amt = member - adj; |
if (HighBitSet (member_high)) |
if (member_high & 0x80000000) |
fprintf (file, "\t%lx%08lx\t %4lx%08lx <none>", |
member_high, member, |
WithoutHighBit (member_high), member); |
/* PR binutils/17512: Handle corrupt PE data. */ |
else if (amt + 2 >= datasize) |
fprintf (file, _("\t<corrupt: 0x%04lx>"), member); |
member_high,member, member_high & 0x7fffffff, member); |
else |
{ |
int ordinal; |
char *member_name; |
ordinal = bfd_get_16 (abfd, data + amt); |
member_name = (char *) data + amt + 2; |
fprintf (file, "\t%04lx\t %4d %.*s",member, ordinal, |
(int) (datasize - (amt + 2)), member_name); |
ordinal = bfd_get_16 (abfd, data + member - adj); |
member_name = (char *) data + member - adj + 2; |
fprintf (file, "\t%04lx\t %4d %s",member, ordinal, member_name); |
} |
/* If the time stamp is not zero, the import address |
1520,7 → 1311,6 |
#else |
for (j = 0; idx + j + 4 <= datasize; j += 4) |
{ |
bfd_size_type amt; |
unsigned long member = bfd_get_32 (abfd, data + idx + j); |
/* Print single IMAGE_IMPORT_BY_NAME vector. */ |
1527,23 → 1317,18 |
if (member == 0) |
break; |
amt = member - adj; |
if (HighBitSet (member)) |
if (member & 0x80000000) |
fprintf (file, "\t%04lx\t %4lu <none>", |
member, WithoutHighBit (member)); |
/* PR binutils/17512: Handle corrupt PE data. */ |
else if (amt + 2 >= datasize) |
fprintf (file, _("\t<corrupt: 0x%04lx>"), member); |
member, member & 0x7fffffff); |
else |
{ |
int ordinal; |
char *member_name; |
ordinal = bfd_get_16 (abfd, data + amt); |
member_name = (char *) data + amt + 2; |
fprintf (file, "\t%04lx\t %4d %.*s", |
member, ordinal, |
(int) (datasize - (amt + 2)), member_name); |
ordinal = bfd_get_16 (abfd, data + member - adj); |
member_name = (char *) data + member - adj + 2; |
fprintf (file, "\t%04lx\t %4d %s", |
member, ordinal, member_name); |
} |
/* If the time stamp is not zero, the import address |
1579,7 → 1364,7 |
bfd_size_type datasize = 0; |
bfd_size_type dataoff; |
bfd_size_type i; |
bfd_vma adj; |
bfd_signed_vma adj; |
struct EDT_type |
{ |
long export_flags; /* Reserved - should be zero. */ |
1629,13 → 1414,6 |
_("\nThere is an export table, but the section containing it could not be found\n")); |
return TRUE; |
} |
else if (!(section->flags & SEC_HAS_CONTENTS)) |
{ |
fprintf (file, |
_("\nThere is an export table in %s, but that section has no contents\n"), |
section->name); |
return TRUE; |
} |
dataoff = addr - section->vma; |
datasize = extra->DataDirectory[PE_EXPORT_TABLE].Size; |
1648,15 → 1426,6 |
} |
} |
/* PR 17512: Handle corrupt PE binaries. */ |
if (datasize < 36) |
{ |
fprintf (file, |
_("\nThere is an export table in %s, but it is too small (%d)\n"), |
section->name, (int) datasize); |
return TRUE; |
} |
fprintf (file, _("\nThere is an export table in %s at 0x%lx\n"), |
section->name, (unsigned long) addr); |
1700,14 → 1469,9 |
fprintf (file, |
_("Name \t\t\t\t")); |
bfd_fprintf_vma (abfd, file, edt.name); |
fprintf (file, |
" %s\n", data + edt.name - adj); |
if ((edt.name >= adj) && (edt.name < adj + datasize)) |
fprintf (file, " %.*s\n", |
(int) (datasize - (edt.name - adj)), |
data + edt.name - adj); |
else |
fprintf (file, "(outside .edata section)\n"); |
fprintf (file, |
_("Ordinal Base \t\t\t%ld\n"), edt.base); |
1752,16 → 1516,7 |
_("\nExport Address Table -- Ordinal Base %ld\n"), |
edt.base); |
/* PR 17512: Handle corrupt PE binaries. */ |
if (edt.eat_addr + (edt.num_functions * 4) - adj >= datasize |
/* PR 17512: file: 092b1829 */ |
|| (edt.num_functions * 4) < edt.num_functions |
/* PR 17512 file: 140-165018-0.004. */ |
|| data + edt.eat_addr - adj < data) |
fprintf (file, _("\tInvalid Export Address Table rva (0x%lx) or entry count (0x%lx)\n"), |
(long) edt.eat_addr, |
(long) edt.num_functions); |
else for (i = 0; i < edt.num_functions; ++i) |
for (i = 0; i < edt.num_functions; ++i) |
{ |
bfd_vma eat_member = bfd_get_32 (abfd, |
data + edt.eat_addr + (i * 4) - adj); |
1773,12 → 1528,11 |
/* This rva is to a name (forwarding function) in our section. */ |
/* Should locate a function descriptor. */ |
fprintf (file, |
"\t[%4ld] +base[%4ld] %04lx %s -- %.*s\n", |
"\t[%4ld] +base[%4ld] %04lx %s -- %s\n", |
(long) i, |
(long) (i + edt.base), |
(unsigned long) eat_member, |
_("Forwarder RVA"), |
(int)(datasize - (eat_member - adj)), |
data + eat_member - adj); |
} |
else |
1798,41 → 1552,22 |
fprintf (file, |
_("\n[Ordinal/Name Pointer] Table\n")); |
/* PR 17512: Handle corrupt PE binaries. */ |
if (edt.npt_addr + (edt.num_names * 4) - adj >= datasize |
/* PR 17512: file: bb68816e. */ |
|| edt.num_names * 4 < edt.num_names |
|| (data + edt.npt_addr - adj) < data) |
fprintf (file, _("\tInvalid Name Pointer Table rva (0x%lx) or entry count (0x%lx)\n"), |
(long) edt.npt_addr, |
(long) edt.num_names); |
/* PR 17512: file: 140-147171-0.004. */ |
else if (edt.ot_addr + (edt.num_names * 2) - adj >= datasize |
|| data + edt.ot_addr - adj < data) |
fprintf (file, _("\tInvalid Ordinal Table rva (0x%lx) or entry count (0x%lx)\n"), |
(long) edt.ot_addr, |
(long) edt.num_names); |
else for (i = 0; i < edt.num_names; ++i) |
for (i = 0; i < edt.num_names; ++i) |
{ |
bfd_vma name_ptr; |
bfd_vma ord; |
bfd_vma name_ptr = bfd_get_32 (abfd, |
data + |
edt.npt_addr |
+ (i*4) - adj); |
ord = bfd_get_16 (abfd, data + edt.ot_addr + (i * 2) - adj); |
name_ptr = bfd_get_32 (abfd, data + edt.npt_addr + (i * 4) - adj); |
if ((name_ptr - adj) >= datasize) |
{ |
fprintf (file, _("\t[%4ld] <corrupt offset: %lx>\n"), |
(long) ord, (long) name_ptr); |
} |
else |
{ |
char * name = (char *) data + name_ptr - adj; |
fprintf (file, "\t[%4ld] %.*s\n", (long) ord, |
(int)((char *)(data + datasize) - name), name); |
bfd_vma ord = bfd_get_16 (abfd, |
data + |
edt.ot_addr |
+ (i*2) - adj); |
fprintf (file, |
"\t[%4ld] %s\n", (long) ord, name); |
} |
} |
free (data); |
1893,14 → 1628,6 |
if (datasize == 0) |
return TRUE; |
/* PR 17512: file: 002-193900-0.004. */ |
if (datasize < stop) |
{ |
fprintf (file, _("Virtual size of .pdata section (%ld) larger than real size (%ld)\n"), |
(long) stop, (long) datasize); |
return FALSE; |
} |
if (! bfd_malloc_and_get_section (abfd, section, &data)) |
{ |
if (data != NULL) |
2010,11 → 1737,7 |
if (storage < 0) |
return NULL; |
if (storage) |
{ |
sy = (asymbol **) bfd_malloc (storage); |
if (sy == NULL) |
return NULL; |
} |
psc->symcount = bfd_canonicalize_symtab (abfd, sy); |
if (psc->symcount < 0) |
2192,11 → 1915,15 |
FILE *file = (FILE *) vfile; |
bfd_byte *data = 0; |
asection *section = bfd_get_section_by_name (abfd, ".reloc"); |
bfd_byte *p, *end; |
bfd_size_type i; |
bfd_size_type start, stop; |
if (section == NULL || section->size == 0 || !(section->flags & SEC_HAS_CONTENTS)) |
if (section == NULL) |
return TRUE; |
if (section->size == 0) |
return TRUE; |
fprintf (file, |
_("\n\nPE File Base Relocations (interpreted .reloc section contents)\n")); |
2207,20 → 1934,20 |
return FALSE; |
} |
p = data; |
end = data + section->size; |
while (p + 8 <= end) |
start = 0; |
stop = section->size; |
for (i = start; i < stop;) |
{ |
int j; |
bfd_vma virtual_address; |
unsigned long number, size; |
bfd_byte *chunk_end; |
long number, size; |
/* The .reloc section is a sequence of blocks, with a header consisting |
of two 32 bit quantities, followed by a number of 16 bit entries. */ |
virtual_address = bfd_get_32 (abfd, p); |
size = bfd_get_32 (abfd, p + 4); |
p += 8; |
virtual_address = bfd_get_32 (abfd, data+i); |
size = bfd_get_32 (abfd, data+i+4); |
number = (size - 8) / 2; |
if (size == 0) |
2228,15 → 1955,11 |
fprintf (file, |
_("\nVirtual Address: %08lx Chunk size %ld (0x%lx) Number of fixups %ld\n"), |
(unsigned long) virtual_address, size, size, number); |
(unsigned long) virtual_address, size, (unsigned long) size, number); |
chunk_end = p + size; |
if (chunk_end > end) |
chunk_end = end; |
j = 0; |
while (p + 2 <= chunk_end) |
for (j = 0; j < number; ++j) |
{ |
unsigned short e = bfd_get_16 (abfd, p); |
unsigned short e = bfd_get_16 (abfd, data + i + 8 + j * 2); |
unsigned int t = (e & 0xF000) >> 12; |
int off = e & 0x0FFF; |
2247,459 → 1970,27 |
_("\treloc %4d offset %4x [%4lx] %s"), |
j, off, (unsigned long) (off + virtual_address), tbl[t]); |
p += 2; |
j++; |
/* HIGHADJ takes an argument, - the next record *is* the |
low 16 bits of addend. */ |
if (t == IMAGE_REL_BASED_HIGHADJ && p + 2 <= chunk_end) |
if (t == IMAGE_REL_BASED_HIGHADJ) |
{ |
fprintf (file, " (%4x)", (unsigned int) bfd_get_16 (abfd, p)); |
p += 2; |
fprintf (file, " (%4x)", |
((unsigned int) |
bfd_get_16 (abfd, data + i + 8 + j * 2 + 2))); |
j++; |
} |
fprintf (file, "\n"); |
} |
} |
free (data); |
return TRUE; |
i += size; |
} |
/* A data structure describing the regions of a .rsrc section. |
Some fields are filled in as the section is parsed. */ |
typedef struct rsrc_regions |
{ |
bfd_byte * section_start; |
bfd_byte * section_end; |
bfd_byte * strings_start; |
bfd_byte * resource_start; |
} rsrc_regions; |
static bfd_byte * |
rsrc_print_resource_directory (FILE * , bfd *, unsigned int, bfd_byte *, |
rsrc_regions *, bfd_vma); |
/* Print the resource entry at DATA, with the text indented by INDENT. |
Recusively calls rsrc_print_resource_directory to print the contents |
of directory entries. |
Returns the address of the end of the data associated with the entry |
or section_end + 1 upon failure. */ |
static bfd_byte * |
rsrc_print_resource_entries (FILE * file, |
bfd * abfd, |
unsigned int indent, |
bfd_boolean is_name, |
bfd_byte * data, |
rsrc_regions * regions, |
bfd_vma rva_bias) |
{ |
unsigned long entry, addr, size; |
bfd_byte * leaf; |
if (data + 8 >= regions->section_end) |
return regions->section_end + 1; |
fprintf (file, _("%03x %*.s Entry: "), (int)(data - regions->section_start), indent, " "); |
entry = (unsigned long) bfd_get_32 (abfd, data); |
if (is_name) |
{ |
bfd_byte * name; |
/* Note - the documentation says that this field is an RVA value |
but windres appears to produce a section relative offset with |
the top bit set. Support both styles for now. */ |
if (HighBitSet (entry)) |
name = regions->section_start + WithoutHighBit (entry); |
else |
name = regions->section_start + entry - rva_bias; |
if (name + 2 < regions->section_end && name > regions->section_start) |
{ |
unsigned int len; |
if (regions->strings_start == NULL) |
regions->strings_start = name; |
len = bfd_get_16 (abfd, name); |
fprintf (file, _("name: [val: %08lx len %d]: "), entry, len); |
if (name + 2 + len * 2 < regions->section_end) |
{ |
/* This strange loop is to cope with multibyte characters. */ |
while (len --) |
{ |
char c; |
name += 2; |
c = * name; |
/* Avoid printing control characters. */ |
if (c > 0 && c < 32) |
fprintf (file, "^%c", c + 64); |
else |
fprintf (file, "%.1s", name); |
} |
} |
else |
{ |
fprintf (file, _("<corrupt string length: %#x>\n"), len); |
/* PR binutils/17512: Do not try to continue decoding a |
corrupted resource section. It is likely to end up with |
reams of extraneous output. FIXME: We could probably |
continue if we disable the printing of strings... */ |
return regions->section_end + 1; |
} |
} |
else |
{ |
fprintf (file, _("<corrupt string offset: %#lx>\n"), entry); |
return regions->section_end + 1; |
} |
} |
else |
fprintf (file, _("ID: %#08lx"), entry); |
entry = (long) bfd_get_32 (abfd, data + 4); |
fprintf (file, _(", Value: %#08lx\n"), entry); |
if (HighBitSet (entry)) |
{ |
data = regions->section_start + WithoutHighBit (entry); |
if (data <= regions->section_start || data > regions->section_end) |
return regions->section_end + 1; |
/* FIXME: PR binutils/17512: A corrupt file could contain a loop |
in the resource table. We need some way to detect this. */ |
return rsrc_print_resource_directory (file, abfd, indent + 1, data, |
regions, rva_bias); |
} |
leaf = regions->section_start + entry; |
if (leaf + 16 >= regions->section_end |
/* PR 17512: file: 055dff7e. */ |
|| leaf < regions->section_start) |
return regions->section_end + 1; |
fprintf (file, _("%03x %*.s Leaf: Addr: %#08lx, Size: %#08lx, Codepage: %d\n"), |
(int) (entry), indent, " ", |
addr = (long) bfd_get_32 (abfd, leaf), |
size = (long) bfd_get_32 (abfd, leaf + 4), |
(int) bfd_get_32 (abfd, leaf + 8)); |
/* Check that the reserved entry is 0. */ |
if (bfd_get_32 (abfd, leaf + 12) != 0 |
/* And that the data address/size is valid too. */ |
|| (regions->section_start + (addr - rva_bias) + size > regions->section_end)) |
return regions->section_end + 1; |
if (regions->resource_start == NULL) |
regions->resource_start = regions->section_start + (addr - rva_bias); |
return regions->section_start + (addr - rva_bias) + size; |
} |
#define max(a,b) ((a) > (b) ? (a) : (b)) |
#define min(a,b) ((a) < (b) ? (a) : (b)) |
static bfd_byte * |
rsrc_print_resource_directory (FILE * file, |
bfd * abfd, |
unsigned int indent, |
bfd_byte * data, |
rsrc_regions * regions, |
bfd_vma rva_bias) |
{ |
unsigned int num_names, num_ids; |
bfd_byte * highest_data = data; |
if (data + 16 >= regions->section_end) |
return regions->section_end + 1; |
fprintf (file, "%03x %*.s ", (int)(data - regions->section_start), indent, " "); |
switch (indent) |
{ |
case 0: fprintf (file, "Type"); break; |
case 2: fprintf (file, "Name"); break; |
case 4: fprintf (file, "Language"); break; |
default: |
fprintf (file, _("<unknown directory type: %d>\n"), indent); |
/* FIXME: For now we end the printing here. If in the |
future more directory types are added to the RSRC spec |
then we will need to change this. */ |
return regions->section_end + 1; |
} |
fprintf (file, _(" Table: Char: %d, Time: %08lx, Ver: %d/%d, Num Names: %d, IDs: %d\n"), |
(int) bfd_get_32 (abfd, data), |
(long) bfd_get_32 (abfd, data + 4), |
(int) bfd_get_16 (abfd, data + 8), |
(int) bfd_get_16 (abfd, data + 10), |
num_names = (int) bfd_get_16 (abfd, data + 12), |
num_ids = (int) bfd_get_16 (abfd, data + 14)); |
data += 16; |
while (num_names --) |
{ |
bfd_byte * entry_end; |
entry_end = rsrc_print_resource_entries (file, abfd, indent + 1, TRUE, |
data, regions, rva_bias); |
data += 8; |
highest_data = max (highest_data, entry_end); |
if (entry_end >= regions->section_end) |
return entry_end; |
} |
while (num_ids --) |
{ |
bfd_byte * entry_end; |
entry_end = rsrc_print_resource_entries (file, abfd, indent + 1, FALSE, |
data, regions, rva_bias); |
data += 8; |
highest_data = max (highest_data, entry_end); |
if (entry_end >= regions->section_end) |
return entry_end; |
} |
return max (highest_data, data); |
} |
/* Display the contents of a .rsrc section. We do not try to |
reproduce the resources, windres does that. Instead we dump |
the tables in a human readable format. */ |
static bfd_boolean |
rsrc_print_section (bfd * abfd, void * vfile) |
{ |
bfd_vma rva_bias; |
pe_data_type * pe; |
FILE * file = (FILE *) vfile; |
bfd_size_type datasize; |
asection * section; |
bfd_byte * data; |
rsrc_regions regions; |
pe = pe_data (abfd); |
if (pe == NULL) |
return TRUE; |
section = bfd_get_section_by_name (abfd, ".rsrc"); |
if (section == NULL) |
return TRUE; |
if (!(section->flags & SEC_HAS_CONTENTS)) |
return TRUE; |
datasize = section->size; |
if (datasize == 0) |
return TRUE; |
rva_bias = section->vma - pe->pe_opthdr.ImageBase; |
if (! bfd_malloc_and_get_section (abfd, section, & data)) |
{ |
if (data != NULL) |
free (data); |
return FALSE; |
} |
regions.section_start = data; |
regions.section_end = data + datasize; |
regions.strings_start = NULL; |
regions.resource_start = NULL; |
fflush (file); |
fprintf (file, "\nThe .rsrc Resource Directory section:\n"); |
while (data < regions.section_end) |
{ |
bfd_byte * p = data; |
data = rsrc_print_resource_directory (file, abfd, 0, data, & regions, rva_bias); |
if (data == regions.section_end + 1) |
fprintf (file, _("Corrupt .rsrc section detected!\n")); |
else |
{ |
/* Align data before continuing. */ |
int align = (1 << section->alignment_power) - 1; |
data = (bfd_byte *) (((ptrdiff_t) (data + align)) & ~ align); |
rva_bias += data - p; |
/* For reasons that are unclear .rsrc sections are sometimes created |
aligned to a 1^3 boundary even when their alignment is set at |
1^2. Catch that case here before we issue a spurious warning |
message. */ |
if (data == (regions.section_end - 4)) |
data = regions.section_end; |
else if (data < regions.section_end) |
{ |
/* If the extra data is all zeros then do not complain. |
This is just padding so that the section meets the |
page size requirements. */ |
while (++ data < regions.section_end) |
if (*data != 0) |
break; |
if (data < regions.section_end) |
fprintf (file, _("\nWARNING: Extra data in .rsrc section - it will be ignored by Windows:\n")); |
} |
} |
} |
if (regions.strings_start != NULL) |
fprintf (file, " String table starts at offset: %#03x\n", |
(int) (regions.strings_start - regions.section_start)); |
if (regions.resource_start != NULL) |
fprintf (file, " Resources start at offset: %#03x\n", |
(int) (regions.resource_start - regions.section_start)); |
free (regions.section_start); |
return TRUE; |
} |
#define IMAGE_NUMBEROF_DEBUG_TYPES 12 |
static char * debug_type_names[IMAGE_NUMBEROF_DEBUG_TYPES] = |
{ |
"Unknown", |
"COFF", |
"CodeView", |
"FPO", |
"Misc", |
"Exception", |
"Fixup", |
"OMAP-to-SRC", |
"OMAP-from-SRC", |
"Borland", |
"Reserved", |
"CLSID", |
}; |
static bfd_boolean |
pe_print_debugdata (bfd * abfd, void * vfile) |
{ |
FILE *file = (FILE *) vfile; |
pe_data_type *pe = pe_data (abfd); |
struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; |
asection *section; |
bfd_byte *data = 0; |
bfd_size_type dataoff; |
unsigned int i; |
bfd_vma addr = extra->DataDirectory[PE_DEBUG_DATA].VirtualAddress; |
bfd_size_type size = extra->DataDirectory[PE_DEBUG_DATA].Size; |
if (size == 0) |
return TRUE; |
addr += extra->ImageBase; |
for (section = abfd->sections; section != NULL; section = section->next) |
{ |
if ((addr >= section->vma) && (addr < (section->vma + section->size))) |
break; |
} |
if (section == NULL) |
{ |
fprintf (file, |
_("\nThere is a debug directory, but the section containing it could not be found\n")); |
return TRUE; |
} |
else if (!(section->flags & SEC_HAS_CONTENTS)) |
{ |
fprintf (file, |
_("\nThere is a debug directory in %s, but that section has no contents\n"), |
section->name); |
return TRUE; |
} |
else if (section->size < size) |
{ |
fprintf (file, |
_("\nError: section %s contains the debug data starting address but it is too small\n"), |
section->name); |
return FALSE; |
} |
fprintf (file, _("\nThere is a debug directory in %s at 0x%lx\n\n"), |
section->name, (unsigned long) addr); |
dataoff = addr - section->vma; |
if (size > (section->size - dataoff)) |
{ |
fprintf (file, _("The debug data size field in the data directory is too big for the section")); |
return FALSE; |
} |
fprintf (file, |
_("Type Size Rva Offset\n")); |
/* Read the whole section. */ |
if (!bfd_malloc_and_get_section (abfd, section, &data)) |
{ |
if (data != NULL) |
free (data); |
return FALSE; |
} |
for (i = 0; i < size / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) |
{ |
const char *type_name; |
struct external_IMAGE_DEBUG_DIRECTORY *ext |
= &((struct external_IMAGE_DEBUG_DIRECTORY *)(data + dataoff))[i]; |
struct internal_IMAGE_DEBUG_DIRECTORY idd; |
_bfd_pei_swap_debugdir_in (abfd, ext, &idd); |
if ((idd.Type) >= IMAGE_NUMBEROF_DEBUG_TYPES) |
type_name = debug_type_names[0]; |
else |
type_name = debug_type_names[idd.Type]; |
fprintf (file, " %2ld %14s %08lx %08lx %08lx\n", |
idd.Type, type_name, idd.SizeOfData, |
idd.AddressOfRawData, idd.PointerToRawData); |
if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW) |
{ |
char signature[CV_INFO_SIGNATURE_LENGTH * 2 + 1]; |
/* PR 17512: file: 065-29434-0.001:0.1 |
We need to use a 32-bit aligned buffer |
to safely read in a codeview record. */ |
char buffer[256 + 1] ATTRIBUTE_ALIGNED_ALIGNOF (CODEVIEW_INFO); |
CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer; |
/* The debug entry doesn't have to have to be in a section, |
in which case AddressOfRawData is 0, so always use PointerToRawData. */ |
if (!_bfd_pei_slurp_codeview_record (abfd, (file_ptr) idd.PointerToRawData, |
idd.SizeOfData, cvinfo)) |
continue; |
for (i = 0; i < cvinfo->SignatureLength; i++) |
sprintf (&signature[i*2], "%02x", cvinfo->Signature[i] & 0xff); |
fprintf (file, "(format %c%c%c%c signature %s age %ld)\n", |
buffer[0], buffer[1], buffer[2], buffer[3], |
signature, cvinfo->Age); |
} |
} |
if (size % sizeof (struct external_IMAGE_DEBUG_DIRECTORY) != 0) |
fprintf (file, |
_("The debug directory size is not a multiple of the debug directory entry size\n")); |
return TRUE; |
} |
/* Print out the program headers. */ |
bfd_boolean |
2873,26 → 2164,10 |
else |
pe_print_pdata (abfd, vfile); |
pe_print_reloc (abfd, vfile); |
pe_print_debugdata (abfd, file); |
rsrc_print_section (abfd, vfile); |
return TRUE; |
} |
static bfd_boolean |
is_vma_in_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sect, void *obj) |
{ |
bfd_vma addr = * (bfd_vma *) obj; |
return (addr >= sect->vma) && (addr < (sect->vma + sect->size)); |
} |
static asection * |
find_section_by_vma (bfd *abfd, bfd_vma addr) |
{ |
return bfd_sections_find_if (abfd, is_vma_in_section, (void *) & addr); |
} |
/* Copy any private info we understand from the input bfd |
to the output bfd. */ |
2931,65 → 2206,6 |
&& ! (pe_data (ibfd)->real_flags & IMAGE_FILE_RELOCS_STRIPPED)) |
pe_data (obfd)->dont_strip_reloc = 1; |
/* The file offsets contained in the debug directory need rewriting. */ |
if (ope->pe_opthdr.DataDirectory[PE_DEBUG_DATA].Size != 0) |
{ |
bfd_vma addr = ope->pe_opthdr.DataDirectory[PE_DEBUG_DATA].VirtualAddress |
+ ope->pe_opthdr.ImageBase; |
asection *section = find_section_by_vma (obfd, addr); |
bfd_byte *data; |
if (section && bfd_malloc_and_get_section (obfd, section, &data)) |
{ |
unsigned int i; |
struct external_IMAGE_DEBUG_DIRECTORY *dd = |
(struct external_IMAGE_DEBUG_DIRECTORY *)(data + (addr - section->vma)); |
/* PR 17512: file: 0f15796a. */ |
if (ope->pe_opthdr.DataDirectory[PE_DEBUG_DATA].Size + (addr - section->vma) |
> bfd_get_section_size (section)) |
{ |
_bfd_error_handler (_("%B: Data Directory size (%lx) exceeds space left in section (%lx)"), |
obfd, ope->pe_opthdr.DataDirectory[PE_DEBUG_DATA].Size, |
bfd_get_section_size (section) - (addr - section->vma)); |
return FALSE; |
} |
for (i = 0; i < ope->pe_opthdr.DataDirectory[PE_DEBUG_DATA].Size |
/ sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) |
{ |
asection *ddsection; |
struct external_IMAGE_DEBUG_DIRECTORY *edd = &(dd[i]); |
struct internal_IMAGE_DEBUG_DIRECTORY idd; |
_bfd_pei_swap_debugdir_in (obfd, edd, &idd); |
if (idd.AddressOfRawData == 0) |
continue; /* RVA 0 means only offset is valid, not handled yet. */ |
ddsection = find_section_by_vma (obfd, idd.AddressOfRawData + ope->pe_opthdr.ImageBase); |
if (!ddsection) |
continue; /* Not in a section! */ |
idd.PointerToRawData = ddsection->filepos + (idd.AddressOfRawData |
+ ope->pe_opthdr.ImageBase) - ddsection->vma; |
_bfd_pei_swap_debugdir_out (obfd, &idd, edd); |
} |
if (!bfd_set_section_contents (obfd, section, data, 0, section->size)) |
{ |
_bfd_error_handler (_("Failed to update file offsets in debug directory")); |
return FALSE; |
} |
} |
else if (section) |
{ |
_bfd_error_handler (_("%B: Failed to read debug data section"), obfd); |
return FALSE; |
} |
} |
return TRUE; |
} |
3054,1269 → 2270,6 |
} |
#endif |
/* Functions to process a .rsrc section. */ |
static unsigned int sizeof_leaves; |
static unsigned int sizeof_strings; |
static unsigned int sizeof_tables_and_entries; |
static bfd_byte * |
rsrc_count_directory (bfd *, bfd_byte *, bfd_byte *, bfd_byte *, bfd_vma); |
static bfd_byte * |
rsrc_count_entries (bfd * abfd, |
bfd_boolean is_name, |
bfd_byte * datastart, |
bfd_byte * data, |
bfd_byte * dataend, |
bfd_vma rva_bias) |
{ |
unsigned long entry, addr, size; |
if (data + 8 >= dataend) |
return dataend + 1; |
if (is_name) |
{ |
bfd_byte * name; |
entry = (long) bfd_get_32 (abfd, data); |
if (HighBitSet (entry)) |
name = datastart + WithoutHighBit (entry); |
else |
name = datastart + entry - rva_bias; |
if (name + 2 >= dataend || name < datastart) |
return dataend + 1; |
unsigned int len = bfd_get_16 (abfd, name); |
if (len == 0 || len > 256) |
return dataend + 1; |
} |
entry = (long) bfd_get_32 (abfd, data + 4); |
if (HighBitSet (entry)) |
{ |
data = datastart + WithoutHighBit (entry); |
if (data <= datastart || data >= dataend) |
return dataend + 1; |
return rsrc_count_directory (abfd, datastart, data, dataend, rva_bias); |
} |
if (datastart + entry + 16 >= dataend) |
return dataend + 1; |
addr = (long) bfd_get_32 (abfd, datastart + entry); |
size = (long) bfd_get_32 (abfd, datastart + entry + 4); |
return datastart + addr - rva_bias + size; |
} |
static bfd_byte * |
rsrc_count_directory (bfd * abfd, |
bfd_byte * datastart, |
bfd_byte * data, |
bfd_byte * dataend, |
bfd_vma rva_bias) |
{ |
unsigned int num_entries, num_ids; |
bfd_byte * highest_data = data; |
if (data + 16 >= dataend) |
return dataend + 1; |
num_entries = (int) bfd_get_16 (abfd, data + 12); |
num_ids = (int) bfd_get_16 (abfd, data + 14); |
num_entries += num_ids; |
data += 16; |
while (num_entries --) |
{ |
bfd_byte * entry_end; |
entry_end = rsrc_count_entries (abfd, num_entries >= num_ids, |
datastart, data, dataend, rva_bias); |
data += 8; |
highest_data = max (highest_data, entry_end); |
if (entry_end >= dataend) |
break; |
} |
return max (highest_data, data); |
} |
typedef struct rsrc_dir_chain |
{ |
unsigned int num_entries; |
struct rsrc_entry * first_entry; |
struct rsrc_entry * last_entry; |
} rsrc_dir_chain; |
typedef struct rsrc_directory |
{ |
unsigned int characteristics; |
unsigned int time; |
unsigned int major; |
unsigned int minor; |
rsrc_dir_chain names; |
rsrc_dir_chain ids; |
struct rsrc_entry * entry; |
} rsrc_directory; |
typedef struct rsrc_string |
{ |
unsigned int len; |
bfd_byte * string; |
} rsrc_string; |
typedef struct rsrc_leaf |
{ |
unsigned int size; |
unsigned int codepage; |
bfd_byte * data; |
} rsrc_leaf; |
typedef struct rsrc_entry |
{ |
bfd_boolean is_name; |
union |
{ |
unsigned int id; |
struct rsrc_string name; |
} name_id; |
bfd_boolean is_dir; |
union |
{ |
struct rsrc_directory * directory; |
struct rsrc_leaf * leaf; |
} value; |
struct rsrc_entry * next_entry; |
struct rsrc_directory * parent; |
} rsrc_entry; |
static bfd_byte * |
rsrc_parse_directory (bfd *, rsrc_directory *, bfd_byte *, |
bfd_byte *, bfd_byte *, bfd_vma, rsrc_entry *); |
static bfd_byte * |
rsrc_parse_entry (bfd * abfd, |
bfd_boolean is_name, |
rsrc_entry * entry, |
bfd_byte * datastart, |
bfd_byte * data, |
bfd_byte * dataend, |
bfd_vma rva_bias, |
rsrc_directory * parent) |
{ |
unsigned long val, addr, size; |
val = bfd_get_32 (abfd, data); |
entry->parent = parent; |
entry->is_name = is_name; |
if (is_name) |
{ |
bfd_byte * address; |
if (HighBitSet (val)) |
{ |
val = WithoutHighBit (val); |
address = datastart + val; |
} |
else |
{ |
address = datastart + val - rva_bias; |
} |
if (address + 3 > dataend) |
return dataend; |
entry->name_id.name.len = bfd_get_16 (abfd, address); |
entry->name_id.name.string = address + 2; |
} |
else |
entry->name_id.id = val; |
val = bfd_get_32 (abfd, data + 4); |
if (HighBitSet (val)) |
{ |
entry->is_dir = TRUE; |
entry->value.directory = bfd_malloc (sizeof * entry->value.directory); |
if (entry->value.directory == NULL) |
return dataend; |
return rsrc_parse_directory (abfd, entry->value.directory, |
datastart, |
datastart + WithoutHighBit (val), |
dataend, rva_bias, entry); |
} |
entry->is_dir = FALSE; |
entry->value.leaf = bfd_malloc (sizeof * entry->value.leaf); |
if (entry->value.leaf == NULL) |
return dataend; |
data = datastart + val; |
if (data < datastart || data >= dataend) |
return dataend; |
addr = bfd_get_32 (abfd, data); |
size = entry->value.leaf->size = bfd_get_32 (abfd, data + 4); |
entry->value.leaf->codepage = bfd_get_32 (abfd, data + 8); |
/* FIXME: We assume that the reserved field (data + 12) is OK. */ |
entry->value.leaf->data = bfd_malloc (size); |
if (entry->value.leaf->data == NULL) |
return dataend; |
memcpy (entry->value.leaf->data, datastart + addr - rva_bias, size); |
return datastart + (addr - rva_bias) + size; |
} |
static bfd_byte * |
rsrc_parse_entries (bfd * abfd, |
rsrc_dir_chain * chain, |
bfd_boolean is_name, |
bfd_byte * highest_data, |
bfd_byte * datastart, |
bfd_byte * data, |
bfd_byte * dataend, |
bfd_vma rva_bias, |
rsrc_directory * parent) |
{ |
unsigned int i; |
rsrc_entry * entry; |
if (chain->num_entries == 0) |
{ |
chain->first_entry = chain->last_entry = NULL; |
return highest_data; |
} |
entry = bfd_malloc (sizeof * entry); |
if (entry == NULL) |
return dataend; |
chain->first_entry = entry; |
for (i = chain->num_entries; i--;) |
{ |
bfd_byte * entry_end; |
entry_end = rsrc_parse_entry (abfd, is_name, entry, datastart, |
data, dataend, rva_bias, parent); |
data += 8; |
highest_data = max (entry_end, highest_data); |
if (entry_end > dataend) |
return dataend; |
if (i) |
{ |
entry->next_entry = bfd_malloc (sizeof * entry); |
entry = entry->next_entry; |
if (entry == NULL) |
return dataend; |
} |
else |
entry->next_entry = NULL; |
} |
chain->last_entry = entry; |
return highest_data; |
} |
static bfd_byte * |
rsrc_parse_directory (bfd * abfd, |
rsrc_directory * table, |
bfd_byte * datastart, |
bfd_byte * data, |
bfd_byte * dataend, |
bfd_vma rva_bias, |
rsrc_entry * entry) |
{ |
bfd_byte * highest_data = data; |
if (table == NULL) |
return dataend; |
table->characteristics = bfd_get_32 (abfd, data); |
table->time = bfd_get_32 (abfd, data + 4); |
table->major = bfd_get_16 (abfd, data + 8); |
table->minor = bfd_get_16 (abfd, data + 10); |
table->names.num_entries = bfd_get_16 (abfd, data + 12); |
table->ids.num_entries = bfd_get_16 (abfd, data + 14); |
table->entry = entry; |
data += 16; |
highest_data = rsrc_parse_entries (abfd, & table->names, TRUE, data, |
datastart, data, dataend, rva_bias, table); |
data += table->names.num_entries * 8; |
highest_data = rsrc_parse_entries (abfd, & table->ids, FALSE, highest_data, |
datastart, data, dataend, rva_bias, table); |
data += table->ids.num_entries * 8; |
return max (highest_data, data); |
} |
typedef struct rsrc_write_data |
{ |
bfd * abfd; |
bfd_byte * datastart; |
bfd_byte * next_table; |
bfd_byte * next_leaf; |
bfd_byte * next_string; |
bfd_byte * next_data; |
bfd_vma rva_bias; |
} rsrc_write_data; |
static void |
rsrc_write_string (rsrc_write_data * data, |
rsrc_string * string) |
{ |
bfd_put_16 (data->abfd, string->len, data->next_string); |
memcpy (data->next_string + 2, string->string, string->len * 2); |
data->next_string += (string->len + 1) * 2; |
} |
static inline unsigned int |
rsrc_compute_rva (rsrc_write_data * data, |
bfd_byte * addr) |
{ |
return (addr - data->datastart) + data->rva_bias; |
} |
static void |
rsrc_write_leaf (rsrc_write_data * data, |
rsrc_leaf * leaf) |
{ |
bfd_put_32 (data->abfd, rsrc_compute_rva (data, data->next_data), |
data->next_leaf); |
bfd_put_32 (data->abfd, leaf->size, data->next_leaf + 4); |
bfd_put_32 (data->abfd, leaf->codepage, data->next_leaf + 8); |
bfd_put_32 (data->abfd, 0 /*reserved*/, data->next_leaf + 12); |
data->next_leaf += 16; |
memcpy (data->next_data, leaf->data, leaf->size); |
/* An undocumented feature of Windows resources is that each unit |
of raw data is 8-byte aligned... */ |
data->next_data += ((leaf->size + 7) & ~7); |
} |
static void rsrc_write_directory (rsrc_write_data *, rsrc_directory *); |
static void |
rsrc_write_entry (rsrc_write_data * data, |
bfd_byte * where, |
rsrc_entry * entry) |
{ |
if (entry->is_name) |
{ |
bfd_put_32 (data->abfd, |
SetHighBit (data->next_string - data->datastart), |
where); |
rsrc_write_string (data, & entry->name_id.name); |
} |
else |
bfd_put_32 (data->abfd, entry->name_id.id, where); |
if (entry->is_dir) |
{ |
bfd_put_32 (data->abfd, |
SetHighBit (data->next_table - data->datastart), |
where + 4); |
rsrc_write_directory (data, entry->value.directory); |
} |
else |
{ |
bfd_put_32 (data->abfd, data->next_leaf - data->datastart, where + 4); |
rsrc_write_leaf (data, entry->value.leaf); |
} |
} |
static void |
rsrc_compute_region_sizes (rsrc_directory * dir) |
{ |
struct rsrc_entry * entry; |
if (dir == NULL) |
return; |
sizeof_tables_and_entries += 16; |
for (entry = dir->names.first_entry; entry != NULL; entry = entry->next_entry) |
{ |
sizeof_tables_and_entries += 8; |
sizeof_strings += (entry->name_id.name.len + 1) * 2; |
if (entry->is_dir) |
rsrc_compute_region_sizes (entry->value.directory); |
else |
sizeof_leaves += 16; |
} |
for (entry = dir->ids.first_entry; entry != NULL; entry = entry->next_entry) |
{ |
sizeof_tables_and_entries += 8; |
if (entry->is_dir) |
rsrc_compute_region_sizes (entry->value.directory); |
else |
sizeof_leaves += 16; |
} |
} |
static void |
rsrc_write_directory (rsrc_write_data * data, |
rsrc_directory * dir) |
{ |
rsrc_entry * entry; |
unsigned int i; |
bfd_byte * next_entry; |
bfd_byte * nt; |
bfd_put_32 (data->abfd, dir->characteristics, data->next_table); |
bfd_put_32 (data->abfd, 0 /*dir->time*/, data->next_table + 4); |
bfd_put_16 (data->abfd, dir->major, data->next_table + 8); |
bfd_put_16 (data->abfd, dir->minor, data->next_table + 10); |
bfd_put_16 (data->abfd, dir->names.num_entries, data->next_table + 12); |
bfd_put_16 (data->abfd, dir->ids.num_entries, data->next_table + 14); |
/* Compute where the entries and the next table will be placed. */ |
next_entry = data->next_table + 16; |
data->next_table = next_entry + (dir->names.num_entries * 8) |
+ (dir->ids.num_entries * 8); |
nt = data->next_table; |
/* Write the entries. */ |
for (i = dir->names.num_entries, entry = dir->names.first_entry; |
i > 0 && entry != NULL; |
i--, entry = entry->next_entry) |
{ |
BFD_ASSERT (entry->is_name); |
rsrc_write_entry (data, next_entry, entry); |
next_entry += 8; |
} |
BFD_ASSERT (i == 0); |
BFD_ASSERT (entry == NULL); |
for (i = dir->ids.num_entries, entry = dir->ids.first_entry; |
i > 0 && entry != NULL; |
i--, entry = entry->next_entry) |
{ |
BFD_ASSERT (! entry->is_name); |
rsrc_write_entry (data, next_entry, entry); |
next_entry += 8; |
} |
BFD_ASSERT (i == 0); |
BFD_ASSERT (entry == NULL); |
BFD_ASSERT (nt == next_entry); |
} |
#if defined HAVE_WCHAR_H && ! defined __CYGWIN__ && ! defined __MINGW32__ |
/* Return the length (number of units) of the first character in S, |
putting its 'ucs4_t' representation in *PUC. */ |
static unsigned int |
#if defined HAVE_WCTYPE_H |
u16_mbtouc (wint_t * puc, const unsigned short * s, unsigned int n) |
#else |
u16_mbtouc (wchar_t * puc, const unsigned short * s, unsigned int n) |
#endif |
{ |
unsigned short c = * s; |
if (c < 0xd800 || c >= 0xe000) |
{ |
*puc = c; |
return 1; |
} |
if (c < 0xdc00) |
{ |
if (n >= 2) |
{ |
if (s[1] >= 0xdc00 && s[1] < 0xe000) |
{ |
*puc = 0x10000 + ((c - 0xd800) << 10) + (s[1] - 0xdc00); |
return 2; |
} |
} |
else |
{ |
/* Incomplete multibyte character. */ |
*puc = 0xfffd; |
return n; |
} |
} |
/* Invalid multibyte character. */ |
*puc = 0xfffd; |
return 1; |
} |
#endif /* HAVE_WCHAR_H and not Cygwin/Mingw */ |
/* Perform a comparison of two entries. */ |
static signed int |
rsrc_cmp (bfd_boolean is_name, rsrc_entry * a, rsrc_entry * b) |
{ |
signed int res; |
bfd_byte * astring; |
unsigned int alen; |
bfd_byte * bstring; |
unsigned int blen; |
if (! is_name) |
return a->name_id.id - b->name_id.id; |
/* We have to perform a case insenstive, unicode string comparison... */ |
astring = a->name_id.name.string; |
alen = a->name_id.name.len; |
bstring = b->name_id.name.string; |
blen = b->name_id.name.len; |
#if defined __CYGWIN__ || defined __MINGW32__ |
/* Under Windows hosts (both Cygwin and Mingw types), |
unicode == UTF-16 == wchar_t. The case insensitive string comparison |
function however goes by different names in the two environments... */ |
#undef rscpcmp |
#ifdef __CYGWIN__ |
#define rscpcmp wcsncasecmp |
#endif |
#ifdef __MINGW32__ |
#define rscpcmp wcsnicmp |
#endif |
res = rscpcmp ((const wchar_t *) astring, (const wchar_t *) bstring, |
min (alen, blen)); |
#elif defined HAVE_WCHAR_H |
{ |
unsigned int i; |
res = 0; |
for (i = min (alen, blen); i--; astring += 2, bstring += 2) |
{ |
#if defined HAVE_WCTYPE_H |
wint_t awc; |
wint_t bwc; |
#else |
wchar_t awc; |
wchar_t bwc; |
#endif |
/* Convert UTF-16 unicode characters into wchar_t characters |
so that we can then perform a case insensitive comparison. */ |
unsigned int Alen = u16_mbtouc (& awc, (const unsigned short *) astring, 2); |
unsigned int Blen = u16_mbtouc (& bwc, (const unsigned short *) bstring, 2); |
if (Alen != Blen) |
return Alen - Blen; |
#ifdef HAVE_WCTYPE_H |
awc = towlower (awc); |
bwc = towlower (bwc); |
res = awc - bwc; |
#else |
res = wcsncasecmp (& awc, & bwc, 1); |
#endif |
if (res) |
break; |
} |
} |
#else |
/* Do the best we can - a case sensitive, untranslated comparison. */ |
res = memcmp (astring, bstring, min (alen, blen) * 2); |
#endif |
if (res == 0) |
res = alen - blen; |
return res; |
} |
static void |
rsrc_print_name (char * buffer, rsrc_string string) |
{ |
unsigned int i; |
bfd_byte * name = string.string; |
for (i = string.len; i--; name += 2) |
sprintf (buffer + strlen (buffer), "%.1s", name); |
} |
static const char * |
rsrc_resource_name (rsrc_entry * entry, rsrc_directory * dir) |
{ |
static char buffer [256]; |
bfd_boolean is_string = FALSE; |
buffer[0] = 0; |
if (dir != NULL && dir->entry != NULL && dir->entry->parent != NULL |
&& dir->entry->parent->entry != NULL) |
{ |
strcpy (buffer, "type: "); |
if (dir->entry->parent->entry->is_name) |
rsrc_print_name (buffer + strlen (buffer), |
dir->entry->parent->entry->name_id.name); |
else |
{ |
unsigned int id = dir->entry->parent->entry->name_id.id; |
sprintf (buffer + strlen (buffer), "%x", id); |
switch (id) |
{ |
case 1: strcat (buffer, " (CURSOR)"); break; |
case 2: strcat (buffer, " (BITMAP)"); break; |
case 3: strcat (buffer, " (ICON)"); break; |
case 4: strcat (buffer, " (MENU)"); break; |
case 5: strcat (buffer, " (DIALOG)"); break; |
case 6: strcat (buffer, " (STRING)"); is_string = TRUE; break; |
case 7: strcat (buffer, " (FONTDIR)"); break; |
case 8: strcat (buffer, " (FONT)"); break; |
case 9: strcat (buffer, " (ACCELERATOR)"); break; |
case 10: strcat (buffer, " (RCDATA)"); break; |
case 11: strcat (buffer, " (MESSAGETABLE)"); break; |
case 12: strcat (buffer, " (GROUP_CURSOR)"); break; |
case 14: strcat (buffer, " (GROUP_ICON)"); break; |
case 16: strcat (buffer, " (VERSION)"); break; |
case 17: strcat (buffer, " (DLGINCLUDE)"); break; |
case 19: strcat (buffer, " (PLUGPLAY)"); break; |
case 20: strcat (buffer, " (VXD)"); break; |
case 21: strcat (buffer, " (ANICURSOR)"); break; |
case 22: strcat (buffer, " (ANIICON)"); break; |
case 23: strcat (buffer, " (HTML)"); break; |
case 24: strcat (buffer, " (MANIFEST)"); break; |
case 240: strcat (buffer, " (DLGINIT)"); break; |
case 241: strcat (buffer, " (TOOLBAR)"); break; |
} |
} |
} |
if (dir != NULL && dir->entry != NULL) |
{ |
strcat (buffer, " name: "); |
if (dir->entry->is_name) |
rsrc_print_name (buffer + strlen (buffer), dir->entry->name_id.name); |
else |
{ |
unsigned int id = dir->entry->name_id.id; |
sprintf (buffer + strlen (buffer), "%x", id); |
if (is_string) |
sprintf (buffer + strlen (buffer), " (resource id range: %d - %d)", |
(id - 1) << 4, (id << 4) - 1); |
} |
} |
if (entry != NULL) |
{ |
strcat (buffer, " lang: "); |
if (entry->is_name) |
rsrc_print_name (buffer + strlen (buffer), entry->name_id.name); |
else |
sprintf (buffer + strlen (buffer), "%x", entry->name_id.id); |
} |
return buffer; |
} |
/* *sigh* Windows resource strings are special. Only the top 28-bits of |
their ID is stored in the NAME entry. The bottom four bits are used as |
an index into unicode string table that makes up the data of the leaf. |
So identical type-name-lang string resources may not actually be |
identical at all. |
This function is called when we have detected two string resources with |
match top-28-bit IDs. We have to scan the string tables inside the leaves |
and discover if there are any real collisions. If there are then we report |
them and return FALSE. Otherwise we copy any strings from B into A and |
then return TRUE. */ |
static bfd_boolean |
rsrc_merge_string_entries (rsrc_entry * a ATTRIBUTE_UNUSED, |
rsrc_entry * b ATTRIBUTE_UNUSED) |
{ |
unsigned int copy_needed = 0; |
unsigned int i; |
bfd_byte * astring; |
bfd_byte * bstring; |
bfd_byte * new_data; |
bfd_byte * nstring; |
/* Step one: Find out what we have to do. */ |
BFD_ASSERT (! a->is_dir); |
astring = a->value.leaf->data; |
BFD_ASSERT (! b->is_dir); |
bstring = b->value.leaf->data; |
for (i = 0; i < 16; i++) |
{ |
unsigned int alen = astring[0] + (astring[1] << 8); |
unsigned int blen = bstring[0] + (bstring[1] << 8); |
if (alen == 0) |
{ |
copy_needed += blen * 2; |
} |
else if (blen == 0) |
; |
else if (alen != blen) |
/* FIXME: Should we continue the loop in order to report other duplicates ? */ |
break; |
/* alen == blen != 0. We might have two identical strings. If so we |
can ignore the second one. There is no need for wchar_t vs UTF-16 |
theatrics here - we are only interested in (case sensitive) equality. */ |
else if (memcmp (astring + 2, bstring + 2, alen * 2) != 0) |
break; |
astring += (alen + 1) * 2; |
bstring += (blen + 1) * 2; |
} |
if (i != 16) |
{ |
if (a->parent != NULL |
&& a->parent->entry != NULL |
&& a->parent->entry->is_name == FALSE) |
_bfd_error_handler (_(".rsrc merge failure: duplicate string resource: %d"), |
((a->parent->entry->name_id.id - 1) << 4) + i); |
return FALSE; |
} |
if (copy_needed == 0) |
return TRUE; |
/* If we reach here then A and B must both have non-colliding strings. |
(We never get string resources with fully empty string tables). |
We need to allocate an extra COPY_NEEDED bytes in A and then bring |
in B's strings. */ |
new_data = bfd_malloc (a->value.leaf->size + copy_needed); |
if (new_data == NULL) |
return FALSE; |
nstring = new_data; |
astring = a->value.leaf->data; |
bstring = b->value.leaf->data; |
for (i = 0; i < 16; i++) |
{ |
unsigned int alen = astring[0] + (astring[1] << 8); |
unsigned int blen = bstring[0] + (bstring[1] << 8); |
if (alen != 0) |
{ |
memcpy (nstring, astring, (alen + 1) * 2); |
nstring += (alen + 1) * 2; |
} |
else if (blen != 0) |
{ |
memcpy (nstring, bstring, (blen + 1) * 2); |
nstring += (blen + 1) * 2; |
} |
else |
{ |
* nstring++ = 0; |
* nstring++ = 0; |
} |
astring += (alen + 1) * 2; |
bstring += (blen + 1) * 2; |
} |
BFD_ASSERT (nstring - new_data == (signed) (a->value.leaf->size + copy_needed)); |
free (a->value.leaf->data); |
a->value.leaf->data = new_data; |
a->value.leaf->size += copy_needed; |
return TRUE; |
} |
static void rsrc_merge (rsrc_entry *, rsrc_entry *); |
/* Sort the entries in given part of the directory. |
We use an old fashioned bubble sort because we are dealing |
with lists and we want to handle matches specially. */ |
static void |
rsrc_sort_entries (rsrc_dir_chain * chain, |
bfd_boolean is_name, |
rsrc_directory * dir) |
{ |
rsrc_entry * entry; |
rsrc_entry * next; |
rsrc_entry ** points_to_entry; |
bfd_boolean swapped; |
if (chain->num_entries < 2) |
return; |
do |
{ |
swapped = FALSE; |
points_to_entry = & chain->first_entry; |
entry = * points_to_entry; |
next = entry->next_entry; |
do |
{ |
signed int cmp = rsrc_cmp (is_name, entry, next); |
if (cmp > 0) |
{ |
entry->next_entry = next->next_entry; |
next->next_entry = entry; |
* points_to_entry = next; |
points_to_entry = & next->next_entry; |
next = entry->next_entry; |
swapped = TRUE; |
} |
else if (cmp == 0) |
{ |
if (entry->is_dir && next->is_dir) |
{ |
/* When we encounter identical directory entries we have to |
merge them together. The exception to this rule is for |
resource manifests - there can only be one of these, |
even if they differ in language. Zero-language manifests |
are assumed to be default manifests (provided by the |
Cygwin/MinGW build system) and these can be silently dropped, |
unless that would reduce the number of manifests to zero. |
There should only ever be one non-zero lang manifest - |
if there are more it is an error. A non-zero lang |
manifest takes precedence over a default manifest. */ |
if (entry->is_name == FALSE |
&& entry->name_id.id == 1 |
&& dir != NULL |
&& dir->entry != NULL |
&& dir->entry->is_name == FALSE |
&& dir->entry->name_id.id == 0x18) |
{ |
if (next->value.directory->names.num_entries == 0 |
&& next->value.directory->ids.num_entries == 1 |
&& next->value.directory->ids.first_entry->is_name == FALSE |
&& next->value.directory->ids.first_entry->name_id.id == 0) |
/* Fall through so that NEXT is dropped. */ |
; |
else if (entry->value.directory->names.num_entries == 0 |
&& entry->value.directory->ids.num_entries == 1 |
&& entry->value.directory->ids.first_entry->is_name == FALSE |
&& entry->value.directory->ids.first_entry->name_id.id == 0) |
{ |
/* Swap ENTRY and NEXT. Then fall through so that the old ENTRY is dropped. */ |
entry->next_entry = next->next_entry; |
next->next_entry = entry; |
* points_to_entry = next; |
points_to_entry = & next->next_entry; |
next = entry->next_entry; |
swapped = TRUE; |
} |
else |
{ |
_bfd_error_handler (_(".rsrc merge failure: multiple non-default manifests")); |
bfd_set_error (bfd_error_file_truncated); |
return; |
} |
/* Unhook NEXT from the chain. */ |
/* FIXME: memory loss here. */ |
entry->next_entry = next->next_entry; |
chain->num_entries --; |
if (chain->num_entries < 2) |
return; |
next = next->next_entry; |
} |
else |
rsrc_merge (entry, next); |
} |
else if (entry->is_dir != next->is_dir) |
{ |
_bfd_error_handler (_(".rsrc merge failure: a directory matches a leaf")); |
bfd_set_error (bfd_error_file_truncated); |
return; |
} |
else |
{ |
/* Otherwise with identical leaves we issue an error |
message - because there should never be duplicates. |
The exception is Type 18/Name 1/Lang 0 which is the |
defaul manifest - this can just be dropped. */ |
if (entry->is_name == FALSE |
&& entry->name_id.id == 0 |
&& dir != NULL |
&& dir->entry != NULL |
&& dir->entry->is_name == FALSE |
&& dir->entry->name_id.id == 1 |
&& dir->entry->parent != NULL |
&& dir->entry->parent->entry != NULL |
&& dir->entry->parent->entry->is_name == FALSE |
&& dir->entry->parent->entry->name_id.id == 0x18 /* RT_MANIFEST */) |
; |
else if (dir != NULL |
&& dir->entry != NULL |
&& dir->entry->parent != NULL |
&& dir->entry->parent->entry != NULL |
&& dir->entry->parent->entry->is_name == FALSE |
&& dir->entry->parent->entry->name_id.id == 0x6 /* RT_STRING */) |
{ |
/* Strings need special handling. */ |
if (! rsrc_merge_string_entries (entry, next)) |
{ |
/* _bfd_error_handler should have been called inside merge_strings. */ |
bfd_set_error (bfd_error_file_truncated); |
return; |
} |
} |
else |
{ |
if (dir == NULL |
|| dir->entry == NULL |
|| dir->entry->parent == NULL |
|| dir->entry->parent->entry == NULL) |
_bfd_error_handler (_(".rsrc merge failure: duplicate leaf")); |
else |
_bfd_error_handler (_(".rsrc merge failure: duplicate leaf: %s"), |
rsrc_resource_name (entry, dir)); |
bfd_set_error (bfd_error_file_truncated); |
return; |
} |
} |
/* Unhook NEXT from the chain. */ |
entry->next_entry = next->next_entry; |
chain->num_entries --; |
if (chain->num_entries < 2) |
return; |
next = next->next_entry; |
} |
else |
{ |
points_to_entry = & entry->next_entry; |
entry = next; |
next = next->next_entry; |
} |
} |
while (next); |
chain->last_entry = entry; |
} |
while (swapped); |
} |
/* Attach B's chain onto A. */ |
static void |
rsrc_attach_chain (rsrc_dir_chain * achain, rsrc_dir_chain * bchain) |
{ |
if (bchain->num_entries == 0) |
return; |
achain->num_entries += bchain->num_entries; |
if (achain->first_entry == NULL) |
{ |
achain->first_entry = bchain->first_entry; |
achain->last_entry = bchain->last_entry; |
} |
else |
{ |
achain->last_entry->next_entry = bchain->first_entry; |
achain->last_entry = bchain->last_entry; |
} |
bchain->num_entries = 0; |
bchain->first_entry = bchain->last_entry = NULL; |
} |
static void |
rsrc_merge (struct rsrc_entry * a, struct rsrc_entry * b) |
{ |
rsrc_directory * adir; |
rsrc_directory * bdir; |
BFD_ASSERT (a->is_dir); |
BFD_ASSERT (b->is_dir); |
adir = a->value.directory; |
bdir = b->value.directory; |
if (adir->characteristics != bdir->characteristics) |
{ |
_bfd_error_handler (_(".rsrc merge failure: dirs with differing characteristics\n")); |
bfd_set_error (bfd_error_file_truncated); |
return; |
} |
if (adir->major != bdir->major || adir->minor != bdir->minor) |
{ |
_bfd_error_handler (_(".rsrc merge failure: differing directory versions\n")); |
bfd_set_error (bfd_error_file_truncated); |
return; |
} |
/* Attach B's name chain to A. */ |
rsrc_attach_chain (& adir->names, & bdir->names); |
/* Attach B's ID chain to A. */ |
rsrc_attach_chain (& adir->ids, & bdir->ids); |
/* Now sort A's entries. */ |
rsrc_sort_entries (& adir->names, TRUE, adir); |
rsrc_sort_entries (& adir->ids, FALSE, adir); |
} |
/* Check the .rsrc section. If it contains multiple concatenated |
resources then we must merge them properly. Otherwise Windows |
will ignore all but the first set. */ |
static void |
rsrc_process_section (bfd * abfd, |
struct coff_final_link_info * pfinfo) |
{ |
rsrc_directory new_table; |
bfd_size_type size; |
asection * sec; |
pe_data_type * pe; |
bfd_vma rva_bias; |
bfd_byte * data; |
bfd_byte * datastart; |
bfd_byte * dataend; |
bfd_byte * new_data; |
unsigned int num_resource_sets; |
rsrc_directory * type_tables; |
rsrc_write_data write_data; |
unsigned int indx; |
bfd * input; |
unsigned int num_input_rsrc = 0; |
unsigned int max_num_input_rsrc = 4; |
ptrdiff_t * rsrc_sizes = NULL; |
new_table.names.num_entries = 0; |
new_table.ids.num_entries = 0; |
sec = bfd_get_section_by_name (abfd, ".rsrc"); |
if (sec == NULL || (size = sec->rawsize) == 0) |
return; |
pe = pe_data (abfd); |
if (pe == NULL) |
return; |
rva_bias = sec->vma - pe->pe_opthdr.ImageBase; |
data = bfd_malloc (size); |
if (data == NULL) |
return; |
datastart = data; |
if (! bfd_get_section_contents (abfd, sec, data, 0, size)) |
goto end; |
/* Step zero: Scan the input bfds looking for .rsrc sections and record |
their lengths. Note - we rely upon the fact that the linker script |
does *not* sort the input .rsrc sections, so that the order in the |
linkinfo list matches the order in the output .rsrc section. |
We need to know the lengths because each input .rsrc section has padding |
at the end of a variable amount. (It does not appear to be based upon |
the section alignment or the file alignment). We need to skip any |
padding bytes when parsing the input .rsrc sections. */ |
rsrc_sizes = bfd_malloc (max_num_input_rsrc * sizeof * rsrc_sizes); |
if (rsrc_sizes == NULL) |
goto end; |
for (input = pfinfo->info->input_bfds; |
input != NULL; |
input = input->link.next) |
{ |
asection * rsrc_sec = bfd_get_section_by_name (input, ".rsrc"); |
/* PR 18372 - skip discarded .rsrc sections. */ |
if (rsrc_sec != NULL && !discarded_section (rsrc_sec)) |
{ |
if (num_input_rsrc == max_num_input_rsrc) |
{ |
max_num_input_rsrc += 10; |
rsrc_sizes = bfd_realloc (rsrc_sizes, max_num_input_rsrc |
* sizeof * rsrc_sizes); |
if (rsrc_sizes == NULL) |
goto end; |
} |
BFD_ASSERT (rsrc_sec->size > 0); |
rsrc_sizes [num_input_rsrc ++] = rsrc_sec->size; |
} |
} |
if (num_input_rsrc < 2) |
goto end; |
/* Step one: Walk the section, computing the size of the tables, |
leaves and data and decide if we need to do anything. */ |
dataend = data + size; |
num_resource_sets = 0; |
while (data < dataend) |
{ |
bfd_byte * p = data; |
data = rsrc_count_directory (abfd, data, data, dataend, rva_bias); |
if (data > dataend) |
{ |
/* Corrupted .rsrc section - cannot merge. */ |
_bfd_error_handler (_("%s: .rsrc merge failure: corrupt .rsrc section"), |
bfd_get_filename (abfd)); |
bfd_set_error (bfd_error_file_truncated); |
goto end; |
} |
if ((data - p) > rsrc_sizes [num_resource_sets]) |
{ |
_bfd_error_handler (_("%s: .rsrc merge failure: unexpected .rsrc size"), |
bfd_get_filename (abfd)); |
bfd_set_error (bfd_error_file_truncated); |
goto end; |
} |
/* FIXME: Should we add a check for "data - p" being much smaller |
than rsrc_sizes[num_resource_sets] ? */ |
data = p + rsrc_sizes[num_resource_sets]; |
rva_bias += data - p; |
++ num_resource_sets; |
} |
BFD_ASSERT (num_resource_sets == num_input_rsrc); |
/* Step two: Walk the data again, building trees of the resources. */ |
data = datastart; |
rva_bias = sec->vma - pe->pe_opthdr.ImageBase; |
type_tables = bfd_malloc (num_resource_sets * sizeof * type_tables); |
if (type_tables == NULL) |
goto end; |
indx = 0; |
while (data < dataend) |
{ |
bfd_byte * p = data; |
(void) rsrc_parse_directory (abfd, type_tables + indx, data, data, |
dataend, rva_bias, NULL); |
data = p + rsrc_sizes[indx]; |
rva_bias += data - p; |
++ indx; |
} |
BFD_ASSERT (indx == num_resource_sets); |
/* Step three: Merge the top level tables (there can be only one). |
We must ensure that the merged entries are in ascending order. |
We also thread the top level table entries from the old tree onto |
the new table, so that they can be pulled off later. */ |
/* FIXME: Should we verify that all type tables are the same ? */ |
new_table.characteristics = type_tables[0].characteristics; |
new_table.time = type_tables[0].time; |
new_table.major = type_tables[0].major; |
new_table.minor = type_tables[0].minor; |
/* Chain the NAME entries onto the table. */ |
new_table.names.first_entry = NULL; |
new_table.names.last_entry = NULL; |
for (indx = 0; indx < num_resource_sets; indx++) |
rsrc_attach_chain (& new_table.names, & type_tables[indx].names); |
rsrc_sort_entries (& new_table.names, TRUE, & new_table); |
/* Chain the ID entries onto the table. */ |
new_table.ids.first_entry = NULL; |
new_table.ids.last_entry = NULL; |
for (indx = 0; indx < num_resource_sets; indx++) |
rsrc_attach_chain (& new_table.ids, & type_tables[indx].ids); |
rsrc_sort_entries (& new_table.ids, FALSE, & new_table); |
/* Step four: Create new contents for the .rsrc section. */ |
/* Step four point one: Compute the size of each region of the .rsrc section. |
We do this now, rather than earlier, as the merging above may have dropped |
some entries. */ |
sizeof_leaves = sizeof_strings = sizeof_tables_and_entries = 0; |
rsrc_compute_region_sizes (& new_table); |
/* We increment sizeof_strings to make sure that resource data |
starts on an 8-byte boundary. FIXME: Is this correct ? */ |
sizeof_strings = (sizeof_strings + 7) & ~ 7; |
new_data = bfd_zalloc (abfd, size); |
if (new_data == NULL) |
goto end; |
write_data.abfd = abfd; |
write_data.datastart = new_data; |
write_data.next_table = new_data; |
write_data.next_leaf = new_data + sizeof_tables_and_entries; |
write_data.next_string = write_data.next_leaf + sizeof_leaves; |
write_data.next_data = write_data.next_string + sizeof_strings; |
write_data.rva_bias = sec->vma - pe->pe_opthdr.ImageBase; |
rsrc_write_directory (& write_data, & new_table); |
/* Step five: Replace the old contents with the new. |
We recompute the size as we may have lost entries due to mergeing. */ |
size = ((write_data.next_data - new_data) + 3) & ~ 3; |
{ |
int page_size; |
if (coff_data (abfd)->link_info) |
{ |
page_size = pe_data (abfd)->pe_opthdr.FileAlignment; |
/* If no file alignment has been set, default to one. |
This repairs 'ld -r' for arm-wince-pe target. */ |
if (page_size == 0) |
page_size = 1; |
} |
else |
page_size = PE_DEF_FILE_ALIGNMENT; |
size = (size + page_size - 1) & - page_size; |
} |
bfd_set_section_contents (pfinfo->output_bfd, sec, new_data, 0, size); |
sec->size = sec->rawsize = size; |
end: |
/* Step six: Free all the memory that we have used. */ |
/* FIXME: Free the resource tree, if we have one. */ |
free (datastart); |
free (rsrc_sizes); |
} |
/* Handle the .idata section and other things that need symbol table |
access. */ |
4522,14 → 2475,10 |
} |
free (tmp_data); |
} |
else |
result = FALSE; |
} |
} |
#endif |
rsrc_process_section (abfd, pfinfo); |
/* If we couldn't find idata$2, we either have an excessively |
trivial program or are in DEEP trouble; we have to assume trivial |
program.... */ |
/contrib/toolchain/binutils/bfd/reloc.c |
---|
1,5 → 1,5 |
/* BFD support for handling relocation entries. |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990-2013 Free Software Foundation, Inc. |
Written by Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
437,7 → 437,6 |
case 3: return 0; |
case 4: return 8; |
case 8: return 16; |
case -1: return 2; |
case -2: return 4; |
default: abort (); |
} |
579,7 → 578,7 |
{ |
bfd_vma relocation; |
bfd_reloc_status_type flag = bfd_reloc_ok; |
bfd_size_type octets; |
bfd_size_type octets = reloc_entry->address * bfd_octets_per_byte (abfd); |
bfd_vma output_base = 0; |
reloc_howto_type *howto = reloc_entry->howto; |
asection *reloc_target_output_section; |
593,10 → 592,6 |
return bfd_reloc_ok; |
} |
/* PR 17512: file: 0f67f69d. */ |
if (howto == NULL) |
return bfd_reloc_undefined; |
/* If we are not producing relocatable output, return an error if |
the symbol is not defined. An undefined weak symbol is |
considered to have a value of zero (SVR4 ABI, p. 4-27). */ |
618,12 → 613,8 |
return cont; |
} |
/* Is the address of the relocation really within the section? |
Include the size of the reloc in the test for out of range addresses. |
PR 17512: file: c146ab8b, 46dff27f, 38e53ebf. */ |
octets = reloc_entry->address * bfd_octets_per_byte (abfd); |
if (octets + bfd_get_reloc_size (howto) |
> bfd_get_section_limit_octets (abfd, input_section)) |
/* Is the address of the relocation really within the section? */ |
if (reloc_entry->address > bfd_get_section_limit (abfd, input_section)) |
return bfd_reloc_outofrange; |
/* Work out which section the relocation is targeted at and the |
793,6 → 784,10 |
} |
} |
} |
else |
{ |
reloc_entry->addend = 0; |
} |
/* FIXME: This overflow checking is incomplete, because the value |
might have overflowed before we get here. For a correct check we |
973,7 → 968,7 |
{ |
bfd_vma relocation; |
bfd_reloc_status_type flag = bfd_reloc_ok; |
bfd_size_type octets; |
bfd_size_type octets = reloc_entry->address * bfd_octets_per_byte (abfd); |
bfd_vma output_base = 0; |
reloc_howto_type *howto = reloc_entry->howto; |
asection *reloc_target_output_section; |
1006,9 → 1001,7 |
} |
/* Is the address of the relocation really within the section? */ |
octets = reloc_entry->address * bfd_octets_per_byte (abfd); |
if (octets + bfd_get_reloc_size (howto) |
> bfd_get_section_limit_octets (abfd, input_section)) |
if (reloc_entry->address > bfd_get_section_limit (abfd, input_section)) |
return bfd_reloc_outofrange; |
/* Work out which section the relocation is targeted at and the |
1343,11 → 1336,9 |
bfd_vma addend) |
{ |
bfd_vma relocation; |
bfd_size_type octets = address * bfd_octets_per_byte (input_bfd); |
/* Sanity check the address. */ |
if (octets + bfd_get_reloc_size (howto) |
> bfd_get_section_limit_octets (input_bfd, input_section)) |
if (address > bfd_get_section_limit (input_bfd, input_section)) |
return bfd_reloc_outofrange; |
/* This function assumes that we are dealing with a basic relocation |
1402,9 → 1393,8 |
switch (size) |
{ |
default: |
case 0: |
abort (); |
case 0: |
return bfd_reloc_ok; |
case 1: |
x = bfd_get_8 (input_bfd, location); |
break; |
1571,9 → 1561,8 |
switch (size) |
{ |
default: |
case 0: |
abort (); |
case 0: |
return; |
case 1: |
x = bfd_get_8 (input_bfd, location); |
break; |
2304,17 → 2293,6 |
microMIPS PC-relative relocations. |
ENUM |
BFD_RELOC_MIPS_21_PCREL_S2 |
ENUMX |
BFD_RELOC_MIPS_26_PCREL_S2 |
ENUMX |
BFD_RELOC_MIPS_18_PCREL_S3 |
ENUMX |
BFD_RELOC_MIPS_19_PCREL_S2 |
ENUMDOC |
MIPS PC-relative relocations. |
ENUM |
BFD_RELOC_MICROMIPS_GPREL16 |
ENUMX |
BFD_RELOC_MICROMIPS_HI16 |
2456,18 → 2434,6 |
COMMENT |
ENUM |
BFD_RELOC_FT32_10 |
ENUMX |
BFD_RELOC_FT32_20 |
ENUMX |
BFD_RELOC_FT32_17 |
ENUMX |
BFD_RELOC_FT32_18 |
ENUMDOC |
FT32 ELF relocations. |
COMMENT |
ENUM |
BFD_RELOC_FRV_LABEL16 |
ENUMX |
BFD_RELOC_FRV_LABEL24 |
2676,8 → 2642,6 |
BFD_RELOC_386_TLS_DESC |
ENUMX |
BFD_RELOC_386_IRELATIVE |
ENUMX |
BFD_RELOC_386_GOT32X |
ENUMDOC |
i386/elf relocations |
2739,10 → 2703,6 |
BFD_RELOC_X86_64_PC32_BND |
ENUMX |
BFD_RELOC_X86_64_PLT32_BND |
ENUMX |
BFD_RELOC_X86_64_GOTPCRELX |
ENUMX |
BFD_RELOC_X86_64_REX_GOTPCRELX |
ENUMDOC |
x86-64/elf relocations |
2890,8 → 2850,6 |
ENUMX |
BFD_RELOC_PPC_VLE_SDAREL_HA16D |
ENUMX |
BFD_RELOC_PPC_REL16DX_HA |
ENUMX |
BFD_RELOC_PPC64_HIGHER |
ENUMX |
BFD_RELOC_PPC64_HIGHER_S |
2941,10 → 2899,6 |
BFD_RELOC_PPC64_ADDR16_HIGH |
ENUMX |
BFD_RELOC_PPC64_ADDR16_HIGHA |
ENUMX |
BFD_RELOC_PPC64_ADDR64_LOCAL |
ENUMX |
BFD_RELOC_PPC64_ENTRY |
ENUMDOC |
Power(rs6000) and PowerPC relocations. |
3525,139 → 3479,18 |
Renesas / SuperH SH relocs. Not all of these appear in object files. |
ENUM |
BFD_RELOC_ARC_NONE |
ENUMX |
BFD_RELOC_ARC_8 |
ENUMX |
BFD_RELOC_ARC_16 |
ENUMX |
BFD_RELOC_ARC_24 |
ENUMX |
BFD_RELOC_ARC_32 |
ENUMX |
BFD_RELOC_ARC_N8 |
ENUMX |
BFD_RELOC_ARC_N16 |
ENUMX |
BFD_RELOC_ARC_N24 |
ENUMX |
BFD_RELOC_ARC_N32 |
ENUMX |
BFD_RELOC_ARC_SDA |
ENUMX |
BFD_RELOC_ARC_SECTOFF |
ENUMX |
BFD_RELOC_ARC_S21H_PCREL |
ENUMX |
BFD_RELOC_ARC_S21W_PCREL |
ENUMX |
BFD_RELOC_ARC_S25H_PCREL |
ENUMX |
BFD_RELOC_ARC_S25W_PCREL |
ENUMX |
BFD_RELOC_ARC_SDA32 |
ENUMX |
BFD_RELOC_ARC_SDA_LDST |
ENUMX |
BFD_RELOC_ARC_SDA_LDST1 |
ENUMX |
BFD_RELOC_ARC_SDA_LDST2 |
ENUMX |
BFD_RELOC_ARC_SDA16_LD |
ENUMX |
BFD_RELOC_ARC_SDA16_LD1 |
ENUMX |
BFD_RELOC_ARC_SDA16_LD2 |
ENUMX |
BFD_RELOC_ARC_S13_PCREL |
ENUMX |
BFD_RELOC_ARC_W |
ENUMX |
BFD_RELOC_ARC_32_ME |
ENUMX |
BFD_RELOC_ARC_32_ME_S |
ENUMX |
BFD_RELOC_ARC_N32_ME |
ENUMX |
BFD_RELOC_ARC_SECTOFF_ME |
ENUMX |
BFD_RELOC_ARC_SDA32_ME |
ENUMX |
BFD_RELOC_ARC_W_ME |
ENUMX |
BFD_RELOC_AC_SECTOFF_U8 |
ENUMX |
BFD_RELOC_AC_SECTOFF_U8_1 |
ENUMX |
BFD_RELOC_AC_SECTOFF_U8_2 |
ENUMX |
BFD_RELOC_AC_SECTFOFF_S9 |
ENUMX |
BFD_RELOC_AC_SECTFOFF_S9_1 |
ENUMX |
BFD_RELOC_AC_SECTFOFF_S9_2 |
ENUMX |
BFD_RELOC_ARC_SECTOFF_ME_1 |
ENUMX |
BFD_RELOC_ARC_SECTOFF_ME_2 |
ENUMX |
BFD_RELOC_ARC_SECTOFF_1 |
ENUMX |
BFD_RELOC_ARC_SECTOFF_2 |
ENUMX |
BFD_RELOC_ARC_SDA16_ST2 |
ENUMX |
BFD_RELOC_ARC_32_PCREL |
ENUMX |
BFD_RELOC_ARC_PC32 |
ENUMX |
BFD_RELOC_ARC_GOT32 |
ENUMX |
BFD_RELOC_ARC_GOTPC32 |
ENUMX |
BFD_RELOC_ARC_PLT32 |
ENUMX |
BFD_RELOC_ARC_COPY |
ENUMX |
BFD_RELOC_ARC_GLOB_DAT |
ENUMX |
BFD_RELOC_ARC_JMP_SLOT |
ENUMX |
BFD_RELOC_ARC_RELATIVE |
ENUMX |
BFD_RELOC_ARC_GOTOFF |
ENUMX |
BFD_RELOC_ARC_GOTPC |
ENUMX |
BFD_RELOC_ARC_S21W_PCREL_PLT |
ENUMX |
BFD_RELOC_ARC_S25H_PCREL_PLT |
ENUMX |
BFD_RELOC_ARC_TLS_DTPMOD |
ENUMX |
BFD_RELOC_ARC_TLS_TPOFF |
ENUMX |
BFD_RELOC_ARC_TLS_GD_GOT |
ENUMX |
BFD_RELOC_ARC_TLS_GD_LD |
ENUMX |
BFD_RELOC_ARC_TLS_GD_CALL |
ENUMX |
BFD_RELOC_ARC_TLS_IE_GOT |
ENUMX |
BFD_RELOC_ARC_TLS_DTPOFF |
ENUMX |
BFD_RELOC_ARC_TLS_DTPOFF_S9 |
ENUMX |
BFD_RELOC_ARC_TLS_LE_S9 |
ENUMX |
BFD_RELOC_ARC_TLS_LE_32 |
ENUMX |
BFD_RELOC_ARC_S25W_PCREL_PLT |
ENUMX |
BFD_RELOC_ARC_S21H_PCREL_PLT |
BFD_RELOC_ARC_B22_PCREL |
ENUMDOC |
ARC relocs. |
ARC Cores relocs. |
ARC 22 bit pc-relative branch. The lowest two bits must be zero and are |
not stored in the instruction. The high 20 bits are installed in bits 26 |
through 7 of the instruction. |
ENUM |
BFD_RELOC_ARC_B26 |
ENUMDOC |
ARC 26 bit absolute branch. The lowest two bits must be zero and are not |
stored in the instruction. The high 24 bits are installed in bits 23 |
through 0. |
ENUM |
BFD_RELOC_BFIN_16_IMM |
4006,322 → 3839,6 |
ENUM |
BFD_RELOC_NDS32_20 |
ENUMDOC |
NDS32 relocs. |
This is a 20 bit absolute address. |
ENUM |
BFD_RELOC_NDS32_9_PCREL |
ENUMDOC |
This is a 9-bit pc-relative reloc with the right 1 bit assumed to be 0. |
ENUM |
BFD_RELOC_NDS32_WORD_9_PCREL |
ENUMDOC |
This is a 9-bit pc-relative reloc with the right 1 bit assumed to be 0. |
ENUM |
BFD_RELOC_NDS32_15_PCREL |
ENUMDOC |
This is an 15-bit reloc with the right 1 bit assumed to be 0. |
ENUM |
BFD_RELOC_NDS32_17_PCREL |
ENUMDOC |
This is an 17-bit reloc with the right 1 bit assumed to be 0. |
ENUM |
BFD_RELOC_NDS32_25_PCREL |
ENUMDOC |
This is a 25-bit reloc with the right 1 bit assumed to be 0. |
ENUM |
BFD_RELOC_NDS32_HI20 |
ENUMDOC |
This is a 20-bit reloc containing the high 20 bits of an address |
used with the lower 12 bits |
ENUM |
BFD_RELOC_NDS32_LO12S3 |
ENUMDOC |
This is a 12-bit reloc containing the lower 12 bits of an address |
then shift right by 3. This is used with ldi,sdi... |
ENUM |
BFD_RELOC_NDS32_LO12S2 |
ENUMDOC |
This is a 12-bit reloc containing the lower 12 bits of an address |
then shift left by 2. This is used with lwi,swi... |
ENUM |
BFD_RELOC_NDS32_LO12S1 |
ENUMDOC |
This is a 12-bit reloc containing the lower 12 bits of an address |
then shift left by 1. This is used with lhi,shi... |
ENUM |
BFD_RELOC_NDS32_LO12S0 |
ENUMDOC |
This is a 12-bit reloc containing the lower 12 bits of an address |
then shift left by 0. This is used with lbisbi... |
ENUM |
BFD_RELOC_NDS32_LO12S0_ORI |
ENUMDOC |
This is a 12-bit reloc containing the lower 12 bits of an address |
then shift left by 0. This is only used with branch relaxations |
ENUM |
BFD_RELOC_NDS32_SDA15S3 |
ENUMDOC |
This is a 15-bit reloc containing the small data area 18-bit signed offset |
and shift left by 3 for use in ldi, sdi... |
ENUM |
BFD_RELOC_NDS32_SDA15S2 |
ENUMDOC |
This is a 15-bit reloc containing the small data area 17-bit signed offset |
and shift left by 2 for use in lwi, swi... |
ENUM |
BFD_RELOC_NDS32_SDA15S1 |
ENUMDOC |
This is a 15-bit reloc containing the small data area 16-bit signed offset |
and shift left by 1 for use in lhi, shi... |
ENUM |
BFD_RELOC_NDS32_SDA15S0 |
ENUMDOC |
This is a 15-bit reloc containing the small data area 15-bit signed offset |
and shift left by 0 for use in lbi, sbi... |
ENUM |
BFD_RELOC_NDS32_SDA16S3 |
ENUMDOC |
This is a 16-bit reloc containing the small data area 16-bit signed offset |
and shift left by 3 |
ENUM |
BFD_RELOC_NDS32_SDA17S2 |
ENUMDOC |
This is a 17-bit reloc containing the small data area 17-bit signed offset |
and shift left by 2 for use in lwi.gp, swi.gp... |
ENUM |
BFD_RELOC_NDS32_SDA18S1 |
ENUMDOC |
This is a 18-bit reloc containing the small data area 18-bit signed offset |
and shift left by 1 for use in lhi.gp, shi.gp... |
ENUM |
BFD_RELOC_NDS32_SDA19S0 |
ENUMDOC |
This is a 19-bit reloc containing the small data area 19-bit signed offset |
and shift left by 0 for use in lbi.gp, sbi.gp... |
ENUM |
BFD_RELOC_NDS32_GOT20 |
ENUMX |
BFD_RELOC_NDS32_9_PLTREL |
ENUMX |
BFD_RELOC_NDS32_25_PLTREL |
ENUMX |
BFD_RELOC_NDS32_COPY |
ENUMX |
BFD_RELOC_NDS32_GLOB_DAT |
ENUMX |
BFD_RELOC_NDS32_JMP_SLOT |
ENUMX |
BFD_RELOC_NDS32_RELATIVE |
ENUMX |
BFD_RELOC_NDS32_GOTOFF |
ENUMX |
BFD_RELOC_NDS32_GOTOFF_HI20 |
ENUMX |
BFD_RELOC_NDS32_GOTOFF_LO12 |
ENUMX |
BFD_RELOC_NDS32_GOTPC20 |
ENUMX |
BFD_RELOC_NDS32_GOT_HI20 |
ENUMX |
BFD_RELOC_NDS32_GOT_LO12 |
ENUMX |
BFD_RELOC_NDS32_GOTPC_HI20 |
ENUMX |
BFD_RELOC_NDS32_GOTPC_LO12 |
ENUMDOC |
for PIC |
ENUM |
BFD_RELOC_NDS32_INSN16 |
ENUMX |
BFD_RELOC_NDS32_LABEL |
ENUMX |
BFD_RELOC_NDS32_LONGCALL1 |
ENUMX |
BFD_RELOC_NDS32_LONGCALL2 |
ENUMX |
BFD_RELOC_NDS32_LONGCALL3 |
ENUMX |
BFD_RELOC_NDS32_LONGJUMP1 |
ENUMX |
BFD_RELOC_NDS32_LONGJUMP2 |
ENUMX |
BFD_RELOC_NDS32_LONGJUMP3 |
ENUMX |
BFD_RELOC_NDS32_LOADSTORE |
ENUMX |
BFD_RELOC_NDS32_9_FIXED |
ENUMX |
BFD_RELOC_NDS32_15_FIXED |
ENUMX |
BFD_RELOC_NDS32_17_FIXED |
ENUMX |
BFD_RELOC_NDS32_25_FIXED |
ENUMX |
BFD_RELOC_NDS32_LONGCALL4 |
ENUMX |
BFD_RELOC_NDS32_LONGCALL5 |
ENUMX |
BFD_RELOC_NDS32_LONGCALL6 |
ENUMX |
BFD_RELOC_NDS32_LONGJUMP4 |
ENUMX |
BFD_RELOC_NDS32_LONGJUMP5 |
ENUMX |
BFD_RELOC_NDS32_LONGJUMP6 |
ENUMX |
BFD_RELOC_NDS32_LONGJUMP7 |
ENUMDOC |
for relax |
ENUM |
BFD_RELOC_NDS32_PLTREL_HI20 |
ENUMX |
BFD_RELOC_NDS32_PLTREL_LO12 |
ENUMX |
BFD_RELOC_NDS32_PLT_GOTREL_HI20 |
ENUMX |
BFD_RELOC_NDS32_PLT_GOTREL_LO12 |
ENUMDOC |
for PIC |
ENUM |
BFD_RELOC_NDS32_SDA12S2_DP |
ENUMX |
BFD_RELOC_NDS32_SDA12S2_SP |
ENUMX |
BFD_RELOC_NDS32_LO12S2_DP |
ENUMX |
BFD_RELOC_NDS32_LO12S2_SP |
ENUMDOC |
for floating point |
ENUM |
BFD_RELOC_NDS32_DWARF2_OP1 |
ENUMX |
BFD_RELOC_NDS32_DWARF2_OP2 |
ENUMX |
BFD_RELOC_NDS32_DWARF2_LEB |
ENUMDOC |
for dwarf2 debug_line. |
ENUM |
BFD_RELOC_NDS32_UPDATE_TA |
ENUMDOC |
for eliminate 16-bit instructions |
ENUM |
BFD_RELOC_NDS32_PLT_GOTREL_LO20 |
ENUMX |
BFD_RELOC_NDS32_PLT_GOTREL_LO15 |
ENUMX |
BFD_RELOC_NDS32_PLT_GOTREL_LO19 |
ENUMX |
BFD_RELOC_NDS32_GOT_LO15 |
ENUMX |
BFD_RELOC_NDS32_GOT_LO19 |
ENUMX |
BFD_RELOC_NDS32_GOTOFF_LO15 |
ENUMX |
BFD_RELOC_NDS32_GOTOFF_LO19 |
ENUMX |
BFD_RELOC_NDS32_GOT15S2 |
ENUMX |
BFD_RELOC_NDS32_GOT17S2 |
ENUMDOC |
for PIC object relaxation |
ENUM |
BFD_RELOC_NDS32_5 |
ENUMDOC |
NDS32 relocs. |
This is a 5 bit absolute address. |
ENUM |
BFD_RELOC_NDS32_10_UPCREL |
ENUMDOC |
This is a 10-bit unsigned pc-relative reloc with the right 1 bit assumed to be 0. |
ENUM |
BFD_RELOC_NDS32_SDA_FP7U2_RELA |
ENUMDOC |
If fp were omitted, fp can used as another gp. |
ENUM |
BFD_RELOC_NDS32_RELAX_ENTRY |
ENUMX |
BFD_RELOC_NDS32_GOT_SUFF |
ENUMX |
BFD_RELOC_NDS32_GOTOFF_SUFF |
ENUMX |
BFD_RELOC_NDS32_PLT_GOT_SUFF |
ENUMX |
BFD_RELOC_NDS32_MULCALL_SUFF |
ENUMX |
BFD_RELOC_NDS32_PTR |
ENUMX |
BFD_RELOC_NDS32_PTR_COUNT |
ENUMX |
BFD_RELOC_NDS32_PTR_RESOLVED |
ENUMX |
BFD_RELOC_NDS32_PLTBLOCK |
ENUMX |
BFD_RELOC_NDS32_RELAX_REGION_BEGIN |
ENUMX |
BFD_RELOC_NDS32_RELAX_REGION_END |
ENUMX |
BFD_RELOC_NDS32_MINUEND |
ENUMX |
BFD_RELOC_NDS32_SUBTRAHEND |
ENUMX |
BFD_RELOC_NDS32_DIFF8 |
ENUMX |
BFD_RELOC_NDS32_DIFF16 |
ENUMX |
BFD_RELOC_NDS32_DIFF32 |
ENUMX |
BFD_RELOC_NDS32_DIFF_ULEB128 |
ENUMX |
BFD_RELOC_NDS32_EMPTY |
ENUMDOC |
relaxation relative relocation types |
ENUM |
BFD_RELOC_NDS32_25_ABS |
ENUMDOC |
This is a 25 bit absolute address. |
ENUM |
BFD_RELOC_NDS32_DATA |
ENUMX |
BFD_RELOC_NDS32_TRAN |
ENUMX |
BFD_RELOC_NDS32_17IFC_PCREL |
ENUMX |
BFD_RELOC_NDS32_10IFCU_PCREL |
ENUMDOC |
For ex9 and ifc using. |
ENUM |
BFD_RELOC_NDS32_TPOFF |
ENUMX |
BFD_RELOC_NDS32_TLS_LE_HI20 |
ENUMX |
BFD_RELOC_NDS32_TLS_LE_LO12 |
ENUMX |
BFD_RELOC_NDS32_TLS_LE_ADD |
ENUMX |
BFD_RELOC_NDS32_TLS_LE_LS |
ENUMX |
BFD_RELOC_NDS32_GOTTPOFF |
ENUMX |
BFD_RELOC_NDS32_TLS_IE_HI20 |
ENUMX |
BFD_RELOC_NDS32_TLS_IE_LO12S2 |
ENUMX |
BFD_RELOC_NDS32_TLS_TPOFF |
ENUMX |
BFD_RELOC_NDS32_TLS_LE_20 |
ENUMX |
BFD_RELOC_NDS32_TLS_LE_15S0 |
ENUMX |
BFD_RELOC_NDS32_TLS_LE_15S1 |
ENUMX |
BFD_RELOC_NDS32_TLS_LE_15S2 |
ENUMDOC |
For TLS. |
ENUM |
BFD_RELOC_V850_9_PCREL |
ENUMDOC |
This is a 9-bit reloc |
4993,35 → 4510,8 |
ENUMDOC |
This is a 8 bit reloc for the AVR that stores bits 16..23 of a symbol |
in .byte hlo8(symbol) |
ENUM |
BFD_RELOC_AVR_DIFF8 |
ENUMX |
BFD_RELOC_AVR_DIFF16 |
ENUMX |
BFD_RELOC_AVR_DIFF32 |
ENUMDOC |
AVR relocations to mark the difference of two local symbols. |
These are only needed to support linker relaxation and can be ignored |
when not relaxing. The field is set to the value of the difference |
assuming no relaxation. The relocation encodes the position of the |
second symbol so the linker can determine whether to adjust the field |
value. |
ENUM |
BFD_RELOC_AVR_LDS_STS_16 |
ENUMDOC |
This is a 7 bit reloc for the AVR that stores SRAM address for 16bit |
lds and sts instructions supported only tiny core. |
ENUM |
BFD_RELOC_AVR_PORT6 |
ENUMDOC |
This is a 6 bit reloc for the AVR that stores an I/O register |
number for the IN and OUT instructions |
ENUM |
BFD_RELOC_AVR_PORT5 |
ENUMDOC |
This is a 5 bit reloc for the AVR that stores an I/O register |
number for the SBIC, SBIS, SBI and CBI instructions |
ENUM |
BFD_RELOC_RL78_NEG8 |
ENUMX |
BFD_RELOC_RL78_NEG16 |
5087,8 → 4577,6 |
BFD_RELOC_RL78_LO16 |
ENUMX |
BFD_RELOC_RL78_CODE |
ENUMX |
BFD_RELOC_RL78_SADDR |
ENUMDOC |
Renesas RL78 Relocations. |
6111,55 → 5599,11 |
Intel i860 Relocations. |
ENUM |
BFD_RELOC_OR1K_REL_26 |
BFD_RELOC_OPENRISC_ABS_26 |
ENUMX |
BFD_RELOC_OR1K_GOTPC_HI16 |
ENUMX |
BFD_RELOC_OR1K_GOTPC_LO16 |
ENUMX |
BFD_RELOC_OR1K_GOT16 |
ENUMX |
BFD_RELOC_OR1K_PLT26 |
ENUMX |
BFD_RELOC_OR1K_GOTOFF_HI16 |
ENUMX |
BFD_RELOC_OR1K_GOTOFF_LO16 |
ENUMX |
BFD_RELOC_OR1K_COPY |
ENUMX |
BFD_RELOC_OR1K_GLOB_DAT |
ENUMX |
BFD_RELOC_OR1K_JMP_SLOT |
ENUMX |
BFD_RELOC_OR1K_RELATIVE |
ENUMX |
BFD_RELOC_OR1K_TLS_GD_HI16 |
ENUMX |
BFD_RELOC_OR1K_TLS_GD_LO16 |
ENUMX |
BFD_RELOC_OR1K_TLS_LDM_HI16 |
ENUMX |
BFD_RELOC_OR1K_TLS_LDM_LO16 |
ENUMX |
BFD_RELOC_OR1K_TLS_LDO_HI16 |
ENUMX |
BFD_RELOC_OR1K_TLS_LDO_LO16 |
ENUMX |
BFD_RELOC_OR1K_TLS_IE_HI16 |
ENUMX |
BFD_RELOC_OR1K_TLS_IE_LO16 |
ENUMX |
BFD_RELOC_OR1K_TLS_LE_HI16 |
ENUMX |
BFD_RELOC_OR1K_TLS_LE_LO16 |
ENUMX |
BFD_RELOC_OR1K_TLS_TPOFF |
ENUMX |
BFD_RELOC_OR1K_TLS_DTPOFF |
ENUMX |
BFD_RELOC_OR1K_TLS_DTPMOD |
BFD_RELOC_OPENRISC_REL_26 |
ENUMDOC |
OpenRISC 1000 Relocations. |
OpenRISC Relocations. |
ENUM |
BFD_RELOC_H8_DIR16A8 |
6353,42 → 5797,6 |
BFD_RELOC_NIOS2_RELATIVE |
ENUMX |
BFD_RELOC_NIOS2_GOTOFF |
ENUMX |
BFD_RELOC_NIOS2_CALL26_NOAT |
ENUMX |
BFD_RELOC_NIOS2_GOT_LO |
ENUMX |
BFD_RELOC_NIOS2_GOT_HA |
ENUMX |
BFD_RELOC_NIOS2_CALL_LO |
ENUMX |
BFD_RELOC_NIOS2_CALL_HA |
ENUMX |
BFD_RELOC_NIOS2_R2_S12 |
ENUMX |
BFD_RELOC_NIOS2_R2_I10_1_PCREL |
ENUMX |
BFD_RELOC_NIOS2_R2_T1I7_1_PCREL |
ENUMX |
BFD_RELOC_NIOS2_R2_T1I7_2 |
ENUMX |
BFD_RELOC_NIOS2_R2_T2I4 |
ENUMX |
BFD_RELOC_NIOS2_R2_T2I4_1 |
ENUMX |
BFD_RELOC_NIOS2_R2_T2I4_2 |
ENUMX |
BFD_RELOC_NIOS2_R2_X1I7_2 |
ENUMX |
BFD_RELOC_NIOS2_R2_X2L5 |
ENUMX |
BFD_RELOC_NIOS2_R2_F1I5_2 |
ENUMX |
BFD_RELOC_NIOS2_R2_L5I4X1 |
ENUMX |
BFD_RELOC_NIOS2_R2_T1X1I6 |
ENUMX |
BFD_RELOC_NIOS2_R2_T1X1I6_2 |
ENUMDOC |
Relocations used by the Altera Nios II core. |
6921,29 → 6329,6 |
the GOT entry for this symbol. Used in conjunction with |
BFD_RELOC_AARCH64_ADR_GOTPAGE. Valid in ILP32 ABI only. |
ENUM |
BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC |
ENUMDOC |
Unsigned 16 bit byte offset for 64 bit load/store from the GOT entry |
for this symbol. Valid in LP64 ABI only. |
ENUM |
BFD_RELOC_AARCH64_MOVW_GOTOFF_G1 |
ENUMDOC |
Unsigned 16 bit byte higher offset for 64 bit load/store from the GOT entry |
for this symbol. Valid in LP64 ABI only. |
ENUM |
BFD_RELOC_AARCH64_LD64_GOTOFF_LO15 |
ENUMDOC |
Unsigned 15 bit byte offset for 64 bit load/store from the page of |
the GOT entry for this symbol. Valid in LP64 ABI only. |
ENUM |
BFD_RELOC_AARCH64_LD32_GOTPAGE_LO14 |
ENUMDOC |
Scaled 14 bit byte offset to the page base of the global offset table. |
ENUM |
BFD_RELOC_AARCH64_LD64_GOTPAGE_LO15 |
ENUMDOC |
Scaled 15 bit byte offset to the page base of the global offset table. |
ENUM |
BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21 |
ENUMDOC |
Get to the page base of the global offset table entry for a symbols |
6951,10 → 6336,6 |
relative value. Used in conjunction with |
BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC. |
ENUM |
BFD_RELOC_AARCH64_TLSGD_ADR_PREL21 |
ENUMDOC |
AArch64 TLS General Dynamic |
ENUM |
BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC |
ENUMDOC |
Unsigned 12 bit byte offset to global offset table entry for a symbols |
6961,13 → 6342,13 |
tls_index structure. Used in conjunction with |
BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21. |
ENUM |
BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC |
BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1 |
ENUMDOC |
AArch64 TLS General Dynamic relocation. |
AArch64 TLS INITIAL EXEC relocation. |
ENUM |
BFD_RELOC_AARCH64_TLSGD_MOVW_G1 |
BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC |
ENUMDOC |
AArch64 TLS General Dynamic relocation. |
AArch64 TLS INITIAL EXEC relocation. |
ENUM |
BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 |
ENUMDOC |
6985,97 → 6366,6 |
ENUMDOC |
AArch64 TLS INITIAL EXEC relocation. |
ENUM |
BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC |
ENUMDOC |
AArch64 TLS INITIAL EXEC relocation. |
ENUM |
BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1 |
ENUMDOC |
AArch64 TLS INITIAL EXEC relocation. |
ENUM |
BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_HI12 |
ENUMDOC |
bit[23:12] of byte offset to module TLS base address. |
ENUM |
BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12 |
ENUMDOC |
Unsigned 12 bit byte offset to module TLS base address. |
ENUM |
BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC |
ENUMDOC |
No overflow check version of BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12. |
ENUM |
BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC |
ENUMDOC |
Unsigned 12 bit byte offset to global offset table entry for a symbols |
tls_index structure. Used in conjunction with |
BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21. |
ENUM |
BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21 |
ENUMDOC |
GOT entry page address for AArch64 TLS Local Dynamic, used with ADRP |
instruction. |
ENUM |
BFD_RELOC_AARCH64_TLSLD_ADR_PREL21 |
ENUMDOC |
GOT entry address for AArch64 TLS Local Dynamic, used with ADR instruction. |
ENUM |
BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12 |
ENUMDOC |
bit[11:1] of byte offset to module TLS base address, encoded in ldst |
instructions. |
ENUM |
BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC |
ENUMDOC |
Similar as BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12, but no overflow check. |
ENUM |
BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12 |
ENUMDOC |
bit[11:2] of byte offset to module TLS base address, encoded in ldst |
instructions. |
ENUM |
BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC |
ENUMDOC |
Similar as BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12, but no overflow check. |
ENUM |
BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12 |
ENUMDOC |
bit[11:3] of byte offset to module TLS base address, encoded in ldst |
instructions. |
ENUM |
BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC |
ENUMDOC |
Similar as BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12, but no overflow check. |
ENUM |
BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12 |
ENUMDOC |
bit[11:0] of byte offset to module TLS base address, encoded in ldst |
instructions. |
ENUM |
BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC |
ENUMDOC |
Similar as BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12, but no overflow check. |
ENUM |
BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0 |
ENUMDOC |
bit[15:0] of byte offset to module TLS base address. |
ENUM |
BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0_NC |
ENUMDOC |
No overflow check version of BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0 |
ENUM |
BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1 |
ENUMDOC |
bit[31:16] of byte offset to module TLS base address. |
ENUM |
BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1_NC |
ENUMDOC |
No overflow check version of BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1 |
ENUM |
BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G2 |
ENUMDOC |
bit[47:32] of byte offset to module TLS base address. |
ENUM |
BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2 |
ENUMDOC |
AArch64 TLS LOCAL EXEC relocation. |
7206,16 → 6496,6 |
AArch64 unspecified load/store instruction, holding bits 0 to 11 of the |
address. Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL. |
ENUM |
BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12 |
ENUMDOC |
AArch64 pseudo relocation code for TLS local dynamic mode. It's to be |
used internally by the AArch64 assembler and not (currently) written to |
any object files. |
ENUM |
BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12_NC |
ENUMDOC |
Similar as BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12, but no overflow check. |
ENUM |
BFD_RELOC_AARCH64_LD_GOT_LO12_NC |
ENUMDOC |
AArch64 pseudo relocation code to be used internally by the AArch64 |
7230,6 → 6510,7 |
ENUMDOC |
AArch64 pseudo relocation code to be used internally by the AArch64 |
assembler and not (currently) written to any object files. |
ENUM |
BFD_RELOC_TILEPRO_COPY |
ENUMX |
7610,7 → 6891,6 |
BFD_RELOC_TILEGX_IMM8_Y1_TLS_ADD |
ENUMDOC |
Tilera TILE-Gx Relocations. |
ENUM |
BFD_RELOC_EPIPHANY_SIMM8 |
ENUMDOC |
7640,22 → 6920,6 |
ENUMDOC |
Adapteva EPIPHANY - 8 bit immediate for 16 bit mov instruction. |
ENUM |
BFD_RELOC_VISIUM_HI16 |
ENUMX |
BFD_RELOC_VISIUM_LO16 |
ENUMX |
BFD_RELOC_VISIUM_IM16 |
ENUMX |
BFD_RELOC_VISIUM_REL16 |
ENUMX |
BFD_RELOC_VISIUM_HI16_PCREL |
ENUMX |
BFD_RELOC_VISIUM_LO16_PCREL |
ENUMX |
BFD_RELOC_VISIUM_IM16_PCREL |
ENUMDOC |
Visium Relocations. |
ENDSENUM |
BFD_RELOC_UNUSED |
7777,7 → 7041,7 |
struct bfd_link_info *link_info ATTRIBUTE_UNUSED, |
bfd_boolean *again) |
{ |
if (bfd_link_relocatable (link_info)) |
if (link_info->relocatable) |
(*link_info->callbacks->einfo) |
(_("%P%F: --relax and -r may not be used together\n")); |
7985,21 → 7249,8 |
abfd, input_section, * parent); |
goto error_return; |
case bfd_reloc_notsupported: |
/* PR ld/17512 |
This error can result when processing a corrupt binary. |
Do not abort. Issue an error message instead. */ |
link_info->callbacks->einfo |
(_("%X%P: %B(%A): relocation \"%R\" is not supported\n"), |
abfd, input_section, * parent); |
goto error_return; |
default: |
/* PR 17512; file: 90c2a92e. |
Report unexpected results, without aborting. */ |
link_info->callbacks->einfo |
(_("%X%P: %B(%A): relocation \"%R\" returns an unrecognized value %x\n"), |
abfd, input_section, * parent, r); |
abort (); |
break; |
} |
/contrib/toolchain/binutils/bfd/section.c |
---|
1,5 → 1,8 |
/* Object file "section" support for the BFD library. |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, |
2012, 2013 |
Free Software Foundation, Inc. |
Written by Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
155,10 → 158,10 |
. const char *name; |
. |
. {* A unique sequence number. *} |
. unsigned int id; |
. int id; |
. |
. {* Which section in the bfd; 0..n-1 as sections are created in a bfd. *} |
. unsigned int index; |
. int index; |
. |
. {* The next section in the list belonging to the BFD, or NULL. *} |
. struct bfd_section *next; |
334,10 → 337,6 |
. executables or shared objects. This is for COFF only. *} |
.#define SEC_COFF_SHARED 0x8000000 |
. |
. {* This section should be compressed. This is for ELF linker |
. internal use only. *} |
.#define SEC_ELF_COMPRESS 0x8000000 |
. |
. {* When a section with this flag is being linked, then if the size of |
. the input section is less than a page, it should not cross a page |
. boundary. If the size of the input section is one page or more, |
345,18 → 344,11 |
. TMS320C54X only. *} |
.#define SEC_TIC54X_BLOCK 0x10000000 |
. |
. {* This section should be renamed. This is for ELF linker |
. internal use only. *} |
.#define SEC_ELF_RENAME 0x10000000 |
. |
. {* Conditionally link this section; do not link if there are no |
. references found to any symbol in the section. This is for TI |
. TMS320C54X only. *} |
.#define SEC_TIC54X_CLINK 0x20000000 |
. |
. {* This section contains vliw code. This is for Toshiba MeP only. *} |
.#define SEC_MEP_VLIW 0x20000000 |
. |
. {* Indicate that section has the no read flag set. This happens |
. when memory read flag isn't set. *} |
.#define SEC_COFF_NOREAD 0x40000000 |
396,8 → 388,6 |
.#define SEC_INFO_TYPE_MERGE 2 |
.#define SEC_INFO_TYPE_EH_FRAME 3 |
.#define SEC_INFO_TYPE_JUST_SYMS 4 |
.#define SEC_INFO_TYPE_TARGET 5 |
.#define SEC_INFO_TYPE_EH_FRAME_ENTRY 6 |
. |
. {* Nonzero if this section uses RELA relocations, rather than REL. *} |
. unsigned int use_rela_p:1; |
552,32 → 542,6 |
. int size; |
.}; |
. |
.{* Note: the following are provided as inline functions rather than macros |
. because not all callers use the return value. A macro implementation |
. would use a comma expression, eg: "((ptr)->foo = val, TRUE)" and some |
. compilers will complain about comma expressions that have no effect. *} |
.static inline bfd_boolean |
.bfd_set_section_userdata (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, void * val) |
.{ |
. ptr->userdata = val; |
. return TRUE; |
.} |
. |
.static inline bfd_boolean |
.bfd_set_section_vma (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, bfd_vma val) |
.{ |
. ptr->vma = ptr->lma = val; |
. ptr->user_set_vma = TRUE; |
. return TRUE; |
.} |
. |
.static inline bfd_boolean |
.bfd_set_section_alignment (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, unsigned int val) |
.{ |
. ptr->alignment_power = val; |
. return TRUE; |
.} |
. |
.{* These sections are global, and are managed by BFD. The application |
. and target back end are not permitted to change the values in |
. these sections. *} |
821,13 → 785,13 |
return TRUE; |
} |
static unsigned int section_id = 0x10; /* id 0 to 3 used by STD_SECTION. */ |
/* Initializes a new section. NEWSECT->NAME is already set. */ |
static asection * |
bfd_section_init (bfd *abfd, asection *newsect) |
{ |
static int section_id = 0x10; /* id 0 to 3 used by STD_SECTION. */ |
newsect->id = section_id; |
newsect->index = abfd->section_count; |
newsect->owner = abfd; |
903,18 → 867,16 |
bfd_get_next_section_by_name |
SYNOPSIS |
asection *bfd_get_next_section_by_name (bfd *ibfd, asection *sec); |
asection *bfd_get_next_section_by_name (asection *sec); |
DESCRIPTION |
Given @var{sec} is a section returned by @code{bfd_get_section_by_name}, |
return the next most recently created section attached to the same |
BFD with the same name, or if no such section exists in the same BFD and |
IBFD is non-NULL, the next section with the same name in any input |
BFD following IBFD. Return NULL on finding no section. |
BFD with the same name. Return NULL if no such section exists. |
*/ |
asection * |
bfd_get_next_section_by_name (bfd *ibfd, asection *sec) |
bfd_get_next_section_by_name (asection *sec) |
{ |
struct section_hash_entry *sh; |
const char *name; |
932,16 → 894,6 |
&& strcmp (sh->root.string, name) == 0) |
return &sh->section; |
if (ibfd != NULL) |
{ |
while ((ibfd = ibfd->link.next) != NULL) |
{ |
asection *s = bfd_get_section_by_name (ibfd, name); |
if (s != NULL) |
return s; |
} |
} |
return NULL; |
} |
963,7 → 915,7 |
asection *sec = bfd_get_section_by_name (abfd, name); |
while (sec != NULL && (sec->flags & SEC_LINKER_CREATED) == 0) |
sec = bfd_get_next_section_by_name (NULL, sec); |
sec = bfd_get_next_section_by_name (sec); |
return sec; |
} |
1006,11 → 958,14 |
return NULL; |
hash = sh->root.hash; |
for (; sh != NULL; sh = (struct section_hash_entry *) sh->root.next) |
if (sh->root.hash == hash |
&& strcmp (sh->root.string, name) == 0 |
&& (*operation) (abfd, &sh->section, user_storage)) |
do |
{ |
if ((*operation) (abfd, &sh->section, user_storage)) |
return &sh->section; |
sh = (struct section_hash_entry *) sh->root.next; |
} |
while (sh != NULL && sh->root.hash == hash |
&& strcmp (sh->root.string, name) == 0); |
return NULL; |
} |
1287,23 → 1242,6 |
/* |
FUNCTION |
bfd_get_next_section_id |
SYNOPSIS |
int bfd_get_next_section_id (void); |
DESCRIPTION |
Returns the id that the next section created will have. |
*/ |
int |
bfd_get_next_section_id (void) |
{ |
return section_id; |
} |
/* |
FUNCTION |
bfd_set_section_flags |
SYNOPSIS |
/contrib/toolchain/binutils/bfd/simple.c |
---|
1,5 → 1,6 |
/* simple.c -- BFD simple client routines |
Copyright (C) 2002-2015 Free Software Foundation, Inc. |
Copyright 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011 |
Free Software Foundation, Inc. |
Contributed by MontaVista Software, Inc. |
This file is part of BFD, the Binary File Descriptor library. |
100,39 → 101,14 |
asection *section; |
}; |
struct saved_offsets |
{ |
unsigned int section_count; |
struct saved_output_info *sections; |
}; |
/* The sections in ABFD may already have output sections and offsets |
set if we are here during linking. |
DWARF-2 specifies offsets into debug sections in many cases and |
bfd_simple_get_relocated_section_contents is called to relocate |
debug info for a single relocatable object file. So we want |
offsets relative to that object file's sections, not offsets in the |
output file. For that reason, reset a debug section->output_offset |
to zero. |
If not called during linking then set section->output_section to |
point back to the input section, because output_section must not be |
NULL when calling the relocation routines. |
Save the original output offset and section to restore later. */ |
static void |
simple_save_output_info (bfd *abfd ATTRIBUTE_UNUSED, |
asection *section, |
void *ptr) |
{ |
struct saved_offsets *saved_offsets = (struct saved_offsets *) ptr; |
struct saved_output_info *output_info; |
output_info = &saved_offsets->sections[section->index]; |
output_info->offset = section->output_offset; |
output_info->section = section->output_section; |
struct saved_output_info *output_info = (struct saved_output_info *) ptr; |
output_info[section->index].offset = section->output_offset; |
output_info[section->index].section = section->output_section; |
if ((section->flags & SEC_DEBUGGING) != 0 |
|| section->output_section == NULL) |
{ |
146,15 → 122,9 |
asection *section, |
void *ptr) |
{ |
struct saved_offsets *saved_offsets = (struct saved_offsets *) ptr; |
struct saved_output_info *output_info; |
if (section->index >= saved_offsets->section_count) |
return; |
output_info = &saved_offsets->sections[section->index]; |
section->output_offset = output_info->offset; |
section->output_section = output_info->section; |
struct saved_output_info *output_info = (struct saved_output_info *) ptr; |
section->output_offset = output_info[section->index].offset; |
section->output_section = output_info[section->index].section; |
} |
/* |
187,8 → 157,7 |
struct bfd_link_callbacks callbacks; |
bfd_byte *contents, *data; |
int storage_needed; |
struct saved_offsets saved_offsets; |
bfd *link_next; |
void *saved_offsets; |
/* Don't apply relocation on executable and shared library. See |
PR 4756. */ |
208,10 → 177,8 |
memset (&link_info, 0, sizeof (link_info)); |
link_info.output_bfd = abfd; |
link_info.input_bfds = abfd; |
link_info.input_bfds_tail = &abfd->link.next; |
link_info.input_bfds_tail = &abfd->link_next; |
link_next = abfd->link.next; |
abfd->link.next = NULL; |
link_info.hash = _bfd_generic_link_hash_table_create (abfd); |
link_info.callbacks = &callbacks; |
callbacks.warning = simple_dummy_warning; |
235,26 → 202,28 |
bfd_size_type amt = sec->rawsize > sec->size ? sec->rawsize : sec->size; |
data = (bfd_byte *) bfd_malloc (amt); |
if (data == NULL) |
{ |
_bfd_generic_link_hash_table_free (abfd); |
abfd->link.next = link_next; |
return NULL; |
} |
outbuf = data; |
} |
saved_offsets.section_count = abfd->section_count; |
saved_offsets.sections = malloc (sizeof (*saved_offsets.sections) |
* saved_offsets.section_count); |
if (saved_offsets.sections == NULL) |
/* The sections in ABFD may already have output sections and offsets set. |
Because this function is primarily for debug sections, and GCC uses the |
knowledge that debug sections will generally have VMA 0 when emitting |
relocations between DWARF-2 sections (which are supposed to be |
section-relative offsets anyway), we need to reset the output offsets |
to zero. We also need to arrange for section->output_section->vma plus |
section->output_offset to equal section->vma, which we do by setting |
section->output_section to point back to section. Save the original |
output offset and output section to restore later. */ |
saved_offsets = malloc (sizeof (struct saved_output_info) |
* abfd->section_count); |
if (saved_offsets == NULL) |
{ |
if (data) |
free (data); |
_bfd_generic_link_hash_table_free (abfd); |
abfd->link.next = link_next; |
return NULL; |
} |
bfd_map_over_sections (abfd, simple_save_output_info, &saved_offsets); |
bfd_map_over_sections (abfd, simple_save_output_info, saved_offsets); |
if (symbol_table == NULL) |
{ |
276,10 → 245,9 |
if (contents == NULL && data != NULL) |
free (data); |
bfd_map_over_sections (abfd, simple_restore_output_info, &saved_offsets); |
free (saved_offsets.sections); |
bfd_map_over_sections (abfd, simple_restore_output_info, saved_offsets); |
free (saved_offsets); |
_bfd_generic_link_hash_table_free (abfd); |
abfd->link.next = link_next; |
_bfd_generic_link_hash_table_free (link_info.hash); |
return contents; |
} |
/contrib/toolchain/binutils/bfd/srec.c |
---|
1,5 → 1,7 |
/* BFD back-end for s-record objects. |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011 |
Free Software Foundation, Inc. |
Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>. |
This file is part of BFD, the Binary File Descriptor library. |
246,10 → 248,10 |
} |
else |
{ |
char buf[40]; |
char buf[10]; |
if (! ISPRINT (c)) |
sprintf (buf, "\\%03o", (unsigned int) c & 0xff); |
sprintf (buf, "\\%03o", (unsigned int) c); |
else |
{ |
buf[0] = c; |
452,8 → 454,8 |
case 'S': |
{ |
file_ptr pos; |
unsigned char hdr[3]; |
unsigned int bytes, min_bytes; |
char hdr[3]; |
unsigned int bytes; |
bfd_vma address; |
bfd_byte *data; |
unsigned char check_sum; |
476,19 → 478,6 |
} |
check_sum = bytes = HEX (hdr + 1); |
min_bytes = 3; |
if (hdr[0] == '2' || hdr[0] == '8') |
min_bytes = 4; |
else if (hdr[0] == '3' || hdr[0] == '7') |
min_bytes = 5; |
if (bytes < min_bytes) |
{ |
(*_bfd_error_handler) (_("%B:%d: byte count %d too small\n"), |
abfd, lineno, bytes); |
bfd_set_error (bfd_error_bad_value); |
goto error_return; |
} |
if (bytes * 2 > bufsize) |
{ |
if (buf != NULL) |
1255,10 → 1244,8 |
#define srec_bfd_is_local_label_name bfd_generic_is_local_label_name |
#define srec_get_lineno _bfd_nosymbols_get_lineno |
#define srec_find_nearest_line _bfd_nosymbols_find_nearest_line |
#define srec_find_line _bfd_nosymbols_find_line |
#define srec_find_inliner_info _bfd_nosymbols_find_inliner_info |
#define srec_make_empty_symbol _bfd_generic_make_empty_symbol |
#define srec_get_symbol_version_string _bfd_nosymbols_get_symbol_version_string |
#define srec_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol |
#define srec_read_minisymbols _bfd_generic_read_minisymbols |
#define srec_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol |
1273,6 → 1260,7 |
#define srec_section_already_linked _bfd_generic_section_already_linked |
#define srec_bfd_define_common_symbol bfd_generic_define_common_symbol |
#define srec_bfd_link_hash_table_create _bfd_generic_link_hash_table_create |
#define srec_bfd_link_hash_table_free _bfd_generic_link_hash_table_free |
#define srec_bfd_link_add_symbols _bfd_generic_link_add_symbols |
#define srec_bfd_link_just_syms _bfd_generic_link_just_syms |
#define srec_bfd_copy_link_hash_symbol_type \ |
/contrib/toolchain/binutils/bfd/stab-syms.c |
---|
1,5 → 1,6 |
/* Table of stab names for the BFD library. |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990, 1991, 1992, 1994, 1995, 1996, 2000, 2005, 2007, 2012 |
Free Software Foundation, Inc. |
Written by Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
/contrib/toolchain/binutils/bfd/stabs.c |
---|
1,5 → 1,6 |
/* Stabs in sections linking support. |
Copyright (C) 1996-2015 Free Software Foundation, Inc. |
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, |
2006, 2007, 2008 Free Software Foundation, Inc. |
Written by Ian Lance Taylor, Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
536,7 → 537,7 |
link, so we should just ignore them. */ |
return FALSE; |
/* We should have initialized our data in _bfd_link_section_stabs. |
/* We should have initialized our data in _bfd_link_stab_sections. |
If there was some bizarre error reading the string sections, though, |
we might not have. Bail rather than asserting. */ |
if (psecinfo == NULL) |
/contrib/toolchain/binutils/bfd/syms.c |
---|
1,5 → 1,7 |
/* Generic symbol-table support for the BFD library. |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2012 |
Free Software Foundation, Inc. |
Written by Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
823,7 → 825,6 |
*minisymsp = syms; |
*sizep = sizeof (asymbol *); |
return symcount; |
error_return: |
933,11 → 934,12 |
struct stab_find_info *info; |
bfd_size_type stabsize, strsize; |
bfd_byte *stab, *str; |
bfd_byte *nul_fun, *nul_str; |
bfd_byte *last_stab, *last_str; |
bfd_size_type stroff; |
struct indexentry *indexentry; |
char *file_name; |
char *directory_name; |
int saw_fun; |
bfd_boolean saw_line, saw_func; |
*pfound = FALSE; |
986,6 → 988,7 |
long reloc_size, reloc_count; |
arelent **reloc_vector; |
int i; |
char *name; |
char *function_name; |
bfd_size_type amt = sizeof *info; |
1018,7 → 1021,6 |
stabsize = (info->stabsec->rawsize |
? info->stabsec->rawsize |
: info->stabsec->size); |
stabsize = (stabsize / STABSIZE) * STABSIZE; |
strsize = (info->strsec->rawsize |
? info->strsec->rawsize |
: info->strsec->size); |
1100,37 → 1102,36 |
table. */ |
info->indextablesize = 0; |
nul_fun = NULL; |
saw_fun = 1; |
for (stab = info->stabs; stab < info->stabs + stabsize; stab += STABSIZE) |
{ |
if (stab[TYPEOFF] == (bfd_byte) N_SO) |
{ |
/* N_SO with null name indicates EOF */ |
if (bfd_get_32 (abfd, stab + STRDXOFF) == 0) |
continue; |
/* if we did not see a function def, leave space for one. */ |
if (nul_fun != NULL) |
if (saw_fun == 0) |
++info->indextablesize; |
/* N_SO with null name indicates EOF */ |
if (bfd_get_32 (abfd, stab + STRDXOFF) == 0) |
nul_fun = NULL; |
else |
{ |
nul_fun = stab; |
saw_fun = 0; |
/* two N_SO's in a row is a filename and directory. Skip */ |
if (stab + STABSIZE + TYPEOFF < info->stabs + stabsize |
if (stab + STABSIZE < info->stabs + stabsize |
&& *(stab + STABSIZE + TYPEOFF) == (bfd_byte) N_SO) |
{ |
stab += STABSIZE; |
} |
} |
else if (stab[TYPEOFF] == (bfd_byte) N_FUN |
&& bfd_get_32 (abfd, stab + STRDXOFF) != 0) |
else if (stab[TYPEOFF] == (bfd_byte) N_FUN) |
{ |
nul_fun = NULL; |
saw_fun = 1; |
++info->indextablesize; |
} |
} |
if (nul_fun != NULL) |
if (saw_fun == 0) |
++info->indextablesize; |
if (info->indextablesize == 0) |
1145,10 → 1146,10 |
file_name = NULL; |
directory_name = NULL; |
nul_fun = NULL; |
saw_fun = 1; |
stroff = 0; |
for (i = 0, stab = info->stabs, nul_str = str = info->strs; |
for (i = 0, last_stab = stab = info->stabs, last_str = str = info->strs; |
i < info->indextablesize && stab < info->stabs + stabsize; |
stab += STABSIZE) |
{ |
1170,33 → 1171,36 |
Note that a N_SO without a file name is an EOF and |
there could be 2 N_SO following it with the new filename |
and directory. */ |
if (nul_fun != NULL) |
if (saw_fun == 0) |
{ |
info->indextable[i].val = bfd_get_32 (abfd, nul_fun + VALOFF); |
info->indextable[i].stab = nul_fun; |
info->indextable[i].str = nul_str; |
info->indextable[i].val = bfd_get_32 (abfd, last_stab + VALOFF); |
info->indextable[i].stab = last_stab; |
info->indextable[i].str = last_str; |
info->indextable[i].directory_name = directory_name; |
info->indextable[i].file_name = file_name; |
info->indextable[i].function_name = NULL; |
++i; |
} |
saw_fun = 0; |
directory_name = NULL; |
file_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF); |
if (file_name == (char *) str) |
if (*file_name == '\0') |
{ |
directory_name = NULL; |
file_name = NULL; |
nul_fun = NULL; |
saw_fun = 1; |
} |
else |
{ |
nul_fun = stab; |
nul_str = str; |
if (file_name >= (char *) info->strs + strsize || file_name < (char *) str) |
file_name = NULL; |
if (stab + STABSIZE + TYPEOFF < info->stabs + stabsize |
&& *(stab + STABSIZE + TYPEOFF) == (bfd_byte) N_SO) |
last_stab = stab; |
last_str = str; |
if (stab + STABSIZE >= info->stabs + stabsize |
|| *(stab + STABSIZE + TYPEOFF) != (bfd_byte) N_SO) |
{ |
directory_name = NULL; |
} |
else |
{ |
/* Two consecutive N_SOs are a directory and a |
file name. */ |
stab += STABSIZE; |
1203,8 → 1207,6 |
directory_name = file_name; |
file_name = ((char *) str |
+ bfd_get_32 (abfd, stab + STRDXOFF)); |
if (file_name >= (char *) info->strs + strsize || file_name < (char *) str) |
file_name = NULL; |
} |
} |
break; |
1212,21 → 1214,21 |
case N_SOL: |
/* The name of an include file. */ |
file_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF); |
/* PR 17512: file: 0c680a1f. */ |
/* PR 17512: file: 5da8aec4. */ |
if (file_name >= (char *) info->strs + strsize || file_name < (char *) str) |
file_name = NULL; |
break; |
case N_FUN: |
/* A function name. */ |
function_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF); |
if (function_name == (char *) str) |
saw_fun = 1; |
name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF); |
if (*name == '\0') |
name = NULL; |
function_name = name; |
if (name == NULL) |
continue; |
if (function_name >= (char *) info->strs + strsize) |
function_name = NULL; |
nul_fun = NULL; |
info->indextable[i].val = bfd_get_32 (abfd, stab + VALOFF); |
info->indextable[i].stab = stab; |
info->indextable[i].str = str; |
1238,11 → 1240,11 |
} |
} |
if (nul_fun != NULL) |
if (saw_fun == 0) |
{ |
info->indextable[i].val = bfd_get_32 (abfd, nul_fun + VALOFF); |
info->indextable[i].stab = nul_fun; |
info->indextable[i].str = nul_str; |
info->indextable[i].val = bfd_get_32 (abfd, last_stab + VALOFF); |
info->indextable[i].stab = last_stab; |
info->indextable[i].str = last_str; |
info->indextable[i].directory_name = directory_name; |
info->indextable[i].file_name = file_name; |
info->indextable[i].function_name = NULL; |
1332,8 → 1334,6 |
if (val <= offset) |
{ |
file_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF); |
if (file_name >= (char *) info->strs + strsize || file_name < (char *) str) |
file_name = NULL; |
*pline = 0; |
} |
break; |
/contrib/toolchain/binutils/bfd/targets.c |
---|
1,5 → 1,5 |
/* Generic target-file-type support for the BFD library. |
Copyright (C) 1990-2015 Free Software Foundation, Inc. |
Copyright 1990-2013 Free Software Foundation, Inc. |
Written by Cygnus Support. |
This file is part of BFD, the Binary File Descriptor library. |
144,7 → 144,6 |
.enum bfd_flavour |
.{ |
. {* N.B. Update bfd_flavour_name if you change this. *} |
. bfd_target_unknown_flavour, |
. bfd_target_aout_flavour, |
. bfd_target_coff_flavour, |
364,12 → 363,12 |
. NAME##_make_empty_symbol, \ |
. NAME##_print_symbol, \ |
. NAME##_get_symbol_info, \ |
. NAME##_get_symbol_version_string, \ |
. NAME##_bfd_is_local_label_name, \ |
. NAME##_bfd_is_target_special_symbol, \ |
. NAME##_get_lineno, \ |
. NAME##_find_nearest_line, \ |
. NAME##_find_line, \ |
. _bfd_generic_find_nearest_line_discriminator, \ |
. _bfd_generic_find_line, \ |
. NAME##_find_inliner_info, \ |
. NAME##_bfd_make_debug_symbol, \ |
. NAME##_read_minisymbols, \ |
386,14 → 385,14 |
. void (*_bfd_get_symbol_info) |
. (bfd *, struct bfd_symbol *, symbol_info *); |
.#define bfd_get_symbol_info(b,p,e) BFD_SEND (b, _bfd_get_symbol_info, (b,p,e)) |
. const char *(*_bfd_get_symbol_version_string) |
. (bfd *, struct bfd_symbol *, bfd_boolean *); |
.#define bfd_get_symbol_version_string(b,s,h) BFD_SEND (b, _bfd_get_symbol_version_string, (b,s,h)) |
. bfd_boolean (*_bfd_is_local_label_name) (bfd *, const char *); |
. bfd_boolean (*_bfd_is_target_special_symbol) (bfd *, asymbol *); |
. alent * (*_get_lineno) (bfd *, struct bfd_symbol *); |
. bfd_boolean (*_bfd_find_nearest_line) |
. (bfd *, struct bfd_symbol **, struct bfd_section *, bfd_vma, |
. (bfd *, struct bfd_section *, struct bfd_symbol **, bfd_vma, |
. const char **, const char **, unsigned int *); |
. bfd_boolean (*_bfd_find_nearest_line_discriminator) |
. (bfd *, struct bfd_section *, struct bfd_symbol **, bfd_vma, |
. const char **, const char **, unsigned int *, unsigned int *); |
. bfd_boolean (*_bfd_find_line) |
. (bfd *, struct bfd_symbol **, struct bfd_symbol *, |
447,6 → 446,7 |
. NAME##_bfd_get_relocated_section_contents, \ |
. NAME##_bfd_relax_section, \ |
. NAME##_bfd_link_hash_table_create, \ |
. NAME##_bfd_link_hash_table_free, \ |
. NAME##_bfd_link_add_symbols, \ |
. NAME##_bfd_link_just_syms, \ |
. NAME##_bfd_copy_link_hash_symbol_type, \ |
473,6 → 473,9 |
. struct bfd_link_hash_table * |
. (*_bfd_link_hash_table_create) (bfd *); |
. |
. {* Release the memory associated with the linker hash table. *} |
. void (*_bfd_link_hash_table_free) (struct bfd_link_hash_table *); |
. |
. {* Add symbols from this object file into the hash table. *} |
. bfd_boolean (*_bfd_link_add_symbols) (bfd *, struct bfd_link_info *); |
. |
479,8 → 482,7 |
. {* Indicate that we are only retrieving symbol values from this section. *} |
. void (*_bfd_link_just_syms) (asection *, struct bfd_link_info *); |
. |
. {* Copy the symbol type and other attributes for a linker script |
. assignment of one symbol to another. *} |
. {* Copy the symbol type of a linker hash table entry. *} |
.#define bfd_copy_link_hash_symbol_type(b, t, f) \ |
. BFD_SEND (b, _bfd_copy_link_hash_symbol_type, (b, t, f)) |
. void (*_bfd_copy_link_hash_symbol_type) |
565,367 → 567,357 |
Alphabetized for easy reference. |
They are listed a second time below, since |
we can't intermix extern's and initializers. */ |
extern const bfd_target aarch64_elf32_be_vec; |
extern const bfd_target aarch64_elf32_le_vec; |
extern const bfd_target aarch64_elf64_be_vec; |
extern const bfd_target aarch64_elf64_be_cloudabi_vec; |
extern const bfd_target aarch64_elf64_le_vec; |
extern const bfd_target aarch64_elf64_le_cloudabi_vec; |
extern const bfd_target alpha_ecoff_le_vec; |
extern const bfd_target alpha_elf64_vec; |
extern const bfd_target alpha_elf64_fbsd_vec; |
extern const bfd_target alpha_nlm32_vec; |
extern const bfd_target alpha_vms_vec; |
extern const bfd_target alpha_vms_lib_txt_vec; |
extern const bfd_target am33_elf32_linux_vec; |
extern const bfd_target aout0_be_vec; |
extern const bfd_target aout64_vec; |
extern const bfd_target aout_vec; |
extern const bfd_target aout_adobe_vec; |
extern const bfd_target arc_elf32_be_vec; |
extern const bfd_target arc_elf32_le_vec; |
extern const bfd_target arm_aout_be_vec; |
extern const bfd_target arm_aout_le_vec; |
extern const bfd_target arm_aout_nbsd_vec; |
extern const bfd_target arm_aout_riscix_vec; |
extern const bfd_target arm_coff_be_vec; |
extern const bfd_target arm_coff_le_vec; |
extern const bfd_target arm_elf32_be_vec; |
extern const bfd_target arm_elf32_le_vec; |
extern const bfd_target arm_elf32_nacl_be_vec; |
extern const bfd_target arm_elf32_nacl_le_vec; |
extern const bfd_target arm_elf32_symbian_be_vec; |
extern const bfd_target arm_elf32_symbian_le_vec; |
extern const bfd_target arm_elf32_vxworks_be_vec; |
extern const bfd_target arm_elf32_vxworks_le_vec; |
extern const bfd_target arm_pe_be_vec; |
extern const bfd_target arm_pe_le_vec; |
extern const bfd_target arm_pe_epoc_be_vec; |
extern const bfd_target arm_pe_epoc_le_vec; |
extern const bfd_target arm_pe_wince_be_vec; |
extern const bfd_target arm_pe_wince_le_vec; |
extern const bfd_target arm_pei_be_vec; |
extern const bfd_target arm_pei_le_vec; |
extern const bfd_target arm_pei_epoc_be_vec; |
extern const bfd_target arm_pei_epoc_le_vec; |
extern const bfd_target arm_pei_wince_be_vec; |
extern const bfd_target arm_pei_wince_le_vec; |
extern const bfd_target avr_elf32_vec; |
extern const bfd_target bfin_elf32_vec; |
extern const bfd_target bfin_elf32_fdpic_vec; |
extern const bfd_target bout_be_vec; |
extern const bfd_target bout_le_vec; |
extern const bfd_target cr16_elf32_vec; |
extern const bfd_target cr16c_elf32_vec; |
extern const bfd_target a_out_adobe_vec; |
extern const bfd_target aix5coff64_vec; |
extern const bfd_target aout0_big_vec; |
extern const bfd_target aout_arm_big_vec; |
extern const bfd_target aout_arm_little_vec; |
extern const bfd_target aout_mips_big_vec; |
extern const bfd_target aout_mips_little_vec; |
extern const bfd_target apollocoff_vec; |
extern const bfd_target arm_epoc_pe_big_vec; |
extern const bfd_target arm_epoc_pe_little_vec; |
extern const bfd_target arm_epoc_pei_big_vec; |
extern const bfd_target arm_epoc_pei_little_vec; |
extern const bfd_target arm_wince_pe_big_vec; |
extern const bfd_target arm_wince_pe_little_vec; |
extern const bfd_target arm_wince_pei_big_vec; |
extern const bfd_target arm_wince_pei_little_vec; |
extern const bfd_target armcoff_big_vec; |
extern const bfd_target armcoff_little_vec; |
extern const bfd_target armnetbsd_vec; |
extern const bfd_target armpe_big_vec; |
extern const bfd_target armpe_little_vec; |
extern const bfd_target armpei_big_vec; |
extern const bfd_target armpei_little_vec; |
extern const bfd_target b_out_vec_big_host; |
extern const bfd_target b_out_vec_little_host; |
extern const bfd_target bfd_pei_ia64_vec; |
extern const bfd_target bfd_elf32_avr_vec; |
extern const bfd_target bfd_elf32_bfin_vec; |
extern const bfd_target bfd_elf32_bfinfdpic_vec; |
extern const bfd_target bfd_elf32_big_generic_vec; |
extern const bfd_target bfd_elf32_bigarc_vec; |
extern const bfd_target bfd_elf32_bigarm_vec; |
extern const bfd_target bfd_elf32_bigarm_nacl_vec; |
extern const bfd_target bfd_elf32_bigarm_symbian_vec; |
extern const bfd_target bfd_elf32_bigarm_vxworks_vec; |
extern const bfd_target bfd_elf32_bigmips_vec; |
extern const bfd_target bfd_elf32_bigmips_vxworks_vec; |
extern const bfd_target bfd_elf32_bigmoxie_vec; |
extern const bfd_target bfd_elf32_bignios2_vec; |
extern const bfd_target bfd_elf32_cr16_vec; |
extern const bfd_target bfd_elf32_cr16c_vec; |
extern const bfd_target bfd_elf32_cris_vec; |
extern const bfd_target bfd_elf32_crx_vec; |
extern const bfd_target bfd_elf32_d10v_vec; |
extern const bfd_target bfd_elf32_d30v_vec; |
extern const bfd_target bfd_elf32_dlx_big_vec; |
extern const bfd_target bfd_elf32_epiphany_vec; |
extern const bfd_target bfd_elf32_fr30_vec; |
extern const bfd_target bfd_elf32_frv_vec; |
extern const bfd_target bfd_elf32_frvfdpic_vec; |
extern const bfd_target bfd_elf32_h8300_vec; |
extern const bfd_target bfd_elf32_hppa_linux_vec; |
extern const bfd_target bfd_elf32_hppa_nbsd_vec; |
extern const bfd_target bfd_elf32_hppa_vec; |
extern const bfd_target bfd_elf32_i370_vec; |
extern const bfd_target bfd_elf32_i386_freebsd_vec; |
extern const bfd_target bfd_elf32_i386_nacl_vec; |
extern const bfd_target bfd_elf32_i386_sol2_vec; |
extern const bfd_target bfd_elf32_i386_vxworks_vec; |
extern const bfd_target bfd_elf32_i386_vec; |
extern const bfd_target bfd_elf32_i860_little_vec; |
extern const bfd_target bfd_elf32_i860_vec; |
extern const bfd_target bfd_elf32_i960_vec; |
extern const bfd_target bfd_elf32_ia64_big_vec; |
extern const bfd_target bfd_elf32_ia64_hpux_big_vec; |
extern const bfd_target bfd_elf32_ip2k_vec; |
extern const bfd_target bfd_elf32_iq2000_vec; |
extern const bfd_target bfd_elf32_lm32_vec; |
extern const bfd_target bfd_elf32_lm32fdpic_vec; |
extern const bfd_target bfd_elf32_little_generic_vec; |
extern const bfd_target bfd_elf32_littlearc_vec; |
extern const bfd_target bfd_elf32_littlearm_vec; |
extern const bfd_target bfd_elf32_littlearm_nacl_vec; |
extern const bfd_target bfd_elf32_littlearm_symbian_vec; |
extern const bfd_target bfd_elf32_littlearm_vxworks_vec; |
extern const bfd_target bfd_elf32_littlemips_vec; |
extern const bfd_target bfd_elf32_littlemips_vxworks_vec; |
extern const bfd_target bfd_elf32_littlemoxie_vec; |
extern const bfd_target bfd_elf32_littlenios2_vec; |
extern const bfd_target bfd_elf32_m32c_vec; |
extern const bfd_target bfd_elf32_m32r_vec; |
extern const bfd_target bfd_elf32_m32rle_vec; |
extern const bfd_target bfd_elf32_m32rlin_vec; |
extern const bfd_target bfd_elf32_m32rlelin_vec; |
extern const bfd_target bfd_elf32_m68hc11_vec; |
extern const bfd_target bfd_elf32_m68hc12_vec; |
extern const bfd_target bfd_elf32_m68k_vec; |
extern const bfd_target bfd_elf32_m88k_vec; |
extern const bfd_target bfd_elf32_mcore_big_vec; |
extern const bfd_target bfd_elf32_mcore_little_vec; |
extern const bfd_target bfd_elf32_mep_vec; |
extern const bfd_target bfd_elf32_mep_little_vec; |
extern const bfd_target bfd_elf32_metag_vec; |
extern const bfd_target bfd_elf32_microblazeel_vec; |
extern const bfd_target bfd_elf32_microblaze_vec; |
extern const bfd_target bfd_elf32_mn10200_vec; |
extern const bfd_target bfd_elf32_mn10300_vec; |
extern const bfd_target bfd_elf32_mt_vec; |
extern const bfd_target bfd_elf32_msp430_vec; |
extern const bfd_target bfd_elf32_msp430_ti_vec; |
extern const bfd_target bfd_elf32_nbigmips_vec; |
extern const bfd_target bfd_elf32_nlittlemips_vec; |
extern const bfd_target bfd_elf32_ntradbigmips_vec; |
extern const bfd_target bfd_elf32_ntradlittlemips_vec; |
extern const bfd_target bfd_elf32_ntradbigmips_freebsd_vec; |
extern const bfd_target bfd_elf32_ntradlittlemips_freebsd_vec; |
extern const bfd_target bfd_elf32_openrisc_vec; |
extern const bfd_target bfd_elf32_or32_big_vec; |
extern const bfd_target bfd_elf32_pj_vec; |
extern const bfd_target bfd_elf32_pjl_vec; |
extern const bfd_target bfd_elf32_powerpc_vec; |
extern const bfd_target bfd_elf32_powerpcle_vec; |
extern const bfd_target bfd_elf32_powerpc_freebsd_vec; |
extern const bfd_target bfd_elf32_powerpc_vxworks_vec; |
extern const bfd_target bfd_elf32_rl78_vec; |
extern const bfd_target bfd_elf32_rx_le_vec; |
extern const bfd_target bfd_elf32_rx_be_vec; |
extern const bfd_target bfd_elf32_rx_be_ns_vec; |
extern const bfd_target bfd_elf32_s390_vec; |
extern const bfd_target bfd_elf32_bigscore_vec; |
extern const bfd_target bfd_elf32_littlescore_vec; |
extern const bfd_target bfd_elf32_sh64_vec; |
extern const bfd_target bfd_elf32_sh64l_vec; |
extern const bfd_target bfd_elf32_sh64lin_vec; |
extern const bfd_target bfd_elf32_sh64blin_vec; |
extern const bfd_target bfd_elf32_sh64lnbsd_vec; |
extern const bfd_target bfd_elf32_sh64nbsd_vec; |
extern const bfd_target bfd_elf32_sh_vec; |
extern const bfd_target bfd_elf32_shbfd_vec; |
extern const bfd_target bfd_elf32_shblin_vec; |
extern const bfd_target bfd_elf32_shfd_vec; |
extern const bfd_target bfd_elf32_shl_vec; |
extern const bfd_target bfd_elf32_shl_symbian_vec; |
extern const bfd_target bfd_elf32_shlin_vec; |
extern const bfd_target bfd_elf32_shlnbsd_vec; |
extern const bfd_target bfd_elf32_shlvxworks_vec; |
extern const bfd_target bfd_elf32_shnbsd_vec; |
extern const bfd_target bfd_elf32_shvxworks_vec; |
extern const bfd_target bfd_elf32_sparc_vec; |
extern const bfd_target bfd_elf32_sparc_sol2_vec; |
extern const bfd_target bfd_elf32_sparc_vxworks_vec; |
extern const bfd_target bfd_elf32_spu_vec; |
extern const bfd_target bfd_elf32_tic6x_be_vec; |
extern const bfd_target bfd_elf32_tic6x_le_vec; |
extern const bfd_target bfd_elf32_tic6x_elf_be_vec; |
extern const bfd_target bfd_elf32_tic6x_elf_le_vec; |
extern const bfd_target bfd_elf32_tic6x_linux_be_vec; |
extern const bfd_target bfd_elf32_tic6x_linux_le_vec; |
extern const bfd_target bfd_elf32_tilegx_be_vec; |
extern const bfd_target bfd_elf32_tilegx_le_vec; |
extern const bfd_target bfd_elf32_tilepro_vec; |
extern const bfd_target bfd_elf32_tradbigmips_vec; |
extern const bfd_target bfd_elf32_tradlittlemips_vec; |
extern const bfd_target bfd_elf32_tradbigmips_freebsd_vec; |
extern const bfd_target bfd_elf32_tradlittlemips_freebsd_vec; |
extern const bfd_target bfd_elf32_us_cris_vec; |
extern const bfd_target bfd_elf32_v850_vec; |
extern const bfd_target bfd_elf32_v850_rh850_vec; |
extern const bfd_target bfd_elf32_vax_vec; |
extern const bfd_target bfd_elf32_xc16x_vec; |
extern const bfd_target bfd_elf32_xgate_vec; |
extern const bfd_target bfd_elf32_xstormy16_vec; |
extern const bfd_target bfd_elf32_xtensa_be_vec; |
extern const bfd_target bfd_elf32_xtensa_le_vec; |
extern const bfd_target bfd_elf64_alpha_freebsd_vec; |
extern const bfd_target bfd_elf64_alpha_vec; |
extern const bfd_target bfd_elf64_big_generic_vec; |
extern const bfd_target bfd_elf64_bigmips_vec; |
extern const bfd_target bfd_elf64_bigaarch64_vec; |
extern const bfd_target bfd_elf32_bigaarch64_vec; |
extern const bfd_target bfd_elf64_hppa_linux_vec; |
extern const bfd_target bfd_elf64_hppa_vec; |
extern const bfd_target bfd_elf64_ia64_big_vec; |
extern const bfd_target bfd_elf64_ia64_hpux_big_vec; |
extern const bfd_target bfd_elf64_ia64_little_vec; |
extern const bfd_target bfd_elf64_ia64_vms_vec; |
extern const bfd_target bfd_elf64_little_generic_vec; |
extern const bfd_target bfd_elf64_littlemips_vec; |
extern const bfd_target bfd_elf64_littleaarch64_vec; |
extern const bfd_target bfd_elf32_littleaarch64_vec; |
extern const bfd_target bfd_elf64_mmix_vec; |
extern const bfd_target bfd_elf64_powerpc_vec; |
extern const bfd_target bfd_elf64_powerpcle_vec; |
extern const bfd_target bfd_elf64_powerpc_freebsd_vec; |
extern const bfd_target bfd_elf64_s390_vec; |
extern const bfd_target bfd_elf64_sh64_vec; |
extern const bfd_target bfd_elf64_sh64l_vec; |
extern const bfd_target bfd_elf64_sh64lin_vec; |
extern const bfd_target bfd_elf64_sh64blin_vec; |
extern const bfd_target bfd_elf64_sh64lnbsd_vec; |
extern const bfd_target bfd_elf64_sh64nbsd_vec; |
extern const bfd_target bfd_elf64_sparc_vec; |
extern const bfd_target bfd_elf64_sparc_freebsd_vec; |
extern const bfd_target bfd_elf64_sparc_sol2_vec; |
extern const bfd_target bfd_elf64_tilegx_be_vec; |
extern const bfd_target bfd_elf64_tilegx_le_vec; |
extern const bfd_target bfd_elf64_tradbigmips_vec; |
extern const bfd_target bfd_elf64_tradlittlemips_vec; |
extern const bfd_target bfd_elf64_tradbigmips_freebsd_vec; |
extern const bfd_target bfd_elf64_tradlittlemips_freebsd_vec; |
extern const bfd_target bfd_elf64_x86_64_freebsd_vec; |
extern const bfd_target bfd_elf64_x86_64_nacl_vec; |
extern const bfd_target bfd_elf64_x86_64_sol2_vec; |
extern const bfd_target bfd_elf64_x86_64_vec; |
extern const bfd_target bfd_elf32_x86_64_nacl_vec; |
extern const bfd_target bfd_elf32_x86_64_vec; |
extern const bfd_target bfd_elf64_l1om_freebsd_vec; |
extern const bfd_target bfd_elf64_l1om_vec; |
extern const bfd_target bfd_elf64_k1om_freebsd_vec; |
extern const bfd_target bfd_elf64_k1om_vec; |
extern const bfd_target bfd_mmo_vec; |
extern const bfd_target bfd_powerpc_pe_vec; |
extern const bfd_target bfd_powerpc_pei_vec; |
extern const bfd_target bfd_powerpcle_pe_vec; |
extern const bfd_target bfd_powerpcle_pei_vec; |
extern const bfd_target cris_aout_vec; |
extern const bfd_target cris_elf32_vec; |
extern const bfd_target cris_elf32_us_vec; |
extern const bfd_target crx_elf32_vec; |
extern const bfd_target d10v_elf32_vec; |
extern const bfd_target d30v_elf32_vec; |
extern const bfd_target dlx_elf32_be_vec; |
extern const bfd_target elf32_be_vec; |
extern const bfd_target elf32_le_vec; |
extern const bfd_target elf64_be_vec; |
extern const bfd_target elf64_le_vec; |
extern const bfd_target epiphany_elf32_vec; |
extern const bfd_target fr30_elf32_vec; |
extern const bfd_target frv_elf32_vec; |
extern const bfd_target frv_elf32_fdpic_vec; |
extern const bfd_target h8300_coff_vec; |
extern const bfd_target h8300_elf32_vec; |
extern const bfd_target h8300_elf32_linux_vec; |
extern const bfd_target h8500_coff_vec; |
extern const bfd_target hppa_elf32_vec; |
extern const bfd_target hppa_elf32_linux_vec; |
extern const bfd_target hppa_elf32_nbsd_vec; |
extern const bfd_target hppa_elf64_vec; |
extern const bfd_target hppa_elf64_linux_vec; |
extern const bfd_target hppa_som_vec; |
extern const bfd_target i370_elf32_vec; |
extern const bfd_target i386_aout_vec; |
extern const bfd_target i386_aout_bsd_vec; |
extern const bfd_target i386_aout_dynix_vec; |
extern const bfd_target i386_aout_fbsd_vec; |
extern const bfd_target i386_aout_linux_vec; |
extern const bfd_target i386_aout_lynx_vec; |
extern const bfd_target i386_aout_mach3_vec; |
extern const bfd_target i386_aout_nbsd_vec; |
extern const bfd_target i386_aout_os9k_vec; |
extern const bfd_target i386_coff_vec; |
extern const bfd_target i386_coff_go32_vec; |
extern const bfd_target i386_coff_go32stubbed_vec; |
extern const bfd_target i386_coff_lynx_vec; |
extern const bfd_target i386_elf32_vec; |
extern const bfd_target i386_elf32_fbsd_vec; |
extern const bfd_target i386_elf32_nacl_vec; |
extern const bfd_target i386_elf32_sol2_vec; |
extern const bfd_target i386_elf32_vxworks_vec; |
extern const bfd_target i386_mach_o_vec; |
extern const bfd_target i386_msdos_vec; |
extern const bfd_target i386_nlm32_vec; |
extern const bfd_target i386_pe_vec; |
extern const bfd_target i386_pei_vec; |
extern const bfd_target iamcu_elf32_vec; |
extern const bfd_target i860_coff_vec; |
extern const bfd_target i860_elf32_vec; |
extern const bfd_target i860_elf32_le_vec; |
extern const bfd_target i960_elf32_vec; |
extern const bfd_target ia64_elf32_be_vec; |
extern const bfd_target ia64_elf32_hpux_be_vec; |
extern const bfd_target ia64_elf64_be_vec; |
extern const bfd_target ia64_elf64_le_vec; |
extern const bfd_target ia64_elf64_hpux_be_vec; |
extern const bfd_target ia64_elf64_vms_vec; |
extern const bfd_target ia64_pei_vec; |
extern const bfd_target icoff_be_vec; |
extern const bfd_target icoff_le_vec; |
extern const bfd_target demo_64_vec; |
extern const bfd_target ecoff_big_vec; |
extern const bfd_target ecoff_biglittle_vec; |
extern const bfd_target ecoff_little_vec; |
extern const bfd_target ecoffalpha_little_vec; |
extern const bfd_target go32coff_vec; |
extern const bfd_target go32stubbedcoff_vec; |
extern const bfd_target h8300coff_vec; |
extern const bfd_target h8500coff_vec; |
extern const bfd_target host_aout_vec; |
extern const bfd_target hp300bsd_vec; |
extern const bfd_target hp300hpux_vec; |
extern const bfd_target i386aout_vec; |
extern const bfd_target i386bsd_vec; |
extern const bfd_target i386coff_vec; |
extern const bfd_target i386dynix_vec; |
extern const bfd_target i386freebsd_vec; |
extern const bfd_target i386linux_vec; |
extern const bfd_target i386lynx_aout_vec; |
extern const bfd_target i386lynx_coff_vec; |
extern const bfd_target i386mach3_vec; |
extern const bfd_target i386msdos_vec; |
extern const bfd_target i386netbsd_vec; |
extern const bfd_target i386os9k_vec; |
extern const bfd_target i386pe_vec; |
extern const bfd_target i386pei_vec; |
extern const bfd_target i860coff_vec; |
extern const bfd_target icoff_big_vec; |
extern const bfd_target icoff_little_vec; |
extern const bfd_target ieee_vec; |
extern const bfd_target ip2k_elf32_vec; |
extern const bfd_target iq2000_elf32_vec; |
extern const bfd_target k1om_elf64_vec; |
extern const bfd_target k1om_elf64_fbsd_vec; |
extern const bfd_target l1om_elf64_vec; |
extern const bfd_target l1om_elf64_fbsd_vec; |
extern const bfd_target lm32_elf32_vec; |
extern const bfd_target lm32_elf32_fdpic_vec; |
extern const bfd_target m32c_elf32_vec; |
extern const bfd_target m32r_elf32_vec; |
extern const bfd_target m32r_elf32_le_vec; |
extern const bfd_target m32r_elf32_linux_vec; |
extern const bfd_target m32r_elf32_linux_le_vec; |
extern const bfd_target m68hc11_elf32_vec; |
extern const bfd_target m68hc12_elf32_vec; |
extern const bfd_target m68k_aout_4knbsd_vec; |
extern const bfd_target m68k_aout_hp300bsd_vec; |
extern const bfd_target m68k_aout_hp300hpux_vec; |
extern const bfd_target m68k_aout_linux_vec; |
extern const bfd_target m68k_aout_nbsd_vec; |
extern const bfd_target m68k_aout_newsos3_vec; |
extern const bfd_target m68k_coff_vec; |
extern const bfd_target m68k_coff_apollo_vec; |
extern const bfd_target m68k_coff_aux_vec; |
extern const bfd_target m68k_coff_sysv_vec; |
extern const bfd_target m68k_coff_un_vec; |
extern const bfd_target m68k_elf32_vec; |
extern const bfd_target m68k_versados_vec; |
extern const bfd_target m88k_aout_mach3_vec; |
extern const bfd_target m88k_aout_obsd_vec; |
extern const bfd_target m88k_coff_bcs_vec; |
extern const bfd_target m88k_elf32_vec; |
extern const bfd_target m68k4knetbsd_vec; |
extern const bfd_target m68kaux_coff_vec; |
extern const bfd_target m68kcoff_vec; |
extern const bfd_target m68kcoffun_vec; |
extern const bfd_target m68klinux_vec; |
extern const bfd_target m68knetbsd_vec; |
extern const bfd_target m68ksysvcoff_vec; |
extern const bfd_target m88kbcs_vec; |
extern const bfd_target m88kmach3_vec; |
extern const bfd_target m88kopenbsd_vec; |
extern const bfd_target mach_o_be_vec; |
extern const bfd_target mach_o_le_vec; |
extern const bfd_target mach_o_fat_vec; |
extern const bfd_target mcore_elf32_be_vec; |
extern const bfd_target mcore_elf32_le_vec; |
extern const bfd_target mcore_pe_be_vec; |
extern const bfd_target mcore_pe_le_vec; |
extern const bfd_target mcore_pei_be_vec; |
extern const bfd_target mcore_pei_le_vec; |
extern const bfd_target mep_elf32_vec; |
extern const bfd_target mep_elf32_le_vec; |
extern const bfd_target metag_elf32_vec; |
extern const bfd_target microblaze_elf32_vec; |
extern const bfd_target microblaze_elf32_le_vec; |
extern const bfd_target mips_aout_be_vec; |
extern const bfd_target mips_aout_le_vec; |
extern const bfd_target mips_ecoff_be_vec; |
extern const bfd_target mips_ecoff_le_vec; |
extern const bfd_target mips_ecoff_bele_vec; |
extern const bfd_target mips_elf32_be_vec; |
extern const bfd_target mips_elf32_le_vec; |
extern const bfd_target mips_elf32_n_be_vec; |
extern const bfd_target mips_elf32_n_le_vec; |
extern const bfd_target mips_elf32_ntrad_be_vec; |
extern const bfd_target mips_elf32_ntrad_le_vec; |
extern const bfd_target mips_elf32_ntradfbsd_be_vec; |
extern const bfd_target mips_elf32_ntradfbsd_le_vec; |
extern const bfd_target mips_elf32_trad_be_vec; |
extern const bfd_target mips_elf32_trad_le_vec; |
extern const bfd_target mips_elf32_tradfbsd_be_vec; |
extern const bfd_target mips_elf32_tradfbsd_le_vec; |
extern const bfd_target mips_elf32_vxworks_be_vec; |
extern const bfd_target mips_elf32_vxworks_le_vec; |
extern const bfd_target mips_elf64_be_vec; |
extern const bfd_target mips_elf64_le_vec; |
extern const bfd_target mips_elf64_trad_be_vec; |
extern const bfd_target mips_elf64_trad_le_vec; |
extern const bfd_target mips_elf64_tradfbsd_be_vec; |
extern const bfd_target mips_elf64_tradfbsd_le_vec; |
extern const bfd_target mips_pe_le_vec; |
extern const bfd_target mips_pei_le_vec; |
extern const bfd_target mmix_elf64_vec; |
extern const bfd_target mmix_mmo_vec; |
extern const bfd_target mn10200_elf32_vec; |
extern const bfd_target mn10300_elf32_vec; |
extern const bfd_target moxie_elf32_be_vec; |
extern const bfd_target moxie_elf32_le_vec; |
extern const bfd_target msp430_elf32_vec; |
extern const bfd_target msp430_elf32_ti_vec; |
extern const bfd_target mt_elf32_vec; |
extern const bfd_target nds32_elf32_be_vec; |
extern const bfd_target nds32_elf32_le_vec; |
extern const bfd_target nds32_elf32_linux_be_vec; |
extern const bfd_target nds32_elf32_linux_le_vec; |
extern const bfd_target nios2_elf32_be_vec; |
extern const bfd_target nios2_elf32_le_vec; |
extern const bfd_target ns32k_aout_pc532mach_vec; |
extern const bfd_target ns32k_aout_pc532nbsd_vec; |
extern const bfd_target mach_o_i386_vec; |
extern const bfd_target mach_o_x86_64_vec; |
extern const bfd_target mcore_pe_big_vec; |
extern const bfd_target mcore_pe_little_vec; |
extern const bfd_target mcore_pei_big_vec; |
extern const bfd_target mcore_pei_little_vec; |
extern const bfd_target mipslpe_vec; |
extern const bfd_target mipslpei_vec; |
extern const bfd_target newsos3_vec; |
extern const bfd_target nlm32_alpha_vec; |
extern const bfd_target nlm32_i386_vec; |
extern const bfd_target nlm32_powerpc_vec; |
extern const bfd_target nlm32_sparc_vec; |
extern const bfd_target oasys_vec; |
extern const bfd_target or1k_elf32_vec; |
extern const bfd_target or32coff_big_vec; |
extern const bfd_target pc532machaout_vec; |
extern const bfd_target pc532netbsd_vec; |
extern const bfd_target pdp11_aout_vec; |
extern const bfd_target pef_vec; |
extern const bfd_target pef_xlib_vec; |
extern const bfd_target pj_elf32_vec; |
extern const bfd_target pj_elf32_le_vec; |
extern const bfd_target plugin_vec; |
extern const bfd_target powerpc_boot_vec; |
extern const bfd_target powerpc_elf32_vec; |
extern const bfd_target powerpc_elf32_le_vec; |
extern const bfd_target powerpc_elf32_fbsd_vec; |
extern const bfd_target powerpc_elf32_vxworks_vec; |
extern const bfd_target powerpc_elf64_vec; |
extern const bfd_target powerpc_elf64_le_vec; |
extern const bfd_target powerpc_elf64_fbsd_vec; |
extern const bfd_target powerpc_nlm32_vec; |
extern const bfd_target powerpc_pe_vec; |
extern const bfd_target powerpc_pe_le_vec; |
extern const bfd_target powerpc_pei_vec; |
extern const bfd_target powerpc_pei_le_vec; |
extern const bfd_target powerpc_xcoff_vec; |
extern const bfd_target rl78_elf32_vec; |
extern const bfd_target rs6000_xcoff64_vec; |
extern const bfd_target rs6000_xcoff64_aix_vec; |
extern const bfd_target rs6000_xcoff_vec; |
extern const bfd_target rx_elf32_be_vec; |
extern const bfd_target rx_elf32_be_ns_vec; |
extern const bfd_target rx_elf32_le_vec; |
extern const bfd_target s390_elf32_vec; |
extern const bfd_target s390_elf64_vec; |
extern const bfd_target score_elf32_be_vec; |
extern const bfd_target score_elf32_le_vec; |
extern const bfd_target sh64_elf32_vec; |
extern const bfd_target sh64_elf32_le_vec; |
extern const bfd_target sh64_elf32_linux_vec; |
extern const bfd_target sh64_elf32_linux_be_vec; |
extern const bfd_target sh64_elf32_nbsd_vec; |
extern const bfd_target sh64_elf32_nbsd_le_vec; |
extern const bfd_target sh64_elf64_vec; |
extern const bfd_target sh64_elf64_le_vec; |
extern const bfd_target sh64_elf64_linux_vec; |
extern const bfd_target sh64_elf64_linux_be_vec; |
extern const bfd_target sh64_elf64_nbsd_vec; |
extern const bfd_target sh64_elf64_nbsd_le_vec; |
extern const bfd_target sh_coff_vec; |
extern const bfd_target sh_coff_le_vec; |
extern const bfd_target sh_coff_small_vec; |
extern const bfd_target sh_coff_small_le_vec; |
extern const bfd_target sh_elf32_vec; |
extern const bfd_target sh_elf32_le_vec; |
extern const bfd_target sh_elf32_fdpic_be_vec; |
extern const bfd_target sh_elf32_fdpic_le_vec; |
extern const bfd_target sh_elf32_linux_vec; |
extern const bfd_target sh_elf32_linux_be_vec; |
extern const bfd_target sh_elf32_nbsd_vec; |
extern const bfd_target sh_elf32_nbsd_le_vec; |
extern const bfd_target sh_elf32_symbian_le_vec; |
extern const bfd_target sh_elf32_vxworks_vec; |
extern const bfd_target sh_elf32_vxworks_le_vec; |
extern const bfd_target sh_pe_le_vec; |
extern const bfd_target sh_pei_le_vec; |
extern const bfd_target sparc_aout_le_vec; |
extern const bfd_target sparc_aout_linux_vec; |
extern const bfd_target sparc_aout_lynx_vec; |
extern const bfd_target sparc_aout_nbsd_vec; |
extern const bfd_target sparc_aout_sunos_be_vec; |
extern const bfd_target sparc_coff_vec; |
extern const bfd_target sparc_coff_lynx_vec; |
extern const bfd_target sparc_elf32_vec; |
extern const bfd_target sparc_elf32_sol2_vec; |
extern const bfd_target sparc_elf32_vxworks_vec; |
extern const bfd_target sparc_elf64_vec; |
extern const bfd_target sparc_elf64_fbsd_vec; |
extern const bfd_target sparc_elf64_sol2_vec; |
extern const bfd_target sparc_nlm32_vec; |
extern const bfd_target spu_elf32_vec; |
extern const bfd_target pmac_xcoff_vec; |
extern const bfd_target ppcboot_vec; |
extern const bfd_target riscix_vec; |
extern const bfd_target rs6000coff64_vec; |
extern const bfd_target rs6000coff_vec; |
extern const bfd_target shcoff_small_vec; |
extern const bfd_target shcoff_vec; |
extern const bfd_target shlcoff_small_vec; |
extern const bfd_target shlcoff_vec; |
extern const bfd_target shlpe_vec; |
extern const bfd_target shlpei_vec; |
extern const bfd_target som_vec; |
extern const bfd_target sparccoff_vec; |
extern const bfd_target sparcle_aout_vec; |
extern const bfd_target sparclinux_vec; |
extern const bfd_target sparclynx_aout_vec; |
extern const bfd_target sparclynx_coff_vec; |
extern const bfd_target sparcnetbsd_vec; |
extern const bfd_target sunos_big_vec; |
extern const bfd_target sym_vec; |
extern const bfd_target tic30_aout_vec; |
extern const bfd_target tic30_coff_vec; |
extern const bfd_target tic4x_coff0_beh_vec; |
extern const bfd_target tic4x_coff0_vec; |
extern const bfd_target tic4x_coff0_beh_vec; |
extern const bfd_target tic4x_coff1_beh_vec; |
extern const bfd_target tic4x_coff1_vec; |
extern const bfd_target tic4x_coff1_beh_vec; |
extern const bfd_target tic4x_coff2_beh_vec; |
extern const bfd_target tic4x_coff2_vec; |
extern const bfd_target tic4x_coff2_beh_vec; |
extern const bfd_target tic54x_coff0_beh_vec; |
extern const bfd_target tic54x_coff0_vec; |
extern const bfd_target tic54x_coff0_beh_vec; |
extern const bfd_target tic54x_coff1_beh_vec; |
extern const bfd_target tic54x_coff1_vec; |
extern const bfd_target tic54x_coff1_beh_vec; |
extern const bfd_target tic54x_coff2_beh_vec; |
extern const bfd_target tic54x_coff2_vec; |
extern const bfd_target tic54x_coff2_beh_vec; |
extern const bfd_target tic6x_elf32_be_vec; |
extern const bfd_target tic6x_elf32_le_vec; |
extern const bfd_target tic6x_elf32_c6000_be_vec; |
extern const bfd_target tic6x_elf32_c6000_le_vec; |
extern const bfd_target tic6x_elf32_linux_be_vec; |
extern const bfd_target tic6x_elf32_linux_le_vec; |
extern const bfd_target tic80_coff_vec; |
extern const bfd_target tilegx_elf32_be_vec; |
extern const bfd_target tilegx_elf32_le_vec; |
extern const bfd_target tilegx_elf64_be_vec; |
extern const bfd_target tilegx_elf64_le_vec; |
extern const bfd_target tilepro_elf32_vec; |
extern const bfd_target v800_elf32_vec; |
extern const bfd_target v850_elf32_vec; |
extern const bfd_target ft32_elf32_vec; |
extern const bfd_target vax_aout_1knbsd_vec; |
extern const bfd_target vax_aout_bsd_vec; |
extern const bfd_target vax_aout_nbsd_vec; |
extern const bfd_target vax_elf32_vec; |
extern const bfd_target visium_elf32_vec; |
extern const bfd_target w65_coff_vec; |
extern const bfd_target we32k_coff_vec; |
extern const bfd_target x86_64_coff_vec; |
extern const bfd_target x86_64_elf32_vec; |
extern const bfd_target x86_64_elf32_nacl_vec; |
extern const bfd_target x86_64_elf64_vec; |
extern const bfd_target x86_64_elf64_cloudabi_vec; |
extern const bfd_target x86_64_elf64_fbsd_vec; |
extern const bfd_target x86_64_elf64_nacl_vec; |
extern const bfd_target x86_64_elf64_sol2_vec; |
extern const bfd_target x86_64_mach_o_vec; |
extern const bfd_target x86_64_pe_vec; |
extern const bfd_target x86_64_pe_be_vec; |
extern const bfd_target x86_64_pei_vec; |
extern const bfd_target xc16x_elf32_vec; |
extern const bfd_target xgate_elf32_vec; |
extern const bfd_target xstormy16_elf32_vec; |
extern const bfd_target xtensa_elf32_be_vec; |
extern const bfd_target xtensa_elf32_le_vec; |
extern const bfd_target z80_coff_vec; |
extern const bfd_target z8k_coff_vec; |
extern const bfd_target tic80coff_vec; |
extern const bfd_target vaxbsd_vec; |
extern const bfd_target vaxnetbsd_vec; |
extern const bfd_target vax1knetbsd_vec; |
extern const bfd_target versados_vec; |
extern const bfd_target vms_alpha_vec; |
extern const bfd_target vms_lib_txt_vec; |
extern const bfd_target w65_vec; |
extern const bfd_target we32kcoff_vec; |
extern const bfd_target x86_64pe_vec; |
extern const bfd_target x86_64pei_vec; |
extern const bfd_target x86_64coff_vec; |
extern const bfd_target z80coff_vec; |
extern const bfd_target z8kcoff_vec; |
/* These are always included. */ |
extern const bfd_target srec_vec; |
extern const bfd_target verilog_vec; |
extern const bfd_target symbolsrec_vec; |
extern const bfd_target verilog_vec; |
extern const bfd_target tekhex_vec; |
extern const bfd_target binary_vec; |
extern const bfd_target ihex_vec; |
/* All of the xvecs for core files. */ |
extern const bfd_target core_aix386_vec; |
extern const bfd_target core_cisco_be_vec; |
extern const bfd_target core_cisco_le_vec; |
extern const bfd_target core_hppabsd_vec; |
extern const bfd_target core_hpux_vec; |
extern const bfd_target core_irix_vec; |
extern const bfd_target core_netbsd_vec; |
extern const bfd_target core_osf_vec; |
extern const bfd_target core_ptrace_vec; |
extern const bfd_target core_sco5_vec; |
extern const bfd_target core_trad_vec; |
extern const bfd_target aix386_core_vec; |
extern const bfd_target cisco_core_big_vec; |
extern const bfd_target cisco_core_little_vec; |
extern const bfd_target hppabsd_core_vec; |
extern const bfd_target hpux_core_vec; |
extern const bfd_target irix_core_vec; |
extern const bfd_target netbsd_core_vec; |
extern const bfd_target osf_core_vec; |
extern const bfd_target ptrace_core_vec; |
extern const bfd_target sco5_core_vec; |
extern const bfd_target trad_core_vec; |
extern const bfd_target bfd_elf32_am33lin_vec; |
static const bfd_target * const _bfd_target_vector[] = |
{ |
#ifdef SELECT_VECS |
939,319 → 931,339 |
#endif |
/* This list is alphabetized to make it easy to compare |
with other vector lists -- the decls above and |
the case statement in configure.ac. |
Try to keep it in order when adding new targets, and |
use a name of the form <cpu>_<format>_<other>_<endian>_vec. |
Note that sorting is done as if _<endian>_vec wasn't present. |
the case statement in configure.in. |
Vectors that don't compile on all systems, or aren't finished, |
should have an entry here with #if 0 around it, to show that |
it wasn't omitted by mistake. */ |
&a_out_adobe_vec, |
#ifdef BFD64 |
&aarch64_elf32_be_vec, |
&aarch64_elf32_le_vec, |
&aarch64_elf64_be_vec, |
&aarch64_elf64_be_cloudabi_vec, |
&aarch64_elf64_le_vec, |
&aarch64_elf64_le_cloudabi_vec, |
&aix5coff64_vec, |
#endif |
#ifdef BFD64 |
&alpha_ecoff_le_vec, |
&alpha_elf64_vec, |
&alpha_elf64_fbsd_vec, |
&alpha_nlm32_vec, |
&alpha_vms_vec, |
#endif |
&alpha_vms_lib_txt_vec, |
&am33_elf32_linux_vec, |
&aout0_be_vec, |
#ifdef BFD64 |
&aout64_vec, /* Only compiled if host has long-long support. */ |
#endif |
&aout0_big_vec, |
#if 0 |
/* Since a.out files lack decent magic numbers, no way to recognize |
which kind of a.out file it is. */ |
&aout_vec, |
#endif |
&aout_adobe_vec, |
&arc_elf32_be_vec, |
&arc_elf32_le_vec, |
#if 0 |
/* We have no way of distinguishing these from other a.out variants. */ |
&arm_aout_be_vec, |
&arm_aout_le_vec, |
&aout_arm_big_vec, |
&aout_arm_little_vec, |
/* No one seems to use this. */ |
&aout_mips_big_vec, |
#endif |
&arm_aout_nbsd_vec, |
&aout_mips_little_vec, |
#if 0 |
/* We have no way of distinguishing these from other a.out variants. */ |
&arm_aout_riscix_vec, |
&apollocoff_vec, |
#endif |
&arm_coff_be_vec, |
&arm_coff_le_vec, |
&arm_elf32_be_vec, |
&arm_elf32_le_vec, |
&arm_elf32_symbian_be_vec, |
&arm_elf32_symbian_le_vec, |
&arm_elf32_vxworks_be_vec, |
&arm_elf32_vxworks_le_vec, |
&arm_pe_be_vec, |
&arm_pe_le_vec, |
&arm_pe_epoc_be_vec, |
&arm_pe_epoc_le_vec, |
&arm_pe_wince_be_vec, |
&arm_pe_wince_le_vec, |
&arm_pei_be_vec, |
&arm_pei_le_vec, |
&arm_pei_epoc_be_vec, |
&arm_pei_epoc_le_vec, |
&arm_pei_wince_be_vec, |
&arm_pei_wince_le_vec, |
&arm_epoc_pe_big_vec, |
&arm_epoc_pe_little_vec, |
&arm_epoc_pei_big_vec, |
&arm_epoc_pei_little_vec, |
&arm_wince_pe_big_vec, |
&arm_wince_pe_little_vec, |
&arm_wince_pei_big_vec, |
&arm_wince_pei_little_vec, |
&armcoff_big_vec, |
&armcoff_little_vec, |
&armnetbsd_vec, |
&armpe_big_vec, |
&armpe_little_vec, |
&armpei_big_vec, |
&armpei_little_vec, |
&b_out_vec_big_host, |
&b_out_vec_little_host, |
#ifdef BFD64 |
&bfd_pei_ia64_vec, |
#endif |
&bfd_elf32_avr_vec, |
&bfd_elf32_bfin_vec, |
&bfd_elf32_bfinfdpic_vec, |
&avr_elf32_vec, |
&bfin_elf32_vec, |
&bfin_elf32_fdpic_vec, |
&bout_be_vec, |
&bout_le_vec, |
&cr16_elf32_vec, |
&cr16c_elf32_vec, |
&cris_aout_vec, |
&cris_elf32_vec, |
&cris_elf32_us_vec, |
&crx_elf32_vec, |
&d10v_elf32_vec, |
&d30v_elf32_vec, |
&dlx_elf32_be_vec, |
/* This, and other vectors, may not be used in any *.mt configuration. |
But that does not mean they are unnecessary. If configured with |
--enable-targets=all, objdump or gdb should be able to examine |
the file even if we don't recognize the machine type. */ |
&elf32_be_vec, |
&elf32_le_vec, |
&bfd_elf32_big_generic_vec, |
&bfd_elf32_bigarc_vec, |
&bfd_elf32_bigarm_vec, |
&bfd_elf32_bigarm_symbian_vec, |
&bfd_elf32_bigarm_vxworks_vec, |
#ifdef BFD64 |
&elf64_be_vec, |
&elf64_le_vec, |
&bfd_elf32_bigmips_vec, |
&bfd_elf32_bigmips_vxworks_vec, |
#endif |
&epiphany_elf32_vec, |
&fr30_elf32_vec, |
&frv_elf32_vec, |
&frv_elf32_fdpic_vec, |
&h8300_coff_vec, |
&h8300_elf32_vec, |
&h8300_elf32_linux_vec, |
&h8500_coff_vec, |
&hppa_elf32_vec, |
&hppa_elf32_linux_vec, |
&hppa_elf32_nbsd_vec, |
&bfd_elf32_bigmoxie_vec, |
&bfd_elf32_bignios2_vec, |
&bfd_elf32_cr16_vec, |
&bfd_elf32_cr16c_vec, |
&bfd_elf32_cris_vec, |
&bfd_elf32_crx_vec, |
&bfd_elf32_d10v_vec, |
&bfd_elf32_d30v_vec, |
&bfd_elf32_dlx_big_vec, |
&bfd_elf32_epiphany_vec, |
&bfd_elf32_fr30_vec, |
&bfd_elf32_frv_vec, |
&bfd_elf32_frvfdpic_vec, |
&bfd_elf32_h8300_vec, |
&bfd_elf32_hppa_linux_vec, |
&bfd_elf32_hppa_nbsd_vec, |
&bfd_elf32_hppa_vec, |
&bfd_elf32_i370_vec, |
&bfd_elf32_i386_freebsd_vec, |
&bfd_elf32_i386_nacl_vec, |
&bfd_elf32_i386_sol2_vec, |
&bfd_elf32_i386_vxworks_vec, |
&bfd_elf32_i386_vec, |
&bfd_elf32_i860_little_vec, |
&bfd_elf32_i860_vec, |
&bfd_elf32_i960_vec, |
#if 0 |
&bfd_elf32_ia64_big_vec, |
#endif |
#ifdef BFD64 |
&hppa_elf64_vec, |
&hppa_elf64_linux_vec, |
&bfd_elf32_ia64_hpux_big_vec, |
#endif |
&hppa_som_vec, |
&i370_elf32_vec, |
&i386_aout_vec, |
&i386_aout_bsd_vec, |
&bfd_elf32_ip2k_vec, |
&bfd_elf32_iq2000_vec, |
&bfd_elf32_lm32_vec, |
&bfd_elf32_little_generic_vec, |
&bfd_elf32_littlearc_vec, |
&bfd_elf32_littlearm_vec, |
&bfd_elf32_littlearm_symbian_vec, |
&bfd_elf32_littlearm_vxworks_vec, |
#ifdef BFD64 |
&bfd_elf32_littlemips_vec, |
&bfd_elf32_littlemips_vxworks_vec, |
#endif |
&bfd_elf32_littlemoxie_vec, |
&bfd_elf32_littlenios2_vec, |
&bfd_elf32_m32c_vec, |
&bfd_elf32_m32r_vec, |
&bfd_elf32_m32rle_vec, |
&bfd_elf32_m32rlin_vec, |
&bfd_elf32_m32rlelin_vec, |
&bfd_elf32_m68hc11_vec, |
&bfd_elf32_m68hc12_vec, |
&bfd_elf32_m68k_vec, |
&bfd_elf32_m88k_vec, |
&bfd_elf32_mcore_big_vec, |
&bfd_elf32_mcore_little_vec, |
&bfd_elf32_mep_vec, |
&bfd_elf32_metag_vec, |
&bfd_elf32_microblaze_vec, |
&bfd_elf32_mn10200_vec, |
&bfd_elf32_mn10300_vec, |
&bfd_elf32_mt_vec, |
&bfd_elf32_msp430_vec, |
&bfd_elf32_msp430_ti_vec, |
#ifdef BFD64 |
&bfd_elf32_nbigmips_vec, |
&bfd_elf32_nlittlemips_vec, |
&bfd_elf32_ntradbigmips_vec, |
&bfd_elf32_ntradlittlemips_vec, |
&bfd_elf32_ntradbigmips_freebsd_vec, |
&bfd_elf32_ntradlittlemips_freebsd_vec, |
#endif |
&bfd_elf32_openrisc_vec, |
&bfd_elf32_or32_big_vec, |
&bfd_elf32_pj_vec, |
&bfd_elf32_pjl_vec, |
&bfd_elf32_powerpc_vec, |
&bfd_elf32_powerpc_vxworks_vec, |
&bfd_elf32_powerpcle_vec, |
&bfd_elf32_powerpc_freebsd_vec, |
&bfd_elf32_rl78_vec, |
&bfd_elf32_rx_be_vec, |
&bfd_elf32_rx_be_ns_vec, |
&bfd_elf32_rx_le_vec, |
&bfd_elf32_s390_vec, |
#ifdef BFD64 |
&bfd_elf32_bigscore_vec, |
&bfd_elf32_littlescore_vec, |
#endif |
&bfd_elf32_sh_vec, |
&bfd_elf32_shbfd_vec, |
&bfd_elf32_shblin_vec, |
&bfd_elf32_shfd_vec, |
&bfd_elf32_shl_vec, |
&bfd_elf32_shl_symbian_vec, |
&bfd_elf32_shlin_vec, |
&bfd_elf32_shlnbsd_vec, |
&bfd_elf32_shlvxworks_vec, |
&bfd_elf32_shnbsd_vec, |
&bfd_elf32_shvxworks_vec, |
#ifdef BFD64 |
&bfd_elf32_sh64_vec, |
&bfd_elf32_sh64l_vec, |
&bfd_elf32_sh64lnbsd_vec, |
&bfd_elf32_sh64nbsd_vec, |
&bfd_elf32_sh64lin_vec, |
&bfd_elf32_sh64blin_vec, |
#endif |
&bfd_elf32_sparc_vec, |
&bfd_elf32_sparc_sol2_vec, |
&bfd_elf32_sparc_vxworks_vec, |
&bfd_elf32_spu_vec, |
&bfd_elf32_tic6x_be_vec, |
&bfd_elf32_tic6x_le_vec, |
&bfd_elf32_tilegx_be_vec, |
&bfd_elf32_tilegx_le_vec, |
&bfd_elf32_tilepro_vec, |
#ifdef BFD64 |
&bfd_elf32_tradbigmips_vec, |
&bfd_elf32_tradlittlemips_vec, |
&bfd_elf32_tradbigmips_freebsd_vec, |
&bfd_elf32_tradlittlemips_freebsd_vec, |
#endif |
&bfd_elf32_us_cris_vec, |
&bfd_elf32_v850_vec, |
&bfd_elf32_v850_rh850_vec, |
&bfd_elf32_vax_vec, |
&bfd_elf32_xc16x_vec, |
&bfd_elf32_xgate_vec, |
&bfd_elf32_xstormy16_vec, |
&bfd_elf32_xtensa_be_vec, |
&bfd_elf32_xtensa_le_vec, |
#ifdef BFD64 |
&bfd_elf64_alpha_freebsd_vec, |
&bfd_elf64_alpha_vec, |
&bfd_elf64_big_generic_vec, |
&bfd_elf64_bigmips_vec, |
&bfd_elf64_bigaarch64_vec, |
&bfd_elf32_bigaarch64_vec, |
&bfd_elf64_hppa_linux_vec, |
&bfd_elf64_hppa_vec, |
&bfd_elf64_ia64_big_vec, |
&bfd_elf64_ia64_hpux_big_vec, |
&bfd_elf64_ia64_little_vec, |
&bfd_elf64_ia64_vms_vec, |
&bfd_elf64_little_generic_vec, |
&bfd_elf64_littlemips_vec, |
&bfd_elf64_littleaarch64_vec, |
&bfd_elf32_littleaarch64_vec, |
&bfd_elf64_mmix_vec, |
&bfd_elf64_powerpc_vec, |
&bfd_elf64_powerpcle_vec, |
&bfd_elf64_powerpc_freebsd_vec, |
&bfd_elf64_s390_vec, |
&bfd_elf64_sh64_vec, |
&bfd_elf64_sh64l_vec, |
&bfd_elf64_sh64lnbsd_vec, |
&bfd_elf64_sh64nbsd_vec, |
&bfd_elf64_sh64lin_vec, |
&bfd_elf64_sh64blin_vec, |
&bfd_elf64_sparc_vec, |
&bfd_elf64_sparc_freebsd_vec, |
&bfd_elf64_sparc_sol2_vec, |
&bfd_elf64_tilegx_be_vec, |
&bfd_elf64_tilegx_le_vec, |
&bfd_elf64_tradbigmips_vec, |
&bfd_elf64_tradlittlemips_vec, |
&bfd_elf64_tradbigmips_freebsd_vec, |
&bfd_elf64_tradlittlemips_freebsd_vec, |
&bfd_elf64_x86_64_freebsd_vec, |
&bfd_elf64_x86_64_nacl_vec, |
&bfd_elf64_x86_64_sol2_vec, |
&bfd_elf64_x86_64_vec, |
&bfd_elf32_x86_64_nacl_vec, |
&bfd_elf32_x86_64_vec, |
&bfd_elf64_l1om_freebsd_vec, |
&bfd_elf64_l1om_vec, |
&bfd_elf64_k1om_freebsd_vec, |
&bfd_elf64_k1om_vec, |
&bfd_mmo_vec, |
#endif |
&bfd_powerpc_pe_vec, |
&bfd_powerpc_pei_vec, |
&bfd_powerpcle_pe_vec, |
&bfd_powerpcle_pei_vec, |
&cris_aout_vec, |
#ifdef BFD64 |
&demo_64_vec, /* Only compiled if host has long-long support. */ |
#endif |
&ecoff_big_vec, |
&ecoff_biglittle_vec, |
&ecoff_little_vec, |
#ifdef BFD64 |
&ecoffalpha_little_vec, |
#endif |
&go32coff_vec, |
&go32stubbedcoff_vec, |
&h8300coff_vec, |
&h8500coff_vec, |
#if 0 |
&i386_aout_dynix_vec, |
/* Since a.out files lack decent magic numbers, no way to recognize |
which kind of a.out file it is. */ |
&host_aout_vec, |
/* Clashes with sunos_big_vec magic no. */ |
&hp300bsd_vec, |
#endif |
&i386_aout_fbsd_vec, |
&hp300hpux_vec, |
&i386aout_vec, |
&i386bsd_vec, |
&i386coff_vec, |
#if 0 |
&i386dynix_vec, |
#endif |
&i386freebsd_vec, |
#if 0 |
/* Since a.out files lack decent magic numbers, no way to recognize |
which kind of a.out file it is. */ |
&i386_aout_linux_vec, |
&i386linux_vec, |
#endif |
&i386_aout_lynx_vec, |
&i386lynx_aout_vec, |
&i386lynx_coff_vec, |
#if 0 |
/* No distinguishing features for Mach 3 executables. */ |
&i386_aout_mach3_vec, |
&i386mach3_vec, |
#endif |
&i386_aout_nbsd_vec, |
&i386_aout_os9k_vec, |
&i386_coff_vec, |
&i386_coff_go32_vec, |
&i386_coff_go32stubbed_vec, |
&i386_coff_lynx_vec, |
&i386_elf32_vec, |
&i386_elf32_fbsd_vec, |
&i386_elf32_nacl_vec, |
&i386_elf32_sol2_vec, |
&i386_elf32_vxworks_vec, |
&i386_mach_o_vec, |
&i386_msdos_vec, |
&i386_nlm32_vec, |
&i386_pe_vec, |
&i386_pei_vec, |
&iamcu_elf32_vec, |
&i860_coff_vec, |
&i860_elf32_vec, |
&i860_elf32_le_vec, |
&i960_elf32_vec, |
&i386msdos_vec, |
&i386netbsd_vec, |
&i386os9k_vec, |
&i386pe_vec, |
&i386pei_vec, |
#ifdef BFD64 |
#if 0 |
&ia64_elf32_be_vec, |
&x86_64coff_vec, |
&x86_64pe_vec, |
&x86_64pei_vec, |
#endif |
&ia64_elf32_hpux_be_vec, |
&ia64_elf64_be_vec, |
&ia64_elf64_le_vec, |
&ia64_elf64_hpux_be_vec, |
&ia64_elf64_vms_vec, |
&ia64_pei_vec, |
#endif |
&icoff_be_vec, |
&icoff_le_vec, |
&i860coff_vec, |
&icoff_big_vec, |
&icoff_little_vec, |
&ieee_vec, |
&ip2k_elf32_vec, |
&iq2000_elf32_vec, |
#ifdef BFD64 |
&k1om_elf64_vec, |
&k1om_elf64_fbsd_vec, |
&l1om_elf64_vec, |
&l1om_elf64_fbsd_vec, |
#endif |
&lm32_elf32_vec, |
&m32c_elf32_vec, |
&m32r_elf32_vec, |
&m32r_elf32_le_vec, |
&m32r_elf32_linux_vec, |
&m32r_elf32_linux_le_vec, |
&m68hc11_elf32_vec, |
&m68hc12_elf32_vec, |
#if 0 |
&m68k_aout_4knbsd_vec, |
/* Clashes with sparc_aout_sunos_be_vec magic no. */ |
&m68k_aout_hp300bsd_vec, |
&m68k4knetbsd_vec, |
&m68kaux_coff_vec, |
#endif |
&m68k_aout_hp300hpux_vec, |
&m68kcoff_vec, |
&m68kcoffun_vec, |
#if 0 |
/* Since a.out files lack decent magic numbers, no way to recognize |
which kind of a.out file it is. */ |
&m68k_aout_linux_vec, |
&m68klinux_vec, |
#endif |
&m68k_aout_nbsd_vec, |
&m68k_aout_newsos3_vec, |
&m68k_coff_vec, |
#if 0 |
&m68k_coff_apollo_vec, |
&m68k_coff_aux_vec, |
#endif |
&m68k_coff_sysv_vec, |
&m68k_coff_un_vec, |
&m68k_elf32_vec, |
&m68k_versados_vec, |
&m88k_aout_mach3_vec, |
&m88k_aout_obsd_vec, |
&m88k_coff_bcs_vec, |
&m88k_elf32_vec, |
&m68knetbsd_vec, |
&m68ksysvcoff_vec, |
&m88kbcs_vec, |
&m88kmach3_vec, |
&m88kopenbsd_vec, |
&mach_o_be_vec, |
&mach_o_le_vec, |
&mach_o_fat_vec, |
&mcore_elf32_be_vec, |
&mcore_elf32_le_vec, |
&mcore_pe_be_vec, |
&mcore_pe_le_vec, |
&mcore_pei_be_vec, |
&mcore_pei_le_vec, |
&mep_elf32_vec, |
&metag_elf32_vec, |
µblaze_elf32_vec, |
#if 0 |
/* No one seems to use this. */ |
&mips_aout_be_vec, |
#endif |
&mips_aout_le_vec, |
&mips_ecoff_be_vec, |
&mips_ecoff_le_vec, |
&mips_ecoff_bele_vec, |
&mach_o_i386_vec, |
#ifdef BFD64 |
&mips_elf32_be_vec, |
&mips_elf32_le_vec, |
&mips_elf32_n_be_vec, |
&mips_elf32_n_le_vec, |
&mips_elf32_ntrad_be_vec, |
&mips_elf32_ntrad_le_vec, |
&mips_elf32_ntradfbsd_be_vec, |
&mips_elf32_ntradfbsd_le_vec, |
&mips_elf32_trad_be_vec, |
&mips_elf32_trad_le_vec, |
&mips_elf32_tradfbsd_be_vec, |
&mips_elf32_tradfbsd_le_vec, |
&mips_elf32_vxworks_be_vec, |
&mips_elf32_vxworks_le_vec, |
&mips_elf64_be_vec, |
&mips_elf64_le_vec, |
&mips_elf64_trad_be_vec, |
&mips_elf64_trad_le_vec, |
&mips_elf64_tradfbsd_be_vec, |
&mips_elf64_tradfbsd_le_vec, |
&mach_o_x86_64_vec, |
#endif |
&mips_pe_le_vec, |
&mips_pei_le_vec, |
&mcore_pe_big_vec, |
&mcore_pe_little_vec, |
&mcore_pei_big_vec, |
&mcore_pei_little_vec, |
&mipslpe_vec, |
&mipslpei_vec, |
&newsos3_vec, |
#ifdef BFD64 |
&mmix_elf64_vec, |
&mmix_mmo_vec, |
&nlm32_alpha_vec, |
#endif |
&mn10200_elf32_vec, |
&mn10300_elf32_vec, |
&moxie_elf32_be_vec, |
&moxie_elf32_le_vec, |
&msp430_elf32_vec, |
&msp430_elf32_ti_vec, |
&mt_elf32_vec, |
&nds32_elf32_be_vec, |
&nds32_elf32_le_vec, |
&nds32_elf32_linux_be_vec, |
&nds32_elf32_linux_le_vec, |
&nios2_elf32_be_vec, |
&nios2_elf32_le_vec, |
&ns32k_aout_pc532mach_vec, |
&ns32k_aout_pc532nbsd_vec, |
&nlm32_i386_vec, |
&nlm32_powerpc_vec, |
&nlm32_sparc_vec, |
#if 0 |
/* We have no oasys tools anymore, so we can't test any of this |
anymore. If you want to test the stuff yourself, go ahead... |
1260,116 → 1272,45 |
can be annoying target mis-matches. */ |
&oasys_vec, |
#endif |
/* Entry for the OpenRISC family. */ |
&or32coff_big_vec, |
&or1k_elf32_vec, |
&pc532machaout_vec, |
&pc532netbsd_vec, |
&pdp11_aout_vec, |
&pef_vec, |
&pef_xlib_vec, |
&pj_elf32_vec, |
&pj_elf32_le_vec, |
#if BFD_SUPPORTS_PLUGINS |
&plugin_vec, |
#endif |
&powerpc_boot_vec, |
&powerpc_elf32_vec, |
&powerpc_elf32_le_vec, |
&powerpc_elf32_fbsd_vec, |
&powerpc_elf32_vxworks_vec, |
#ifdef BFD64 |
&powerpc_elf64_vec, |
&powerpc_elf64_le_vec, |
&powerpc_elf64_fbsd_vec, |
#endif |
&powerpc_nlm32_vec, |
&powerpc_pe_vec, |
&powerpc_pe_le_vec, |
&powerpc_pei_vec, |
&powerpc_pei_le_vec, |
#if 0 |
/* This has the same magic number as RS/6000. */ |
&powerpc_xcoff_vec, |
&pmac_xcoff_vec, |
#endif |
&rl78_elf32_vec, |
#ifdef BFD64 |
&rs6000_xcoff64_vec, |
&rs6000_xcoff64_aix_vec, |
&ppcboot_vec, |
#if 0 |
/* We have no way of distinguishing these from other a.out variants. */ |
&riscix_vec, |
#endif |
&rs6000_xcoff_vec, |
&rx_elf32_be_vec, |
&rx_elf32_be_ns_vec, |
&rx_elf32_le_vec, |
&s390_elf32_vec, |
#ifdef BFD64 |
&s390_elf64_vec, |
&rs6000coff64_vec, |
#endif |
#ifdef BFD64 |
&score_elf32_be_vec, |
&score_elf32_le_vec, |
#endif |
#ifdef BFD64 |
&sh64_elf32_vec, |
&sh64_elf32_le_vec, |
&sh64_elf32_linux_vec, |
&sh64_elf32_linux_be_vec, |
&sh64_elf32_nbsd_vec, |
&sh64_elf32_nbsd_le_vec, |
&sh64_elf64_vec, |
&sh64_elf64_le_vec, |
&sh64_elf64_linux_vec, |
&sh64_elf64_linux_be_vec, |
&sh64_elf64_nbsd_vec, |
&sh64_elf64_nbsd_le_vec, |
#endif |
&sh_coff_vec, |
&sh_coff_le_vec, |
&sh_coff_small_vec, |
&sh_coff_small_le_vec, |
&sh_elf32_vec, |
&sh_elf32_le_vec, |
&sh_elf32_fdpic_be_vec, |
&sh_elf32_fdpic_le_vec, |
&sh_elf32_linux_vec, |
&sh_elf32_linux_be_vec, |
&sh_elf32_nbsd_vec, |
&sh_elf32_nbsd_le_vec, |
&sh_elf32_symbian_le_vec, |
&sh_elf32_vxworks_vec, |
&sh_elf32_vxworks_le_vec, |
&sh_pe_le_vec, |
&sh_pei_le_vec, |
&sparc_aout_le_vec, |
&sparc_aout_linux_vec, |
&sparc_aout_lynx_vec, |
&sparc_aout_nbsd_vec, |
&sparc_aout_sunos_be_vec, |
&sparc_coff_vec, |
&sparc_coff_lynx_vec, |
&sparc_elf32_vec, |
&sparc_elf32_sol2_vec, |
&sparc_elf32_vxworks_vec, |
#ifdef BFD64 |
&sparc_elf64_vec, |
&sparc_elf64_fbsd_vec, |
&sparc_elf64_sol2_vec, |
#endif |
&sparc_nlm32_vec, |
&spu_elf32_vec, |
&rs6000coff_vec, |
&shcoff_small_vec, |
&shcoff_vec, |
&shlcoff_small_vec, |
&shlcoff_vec, |
&shlpe_vec, |
&shlpei_vec, |
&som_vec, |
&sparccoff_vec, |
&sparcle_aout_vec, |
&sparclinux_vec, |
&sparclynx_aout_vec, |
&sparclynx_coff_vec, |
&sparcnetbsd_vec, |
&sunos_big_vec, |
&sym_vec, |
&tic30_aout_vec, |
&tic30_coff_vec, |
&tic54x_coff0_beh_vec, |
1378,61 → 1319,20 |
&tic54x_coff1_vec, |
&tic54x_coff2_beh_vec, |
&tic54x_coff2_vec, |
&tic6x_elf32_be_vec, |
&tic6x_elf32_le_vec, |
&tic80_coff_vec, |
&tilegx_elf32_be_vec, |
&tilegx_elf32_le_vec, |
&tic80coff_vec, |
&vaxbsd_vec, |
&vaxnetbsd_vec, |
&vax1knetbsd_vec, |
&versados_vec, |
#ifdef BFD64 |
&tilegx_elf64_be_vec, |
&tilegx_elf64_le_vec, |
&vms_alpha_vec, |
#endif |
&tilepro_elf32_vec, |
&ft32_elf32_vec, |
&v800_elf32_vec, |
&v850_elf32_vec, |
&vax_aout_1knbsd_vec, |
&vax_aout_bsd_vec, |
&vax_aout_nbsd_vec, |
&vax_elf32_vec, |
&visium_elf32_vec, |
&w65_coff_vec, |
&we32k_coff_vec, |
#ifdef BFD64 |
&x86_64_coff_vec, |
&x86_64_elf32_vec, |
&x86_64_elf32_nacl_vec, |
&x86_64_elf64_vec, |
&x86_64_elf64_cloudabi_vec, |
&x86_64_elf64_fbsd_vec, |
&x86_64_elf64_nacl_vec, |
&x86_64_elf64_sol2_vec, |
&x86_64_mach_o_vec, |
&x86_64_pe_vec, |
&x86_64_pe_be_vec, |
&x86_64_pei_vec, |
#endif |
&xc16x_elf32_vec, |
&xgate_elf32_vec, |
&xstormy16_elf32_vec, |
&xtensa_elf32_be_vec, |
&xtensa_elf32_le_vec, |
&z80_coff_vec, |
&z8k_coff_vec, |
&vms_lib_txt_vec, |
&w65_vec, |
&we32kcoff_vec, |
&z80coff_vec, |
&z8kcoff_vec, |
&bfd_elf32_am33lin_vec, |
#endif /* not SELECT_VECS */ |
/* Always support S-records, for convenience. */ |
1450,38 → 1350,38 |
/* Add any required traditional-core-file-handler. */ |
#ifdef AIX386_CORE |
&core_aix386_vec, |
&aix386_core_vec, |
#endif |
#if 0 |
/* We don't include cisco_core_*_vec. Although it has a magic number, |
the magic number isn't at the beginning of the file, and thus |
might spuriously match other kinds of files. */ |
&core_cisco_be_vec, |
&core_cisco_le_vec, |
&cisco_core_big_vec, |
&cisco_core_little_vec, |
#endif |
#ifdef HPPABSD_CORE |
&core_hppabsd_vec, |
&hppabsd_core_vec, |
#endif |
#ifdef HPUX_CORE |
&core_hpux_vec, |
&hpux_core_vec, |
#endif |
#ifdef IRIX_CORE |
&core_irix_vec, |
&irix_core_vec, |
#endif |
#ifdef NETBSD_CORE |
&core_netbsd_vec, |
&netbsd_core_vec, |
#endif |
#ifdef OSF_CORE |
&core_osf_vec, |
&osf_core_vec, |
#endif |
#ifdef PTRACE_CORE |
&core_ptrace_vec, |
&ptrace_core_vec, |
#endif |
#ifdef SCO5_CORE |
&core_sco5_vec, |
&sco5_core_vec, |
#endif |
#ifdef TRAD_CORE |
&core_trad_vec, |
&trad_core_vec, |
#endif |
NULL /* end of list marker */ |
1834,50 → 1734,3 |
return NULL; |
} |
/* |
FUNCTION |
bfd_flavour_name |
SYNOPSIS |
const char *bfd_flavour_name (enum bfd_flavour flavour); |
DESCRIPTION |
Return the string form of @var{flavour}. |
*/ |
const char * |
bfd_flavour_name (enum bfd_flavour flavour) |
{ |
switch (flavour) |
{ |
case bfd_target_unknown_flavour: return "unknown file format"; |
case bfd_target_aout_flavour: return "a.out"; |
case bfd_target_coff_flavour: return "COFF"; |
case bfd_target_ecoff_flavour: return "ECOFF"; |
case bfd_target_xcoff_flavour: return "XCOFF"; |
case bfd_target_elf_flavour: return "ELF"; |
case bfd_target_ieee_flavour: return "IEEE"; |
case bfd_target_nlm_flavour: return "NLM"; |
case bfd_target_oasys_flavour: return "Oasys"; |
case bfd_target_tekhex_flavour: return "Tekhex"; |
case bfd_target_srec_flavour: return "Srec"; |
case bfd_target_verilog_flavour: return "Verilog"; |
case bfd_target_ihex_flavour: return "Ihex"; |
case bfd_target_som_flavour: return "SOM"; |
case bfd_target_os9k_flavour: return "OS9K"; |
case bfd_target_versados_flavour: return "Versados"; |
case bfd_target_msdos_flavour: return "MSDOS"; |
case bfd_target_ovax_flavour: return "Ovax"; |
case bfd_target_evax_flavour: return "Evax"; |
case bfd_target_mmo_flavour: return "mmo"; |
case bfd_target_mach_o_flavour: return "MACH_O"; |
case bfd_target_pef_flavour: return "PEF"; |
case bfd_target_pef_xlib_flavour: return "PEF_XLIB"; |
case bfd_target_sym_flavour: return "SYM"; |
/* There is no "default" case here so that -Wswitch (part of -Wall) |
catches missing entries. */ |
} |
abort (); |
} |
/contrib/toolchain/binutils/bfd/targmatch.h |
---|
1,62 → 1,44 |
#ifdef BFD64 |
#if !defined (SELECT_VECS) || defined (HAVE_aarch64_elf64_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_littleaarch64_vec) |
{ "aarch64-*-elf", |
&aarch64_elf64_le_vec }, |
&bfd_elf64_littleaarch64_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_aarch64_elf64_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_bigaarch64_vec) |
{ "aarch64_be-*-elf", |
&aarch64_elf64_be_vec }, |
&bfd_elf64_bigaarch64_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_aarch64_elf64_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_littleaarch64_vec) |
{ "aarch64-*-freebsd*", |
&aarch64_elf64_le_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_aarch64_elf64_le_cloudabi_vec) |
{ "aarch64-*-cloudabi*", |
&aarch64_elf64_le_cloudabi_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_aarch64_elf64_le_vec) |
{ "aarch64-*-linux*", |
&aarch64_elf64_le_vec }, |
&bfd_elf64_littleaarch64_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_aarch64_elf64_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_bigaarch64_vec) |
{ "aarch64_be-*-linux*", |
&aarch64_elf64_be_vec }, |
&bfd_elf64_bigaarch64_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_alpha_elf64_fbsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_alpha_freebsd_vec) |
{ "alpha*-*-freebsd*", NULL },{ "alpha*-*-kfreebsd*-gnu", |
&alpha_elf64_fbsd_vec }, |
&bfd_elf64_alpha_freebsd_vec }, |
#endif |
63,98 → 45,98 |
#if !defined (SELECT_VECS) || defined (HAVE_alpha_elf64_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_alpha_vec) |
{ "alpha*-*-netbsd*", NULL },{ "alpha*-*-openbsd*", |
&alpha_elf64_vec }, |
&bfd_elf64_alpha_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_alpha_ecoff_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_ecoffalpha_little_vec) |
{ "alpha*-*-netware*", |
&alpha_ecoff_le_vec }, |
&ecoffalpha_little_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_alpha_ecoff_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_ecoffalpha_little_vec) |
{ "alpha*-*-linux*ecoff*", |
&alpha_ecoff_le_vec }, |
&ecoffalpha_little_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_alpha_elf64_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_alpha_vec) |
{ "alpha*-*-linux-*", NULL },{ "alpha*-*-elf*", |
&alpha_elf64_vec }, |
&bfd_elf64_alpha_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_alpha_vms_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_vms_alpha_vec) |
{ "alpha*-*-*vms*", |
&alpha_vms_vec }, |
&vms_alpha_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_alpha_ecoff_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_ecoffalpha_little_vec) |
{ "alpha*-*-*", |
&alpha_ecoff_le_vec }, |
&ecoffalpha_little_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_ia64_elf64_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_ia64_little_vec) |
{ "ia64*-*-freebsd*", NULL },{ "ia64*-*-netbsd*", NULL },{ "ia64*-*-linux-*", NULL },{ "ia64*-*-elf*", NULL },{ "ia64*-*-kfreebsd*-gnu", |
&ia64_elf64_le_vec }, |
&bfd_elf64_ia64_little_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_ia64_elf32_hpux_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_ia64_hpux_big_vec) |
{ "ia64*-*-hpux*", |
&ia64_elf32_hpux_be_vec }, |
&bfd_elf32_ia64_hpux_big_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_ia64_elf64_vms_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_ia64_vms_vec) |
{ "ia64*-*-*vms*", |
&ia64_elf64_vms_vec }, |
&bfd_elf64_ia64_vms_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_elf64_fbsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_sparc_freebsd_vec) |
{ "sparc64-*-freebsd*", NULL },{ "sparc64-*-kfreebsd*-gnu", |
&sparc_elf64_fbsd_vec }, |
&bfd_elf64_sparc_freebsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_elf64_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_sparc_vec) |
{ "sparc64-*-netbsd*", NULL },{ "sparc64-*-openbsd*", |
&sparc_elf64_vec }, |
&bfd_elf64_sparc_vec }, |
#endif |
162,27 → 144,27 |
#endif /* BFD64 */ |
#if !defined (SELECT_VECS) || defined (HAVE_am33_elf32_linux_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_am33lin_vec) |
{ "am34-*-linux*", NULL },{ "am33_2.0-*-linux*", |
&am33_elf32_linux_vec }, |
&bfd_elf32_am33lin_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_arc_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_littlearc_vec) |
{ "arc*-*-elf*", NULL },{ "arc*-*-linux-uclibc*", |
&arc_elf32_le_vec }, |
{ "arc-*-elf*", |
&bfd_elf32_littlearc_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_arm_elf32_nacl_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_littlearm_nacl_vec) |
{ "arm-*-nacl*", |
&arm_elf32_nacl_le_vec }, |
&bfd_elf32_littlearm_nacl_vec }, |
#endif |
189,10 → 171,10 |
#if !defined (SELECT_VECS) || defined (HAVE_arm_elf32_nacl_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_bigarm_nacl_vec) |
{ "armeb-*-nacl*", |
&arm_elf32_nacl_be_vec }, |
&bfd_elf32_bigarm_nacl_vec }, |
#endif |
199,51 → 181,51 |
#if !defined (SELECT_VECS) || defined (HAVE_arm_elf32_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_bigarm_vec) |
{ "armeb-*-netbsdelf*", |
&arm_elf32_be_vec }, |
&bfd_elf32_bigarm_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_arm_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_littlearm_vec) |
{ "arm-*-netbsdelf*", |
&arm_elf32_le_vec }, |
&bfd_elf32_littlearm_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_arm_aout_nbsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_armnetbsd_vec) |
{ "arm-*-netbsd*", NULL },{ "arm-*-openbsd*", |
&arm_aout_nbsd_vec }, |
&armnetbsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_arm_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_littlearm_vec) |
{ "arm-*-nto*", NULL },{ "nto*arm*", |
&arm_elf32_le_vec }, |
&bfd_elf32_littlearm_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_riscix_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_arm_aout_riscix_vec) |
{ "arm-*-riscix*", |
&arm_aout_riscix_vec }, |
&riscix_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_arm_pe_epoc_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_arm_epoc_pe_little_vec) |
{ "arm-epoc-pe*", |
&arm_pe_epoc_le_vec }, |
&arm_epoc_pe_little_vec }, |
#endif |
250,10 → 232,10 |
#if !defined (SELECT_VECS) || defined (HAVE_arm_pe_wince_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_arm_wince_pe_little_vec) |
{ "arm-wince-pe", NULL },{ "arm-*-wince", NULL },{ "arm*-*-mingw32ce*", NULL },{ "arm*-*-cegcc*", |
&arm_pe_wince_le_vec }, |
&arm_wince_pe_little_vec }, |
#endif |
260,111 → 242,111 |
#if !defined (SELECT_VECS) || defined (HAVE_arm_pe_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_armpe_little_vec) |
{ "arm-*-pe*", |
&arm_pe_le_vec }, |
&armpe_little_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_arm_aout_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_aout_arm_little_vec) |
{ "arm-*-aout", NULL },{ "armel-*-aout", |
&arm_aout_le_vec }, |
&aout_arm_little_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_arm_aout_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_aout_arm_big_vec) |
{ "armeb-*-aout", |
&arm_aout_be_vec }, |
&aout_arm_big_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_arm_coff_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_armcoff_little_vec) |
{ "arm-*-coff", |
&arm_coff_le_vec }, |
&armcoff_little_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_arm_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_littlearm_vec) |
{ "arm-*-rtems*", |
&arm_elf32_le_vec }, |
&bfd_elf32_littlearm_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_arm_elf32_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_bigarm_vec) |
{ "armeb-*-elf", NULL },{ "arm*b-*-freebsd*", NULL },{ "arm*b-*-linux-*", NULL },{ "armeb-*-eabi*", |
&arm_elf32_be_vec }, |
{ "armeb-*-elf", NULL },{ "arm*b-*-linux-*", |
&bfd_elf32_bigarm_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_arm_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_littlearm_vec) |
{ "arm-*-kaos*", |
&arm_elf32_le_vec }, |
&bfd_elf32_littlearm_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_arm_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_littlearm_vec) |
{ "arm-*-elf", NULL },{ "arm*-*-freebsd*", NULL },{ "arm*-*-linux-*", NULL },{ "arm*-*-conix*", NULL }, |
{ "arm-*-elf", NULL },{ "arm-*-freebsd*", NULL },{ "arm*-*-linux-*", NULL },{ "arm*-*-conix*", NULL }, |
{ "arm*-*-uclinux*", NULL },{ "arm-*-kfreebsd*-gnu", NULL }, |
{ "arm*-*-eabi*", |
&arm_elf32_le_vec }, |
&bfd_elf32_littlearm_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_arm_elf32_vxworks_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_littlearm_vxworks_vec) |
{ "arm*-*-vxworks", NULL },{ "arm*-*-windiss", |
&arm_elf32_vxworks_le_vec }, |
&bfd_elf32_littlearm_vxworks_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_arm_elf32_symbian_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_littlearm_symbian_vec) |
{ "arm*-*-symbianelf*", |
&arm_elf32_symbian_le_vec }, |
&bfd_elf32_littlearm_symbian_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_arm_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_littlearm_vec) |
{ "arm9e-*-elf", |
&arm_elf32_le_vec }, |
&bfd_elf32_littlearm_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_avr_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_avr_vec) |
{ "avr-*-*", |
&avr_elf32_vec }, |
&bfd_elf32_avr_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_bfin_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_bfin_vec) |
{ "bfin-*-*", |
&bfin_elf32_vec }, |
&bfd_elf32_bfin_vec }, |
#endif |
406,19 → 388,19 |
#if !defined (SELECT_VECS) || defined (HAVE_cr16_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_cr16_vec) |
{ "cr16-*-elf*", NULL },{ "cr16*-*-uclinux*", |
&cr16_elf32_vec }, |
&bfd_elf32_cr16_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_cr16c_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_cr16c_vec) |
{ "cr16c-*-elf*", |
&cr16c_elf32_vec }, |
&bfd_elf32_cr16c_vec }, |
#endif |
434,139 → 416,123 |
#if !defined (SELECT_VECS) || defined (HAVE_crx_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_crx_vec) |
{ "crx-*-elf*", |
&crx_elf32_vec }, |
&bfd_elf32_crx_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_d10v_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_d10v_vec) |
{ "d10v-*-*", |
&d10v_elf32_vec }, |
&bfd_elf32_d10v_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_dlx_elf32_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_dlx_big_vec) |
{ "dlx-*-elf*", |
&dlx_elf32_be_vec }, |
&bfd_elf32_dlx_big_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_d30v_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_d30v_vec) |
{ "d30v-*-*", |
&d30v_elf32_vec }, |
&bfd_elf32_d30v_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_epiphany_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_epiphany_vec) |
{ "epiphany-*-elf", |
&epiphany_elf32_vec }, |
&bfd_elf32_epiphany_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m68k_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_m68k_vec) |
{ "fido-*-elf*", |
&m68k_elf32_vec }, |
&bfd_elf32_m68k_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_fr30_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_fr30_vec) |
{ "fr30-*-elf", |
&fr30_elf32_vec }, |
&bfd_elf32_fr30_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_frv_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_frv_vec) |
{ "frv-*-elf", |
&frv_elf32_vec }, |
&bfd_elf32_frv_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_frv_elf32_fdpic_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_frvfdpic_vec) |
{ "frv-*-*linux*", |
&frv_elf32_fdpic_vec }, |
&bfd_elf32_frvfdpic_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_moxie_elf32_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_bigmoxie_vec) |
{ "moxie-*-elf", NULL },{ "moxie-*-rtems*", NULL },{ "moxie-*-uclinux", |
&moxie_elf32_be_vec }, |
&bfd_elf32_bigmoxie_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_moxie_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_h8300coff_vec) |
{ "moxie-*-moxiebox*", |
&moxie_elf32_le_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_h8300_coff_vec) |
{ "h8300*-*-rtemscoff*", |
&h8300_coff_vec }, |
&h8300coff_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_h8300_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_h8300_vec) |
{ "h8300*-*-elf", NULL },{ "h8300*-*-rtems*", |
&h8300_elf32_vec }, |
&bfd_elf32_h8300_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_h8300_elf32_linux_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_h8300coff_vec) |
{ "h8300*-*-linux*", |
&h8300_elf32_linux_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_h8300_coff_vec) |
{ "h8300*-*-*", |
&h8300_coff_vec }, |
&h8300coff_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_h8500_coff_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_h8500coff_vec) |
{ "h8500-*-*", |
&h8500_coff_vec }, |
&h8500coff_vec }, |
#endif |
573,19 → 539,19 |
#ifdef BFD64 |
#if !defined (SELECT_VECS) || defined (HAVE_hppa_elf64_linux_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_hppa_linux_vec) |
{ "hppa*64*-*-linux-*", |
&hppa_elf64_linux_vec }, |
&bfd_elf64_hppa_linux_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_hppa_elf64_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_hppa_vec) |
{ "hppa*64*-*-hpux11*", |
&hppa_elf64_vec }, |
&bfd_elf64_hppa_vec }, |
#endif |
594,85 → 560,85 |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_hppa_elf32_linux_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_hppa_linux_vec) |
{ "hppa*-*-linux-*", |
&hppa_elf32_linux_vec }, |
&bfd_elf32_hppa_linux_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_hppa_elf32_nbsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_hppa_nbsd_vec) |
{ "hppa*-*-netbsd*", |
&hppa_elf32_nbsd_vec }, |
&bfd_elf32_hppa_nbsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_hppa_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_hppa_vec) |
{ "hppa*-*-*elf*", NULL },{ "hppa*-*-lites*", NULL },{ "hppa*-*-sysv4*", NULL },{ "hppa*-*-openbsd*", |
&hppa_elf32_vec }, |
&bfd_elf32_hppa_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_hppa_som_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_som_vec) |
{ "hppa*-*-bsd*", |
&hppa_som_vec }, |
&som_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_hppa_som_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_som_vec) |
{ "hppa*-*-hpux*", NULL },{ "hppa*-*-hiux*", NULL },{ "hppa*-*-mpeix*", |
&hppa_som_vec }, |
&som_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_hppa_som_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_som_vec) |
{ "hppa*-*-osf*", |
&hppa_som_vec }, |
&som_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i370_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i370_vec) |
{ "i370-*-*", |
&i370_elf32_vec }, |
&bfd_elf32_i370_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_coff_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_i386coff_vec) |
{ "i[3-7]86-*-sco3.2v5*coff", |
&i386_coff_vec }, |
&i386coff_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_vec) |
{ "i[3-7]86-*-sysv4*", NULL },{ "i[3-7]86-*-unixware*", NULL }, |
{ "i[3-7]86-*-elf*", NULL },{ "i[3-7]86-*-sco3.2v5*", NULL }, |
{ "i[3-7]86-*-elf", NULL },{ "i[3-7]86-*-sco3.2v5*", NULL }, |
{ "i[3-7]86-*-dgux*", NULL },{ "i[3-7]86-*-sysv5*", |
&i386_elf32_vec }, |
&bfd_elf32_i386_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_sol2_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_sol2_vec) |
{ "i[3-7]86-*-solaris2*", |
&i386_elf32_sol2_vec }, |
&bfd_elf32_i386_sol2_vec }, |
#endif |
680,10 → 646,10 |
#ifdef BFD64 |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_sol2_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_sol2_vec) |
{ "x86_64-*-solaris2*", |
&i386_elf32_sol2_vec }, |
&bfd_elf32_i386_sol2_vec }, |
#endif |
690,75 → 656,72 |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_vec) |
{ "i[3-7]86-*-kaos*", |
&i386_elf32_vec }, |
&bfd_elf32_i386_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_vec) |
{ "i[3-7]86-*-nto*", |
&i386_elf32_vec }, |
&bfd_elf32_i386_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_vec) |
{ "i[3-7]86-*-aros*", |
&i386_elf32_vec }, |
&bfd_elf32_i386_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_vec) |
{ "i[3-7]86-*-chorus*", |
&i386_elf32_vec }, |
&bfd_elf32_i386_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_vec) |
{ "i[3-7]86-*-dicos*", |
&i386_elf32_vec }, |
&bfd_elf32_i386_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_go32coff_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_i386_coff_go32_vec) |
{ "*-*-msdosdjgpp*", NULL },{ "*-*-go32*", |
&i386_coff_go32_vec }, |
&go32coff_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_coff_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_i386coff_vec) |
{ "i[3-7]86-*-sysv*", NULL },{ "i[3-7]86-*-isc*", NULL },{ "i[3-7]86-*-sco*", NULL },{ "i[3-7]86-*-coff", NULL }, |
{ "i[3-7]86-*-aix*", |
&i386_coff_vec }, |
&i386coff_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_vec) |
{ "i[3-7]86-*-rtems*", |
&i386_elf32_vec }, |
&bfd_elf32_i386_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_mach_o_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_mach_o_i386_vec) |
{ "i[3-7]86-*-darwin*", NULL },{ "i[3-7]86-*-macos10*", NULL },{ "i[3-7]86-*-rhapsody*", |
&i386_mach_o_vec }, |
&mach_o_i386_vec }, |
#endif |
765,45 → 728,44 |
#if !defined (SELECT_VECS) || defined (HAVE_i386_aout_dynix_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_i386dynix_vec) |
{ "i[3-7]86-sequent-bsd*", |
&i386_aout_dynix_vec }, |
&i386dynix_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_aout_bsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_i386bsd_vec) |
{ "i[3-7]86-*-bsd*", |
&i386_aout_bsd_vec }, |
&i386bsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_vec) |
{ "i[3-7]86-*-dragonfly*", |
&i386_elf32_vec }, |
&bfd_elf32_i386_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386freebsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_i386_aout_fbsd_vec) |
{ "i[3-7]86-*-freebsdaout*", NULL },{ "i[3-7]86-*-freebsd[12].*", NULL }, |
{ "i[3-7]86-*-freebsd[12]", |
&i386_aout_fbsd_vec }, |
&i386freebsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_fbsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_freebsd_vec) |
{ "i[3-7]86-*-freebsd*", NULL },{ "i[3-7]86-*-kfreebsd*-gnu", |
&i386_elf32_fbsd_vec }, |
&bfd_elf32_i386_freebsd_vec }, |
#endif |
810,71 → 772,71 |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_vec) |
{ "i[3-7]86-*-netbsdelf*", NULL },{ "i[3-7]86-*-netbsd*-gnu*", NULL },{ "i[3-7]86-*-knetbsd*-gnu", |
&i386_elf32_vec }, |
&bfd_elf32_i386_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_pe_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_i386pe_vec) |
{ "i[3-7]86-*-netbsdpe*", |
&i386_pe_vec }, |
&i386pe_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_aout_nbsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_i386netbsd_vec) |
{ "i[3-7]86-*-netbsdaout*", NULL },{ "i[3-7]86-*-netbsd*", NULL }, |
{ "i[3-7]86-*-openbsd[0-2].*", NULL },{ "i[3-7]86-*-openbsd3.[0-3]", |
&i386_aout_nbsd_vec }, |
&i386netbsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_vec) |
{ "i[3-7]86-*-openbsd*", |
&i386_elf32_vec }, |
&bfd_elf32_i386_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_vec) |
{ "i[3-7]86-*-netware*", |
&i386_elf32_vec }, |
&bfd_elf32_i386_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_aout_linux_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_i386linux_vec) |
{ "i[3-7]86-*-linux*aout*", |
&i386_aout_linux_vec }, |
&i386linux_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_vec) |
{ "i[3-7]86-*-linux-*", |
&i386_elf32_vec }, |
&bfd_elf32_i386_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_nacl_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_nacl_vec) |
{ "i[3-7]86-*-nacl*", |
&i386_elf32_nacl_vec }, |
&bfd_elf32_i386_nacl_vec }, |
#endif |
882,18 → 844,10 |
#ifdef BFD64 |
#if !defined (SELECT_VECS) || defined (HAVE_x86_64_elf64_cloudabi_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_mach_o_x86_64_vec) |
{ "x86_64-*-cloudabi*", |
&x86_64_elf64_cloudabi_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_x86_64_mach_o_vec) |
{ "x86_64-*-darwin*", |
&x86_64_mach_o_vec }, |
&mach_o_x86_64_vec }, |
#endif |
900,64 → 854,64 |
#if !defined (SELECT_VECS) || defined (HAVE_x86_64_elf64_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_x86_64_vec) |
{ "x86_64-*-dicos*", |
&x86_64_elf64_vec }, |
&bfd_elf64_x86_64_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_x86_64_elf64_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_x86_64_vec) |
{ "x86_64-*-elf*", |
&x86_64_elf64_vec }, |
&bfd_elf64_x86_64_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_x86_64_elf64_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_x86_64_vec) |
{ "x86_64-*-dragonfly*", |
&x86_64_elf64_vec }, |
&bfd_elf64_x86_64_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_x86_64_elf64_fbsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_x86_64_freebsd_vec) |
{ "x86_64-*-freebsd*", NULL },{ "x86_64-*-kfreebsd*-gnu", |
&x86_64_elf64_fbsd_vec }, |
&bfd_elf64_x86_64_freebsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_x86_64_elf64_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_x86_64_vec) |
{ "x86_64-*-netbsd*", NULL },{ "x86_64-*-openbsd*", |
&x86_64_elf64_vec }, |
&bfd_elf64_x86_64_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_x86_64_elf64_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_x86_64_vec) |
{ "x86_64-*-linux-*", |
&x86_64_elf64_vec }, |
&bfd_elf64_x86_64_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_x86_64_elf32_nacl_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_x86_64_nacl_vec) |
{ "x86_64-*-nacl*", |
&x86_64_elf32_nacl_vec }, |
&bfd_elf32_x86_64_nacl_vec }, |
#endif |
964,10 → 918,10 |
#if !defined (SELECT_VECS) || defined (HAVE_x86_64_pe_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_x86_64pe_vec) |
{ "x86_64-*-mingw*", NULL },{ "x86_64-*-pe", NULL },{ "x86_64-*-pep", NULL },{ "x86_64-*-cygwin", |
&x86_64_pe_vec }, |
&x86_64pe_vec }, |
#endif |
974,83 → 928,82 |
#if !defined (SELECT_VECS) || defined (HAVE_x86_64_elf64_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_x86_64_vec) |
{ "x86_64-*-rdos*", |
&x86_64_elf64_vec }, |
&bfd_elf64_x86_64_vec }, |
#endif |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_vec) |
{ "i[3-7]86-*-lynxos*", |
&i386_elf32_vec }, |
&bfd_elf32_i386_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_vec) |
{ "i[3-7]86-*-gnu*", |
&i386_elf32_vec }, |
&bfd_elf32_i386_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386mach3_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_i386_aout_mach3_vec) |
{ "i[3-7]86-*-mach*", NULL },{ "i[3-7]86-*-osf1mk*", |
&i386_aout_mach3_vec }, |
&i386mach3_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_aout_os9k_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_i386os9k_vec) |
{ "i[3-7]86-*-os9k", |
&i386_aout_os9k_vec }, |
&i386os9k_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_aout_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_i386aout_vec) |
{ "i[3-7]86-*-msdos*", |
&i386_aout_vec }, |
&i386aout_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_vec) |
{ "i[3-7]86-*-moss*", |
&i386_elf32_vec }, |
&bfd_elf32_i386_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_pe_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_i386pe_vec) |
{ "i[3-7]86-*-beospe*", |
&i386_pe_vec }, |
&i386pe_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_vec) |
{ "i[3-7]86-*-beoself*", NULL },{ "i[3-7]86-*-beos*", |
&i386_elf32_vec }, |
&bfd_elf32_i386_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_pei_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_i386pei_vec) |
{ "i[3-7]86-*-interix*", |
&i386_pei_vec }, |
&i386pei_vec }, |
#endif |
1057,223 → 1010,223 |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_vec) |
{ "i[3-7]86-*-rdos*", |
&i386_elf32_vec }, |
&bfd_elf32_i386_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_pe_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_i386pe_vec) |
{ "i[3-7]86-*-mingw32*", NULL },{ "i[3-7]86-*-cygwin*", NULL },{ "i[3-7]86-*-winnt", NULL },{ "i[3-7]86-*-pe", |
&i386_pe_vec }, |
&i386pe_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_coff_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_i386coff_vec) |
{ "i[3-7]86-none-*", |
&i386_coff_vec }, |
&i386coff_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_aout_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_i386aout_vec) |
{ "i[3-7]86-*-aout*", NULL },{ "i[3-7]86*-*-vsta*", |
&i386_aout_vec }, |
&i386aout_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_vxworks_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_vxworks_vec) |
{ "i[3-7]86-*-vxworks*", |
&i386_elf32_vxworks_vec }, |
&bfd_elf32_i386_vxworks_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i386_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i386_vec) |
{ "i[3-7]86-*-chaos", |
&i386_elf32_vec }, |
&bfd_elf32_i386_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i860_coff_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_i860coff_vec) |
{ "i860-*-mach3*", NULL },{ "i860-*-osf1*", NULL },{ "i860-*-coff*", |
&i860_coff_vec }, |
&i860coff_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i860_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i860_little_vec) |
{ "i860-stardent-sysv4*", NULL },{ "i860-stardent-elf*", |
&i860_elf32_le_vec }, |
&bfd_elf32_i860_little_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i860_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i860_vec) |
{ "i860-*-sysv4*", NULL },{ "i860-*-elf*", |
&i860_elf32_vec }, |
&bfd_elf32_i860_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_bout_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_b_out_vec_little_host) |
{ "i960-*-vxworks4*", NULL },{ "i960-*-vxworks5.0", |
&bout_le_vec }, |
&b_out_vec_little_host }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_icoff_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_icoff_little_vec) |
{ "i960-*-vxworks5.*", NULL },{ "i960-*-coff*", NULL },{ "i960-*-sysv*", |
&icoff_le_vec }, |
&icoff_little_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_bout_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_b_out_vec_little_host) |
{ "i960-*-vxworks*", NULL },{ "i960-*-aout*", NULL },{ "i960-*-bout*", NULL },{ "i960-*-nindy*", |
&bout_le_vec }, |
&b_out_vec_little_host }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_i960_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_i960_vec) |
{ "i960-*-elf*", |
&i960_elf32_vec }, |
&bfd_elf32_i960_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_ip2k_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_ip2k_vec) |
{ "ip2k-*-elf", |
&ip2k_elf32_vec }, |
&bfd_elf32_ip2k_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_iq2000_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_iq2000_vec) |
{ "iq2000-*-elf", |
&iq2000_elf32_vec }, |
&bfd_elf32_iq2000_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_lm32_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_lm32_vec) |
{ "lm32-*-elf", NULL },{ "lm32-*-rtems*", |
&lm32_elf32_vec }, |
&bfd_elf32_lm32_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_lm32_elf32_fdpic_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_lm32fdpic_vec) |
{ "lm32-*-*linux*", |
&lm32_elf32_fdpic_vec }, |
&bfd_elf32_lm32fdpic_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m32c_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_m32c_vec) |
{ "m32c-*-elf", NULL },{ "m32c-*-rtems*", |
&m32c_elf32_vec }, |
&bfd_elf32_m32c_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m32r_elf32_linux_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_m32rlelin_vec) |
{ "m32r*le-*-linux*", |
&m32r_elf32_linux_le_vec }, |
&bfd_elf32_m32rlelin_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m32r_elf32_linux_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_m32rlin_vec) |
{ "m32r*-*-linux*", |
&m32r_elf32_linux_vec }, |
&bfd_elf32_m32rlin_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m32r_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_m32rle_vec) |
{ "m32r*le-*-*", |
&m32r_elf32_le_vec }, |
&bfd_elf32_m32rle_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m32r_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_m32r_vec) |
{ "m32r-*-*", |
&m32r_elf32_vec }, |
&bfd_elf32_m32r_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m68hc11_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_m68hc11_vec) |
{ "m68hc11-*-*", NULL },{ "m6811-*-*", |
&m68hc11_elf32_vec }, |
&bfd_elf32_m68hc11_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m68hc12_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_m68hc12_vec) |
{ "m68hc12-*-*", NULL },{ "m6812-*-*", |
&m68hc12_elf32_vec }, |
&bfd_elf32_m68hc12_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m68k_coff_sysv_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_m68ksysvcoff_vec) |
{ "m68*-motorola-sysv*", |
&m68k_coff_sysv_vec }, |
&m68ksysvcoff_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m68k_aout_hp300bsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_hp300bsd_vec) |
{ "m68*-hp-bsd*", |
&m68k_aout_hp300bsd_vec }, |
&hp300bsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_aout0_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_aout0_big_vec) |
{ "m68*-*-aout*", |
&aout0_be_vec }, |
&aout0_big_vec }, |
#endif |
1282,129 → 1235,129 |
#if !defined (SELECT_VECS) || defined (HAVE_m68k_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_m68k_vec) |
{ "m68*-*-elf*", NULL },{ "m68*-*-sysv4*", NULL },{ "m68*-*-uclinux*", |
&m68k_elf32_vec }, |
&bfd_elf32_m68k_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m68k_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_m68k_vec) |
{ "m68*-*-rtems*", |
&m68k_elf32_vec }, |
&bfd_elf32_m68k_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m68k_coff_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_m68kcoff_vec) |
{ "m68*-*-coff*", NULL },{ "m68*-*-sysv*", |
&m68k_coff_vec }, |
&m68kcoff_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m68k_aout_hp300hpux_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_hp300hpux_vec) |
{ "m68*-*-hpux*", |
&m68k_aout_hp300hpux_vec }, |
&hp300hpux_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m68k_aout_linux_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_m68klinux_vec) |
{ "m68*-*-linux*aout*", |
&m68k_aout_linux_vec }, |
&m68klinux_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m68k_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_m68k_vec) |
{ "m68*-*-linux-*", |
&m68k_elf32_vec }, |
&bfd_elf32_m68k_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m68k_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_m68k_vec) |
{ "m68*-*-gnu*", |
&m68k_elf32_vec }, |
&bfd_elf32_m68k_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m68k_aout_4knbsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_m68k4knetbsd_vec) |
{ "m68*-hp*-netbsd*", |
&m68k_aout_4knbsd_vec }, |
&m68k4knetbsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m68k_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_m68k_vec) |
{ "m68*-*-netbsdelf*", |
&m68k_elf32_vec }, |
&bfd_elf32_m68k_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m68k_aout_nbsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_m68knetbsd_vec) |
{ "m68*-*-netbsdaout*", NULL },{ "m68*-*-netbsd*", |
&m68k_aout_nbsd_vec }, |
&m68knetbsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m68k_aout_nbsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_m68knetbsd_vec) |
{ "m68*-*-openbsd*", |
&m68k_aout_nbsd_vec }, |
&m68knetbsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_aout_sunos_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_sunos_big_vec) |
{ "m68*-*-sunos*", NULL },{ "m68*-*-os68k*", NULL },{ "m68*-*-vxworks*", NULL },{ "m68*-netx-*", NULL }, |
{ "m68*-*-bsd*", NULL },{ "m68*-*-vsta*", |
&sparc_aout_sunos_be_vec }, |
&sunos_big_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_aout_sunos_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_sunos_big_vec) |
{ "m68*-ericsson-*", |
&sparc_aout_sunos_be_vec }, |
&sunos_big_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m68k_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_m68k_vec) |
{ "m68*-cbm-*", |
&m68k_elf32_vec }, |
&bfd_elf32_m68k_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m68k_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_m68k_vec) |
{ "m68*-*-psos*", |
&m68k_elf32_vec }, |
&bfd_elf32_m68k_vec }, |
#endif |
1411,320 → 1364,320 |
#if !defined (SELECT_VECS) || defined (HAVE_m88k_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_m88k_vec) |
{ "m88*-harris-cxux*", NULL },{ "m88*-*-dgux*", NULL },{ "m88*-*-sysv4*", |
&m88k_elf32_vec }, |
&bfd_elf32_m88k_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m88k_aout_mach3_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_m88kmach3_vec) |
{ "m88*-*-mach3*", |
&m88k_aout_mach3_vec }, |
&m88kmach3_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m88k_aout_obsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_m88kopenbsd_vec) |
{ "m88*-*-openbsd*", |
&m88k_aout_obsd_vec }, |
&m88kopenbsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m88k_coff_bcs_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_m88kbcs_vec) |
{ "m88*-*-*", |
&m88k_coff_bcs_vec }, |
&m88kbcs_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mcore_elf32_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_mcore_big_vec) |
{ "mcore-*-elf", |
&mcore_elf32_be_vec }, |
&bfd_elf32_mcore_big_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mcore_pe_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_mcore_pe_big_vec) |
{ "mcore-*-pe", |
&mcore_pe_be_vec }, |
&mcore_pe_big_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mep_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_mep_vec) |
{ "mep-*-elf", |
&mep_elf32_vec }, |
&bfd_elf32_mep_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_metag_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_metag_vec) |
{ "metag-*-*", |
&metag_elf32_vec }, |
&bfd_elf32_metag_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_microblaze_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_microblazeel_vec) |
{ "microblazeel*-*", |
µblaze_elf32_le_vec }, |
&bfd_elf32_microblazeel_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_microblaze_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_microblaze_vec) |
{ "microblaze*-*", |
µblaze_elf32_vec }, |
&bfd_elf32_microblaze_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_ecoff_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_ecoff_big_vec) |
{ "mips*-big-*", |
&mips_ecoff_be_vec }, |
&ecoff_big_vec }, |
#endif |
#ifdef BFD64 |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_trad_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_tradlittlemips_vec) |
{ "mips*el-*-netbsd*", |
&mips_elf32_trad_le_vec }, |
&bfd_elf32_tradlittlemips_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_trad_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_tradbigmips_vec) |
{ "mips*-*-netbsd*", |
&mips_elf32_trad_be_vec }, |
&bfd_elf32_tradbigmips_vec }, |
#endif |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_ecoff_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_ecoff_little_vec) |
{ "mips*-dec-*", NULL },{ "mips*el-*-ecoff*", |
&mips_ecoff_le_vec }, |
&ecoff_little_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_ecoff_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_ecoff_big_vec) |
{ "mips*-*-ecoff*", |
&mips_ecoff_be_vec }, |
&ecoff_big_vec }, |
#endif |
#ifdef BFD64 |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_n_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_nbigmips_vec) |
{ "mips*-*-irix6*", |
&mips_elf32_n_be_vec }, |
&bfd_elf32_nbigmips_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_n_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_nlittlemips_vec) |
{ "mips64*-ps2-elf*", |
&mips_elf32_n_le_vec }, |
&bfd_elf32_nlittlemips_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_littlemips_vec) |
{ "mips*-ps2-elf*", |
&mips_elf32_le_vec }, |
&bfd_elf32_littlemips_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_bigmips_vec) |
{ "mips*-*-irix5*", |
&mips_elf32_be_vec }, |
&bfd_elf32_bigmips_vec }, |
#endif |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_ecoff_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_ecoff_big_vec) |
{ "mips*-sgi-*", NULL },{ "mips*-*-bsd*", |
&mips_ecoff_be_vec }, |
&ecoff_big_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_ecoff_bele_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_ecoff_biglittle_vec) |
{ "mips*-*-lnews*", |
&mips_ecoff_bele_vec }, |
&ecoff_biglittle_vec }, |
#endif |
#ifdef BFD64 |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_trad_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_tradbigmips_vec) |
{ "mips*-*-sysv4*", |
&mips_elf32_trad_be_vec }, |
&bfd_elf32_tradbigmips_vec }, |
#endif |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_ecoff_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_ecoff_big_vec) |
{ "mips*-*-sysv*", NULL },{ "mips*-*-riscos*", |
&mips_ecoff_be_vec }, |
&ecoff_big_vec }, |
#endif |
#ifdef BFD64 |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_vxworks_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_littlemips_vxworks_vec) |
{ "mips*el-*-vxworks*", |
&mips_elf32_vxworks_le_vec }, |
&bfd_elf32_littlemips_vxworks_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_vxworks_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_bigmips_vxworks_vec) |
{ "mips*-*-vxworks*", |
&mips_elf32_vxworks_be_vec }, |
&bfd_elf32_bigmips_vxworks_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_trad_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_tradlittlemips_vec) |
{ "mips*el-sde-elf*", |
&mips_elf32_trad_le_vec }, |
&bfd_elf32_tradlittlemips_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_trad_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_tradbigmips_vec) |
{ "mips*-sde-elf*", NULL },{ "mips*-mti-elf*", NULL },{ "mips*-img-elf*", |
&mips_elf32_trad_be_vec }, |
{ "mips*-sde-elf*", NULL },{ "mips*-mti-elf*", |
&bfd_elf32_tradbigmips_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_littlemips_vec) |
{ "mips*el-*-elf*", NULL },{ "mips*el-*-vxworks*", NULL },{ "mips*-*-chorus*", |
&mips_elf32_le_vec }, |
&bfd_elf32_littlemips_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_bigmips_vec) |
{ "mips*-*-elf*", NULL },{ "mips*-*-rtems*", NULL },{ "mips*-*-vxworks", NULL },{ "mips*-*-windiss", |
&mips_elf32_be_vec }, |
&bfd_elf32_bigmips_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_bigmips_vec) |
{ "mips*-*-none", |
&mips_elf32_be_vec }, |
&bfd_elf32_bigmips_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf64_trad_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_tradbigmips_vec) |
{ "mips64*-*-openbsd*", |
&mips_elf64_trad_be_vec }, |
&bfd_elf64_tradbigmips_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_littlemips_vec) |
{ "mips*el-*-openbsd*", |
&mips_elf32_le_vec }, |
&bfd_elf32_littlemips_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_bigmips_vec) |
{ "mips*-*-openbsd*", |
&mips_elf32_be_vec }, |
&bfd_elf32_bigmips_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_ntrad_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_ntradlittlemips_vec) |
{ "mips64*el-*-linux*", |
&mips_elf32_ntrad_le_vec }, |
&bfd_elf32_ntradlittlemips_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_ntrad_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_ntradbigmips_vec) |
{ "mips64*-*-linux*", |
&mips_elf32_ntrad_be_vec }, |
&bfd_elf32_ntradbigmips_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_trad_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_tradlittlemips_vec) |
{ "mips*el-*-linux*", |
&mips_elf32_trad_le_vec }, |
&bfd_elf32_tradlittlemips_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_trad_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_tradbigmips_vec) |
{ "mips*-*-linux*", |
&mips_elf32_trad_be_vec }, |
&bfd_elf32_tradbigmips_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_ntradfbsd_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_ntradlittlemips_freebsd_vec) |
{ "mips64*el-*-freebsd*", NULL },{ "mips64*el-*-kfreebsd*-gnu", |
&mips_elf32_ntradfbsd_le_vec }, |
&bfd_elf32_ntradlittlemips_freebsd_vec }, |
#endif |
1732,10 → 1685,10 |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_ntradfbsd_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_ntradbigmips_freebsd_vec) |
{ "mips64*-*-freebsd*", NULL },{ "mips64*-*-kfreebsd*-gnu", |
&mips_elf32_ntradfbsd_be_vec }, |
&bfd_elf32_ntradbigmips_freebsd_vec }, |
#endif |
1743,10 → 1696,10 |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_tradfbsd_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_tradlittlemips_freebsd_vec) |
{ "mips*el-*-freebsd*", NULL },{ "mips*el-*-kfreebsd*-gnu", |
&mips_elf32_tradfbsd_le_vec }, |
&bfd_elf32_tradlittlemips_freebsd_vec }, |
#endif |
1754,10 → 1707,10 |
#if !defined (SELECT_VECS) || defined (HAVE_mips_elf32_tradfbsd_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_tradbigmips_freebsd_vec) |
{ "mips*-*-freebsd*", NULL },{ "mips*-*-kfreebsd*-gnu", |
&mips_elf32_tradfbsd_be_vec }, |
&bfd_elf32_tradbigmips_freebsd_vec }, |
#endif |
1764,10 → 1717,10 |
#if !defined (SELECT_VECS) || defined (HAVE_mmix_elf64_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_mmix_vec) |
{ "mmix-*-*", |
&mmix_elf64_vec }, |
&bfd_elf64_mmix_vec }, |
#endif |
1774,136 → 1727,109 |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mn10200_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_mn10200_vec) |
{ "mn10200-*-*", |
&mn10200_elf32_vec }, |
&bfd_elf32_mn10200_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mn10300_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_mn10300_vec) |
{ "mn10300-*-*", |
&mn10300_elf32_vec }, |
&bfd_elf32_mn10300_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_mt_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_mt_vec) |
{ "mt-*-elf", |
&mt_elf32_vec }, |
&bfd_elf32_mt_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_msp430_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_msp430_vec) |
{ "msp430-*-*", |
&msp430_elf32_vec }, |
&bfd_elf32_msp430_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_nds32_elf32_linux_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_pc532machaout_vec) |
{ "nds32*le-*-linux*", |
&nds32_elf32_linux_le_vec }, |
{ "ns32k-pc532-mach*", NULL },{ "ns32k-pc532-ux*", |
&pc532machaout_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_pc532netbsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_nds32_elf32_linux_be_vec) |
{ "nds32*be-*-linux*", |
&nds32_elf32_linux_be_vec }, |
{ "ns32k-*-netbsd*", NULL },{ "ns32k-*-lites*", NULL },{ "ns32k-*-openbsd*", |
&pc532netbsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_nds32_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_bignios2_vec) |
{ "nds32*le-*-*", |
&nds32_elf32_le_vec }, |
{ "nios2eb-*-*", |
&bfd_elf32_bignios2_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_nds32_elf32_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_littlenios2_vec) |
{ "nds32*be-*-*", |
&nds32_elf32_be_vec }, |
{ "nios2el-*-*", |
&bfd_elf32_littlenios2_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_ns32k_aout_pc532mach_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_littlenios2_vec) |
{ "ns32k-pc532-mach*", NULL },{ "ns32k-pc532-ux*", |
&ns32k_aout_pc532mach_vec }, |
{ "nios2-*-*", |
&bfd_elf32_littlenios2_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_ns32k_aout_pc532nbsd_vec) |
{ "ns32k-*-netbsd*", NULL },{ "ns32k-*-lites*", NULL },{ "ns32k-*-openbsd*", |
&ns32k_aout_pc532nbsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_openrisc_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_nios2_elf32_be_vec) |
{ "nios2eb-*-*", |
&nios2_elf32_be_vec }, |
{ "openrisc-*-elf", |
&bfd_elf32_openrisc_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_or32coff_big_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_nios2_elf32_le_vec) |
{ "nios2el-*-*", |
&nios2_elf32_le_vec }, |
{ "or32-*-coff", |
&or32coff_big_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_nios2_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_or32_big_vec) |
{ "nios2-*-*", |
&nios2_elf32_le_vec }, |
{ "or32-*-elf", |
&bfd_elf32_or32_big_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_or1k_elf32_vec) |
{ "or1k-*-elf", NULL },{ "or1k-*-linux*", NULL },{ "or1k-*-rtems*", |
&or1k_elf32_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_or1k_elf32_vec) |
{ "or1knd-*-elf", NULL },{ "or1knd-*-linux*", NULL },{ "or1knd-*-rtems*", |
&or1k_elf32_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_pdp11_aout_vec) |
{ "pdp11-*-*", |
1913,28 → 1839,28 |
#if !defined (SELECT_VECS) || defined (HAVE_pj_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_pj_vec) |
{ "pj-*-*", |
&pj_elf32_vec }, |
&bfd_elf32_pj_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_pj_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_pjl_vec) |
{ "pjl-*-*", |
&pj_elf32_le_vec }, |
&bfd_elf32_pjl_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_rs6000_xcoff_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_rs6000coff_vec) |
{ "powerpc-*-aix5.[01]", NULL },{ "rs6000-*-aix5.[01]", |
&rs6000_xcoff_vec }, |
&rs6000coff_vec }, |
#endif |
1941,10 → 1867,10 |
#ifdef BFD64 |
#if !defined (SELECT_VECS) || defined (HAVE_rs6000_xcoff64_aix_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_aix5coff64_vec) |
{ "powerpc64-*-aix5.[01]", NULL },{ "rs6000-*-aix5.[01]", |
&rs6000_xcoff64_aix_vec }, |
&aix5coff64_vec }, |
#endif |
1952,10 → 1878,10 |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_rs6000_xcoff_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_rs6000coff_vec) |
{ "powerpc-*-aix[5-9]*", NULL },{ "rs6000-*-aix[5-9]*", |
&rs6000_xcoff_vec }, |
&rs6000coff_vec }, |
#endif |
1963,10 → 1889,10 |
#ifdef BFD64 |
#if !defined (SELECT_VECS) || defined (HAVE_rs6000_xcoff64_aix_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_aix5coff64_vec) |
{ "powerpc64-*-aix[5-9]*", NULL },{ "rs6000-*-aix[5-9]*", |
&rs6000_xcoff64_aix_vec }, |
&aix5coff64_vec }, |
#endif |
1974,48 → 1900,48 |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_rs6000_xcoff_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_rs6000coff_vec) |
{ "powerpc-*-aix*", NULL },{ "powerpc-*-beos*", NULL },{ "rs6000-*-*", |
&rs6000_xcoff_vec }, |
&rs6000coff_vec }, |
#endif |
#ifdef BFD64 |
#if !defined (SELECT_VECS) || defined (HAVE_rs6000_xcoff64_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_rs6000coff64_vec) |
{ "powerpc64-*-aix*", |
&rs6000_xcoff64_vec }, |
&rs6000coff64_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_powerpc_elf64_fbsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_powerpc_freebsd_vec) |
{ "powerpc64-*-freebsd*", |
&powerpc_elf64_fbsd_vec }, |
&bfd_elf64_powerpc_freebsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_powerpc_elf64_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_powerpc_vec) |
{ "powerpc64-*-elf*", NULL },{ "powerpc-*-elf64*", NULL },{ "powerpc64-*-linux*", NULL }, |
{ "powerpc64-*-*bsd*", |
&powerpc_elf64_vec }, |
&bfd_elf64_powerpc_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_powerpc_elf64_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_powerpcle_vec) |
{ "powerpc64le-*-elf*", NULL },{ "powerpcle-*-elf64*", NULL },{ "powerpc64le-*-linux*", NULL }, |
{ "powerpc64le-*-*bsd*", |
&powerpc_elf64_le_vec }, |
&bfd_elf64_powerpcle_vec }, |
#endif |
2022,30 → 1948,30 |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_powerpc_elf32_fbsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_powerpc_freebsd_vec) |
{ "powerpc-*-*freebsd*", |
&powerpc_elf32_fbsd_vec }, |
&bfd_elf32_powerpc_freebsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_powerpc_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_powerpc_vec) |
{ "powerpc-*-*bsd*", NULL },{ "powerpc-*-elf*", NULL },{ "powerpc-*-sysv4*", NULL },{ "powerpc-*-eabi*", NULL }, |
{ "powerpc-*-solaris2*", NULL },{ "powerpc-*-linux-*", NULL },{ "powerpc-*-rtems*", NULL }, |
{ "powerpc-*-chorus*", |
&powerpc_elf32_vec }, |
&bfd_elf32_powerpc_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_powerpc_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_powerpc_vec) |
{ "powerpc-*-kaos*", |
&powerpc_elf32_vec }, |
&bfd_elf32_powerpc_vec }, |
#endif |
2060,95 → 1986,95 |
#if !defined (SELECT_VECS) || defined (HAVE_powerpc_xcoff_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_pmac_xcoff_vec) |
{ "powerpc-*-macos*", |
&powerpc_xcoff_vec }, |
&pmac_xcoff_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_powerpc_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_powerpc_vec) |
{ "powerpc-*-lynxos*", |
&powerpc_elf32_vec }, |
&bfd_elf32_powerpc_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_powerpc_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_powerpc_vec) |
{ "powerpc-*-netware*", |
&powerpc_elf32_vec }, |
&bfd_elf32_powerpc_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_powerpc_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_powerpc_vec) |
{ "powerpc-*-nto*", |
&powerpc_elf32_vec }, |
&bfd_elf32_powerpc_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_powerpc_elf32_vxworks_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_powerpc_vxworks_vec) |
{ "powerpc-*-vxworks*", NULL },{ "powerpc-*-windiss*", |
&powerpc_elf32_vxworks_vec }, |
&bfd_elf32_powerpc_vxworks_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_powerpc_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_powerpcle_vec) |
{ "powerpcle-*-nto*", |
&powerpc_elf32_le_vec }, |
&bfd_elf32_powerpcle_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_powerpc_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_powerpcle_vec) |
{ "powerpcle-*-elf*", NULL },{ "powerpcle-*-sysv4*", NULL },{ "powerpcle-*-eabi*", NULL }, |
{ "powerpcle-*-solaris2*", NULL },{ "powerpcle-*-linux-*", NULL },{ "powerpcle-*-vxworks*", |
&powerpc_elf32_le_vec }, |
&bfd_elf32_powerpcle_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_powerpc_pe_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_powerpcle_pe_vec) |
{ "powerpcle-*-pe", NULL },{ "powerpcle-*-winnt*", NULL },{ "powerpcle-*-cygwin*", |
&powerpc_pe_le_vec }, |
&bfd_powerpcle_pe_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_rl78_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_rl78_vec) |
{ "rl78-*-elf", |
&rl78_elf32_vec }, |
&bfd_elf32_rl78_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_rx_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_rx_le_vec) |
{ "rx-*-elf", |
&rx_elf32_le_vec }, |
&bfd_elf32_rx_le_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_s390_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_s390_vec) |
{ "s390-*-linux*", |
&s390_elf32_vec }, |
&bfd_elf32_s390_vec }, |
#endif |
2155,37 → 2081,37 |
#ifdef BFD64 |
#if !defined (SELECT_VECS) || defined (HAVE_s390_elf64_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_s390_vec) |
{ "s390x-*-linux*", |
&s390_elf64_vec }, |
&bfd_elf64_s390_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_s390_elf64_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_s390_vec) |
{ "s390x-*-tpf*", |
&s390_elf64_vec }, |
&bfd_elf64_s390_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_score_elf32_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_bigscore_vec) |
{ "score*-*-elf*", |
&score_elf32_be_vec }, |
&bfd_elf32_bigscore_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sh64_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_sh64l_vec) |
{ "sh64l*-*-elf*", |
&sh64_elf32_le_vec }, |
&bfd_elf32_sh64l_vec }, |
#endif |
2192,10 → 2118,10 |
#if !defined (SELECT_VECS) || defined (HAVE_sh64_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_sh64_vec) |
{ "sh64-*-elf*", |
&sh64_elf32_vec }, |
&bfd_elf32_sh64_vec }, |
#endif |
2202,59 → 2128,56 |
#if !defined (SELECT_VECS) || defined (HAVE_sh64_elf32_linux_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_sh64blin_vec) |
{ "sh64eb-*-linux*", |
&sh64_elf32_linux_be_vec }, |
&bfd_elf32_sh64blin_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sh64_elf32_linux_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_sh64lin_vec) |
{ "sh64-*-linux*", |
&sh64_elf32_linux_vec }, |
&bfd_elf32_sh64lin_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sh_elf32_linux_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_shblin_vec) |
{ "sh-*-linux*", |
&sh_elf32_linux_be_vec }, |
&bfd_elf32_shblin_vec }, |
#endif |
#endif /* BFD64 */ |
#if !defined (SELECT_VECS) || defined (HAVE_sh_elf32_linux_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_shblin_vec) |
{ "sh*eb-*-linux*", |
&sh_elf32_linux_be_vec }, |
&bfd_elf32_shblin_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_shlin_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_sh_elf32_linux_vec) |
{ "sh*-*-linux*", |
&sh_elf32_linux_vec }, |
&bfd_elf32_shlin_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_sh_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_sh_elf32_vec) |
{ "sh-*-uclinux*", NULL },{ "sh[12]-*-uclinux*", |
&sh_elf32_vec }, |
&bfd_elf32_sh_vec }, |
#endif |
2264,19 → 2187,19 |
#ifdef BFD64 |
#if !defined (SELECT_VECS) || defined (HAVE_sh64_elf32_nbsd_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_sh64lnbsd_vec) |
{ "sh5le-*-netbsd*", |
&sh64_elf32_nbsd_le_vec }, |
&bfd_elf32_sh64lnbsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sh64_elf32_nbsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_sh64nbsd_vec) |
{ "sh5-*-netbsd*", |
&sh64_elf32_nbsd_vec }, |
&bfd_elf32_sh64nbsd_vec }, |
#endif |
2283,19 → 2206,19 |
#if !defined (SELECT_VECS) || defined (HAVE_sh64_elf64_nbsd_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_sh64lnbsd_vec) |
{ "sh64le-*-netbsd*", |
&sh64_elf64_nbsd_le_vec }, |
&bfd_elf64_sh64lnbsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sh64_elf64_nbsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_sh64nbsd_vec) |
{ "sh64-*-netbsd*", |
&sh64_elf64_nbsd_vec }, |
&bfd_elf64_sh64nbsd_vec }, |
#endif |
2302,19 → 2225,19 |
#if !defined (SELECT_VECS) || defined (HAVE_sh_elf32_nbsd_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_shlnbsd_vec) |
{ "sh*l*-*-netbsdelf*", |
&sh_elf32_nbsd_le_vec }, |
&bfd_elf32_shlnbsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sh_elf32_nbsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_shnbsd_vec) |
{ "sh-*-netbsdelf*", |
&sh_elf32_nbsd_vec }, |
&bfd_elf32_shnbsd_vec }, |
#endif |
2322,18 → 2245,18 |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sh_elf32_nbsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_shnbsd_vec) |
{ "sh*-*-netbsdelf*", |
&sh_elf32_nbsd_vec }, |
&bfd_elf32_shnbsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sh_elf32_symbian_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_shl_symbian_vec) |
{ "sh*-*-symbianelf*", |
&sh_elf32_symbian_le_vec }, |
&bfd_elf32_shl_symbian_vec }, |
#endif |
2341,10 → 2264,10 |
#ifdef BFD64 |
#if !defined (SELECT_VECS) || defined (HAVE_sh_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_shl_vec) |
{ "shl*-*-elf*", NULL },{ "sh[1234]l*-*-elf*", NULL },{ "sh3el*-*-elf*", NULL },{ "shl*-*-kaos*", |
&sh_elf32_le_vec }, |
&bfd_elf32_shl_vec }, |
#endif |
2353,10 → 2276,10 |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sh_coff_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_shcoff_vec) |
{ "sh-*-rtemscoff*", |
&sh_coff_vec }, |
&shcoff_vec }, |
#endif |
2364,10 → 2287,10 |
#ifdef BFD64 |
#if !defined (SELECT_VECS) || defined (HAVE_sh_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_sh_vec) |
{ "sh-*-elf*", NULL },{ "sh[1234]*-elf*", NULL },{ "sh-*-rtems*", NULL },{ "sh-*-kaos*", |
&sh_elf32_vec }, |
&bfd_elf32_sh_vec }, |
#endif |
2376,36 → 2299,36 |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sh_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_sh_vec) |
{ "sh-*-nto*", |
&sh_elf32_vec }, |
&bfd_elf32_sh_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sh_elf32_nbsd_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_shlnbsd_vec) |
{ "sh*-*-openbsd*", |
&sh_elf32_nbsd_le_vec }, |
&bfd_elf32_shlnbsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sh_pe_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_shlpe_vec) |
{ "sh-*-pe", |
&sh_pe_le_vec }, |
&shlpe_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sh_elf32_vxworks_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_shvxworks_vec) |
{ "sh-*-vxworks", |
&sh_elf32_vxworks_vec }, |
&bfd_elf32_shvxworks_vec }, |
#endif |
2415,10 → 2338,10 |
#if !defined (SELECT_VECS) || defined (HAVE_sh_coff_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_shcoff_vec) |
{ "sh-*-*", |
&sh_coff_vec }, |
&shcoff_vec }, |
#endif |
2425,108 → 2348,108 |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_aout_sunos_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_sunos_big_vec) |
{ "sparclet-*-aout*", |
&sparc_aout_sunos_be_vec }, |
&sunos_big_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_aout_sunos_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_sunos_big_vec) |
{ "sparc86x-*-aout*", |
&sparc_aout_sunos_be_vec }, |
&sunos_big_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_sparc_vec) |
{ "sparclite-*-elf*", NULL },{ "sparc86x-*-elf*", |
&sparc_elf32_vec }, |
&bfd_elf32_sparc_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_sparc_vec) |
{ "sparc*-*-chorus*", |
&sparc_elf32_vec }, |
&bfd_elf32_sparc_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_aout_linux_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_sparclinux_vec) |
{ "sparc-*-linux*aout*", |
&sparc_aout_linux_vec }, |
&sparclinux_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_sparc_vec) |
{ "sparc-*-linux-*", NULL },{ "sparcv*-*-linux-*", |
&sparc_elf32_vec }, |
&bfd_elf32_sparc_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_sparc_vec) |
{ "sparc-*-netbsdelf*", |
&sparc_elf32_vec }, |
&bfd_elf32_sparc_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_aout_nbsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_sparcnetbsd_vec) |
{ "sparc-*-netbsdaout*", NULL },{ "sparc-*-netbsd*", |
&sparc_aout_nbsd_vec }, |
&sparcnetbsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_aout_nbsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_sparcnetbsd_vec) |
{ "sparc-*-openbsd[0-2].*", NULL },{ "sparc-*-openbsd3.[0-1]", |
&sparc_aout_nbsd_vec }, |
&sparcnetbsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_sparc_vec) |
{ "sparc-*-openbsd*", |
&sparc_elf32_vec }, |
&bfd_elf32_sparc_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_sparc_vec) |
{ "sparc-*-elf*", |
&sparc_elf32_vec }, |
&bfd_elf32_sparc_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_elf32_sol2_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_sparc_sol2_vec) |
{ "sparc-*-solaris2.[0-6]", NULL },{ "sparc-*-solaris2.[0-6].*", |
&sparc_elf32_sol2_vec }, |
&bfd_elf32_sparc_sol2_vec }, |
#endif |
#ifdef BFD64 |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_elf32_sol2_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_sparc_sol2_vec) |
{ "sparc-*-solaris2*", NULL },{ "sparcv9-*-solaris2*", NULL },{ "sparc64-*-solaris2*", |
&sparc_elf32_sol2_vec }, |
&bfd_elf32_sparc_sol2_vec }, |
#endif |
2533,52 → 2456,52 |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_sparc_vec) |
{ "sparc-*-sysv4*", |
&sparc_elf32_vec }, |
&bfd_elf32_sparc_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_elf32_vxworks_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_sparc_vxworks_vec) |
{ "sparc-*-vxworks*", |
&sparc_elf32_vxworks_vec }, |
&bfd_elf32_sparc_vxworks_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_sparc_vec) |
{ "sparc-*-netware*", |
&sparc_elf32_vec }, |
&bfd_elf32_sparc_vec }, |
#endif |
#ifdef BFD64 |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_aout_sunos_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_sunos_big_vec) |
{ "sparc64-*-aout*", |
&sparc_aout_sunos_be_vec }, |
&sunos_big_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_elf64_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_sparc_vec) |
{ "sparc64*-*-linux-*", |
&sparc_elf64_vec }, |
&bfd_elf64_sparc_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_elf64_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_sparc_vec) |
{ "sparc64-*-elf*", NULL },{ "sparc64-*-rtems*", |
&sparc_elf64_vec }, |
&bfd_elf64_sparc_vec }, |
#endif |
2585,44 → 2508,44 |
#endif /* BFD64 */ |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_coff_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_sparccoff_vec) |
{ "sparc*-*-coff*", |
&sparc_coff_vec }, |
&sparccoff_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_sparc_vec) |
{ "sparc-*-rtems*", |
&sparc_elf32_vec }, |
&bfd_elf32_sparc_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_sparc_aout_sunos_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_sunos_big_vec) |
{ "sparc*-*-*", |
&sparc_aout_sunos_be_vec }, |
&sunos_big_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_spu_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_spu_vec) |
{ "spu-*-elf", |
&spu_elf32_vec }, |
&bfd_elf32_spu_vec }, |
#endif |
#if HAVE_aout_vec |
#if !defined (SELECT_VECS) || defined (HAVE_aout_vec) |
#if HAVE_host_aout_vec |
#if !defined (SELECT_VECS) || defined (HAVE_host_aout_vec) |
{ "tahoe-*-*", |
&aout_vec }, |
&host_aout_vec }, |
#endif |
2629,28 → 2552,28 |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_tic6x_elf32_c6000_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_tic6x_elf_le_vec) |
{ "tic6x-*-elf", |
&tic6x_elf32_c6000_le_vec }, |
&bfd_elf32_tic6x_elf_le_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_tic6x_elf32_linux_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_tic6x_linux_le_vec) |
{ "tic6x-*-uclinux", |
&tic6x_elf32_linux_le_vec }, |
&bfd_elf32_tic6x_linux_le_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_tic80_coff_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_tic80coff_vec) |
{ "tic80*-*-*", |
&tic80_coff_vec }, |
&tic80coff_vec }, |
#endif |
2657,18 → 2580,18 |
#ifdef BFD64 |
#if !defined (SELECT_VECS) || defined (HAVE_tilegx_elf64_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_tilegx_le_vec) |
{ "tilegx-*-*", |
&tilegx_elf64_le_vec }, |
&bfd_elf64_tilegx_le_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_tilegx_elf64_be_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf64_tilegx_be_vec) |
{ "tilegxbe-*-*", |
&tilegx_elf64_be_vec }, |
&bfd_elf64_tilegx_be_vec }, |
#endif |
2675,44 → 2598,36 |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_tilepro_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_tilepro_vec) |
{ "tilepro-*-*", |
&tilepro_elf32_vec }, |
&bfd_elf32_tilepro_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_ft32_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_v850_vec) |
{ "ft32*-*-*", |
&ft32_elf32_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_v850_elf32_vec) |
{ "v850*-*-*", |
&v850_elf32_vec }, |
&bfd_elf32_v850_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_vax_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_vax_vec) |
{ "vax-*-netbsdelf*", |
&vax_elf32_vec }, |
&bfd_elf32_vax_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_vax_aout_nbsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_vaxnetbsd_vec) |
{ "vax-*-netbsdaout*", NULL },{ "vax-*-netbsd*", |
&vax_aout_nbsd_vec }, |
&vaxnetbsd_vec }, |
#endif |
2719,102 → 2634,94 |
#if !defined (SELECT_VECS) || defined (HAVE_vax_aout_bsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_vaxbsd_vec) |
{ "vax-*-bsd*", NULL },{ "vax-*-ultrix*", |
&vax_aout_bsd_vec }, |
&vaxbsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_vax_aout_nbsd_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_vaxnetbsd_vec) |
{ "vax-*-openbsd*", |
&vax_aout_nbsd_vec }, |
&vaxnetbsd_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_vax_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_vax_vec) |
{ "vax-*-linux-*", |
&vax_elf32_vec }, |
&bfd_elf32_vax_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_visium_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_we32kcoff_vec) |
{ "visium-*-elf", |
&visium_elf32_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_we32k_coff_vec) |
{ "we32k-*-*", |
&we32k_coff_vec }, |
&we32kcoff_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_w65_coff_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_w65_vec) |
{ "w65-*-*", |
&w65_coff_vec }, |
&w65_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_xgate_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_xgate_vec) |
{ "xgate-*-*", |
&xgate_elf32_vec }, |
&bfd_elf32_xgate_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_xstormy16_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_xstormy16_vec) |
{ "xstormy16-*-elf", |
&xstormy16_elf32_vec }, |
&bfd_elf32_xstormy16_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_xtensa_elf32_le_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_xtensa_le_vec) |
{ "xtensa*-*-*", |
&xtensa_elf32_le_vec }, |
&bfd_elf32_xtensa_le_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_xc16x_elf32_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_bfd_elf32_xc16x_vec) |
{ "xc16x-*-elf", |
&xc16x_elf32_vec }, |
&bfd_elf32_xc16x_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_z80_coff_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_z80coff_vec) |
{ "z80-*-*", |
&z80_coff_vec }, |
&z80coff_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_z8k_coff_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_z8kcoff_vec) |
{ "z8k*-*-*", |
&z8k_coff_vec }, |
&z8kcoff_vec }, |
#endif |
2828,28 → 2735,28 |
#if !defined (SELECT_VECS) || defined (HAVE_aout_adobe_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_a_out_adobe_vec) |
{ "*-adobe-*", |
&aout_adobe_vec }, |
&a_out_adobe_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m68k_aout_newsos3_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_newsos3_vec) |
{ "*-sony-*", |
&m68k_aout_newsos3_vec }, |
&newsos3_vec }, |
#endif |
#if !defined (SELECT_VECS) || defined (HAVE_m68k_coff_vec) |
#if !defined (SELECT_VECS) || defined (HAVE_m68kcoff_vec) |
{ "*-tandem-*", |
&m68k_coff_vec }, |
&m68kcoff_vec }, |
#endif |
/contrib/toolchain/binutils/bfd/tekhex.c |
---|
1,5 → 1,6 |
/* BFD backend for Extended Tektronix Hex Format objects. |
Copyright (C) 1992-2015 Free Software Foundation, Inc. |
Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, |
2003, 2004, 2005, 2006, 2007, 2009, 2011 Free Software Foundation, Inc. |
Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>. |
This file is part of BFD, the Binary File Descriptor library. |
246,12 → 247,11 |
typedef struct tekhex_data_list_struct tekhex_data_list_type; |
#define CHUNK_MASK 0x1fff |
#define CHUNK_SPAN 32 |
struct data_struct |
{ |
unsigned char chunk_data[CHUNK_MASK + 1]; |
unsigned char chunk_init[(CHUNK_MASK + 1 + CHUNK_SPAN - 1) / CHUNK_SPAN]; |
char chunk_data[CHUNK_MASK + 1]; |
char chunk_init[CHUNK_MASK + 1]; |
bfd_vma vma; |
struct data_struct *next; |
}; |
267,7 → 267,7 |
#define enda(x) (x->vma + x->size) |
static bfd_boolean |
getvalue (char **srcp, bfd_vma *valuep, char * endp) |
getvalue (char **srcp, bfd_vma *valuep) |
{ |
char *src = *srcp; |
bfd_vma value = 0; |
279,7 → 279,7 |
len = hex_value (*src++); |
if (len == 0) |
len = 16; |
while (len-- && src < endp) |
while (len--) |
{ |
if (!ISHEX (*src)) |
return FALSE; |
288,11 → 288,11 |
*srcp = src; |
*valuep = value; |
return len == -1U; |
return TRUE; |
} |
static bfd_boolean |
getsym (char *dstp, char **srcp, unsigned int *lenp, char * endp) |
getsym (char *dstp, char **srcp, unsigned int *lenp) |
{ |
char *src = *srcp; |
unsigned int i; |
304,16 → 304,16 |
len = hex_value (*src++); |
if (len == 0) |
len = 16; |
for (i = 0; i < len && src < endp; i++) |
for (i = 0; i < len; i++) |
dstp[i] = src[i]; |
dstp[i] = 0; |
*srcp = src + i; |
*lenp = len; |
return i == len; |
return TRUE; |
} |
static struct data_struct * |
find_chunk (bfd *abfd, bfd_vma vma, bfd_boolean create) |
find_chunk (bfd *abfd, bfd_vma vma) |
{ |
struct data_struct *d = abfd->tdata.tekhex_data->data; |
321,7 → 321,7 |
while (d && (d->vma) != vma) |
d = d->next; |
if (!d && create) |
if (!d) |
{ |
/* No chunk for this address, so make one up. */ |
d = (struct data_struct *) |
340,23 → 340,20 |
static void |
insert_byte (bfd *abfd, int value, bfd_vma addr) |
{ |
if (value != 0) |
{ |
/* Find the chunk that this byte needs and put it in. */ |
struct data_struct *d = find_chunk (abfd, addr, TRUE); |
struct data_struct *d = find_chunk (abfd, addr); |
d->chunk_data[addr & CHUNK_MASK] = value; |
d->chunk_init[(addr & CHUNK_MASK) / CHUNK_SPAN] = 1; |
d->chunk_init[addr & CHUNK_MASK] = 1; |
} |
} |
/* The first pass is to find the names of all the sections, and see |
how big the data is. */ |
static bfd_boolean |
first_phase (bfd *abfd, int type, char *src, char * src_end) |
first_phase (bfd *abfd, int type, char *src) |
{ |
asection *section, *alt_section; |
asection *section = bfd_abs_section_ptr; |
unsigned int len; |
bfd_vma val; |
char sym[17]; /* A symbol can only be 16chars long. */ |
368,21 → 365,21 |
{ |
bfd_vma addr; |
if (!getvalue (&src, &addr, src_end)) |
if (!getvalue (&src, &addr)) |
return FALSE; |
while (*src && src < src_end - 1) |
while (*src) |
{ |
insert_byte (abfd, HEX (src), addr); |
src += 2; |
addr++; |
} |
return TRUE; |
} |
return TRUE; |
case '3': |
/* Symbol record, read the segment. */ |
if (!getsym (sym, &src, &len, src_end)) |
if (!getsym (sym, &src, &len)) |
return FALSE; |
section = bfd_get_section_by_name (abfd, sym); |
if (section == NULL) |
396,24 → 393,17 |
if (section == NULL) |
return FALSE; |
} |
alt_section = NULL; |
while (src < src_end && *src) |
while (*src) |
{ |
switch (*src) |
{ |
case '1': /* Section range. */ |
src++; |
if (!getvalue (&src, §ion->vma, src_end)) |
if (!getvalue (&src, §ion->vma)) |
return FALSE; |
if (!getvalue (&src, &val, src_end)) |
if (!getvalue (&src, &val)) |
return FALSE; |
if (val < section->vma) |
val = section->vma; |
section->size = val - section->vma; |
/* PR 17512: file: objdump-s-endless-loop.tekhex. |
Check for overlarge section sizes. */ |
if (section->size & 0x80000000) |
return FALSE; |
section->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC; |
break; |
case '0': |
438,7 → 428,7 |
abfd->flags |= HAS_SYMS; |
new_symbol->prev = abfd->tdata.tekhex_data->symbols; |
abfd->tdata.tekhex_data->symbols = new_symbol; |
if (!getsym (sym, &src, &len, src_end)) |
if (!getsym (sym, &src, &len)) |
return FALSE; |
new_symbol->symbol.name = (const char *) |
bfd_alloc (abfd, (bfd_size_type) len + 1); |
450,46 → 440,8 |
new_symbol->symbol.flags = (BSF_GLOBAL | BSF_EXPORT); |
else |
new_symbol->symbol.flags = BSF_LOCAL; |
if (stype == '2' || stype == '6') |
new_symbol->symbol.section = bfd_abs_section_ptr; |
else if (stype == '3' || stype == '7') |
{ |
if ((section->flags & SEC_DATA) == 0) |
section->flags |= SEC_CODE; |
else |
{ |
if (alt_section == NULL) |
alt_section |
= bfd_get_next_section_by_name (NULL, section); |
if (alt_section == NULL) |
alt_section = bfd_make_section_anyway_with_flags |
(abfd, section->name, |
(section->flags & ~SEC_DATA) | SEC_CODE); |
if (alt_section == NULL) |
if (!getvalue (&src, &val)) |
return FALSE; |
new_symbol->symbol.section = alt_section; |
} |
} |
else if (stype == '4' || stype == '8') |
{ |
if ((section->flags & SEC_CODE) == 0) |
section->flags |= SEC_DATA; |
else |
{ |
if (alt_section == NULL) |
alt_section |
= bfd_get_next_section_by_name (NULL, section); |
if (alt_section == NULL) |
alt_section = bfd_make_section_anyway_with_flags |
(abfd, section->name, |
(section->flags & ~SEC_CODE) | SEC_DATA); |
if (alt_section == NULL) |
return FALSE; |
new_symbol->symbol.section = alt_section; |
} |
} |
if (!getvalue (&src, &val, src_end)) |
return FALSE; |
new_symbol->symbol.value = val - section->vma; |
break; |
} |
506,7 → 458,7 |
record. */ |
static bfd_boolean |
pass_over (bfd *abfd, bfd_boolean (*func) (bfd *, int, char *, char *)) |
pass_over (bfd *abfd, bfd_boolean (*func) (bfd *, int, char *)) |
{ |
unsigned int chars_on_line; |
bfd_boolean is_eof = FALSE; |
547,7 → 499,8 |
/* Put a null at the end. */ |
src[chars_on_line] = 0; |
if (!func (abfd, type, src, src + chars_on_line)) |
if (!func (abfd, type, src)) |
return FALSE; |
} |
637,26 → 590,22 |
/* Get high bits of address. */ |
bfd_vma chunk_number = addr & ~(bfd_vma) CHUNK_MASK; |
bfd_vma low_bits = addr & CHUNK_MASK; |
bfd_boolean must_write = !get && *location != 0; |
if (chunk_number != prev_number || (!d && must_write)) |
{ |
if (chunk_number != prev_number) |
/* Different chunk, so move pointer. */ |
d = find_chunk (abfd, chunk_number, must_write); |
prev_number = chunk_number; |
} |
d = find_chunk (abfd, chunk_number); |
if (get) |
{ |
if (d) |
if (d->chunk_init[low_bits]) |
*location = d->chunk_data[low_bits]; |
else |
*location = 0; |
} |
else if (must_write) |
else |
{ |
d->chunk_data[low_bits] = *location; |
d->chunk_init[low_bits / CHUNK_SPAN] = 1; |
d->chunk_init[low_bits] = (*location != 0); |
} |
location++; |
684,9 → 633,7 |
enum bfd_architecture arch, |
unsigned long machine) |
{ |
/* Ignore errors about unknown architecture. */ |
return (bfd_default_set_arch_mach (abfd, arch, machine) |
|| arch == bfd_arch_unknown); |
return bfd_default_set_arch_mach (abfd, arch, machine); |
} |
/* We have to save up all the Tekhexords for a splurge before output. */ |
698,6 → 645,24 |
file_ptr offset, |
bfd_size_type bytes_to_do) |
{ |
if (! abfd->output_has_begun) |
{ |
/* The first time around, allocate enough sections to hold all the chunks. */ |
asection *s = abfd->sections; |
bfd_vma vma; |
for (s = abfd->sections; s; s = s->next) |
{ |
if (s->flags & SEC_LOAD) |
{ |
for (vma = s->vma & ~(bfd_vma) CHUNK_MASK; |
vma < s->vma + s->size; |
vma += CHUNK_MASK) |
find_chunk (abfd, vma); |
} |
} |
} |
if (section->flags & (SEC_LOAD | SEC_ALLOC)) |
{ |
move_section_contents (abfd, section, locationp, offset, bytes_to_do, |
808,17 → 773,26 |
d = d->next) |
{ |
int low; |
const int span = 32; |
int addr; |
/* Write it in blocks of 32 bytes. */ |
for (addr = 0; addr < CHUNK_MASK + 1; addr += CHUNK_SPAN) |
for (addr = 0; addr < CHUNK_MASK + 1; addr += span) |
{ |
if (d->chunk_init[addr / CHUNK_SPAN]) |
int need = 0; |
/* Check to see if necessary. */ |
for (low = 0; !need && low < span; low++) |
if (d->chunk_init[addr + low]) |
need = 1; |
if (need) |
{ |
char *dst = buffer; |
writevalue (&dst, addr + d->vma); |
for (low = 0; low < CHUNK_SPAN; low++) |
for (low = 0; low < span; low++) |
{ |
TOHEX (dst, d->chunk_data[addr + low]); |
dst += 2; |
962,9 → 936,7 |
#define tekhex_bfd_is_local_label_name bfd_generic_is_local_label_name |
#define tekhex_get_lineno _bfd_nosymbols_get_lineno |
#define tekhex_find_nearest_line _bfd_nosymbols_find_nearest_line |
#define tekhex_find_line _bfd_nosymbols_find_line |
#define tekhex_find_inliner_info _bfd_nosymbols_find_inliner_info |
#define tekhex_get_symbol_version_string _bfd_nosymbols_get_symbol_version_string |
#define tekhex_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol |
#define tekhex_read_minisymbols _bfd_generic_read_minisymbols |
#define tekhex_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol |
978,6 → 950,7 |
#define tekhex_section_already_linked _bfd_generic_section_already_linked |
#define tekhex_bfd_define_common_symbol bfd_generic_define_common_symbol |
#define tekhex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create |
#define tekhex_bfd_link_hash_table_free _bfd_generic_link_hash_table_free |
#define tekhex_bfd_link_add_symbols _bfd_generic_link_add_symbols |
#define tekhex_bfd_link_just_syms _bfd_generic_link_just_syms |
#define tekhex_bfd_copy_link_hash_symbol_type \ |
/contrib/toolchain/binutils/bfd/verilog.c |
---|
1,5 → 1,6 |
/* BFD back-end for verilog hex memory dump files. |
Copyright (C) 2009-2015 Free Software Foundation, Inc. |
Copyright 2009, 2010, 2011 |
Free Software Foundation, Inc. |
Written by Anthony Green <green@moxielogic.com> |
This file is part of BFD, the Binary File Descriptor library. |
191,7 → 192,7 |
const bfd_byte *data, |
const bfd_byte *end) |
{ |
char buffer[50]; |
char buffer[48]; |
const bfd_byte *src = data; |
char *dst = buffer; |
bfd_size_type wrlen; |
311,6 → 312,7 |
#define verilog_bfd_discard_group bfd_generic_discard_group |
#define verilog_section_already_linked _bfd_generic_section_already_linked |
#define verilog_bfd_link_hash_table_create _bfd_generic_link_hash_table_create |
#define verilog_bfd_link_hash_table_free _bfd_generic_link_hash_table_free |
#define verilog_bfd_link_add_symbols _bfd_generic_link_add_symbols |
#define verilog_bfd_link_just_syms _bfd_generic_link_just_syms |
#define verilog_bfd_final_link _bfd_generic_final_link |