|
|
381f6c |
diff -rup binutils-2.26.orig/bfd/bfd.c binutils-2.26/bfd/bfd.c
|
|
|
381f6c |
--- binutils-2.26.orig/bfd/bfd.c 2016-02-19 09:35:36.231000625 +0000
|
|
|
381f6c |
+++ binutils-2.26/bfd/bfd.c 2016-02-19 09:35:54.901106498 +0000
|
|
|
381f6c |
@@ -57,6 +57,14 @@ CODE_FRAGMENT
|
|
|
381f6c |
. bfd_byte data[1];
|
|
|
381f6c |
. };
|
|
|
381f6c |
.
|
|
|
381f6c |
+.enum bfd_lto_object_type
|
|
|
381f6c |
+. {
|
|
|
381f6c |
+. lto_non_object,
|
|
|
381f6c |
+. lto_non_ir_object,
|
|
|
381f6c |
+. lto_ir_object,
|
|
|
381f6c |
+. lto_mixed_object
|
|
|
381f6c |
+. };
|
|
|
381f6c |
+.
|
|
|
381f6c |
.struct bfd
|
|
|
381f6c |
.{
|
|
|
381f6c |
. {* The filename the application opened the BFD with. *}
|
|
|
381f6c |
@@ -227,6 +235,9 @@ CODE_FRAGMENT
|
|
|
381f6c |
. {* Set if this is a plugin output file. *}
|
|
|
381f6c |
. unsigned int lto_output : 1;
|
|
|
381f6c |
.
|
|
|
381f6c |
+. {* LTO object type. *}
|
|
|
381f6c |
+. ENUM_BITFIELD (bfd_lto_object_type) lto_type : 2;
|
|
|
381f6c |
+.
|
|
|
381f6c |
. {* Set to dummy BFD created when claimed by a compiler plug-in
|
|
|
381f6c |
. library. *}
|
|
|
381f6c |
. bfd *plugin_dummy_bfd;
|
|
|
381f6c |
@@ -252,6 +263,9 @@ CODE_FRAGMENT
|
|
|
381f6c |
. {* The last section on the section list. *}
|
|
|
381f6c |
. struct bfd_section *section_last;
|
|
|
381f6c |
.
|
|
|
381f6c |
+. {* The object-only section on the section list. *}
|
|
|
381f6c |
+. struct bfd_section *object_only_section;
|
|
|
381f6c |
+.
|
|
|
381f6c |
. {* The number of sections. *}
|
|
|
381f6c |
. unsigned int section_count;
|
|
|
381f6c |
.
|
|
|
381f6c |
@@ -2270,3 +2284,36 @@ bfd_convert_section_contents (bfd *ibfd,
|
|
|
381f6c |
*ptr_size = size;
|
|
|
381f6c |
return TRUE;
|
|
|
381f6c |
}
|
|
|
381f6c |
+
|
|
|
381f6c |
+/*
|
|
|
381f6c |
+FUNCTION
|
|
|
381f6c |
+ bfd_group_signature
|
|
|
381f6c |
+
|
|
|
381f6c |
+SYNOPSIS
|
|
|
381f6c |
+ asymbol *bfd_group_signature (asection *group, asymbol **isympp);
|
|
|
381f6c |
+
|
|
|
381f6c |
+DESCRIPTION
|
|
|
381f6c |
+ Return a pointer to the symbol used as a signature for GROUP.
|
|
|
381f6c |
+*/
|
|
|
381f6c |
+
|
|
|
381f6c |
+asymbol *
|
|
|
381f6c |
+bfd_group_signature (asection *group, asymbol **isympp)
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ bfd *abfd = group->owner;
|
|
|
381f6c |
+ Elf_Internal_Shdr *ghdr;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
|
|
|
381f6c |
+ return NULL;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ ghdr = &elf_section_data (group)->this_hdr;
|
|
|
381f6c |
+ if (ghdr->sh_link < elf_numsections (abfd))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ const struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
|
|
381f6c |
+ Elf_Internal_Shdr *symhdr = elf_elfsections (abfd) [ghdr->sh_link];
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (symhdr->sh_type == SHT_SYMTAB
|
|
|
381f6c |
+ && ghdr->sh_info < symhdr->sh_size / bed->s->sizeof_sym)
|
|
|
381f6c |
+ return isympp[ghdr->sh_info - 1];
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ return NULL;
|
|
|
381f6c |
+}
|
|
|
381f6c |
diff -rup binutils-2.26.orig/bfd/bfd-in2.h binutils-2.26/bfd/bfd-in2.h
|
|
|
381f6c |
--- binutils-2.26.orig/bfd/bfd-in2.h 2016-02-19 09:35:36.280000903 +0000
|
|
|
381f6c |
+++ binutils-2.26/bfd/bfd-in2.h 2016-02-19 09:35:54.900106492 +0000
|
|
|
381f6c |
@@ -1654,6 +1657,9 @@ extern asection _bfd_std_section[4];
|
|
|
381f6c |
#define BFD_COM_SECTION_NAME "*COM*"
|
|
|
381f6c |
#define BFD_IND_SECTION_NAME "*IND*"
|
|
|
381f6c |
|
|
|
381f6c |
+/* GNU object-only section name. */
|
|
|
381f6c |
+#define GNU_OBJECT_ONLY_SECTION_NAME ".gnu_object_only"
|
|
|
381f6c |
+
|
|
|
381f6c |
/* Pointer to the common section. */
|
|
|
381f6c |
#define bfd_com_section_ptr (&_bfd_std_section[0])
|
|
|
381f6c |
/* Pointer to the undefined section. */
|
|
|
381f6c |
@@ -6511,6 +6517,14 @@ struct bfd_build_id
|
|
|
381f6c |
bfd_byte data[1];
|
|
|
381f6c |
};
|
|
|
381f6c |
|
|
|
381f6c |
+enum bfd_lto_object_type
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ lto_non_object,
|
|
|
381f6c |
+ lto_non_ir_object,
|
|
|
381f6c |
+ lto_ir_object,
|
|
|
381f6c |
+ lto_mixed_object
|
|
|
381f6c |
+ };
|
|
|
381f6c |
+
|
|
|
381f6c |
struct bfd
|
|
|
381f6c |
{
|
|
|
381f6c |
/* The filename the application opened the BFD with. */
|
|
|
381f6c |
@@ -6681,6 +6695,9 @@ struct bfd
|
|
|
381f6c |
/* Set if this is a plugin output file. */
|
|
|
381f6c |
unsigned int lto_output : 1;
|
|
|
381f6c |
|
|
|
381f6c |
+ /* LTO object type. */
|
|
|
381f6c |
+ ENUM_BITFIELD (bfd_lto_object_type) lto_type : 2;
|
|
|
381f6c |
+
|
|
|
381f6c |
/* Set to dummy BFD created when claimed by a compiler plug-in
|
|
|
381f6c |
library. */
|
|
|
381f6c |
bfd *plugin_dummy_bfd;
|
|
|
381f6c |
@@ -6706,6 +6723,9 @@ struct bfd
|
|
|
381f6c |
/* The last section on the section list. */
|
|
|
381f6c |
struct bfd_section *section_last;
|
|
|
381f6c |
|
|
|
381f6c |
+ /* The object-only section on the section list. */
|
|
|
381f6c |
+ struct bfd_section *object_only_section;
|
|
|
381f6c |
+
|
|
|
381f6c |
/* The number of sections. */
|
|
|
381f6c |
unsigned int section_count;
|
|
|
381f6c |
|
|
|
381f6c |
@@ -7026,6 +7046,8 @@ bfd_boolean bfd_convert_section_contents
|
|
|
381f6c |
(bfd *ibfd, asection *isec, bfd *obfd,
|
|
|
381f6c |
bfd_byte **ptr, bfd_size_type *ptr_size);
|
|
|
381f6c |
|
|
|
381f6c |
+asymbol *bfd_group_signature (asection *group, asymbol **isympp);
|
|
|
381f6c |
+
|
|
|
381f6c |
/* Extracted from archive.c. */
|
|
|
381f6c |
symindex bfd_get_next_mapent
|
|
|
381f6c |
(bfd *abfd, symindex previous, carsym **sym);
|
|
|
381f6c |
diff -rup binutils-2.26.orig/bfd/elf.c binutils-2.26/bfd/elf.c
|
|
|
381f6c |
--- binutils-2.26.orig/bfd/elf.c 2016-02-19 09:35:36.280000903 +0000
|
|
|
381f6c |
+++ binutils-2.26/bfd/elf.c 2016-02-19 09:35:54.904106515 +0000
|
|
|
381f6c |
@@ -2387,6 +2387,7 @@ static const struct bfd_elf_special_sect
|
|
|
381f6c |
{ STRING_COMMA_LEN (".gnu.linkonce.b"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE },
|
|
|
381f6c |
{ STRING_COMMA_LEN (".gnu.lto_"), -1, SHT_PROGBITS, SHF_EXCLUDE },
|
|
|
381f6c |
{ STRING_COMMA_LEN (".got"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
|
|
|
381f6c |
+ { STRING_COMMA_LEN (".gnu_object_only"), 0, SHT_GNU_OBJECT_ONLY, SHF_EXCLUDE },
|
|
|
381f6c |
{ STRING_COMMA_LEN (".gnu.version"), 0, SHT_GNU_versym, 0 },
|
|
|
381f6c |
{ STRING_COMMA_LEN (".gnu.version_d"), 0, SHT_GNU_verdef, 0 },
|
|
|
381f6c |
{ STRING_COMMA_LEN (".gnu.version_r"), 0, SHT_GNU_verneed, 0 },
|
|
|
381f6c |
diff -rup binutils-2.26.orig/bfd/format.c binutils-2.26/bfd/format.c
|
|
|
381f6c |
--- binutils-2.26.orig/bfd/format.c 2016-02-19 09:35:36.265000818 +0000
|
|
|
381f6c |
+++ binutils-2.26/bfd/format.c 2016-02-19 09:36:21.420256880 +0000
|
|
|
381f6c |
@@ -46,6 +46,9 @@ SUBSECTION
|
|
|
381f6c |
#include "sysdep.h"
|
|
|
381f6c |
#include "bfd.h"
|
|
|
381f6c |
#include "libbfd.h"
|
|
|
381f6c |
+#if BFD_SUPPORTS_PLUGINS
|
|
|
381f6c |
+#include "plugin.h"
|
|
|
381f6c |
+#endif
|
|
|
381f6c |
|
|
|
381f6c |
/* IMPORT from targets.c. */
|
|
|
381f6c |
extern const size_t _bfd_target_vector_entries;
|
|
|
381f6c |
@@ -179,6 +182,33 @@ bfd_preserve_finish (bfd *abfd ATTRIBUTE
|
|
|
381f6c |
preserve->marker = NULL;
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
+/* Set lto_type in ABFD. */
|
|
|
381f6c |
+
|
|
|
381f6c |
+static void
|
|
|
381f6c |
+bfd_set_lto_type (bfd *abfd)
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ if (abfd->format == bfd_object
|
|
|
381f6c |
+ && abfd->lto_type == lto_non_object
|
|
|
381f6c |
+ && (abfd->flags & (DYNAMIC | EXEC_P)) == 0)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ asection *sec;
|
|
|
381f6c |
+ enum bfd_lto_object_type type = lto_non_ir_object;
|
|
|
381f6c |
+ for (sec = abfd->sections; sec != NULL; sec = sec->next)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ if (strcmp (sec->name, GNU_OBJECT_ONLY_SECTION_NAME) == 0)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ type = lto_mixed_object;
|
|
|
381f6c |
+ abfd->object_only_section = sec;
|
|
|
381f6c |
+ break;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ else if (type != lto_ir_object
|
|
|
381f6c |
+ && strncmp (sec->name, ".gnu.lto_", 9) == 0)
|
|
|
381f6c |
+ type = lto_ir_object;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ abfd->lto_type = type;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+}
|
|
|
381f6c |
+
|
|
|
381f6c |
/*
|
|
|
381f6c |
FUNCTION
|
|
|
381f6c |
bfd_check_format_matches
|
|
|
381f6c |
@@ -221,7 +251,10 @@ bfd_check_format_matches (bfd *abfd, bfd
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
if (abfd->format != bfd_unknown)
|
|
|
381f6c |
- return abfd->format == format;
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ bfd_set_lto_type (abfd);
|
|
|
381f6c |
+ return abfd->format == format;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
|
|
|
381f6c |
if (matching != NULL || *bfd_associated_vector != NULL)
|
|
|
381f6c |
{
|
|
|
381f6c |
@@ -285,6 +318,13 @@ bfd_check_format_matches (bfd *abfd, bfd
|
|
|
381f6c |
|| (*target)->match_priority > best_match)
|
|
|
381f6c |
continue;
|
|
|
381f6c |
|
|
|
381f6c |
+#if BFD_SUPPORTS_PLUGINS
|
|
|
381f6c |
+ /* If the plugin target is explicitly specified when a BFD file
|
|
|
381f6c |
+ is opened, don't check it twice. */
|
|
|
381f6c |
+ if (bfd_plugin_specified_p () && bfd_plugin_target_p (*target))
|
|
|
381f6c |
+ continue;
|
|
|
381f6c |
+#endif
|
|
|
381f6c |
+
|
|
|
381f6c |
/* If we already tried a match, the bfd is modified and may
|
|
|
381f6c |
have sections attached, which will confuse the next
|
|
|
381f6c |
_bfd_check_format call. */
|
|
|
381f6c |
@@ -449,6 +489,8 @@ bfd_check_format_matches (bfd *abfd, bfd
|
|
|
381f6c |
if (matching_vector)
|
|
|
381f6c |
free (matching_vector);
|
|
|
381f6c |
|
|
|
381f6c |
+ bfd_set_lto_type (abfd);
|
|
|
381f6c |
+
|
|
|
381f6c |
/* File position has moved, BTW. */
|
|
|
381f6c |
return TRUE;
|
|
|
381f6c |
}
|
|
|
381f6c |
diff -rup binutils-2.26.orig/bfd/plugin.c binutils-2.26/bfd/plugin.c
|
|
|
381f6c |
--- binutils-2.26.orig/bfd/plugin.c 2016-02-19 09:35:36.271000852 +0000
|
|
|
381f6c |
+++ binutils-2.26/bfd/plugin.c 2016-02-19 09:35:54.905106520 +0000
|
|
|
381f6c |
@@ -130,6 +130,146 @@ register_claim_file (ld_plugin_claim_fil
|
|
|
381f6c |
return LDPS_OK;
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
+static asection bfd_plugin_fake_text_section
|
|
|
381f6c |
+ = BFD_FAKE_SECTION (bfd_plugin_fake_text_section, 0, 0, ".text", 0);
|
|
|
381f6c |
+static asection bfd_plugin_fake_common_section
|
|
|
381f6c |
+ = BFD_FAKE_SECTION (bfd_plugin_fake_common_section, SEC_IS_COMMON, 0,
|
|
|
381f6c |
+ NULL, 0);
|
|
|
381f6c |
+
|
|
|
381f6c |
+/* Get symbols from object only section. */
|
|
|
381f6c |
+
|
|
|
381f6c |
+static void
|
|
|
381f6c |
+bfd_plugin_get_symbols_in_object_only (bfd *abfd)
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data;
|
|
|
381f6c |
+ const char *object_only_file;
|
|
|
381f6c |
+ bfd *nbfd;
|
|
|
381f6c |
+ long storage;
|
|
|
381f6c |
+ long object_only_nsyms, added_nsyms, i;
|
|
|
381f6c |
+ asymbol **object_only_syms, **added_syms;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ plugin_data->object_only_syms = NULL;
|
|
|
381f6c |
+ plugin_data->object_only_nsyms = 0;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (abfd->sections == NULL && abfd->my_archive == NULL)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ nbfd = bfd_openr (abfd->filename, NULL);
|
|
|
381f6c |
+ if (nbfd == NULL)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ (*_bfd_error_handler)
|
|
|
381f6c |
+ (_("%s: failed to open to extract object only section: %s"),
|
|
|
381f6c |
+ abfd->filename, bfd_errmsg (bfd_get_error ()));
|
|
|
381f6c |
+ goto error_return;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ else if (!bfd_check_format (nbfd, bfd_object))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ /* There is no object only section if it isn't a bfd_object
|
|
|
381f6c |
+ file. */
|
|
|
381f6c |
+error_return:
|
|
|
381f6c |
+ bfd_close (nbfd);
|
|
|
381f6c |
+ return;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ else
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ if (!bfd_check_format (abfd, bfd_object))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ (*_bfd_error_handler)
|
|
|
381f6c |
+ (_("%B: invalid file to extract object only section: %s"),
|
|
|
381f6c |
+ abfd, bfd_errmsg (bfd_get_error ()));
|
|
|
381f6c |
+ return;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ nbfd = abfd;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (nbfd->lto_type == lto_mixed_object
|
|
|
381f6c |
+ && (nbfd->flags & HAS_SYMS) != 0)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ object_only_file = bfd_extract_object_only_section (nbfd);
|
|
|
381f6c |
+ if (object_only_file == NULL)
|
|
|
381f6c |
+ (*_bfd_error_handler)
|
|
|
381f6c |
+ (_("%B: failed to extract object only section: %s"),
|
|
|
381f6c |
+ abfd, bfd_errmsg (bfd_get_error ()));
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ else
|
|
|
381f6c |
+ object_only_file = NULL;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Close the new bfd we just opened. */
|
|
|
381f6c |
+ if (nbfd != abfd)
|
|
|
381f6c |
+ bfd_close (nbfd);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Return if there is no object only section or there is no
|
|
|
381f6c |
+ symbol in object only section. */
|
|
|
381f6c |
+ if (!object_only_file)
|
|
|
381f6c |
+ return;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Open the file containing object only section. */
|
|
|
381f6c |
+ nbfd = bfd_openr (object_only_file, NULL);
|
|
|
381f6c |
+ if (!bfd_check_format (nbfd, bfd_object))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ (*_bfd_error_handler)
|
|
|
381f6c |
+ (_("%B: failed to open object only section: %s"),
|
|
|
381f6c |
+ abfd, bfd_errmsg (bfd_get_error ()));
|
|
|
381f6c |
+ goto quit;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ storage = bfd_get_symtab_upper_bound (nbfd);
|
|
|
381f6c |
+ if (storage <= 0)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ if (storage < 0)
|
|
|
381f6c |
+ (*_bfd_error_handler)
|
|
|
381f6c |
+ (_("%B: failed to get symbol table in object only section: %s"),
|
|
|
381f6c |
+ abfd, bfd_errmsg (bfd_get_error ()));
|
|
|
381f6c |
+
|
|
|
381f6c |
+ goto quit;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ object_only_syms = (asymbol **) bfd_malloc (storage);
|
|
|
381f6c |
+ object_only_nsyms = bfd_canonicalize_symtab (nbfd, object_only_syms);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* FIXME: We waste some spaces if not all symbols are copied. */
|
|
|
381f6c |
+ added_syms = (asymbol **) bfd_alloc (abfd, storage);
|
|
|
381f6c |
+ added_nsyms = 0;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Copy only global symbols from object only section. */
|
|
|
381f6c |
+ for (i = 0; i < object_only_nsyms; i++)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ asection *sec = object_only_syms[i]->section;
|
|
|
381f6c |
+ flagword flags = object_only_syms[i]->flags;
|
|
|
381f6c |
+ asymbol *s;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (bfd_is_com_section (sec))
|
|
|
381f6c |
+ sec = &bfd_plugin_fake_common_section;
|
|
|
381f6c |
+ else if (bfd_is_und_section (sec))
|
|
|
381f6c |
+ ;
|
|
|
381f6c |
+ else if ((flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0)
|
|
|
381f6c |
+ sec = &bfd_plugin_fake_text_section;
|
|
|
381f6c |
+ else
|
|
|
381f6c |
+ continue;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ s = bfd_alloc (abfd, sizeof (asymbol));
|
|
|
381f6c |
+ BFD_ASSERT (s);
|
|
|
381f6c |
+ added_syms[added_nsyms++] = s;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ s->section = sec;
|
|
|
381f6c |
+ s->the_bfd = abfd;
|
|
|
381f6c |
+ s->name = xstrdup (object_only_syms[i]->name);
|
|
|
381f6c |
+ s->value = 0;
|
|
|
381f6c |
+ s->flags = flags;
|
|
|
381f6c |
+ s->udata.p = NULL;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ plugin_data->object_only_syms = added_syms;
|
|
|
381f6c |
+ plugin_data->object_only_nsyms = added_nsyms;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ free (object_only_syms);
|
|
|
381f6c |
+
|
|
|
381f6c |
+quit:
|
|
|
381f6c |
+ /* Close and remove the object only section file. */
|
|
|
381f6c |
+ bfd_close (nbfd);
|
|
|
381f6c |
+ unlink (object_only_file);
|
|
|
381f6c |
+}
|
|
|
381f6c |
+
|
|
|
381f6c |
static enum ld_plugin_status
|
|
|
381f6c |
add_symbols (void * handle,
|
|
|
381f6c |
int nsyms,
|
|
|
381f6c |
@@ -142,10 +282,13 @@ add_symbols (void * handle,
|
|
|
381f6c |
plugin_data->nsyms = nsyms;
|
|
|
381f6c |
plugin_data->syms = syms;
|
|
|
381f6c |
|
|
|
381f6c |
- if (nsyms != 0)
|
|
|
381f6c |
+ abfd->tdata.plugin_data = plugin_data;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ bfd_plugin_get_symbols_in_object_only (abfd);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if ((nsyms + plugin_data->object_only_nsyms) != 0)
|
|
|
381f6c |
abfd->flags |= HAS_SYMS;
|
|
|
381f6c |
|
|
|
381f6c |
- abfd->tdata.plugin_data = plugin_data;
|
|
|
381f6c |
return LDPS_OK;
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
@@ -440,7 +583,8 @@ static long
|
|
|
381f6c |
bfd_plugin_get_symtab_upper_bound (bfd *abfd)
|
|
|
381f6c |
{
|
|
|
381f6c |
struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data;
|
|
|
381f6c |
- long nsyms = plugin_data->nsyms;
|
|
|
381f6c |
+ /* Add symbols from object only section. */
|
|
|
381f6c |
+ long nsyms = plugin_data->nsyms + plugin_data->object_only_nsyms;
|
|
|
381f6c |
|
|
|
381f6c |
BFD_ASSERT (nsyms >= 0);
|
|
|
381f6c |
|
|
|
381f6c |
@@ -474,12 +618,7 @@ bfd_plugin_canonicalize_symtab (bfd *abf
|
|
|
381f6c |
struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data;
|
|
|
381f6c |
long nsyms = plugin_data->nsyms;
|
|
|
381f6c |
const struct ld_plugin_symbol *syms = plugin_data->syms;
|
|
|
381f6c |
- static asection fake_section;
|
|
|
381f6c |
- static asection fake_common_section;
|
|
|
381f6c |
- int i;
|
|
|
381f6c |
-
|
|
|
381f6c |
- fake_section.name = ".text";
|
|
|
381f6c |
- fake_common_section.flags = SEC_IS_COMMON;
|
|
|
381f6c |
+ int i, j;
|
|
|
381f6c |
|
|
|
381f6c |
for (i = 0; i < nsyms; i++)
|
|
|
381f6c |
{
|
|
|
381f6c |
@@ -492,10 +631,11 @@ bfd_plugin_canonicalize_symtab (bfd *abf
|
|
|
381f6c |
s->name = syms[i].name;
|
|
|
381f6c |
s->value = 0;
|
|
|
381f6c |
s->flags = convert_flags (&syms[i]);
|
|
|
381f6c |
+ s->udata.p = NULL;
|
|
|
381f6c |
switch (syms[i].def)
|
|
|
381f6c |
{
|
|
|
381f6c |
case LDPK_COMMON:
|
|
|
381f6c |
- s->section = &fake_common_section;
|
|
|
381f6c |
+ s->section = &bfd_plugin_fake_common_section;
|
|
|
381f6c |
break;
|
|
|
381f6c |
case LDPK_UNDEF:
|
|
|
381f6c |
case LDPK_WEAKUNDEF:
|
|
|
381f6c |
@@ -503,15 +643,18 @@ bfd_plugin_canonicalize_symtab (bfd *abf
|
|
|
381f6c |
break;
|
|
|
381f6c |
case LDPK_DEF:
|
|
|
381f6c |
case LDPK_WEAKDEF:
|
|
|
381f6c |
- s->section = &fake_section;
|
|
|
381f6c |
+ s->section = &bfd_plugin_fake_text_section;
|
|
|
381f6c |
break;
|
|
|
381f6c |
default:
|
|
|
381f6c |
BFD_ASSERT (0);
|
|
|
381f6c |
}
|
|
|
381f6c |
-
|
|
|
381f6c |
- s->udata.p = (void *) &syms[i];
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
+ /* Copy symbols from object only section. */
|
|
|
381f6c |
+ nsyms += plugin_data->object_only_nsyms;
|
|
|
381f6c |
+ for (j = 0; j < plugin_data->object_only_nsyms; j++, i++)
|
|
|
381f6c |
+ alocation[i] = plugin_data->object_only_syms[j];
|
|
|
381f6c |
+
|
|
|
381f6c |
return nsyms;
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
diff -rup binutils-2.26.orig/bfd/plugin.h binutils-2.26/bfd/plugin.h
|
|
|
381f6c |
--- binutils-2.26.orig/bfd/plugin.h 2016-02-19 09:35:36.271000852 +0000
|
|
|
381f6c |
+++ binutils-2.26/bfd/plugin.h 2016-02-19 09:35:54.906106526 +0000
|
|
|
381f6c |
@@ -33,6 +33,8 @@ typedef struct plugin_data_struct
|
|
|
381f6c |
{
|
|
|
381f6c |
int nsyms;
|
|
|
381f6c |
const struct ld_plugin_symbol *syms;
|
|
|
381f6c |
+ int object_only_nsyms;
|
|
|
381f6c |
+ asymbol **object_only_syms;
|
|
|
381f6c |
}
|
|
|
381f6c |
plugin_data_struct;
|
|
|
381f6c |
|
|
|
381f6c |
diff -rup binutils-2.26.orig/bfd/section.c binutils-2.26/bfd/section.c
|
|
|
381f6c |
--- binutils-2.26.orig/bfd/section.c 2016-02-19 09:35:36.276000881 +0000
|
|
|
381f6c |
+++ binutils-2.26/bfd/section.c 2016-02-19 09:35:54.906106526 +0000
|
|
|
381f6c |
@@ -588,6 +588,9 @@ CODE_FRAGMENT
|
|
|
381f6c |
.#define BFD_COM_SECTION_NAME "*COM*"
|
|
|
381f6c |
.#define BFD_IND_SECTION_NAME "*IND*"
|
|
|
381f6c |
.
|
|
|
381f6c |
+.{* GNU object-only section name. *}
|
|
|
381f6c |
+.#define GNU_OBJECT_ONLY_SECTION_NAME ".gnu_object_only"
|
|
|
381f6c |
+.
|
|
|
381f6c |
.{* Pointer to the common section. *}
|
|
|
381f6c |
.#define bfd_com_section_ptr (&_bfd_std_section[0])
|
|
|
381f6c |
.{* Pointer to the undefined section. *}
|
|
|
381f6c |
diff -rup binutils-2.26.orig/binutils/readelf.c binutils-2.26/binutils/readelf.c
|
|
|
381f6c |
--- binutils-2.26.orig/binutils/readelf.c 2016-02-19 09:35:36.295000988 +0000
|
|
|
381f6c |
+++ binutils-2.26/binutils/readelf.c 2016-02-19 09:35:54.911106554 +0000
|
|
|
381f6c |
@@ -3900,6 +3900,7 @@ get_section_type_name (unsigned int sh_t
|
|
|
381f6c |
case 0x7ffffffd: return "AUXILIARY";
|
|
|
381f6c |
case 0x7fffffff: return "FILTER";
|
|
|
381f6c |
case SHT_GNU_LIBLIST: return "GNU_LIBLIST";
|
|
|
381f6c |
+ case SHT_GNU_OBJECT_ONLY: return "GNU_OBJECT_ONLY";
|
|
|
381f6c |
|
|
|
381f6c |
default:
|
|
|
381f6c |
if ((sh_type >= SHT_LOPROC) && (sh_type <= SHT_HIPROC))
|
|
|
381f6c |
diff -rup binutils-2.26.orig/gas/testsuite/gas/elf/section9.d binutils-2.26/gas/testsuite/gas/elf/section9.d
|
|
|
381f6c |
--- binutils-2.26.orig/gas/testsuite/gas/elf/section9.d 2016-02-19 09:35:36.397001567 +0000
|
|
|
381f6c |
+++ binutils-2.26/gas/testsuite/gas/elf/section9.d 2016-02-19 09:35:54.912106560 +0000
|
|
|
381f6c |
@@ -4,4 +4,5 @@
|
|
|
381f6c |
#...
|
|
|
381f6c |
[ ]*\[.*\][ ]+\.gnu\.lto_main[ ]+PROGBITS.*[ ]+E[ ]+.*
|
|
|
381f6c |
[ ]*\[.*\][ ]+\.gnu\.lto_\.pureconst[ ]+PROGBITS.*[ ]+E[ ]+.*
|
|
|
381f6c |
+[ ]*\[.*\][ ]+\.gnu_object_only[ ]+GNU_OBJECT_ONLY.*[ ]+E[ ]+.*
|
|
|
381f6c |
#pass
|
|
|
381f6c |
diff -rup binutils-2.26.orig/gas/testsuite/gas/elf/section9.s binutils-2.26/gas/testsuite/gas/elf/section9.s
|
|
|
381f6c |
--- binutils-2.26.orig/gas/testsuite/gas/elf/section9.s 2016-02-19 09:35:36.397001567 +0000
|
|
|
381f6c |
+++ binutils-2.26/gas/testsuite/gas/elf/section9.s 2016-02-19 09:35:54.912106560 +0000
|
|
|
381f6c |
@@ -2,3 +2,5 @@
|
|
|
381f6c |
.byte 0,0,0,0
|
|
|
381f6c |
.section .gnu.lto_.pureconst,"",%progbits
|
|
|
381f6c |
.byte 0,0,0,0
|
|
|
381f6c |
+ .section .gnu_object_only
|
|
|
381f6c |
+ .byte 0,0,0,0
|
|
|
381f6c |
diff -rup binutils-2.26.orig/include/bfdlink.h binutils-2.26/include/bfdlink.h
|
|
|
381f6c |
--- binutils-2.26.orig/include/bfdlink.h 2016-02-19 09:35:36.672003126 +0000
|
|
|
381f6c |
+++ binutils-2.26/include/bfdlink.h 2016-02-19 09:35:54.913106566 +0000
|
|
|
381f6c |
@@ -400,6 +400,12 @@ struct bfd_link_info
|
|
|
381f6c |
/* TRUE if ok to have multiple definition. */
|
|
|
381f6c |
unsigned int allow_multiple_definition: 1;
|
|
|
381f6c |
|
|
|
381f6c |
+ /* TRUE if .gnu_object_only section should be created. */
|
|
|
381f6c |
+ unsigned int emit_gnu_object_only: 1;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* TRUE if .gnu_object_only section is being created. */
|
|
|
381f6c |
+ unsigned int emitting_gnu_object_only: 1;
|
|
|
381f6c |
+
|
|
|
381f6c |
/* TRUE if ok to have version with no definition. */
|
|
|
381f6c |
unsigned int allow_undefined_version: 1;
|
|
|
381f6c |
|
|
|
381f6c |
diff -rup binutils-2.26.orig/include/elf/common.h binutils-2.26/include/elf/common.h
|
|
|
381f6c |
--- binutils-2.26.orig/include/elf/common.h 2016-02-19 09:35:36.675003143 +0000
|
|
|
381f6c |
+++ binutils-2.26/include/elf/common.h 2016-02-19 09:35:54.913106566 +0000
|
|
|
381f6c |
@@ -478,6 +478,7 @@
|
|
|
381f6c |
#define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes */
|
|
|
381f6c |
#define SHT_GNU_HASH 0x6ffffff6 /* GNU style symbol hash table */
|
|
|
381f6c |
#define SHT_GNU_LIBLIST 0x6ffffff7 /* List of prelink dependencies */
|
|
|
381f6c |
+#define SHT_GNU_OBJECT_ONLY 0x6ffffff8 /* Object only */
|
|
|
381f6c |
|
|
|
381f6c |
/* The next three section types are defined by Solaris, and are named
|
|
|
381f6c |
SHT_SUNW*. We use them in GNU code, so we also define SHT_GNU*
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/emultempl/aarch64elf.em binutils-2.26/ld/emultempl/aarch64elf.em
|
|
|
381f6c |
--- binutils-2.26.orig/ld/emultempl/aarch64elf.em 2016-02-19 09:35:36.698003274 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/emultempl/aarch64elf.em 2016-02-19 09:35:54.914106571 +0000
|
|
|
381f6c |
@@ -271,7 +271,7 @@ gld${EMULATION_NAME}_after_allocation (v
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
static void
|
|
|
381f6c |
-gld${EMULATION_NAME}_finish (void)
|
|
|
381f6c |
+aarch64_finish (void)
|
|
|
381f6c |
{
|
|
|
381f6c |
if (!bfd_link_relocatable (&link_info))
|
|
|
381f6c |
{
|
|
|
381f6c |
@@ -283,7 +283,7 @@ gld${EMULATION_NAME}_finish (void)
|
|
|
381f6c |
}
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
- finish_default ();
|
|
|
381f6c |
+ gld${EMULATION_NAME}_finish ();
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
/* This is a convenient point to tell BFD about target specific flags.
|
|
|
381f6c |
@@ -435,4 +435,4 @@ LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=
|
|
|
381f6c |
LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse
|
|
|
381f6c |
|
|
|
381f6c |
# Call the extra arm-elf function
|
|
|
381f6c |
-LDEMUL_FINISH=gld${EMULATION_NAME}_finish
|
|
|
381f6c |
+LDEMUL_FINISH=aarch64_finish
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/emultempl/alphaelf.em binutils-2.26/ld/emultempl/alphaelf.em
|
|
|
381f6c |
--- binutils-2.26.orig/ld/emultempl/alphaelf.em 2016-02-19 09:35:36.698003274 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/emultempl/alphaelf.em 2016-02-19 09:35:54.914106571 +0000
|
|
|
381f6c |
@@ -104,7 +104,7 @@ alpha_finish (void)
|
|
|
381f6c |
if (limit_32bit)
|
|
|
381f6c |
elf_elfheader (link_info.output_bfd)->e_flags |= EF_ALPHA_32BIT;
|
|
|
381f6c |
|
|
|
381f6c |
- finish_default ();
|
|
|
381f6c |
+ gld${EMULATION_NAME}_finish ();
|
|
|
381f6c |
}
|
|
|
381f6c |
EOF
|
|
|
381f6c |
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/emultempl/avrelf.em binutils-2.26/ld/emultempl/avrelf.em
|
|
|
381f6c |
--- binutils-2.26.orig/ld/emultempl/avrelf.em 2016-02-19 09:35:36.698003274 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/emultempl/avrelf.em 2016-02-19 09:35:54.915106577 +0000
|
|
|
381f6c |
@@ -209,7 +209,7 @@ avr_finish (void)
|
|
|
381f6c |
elf_elfheader (abfd)->e_flags &= ~EF_AVR_LINKRELAX_PREPARED;
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
- finish_default ();
|
|
|
381f6c |
+ gld${EMULATION_NAME}_finish ();
|
|
|
381f6c |
}
|
|
|
381f6c |
EOF
|
|
|
381f6c |
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/emultempl/elf32.em binutils-2.26/ld/emultempl/elf32.em
|
|
|
381f6c |
--- binutils-2.26.orig/ld/emultempl/elf32.em 2016-02-19 09:35:36.700003285 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/emultempl/elf32.em 2016-02-19 09:35:54.915106577 +0000
|
|
|
381f6c |
@@ -66,6 +66,7 @@ static void gld${EMULATION_NAME}_before_
|
|
|
381f6c |
static void gld${EMULATION_NAME}_after_allocation (void);
|
|
|
381f6c |
static lang_output_section_statement_type *gld${EMULATION_NAME}_place_orphan
|
|
|
381f6c |
(asection *, const char *, int);
|
|
|
381f6c |
+static void gld${EMULATION_NAME}_finish (void);
|
|
|
381f6c |
EOF
|
|
|
381f6c |
|
|
|
381f6c |
if [ "x${USE_LIBPATH}" = xyes ] ; then
|
|
|
381f6c |
@@ -1795,6 +1796,8 @@ output_rel_find (asection *sec, int isdy
|
|
|
381f6c |
in->owner, in);
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
+static int orphan_init_done = 0;
|
|
|
381f6c |
+
|
|
|
381f6c |
/* Place an orphan section. We use this to put random SHF_ALLOC
|
|
|
381f6c |
sections in the right segment. */
|
|
|
381f6c |
|
|
|
381f6c |
@@ -1803,7 +1806,7 @@ gld${EMULATION_NAME}_place_orphan (asect
|
|
|
381f6c |
const char *secname,
|
|
|
381f6c |
int constraint)
|
|
|
381f6c |
{
|
|
|
381f6c |
- static struct orphan_save hold[] =
|
|
|
381f6c |
+ static struct orphan_save orig_hold[] =
|
|
|
381f6c |
{
|
|
|
381f6c |
{ ".text",
|
|
|
381f6c |
SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE,
|
|
|
381f6c |
@@ -1833,6 +1836,7 @@ gld${EMULATION_NAME}_place_orphan (asect
|
|
|
381f6c |
SEC_HAS_CONTENTS,
|
|
|
381f6c |
0, 0, 0, 0 },
|
|
|
381f6c |
};
|
|
|
381f6c |
+ static struct orphan_save hold[ARRAY_SIZE (orig_hold)];
|
|
|
381f6c |
enum orphan_save_index
|
|
|
381f6c |
{
|
|
|
381f6c |
orphan_text = 0,
|
|
|
381f6c |
@@ -1845,7 +1849,6 @@ gld${EMULATION_NAME}_place_orphan (asect
|
|
|
381f6c |
orphan_sdata,
|
|
|
381f6c |
orphan_nonalloc
|
|
|
381f6c |
};
|
|
|
381f6c |
- static int orphan_init_done = 0;
|
|
|
381f6c |
struct orphan_save *place;
|
|
|
381f6c |
lang_output_section_statement_type *after;
|
|
|
381f6c |
lang_output_section_statement_type *os;
|
|
|
381f6c |
@@ -1924,15 +1927,22 @@ gld${EMULATION_NAME}_place_orphan (asect
|
|
|
381f6c |
|
|
|
381f6c |
if (!orphan_init_done)
|
|
|
381f6c |
{
|
|
|
381f6c |
- struct orphan_save *ho;
|
|
|
381f6c |
+ struct orphan_save *ho, *horig;
|
|
|
381f6c |
|
|
|
381f6c |
for (ho = hold; ho < hold + sizeof (hold) / sizeof (hold[0]); ++ho)
|
|
|
381f6c |
+ for (ho = hold, horig = orig_hold;
|
|
|
381f6c |
+ ho < hold + ARRAY_SIZE (hold);
|
|
|
381f6c |
+ ++ho, ++horig)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ *ho = *horig;
|
|
|
381f6c |
+ if (ho->name != NULL)
|
|
|
381f6c |
if (ho->name != NULL)
|
|
|
381f6c |
{
|
|
|
381f6c |
ho->os = lang_output_section_find (ho->name);
|
|
|
381f6c |
if (ho->os != NULL && ho->os->flags == 0)
|
|
|
381f6c |
ho->os->flags = ho->flags;
|
|
|
381f6c |
}
|
|
|
381f6c |
+ }
|
|
|
381f6c |
orphan_init_done = 1;
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
@@ -2017,6 +2027,27 @@ gld${EMULATION_NAME}_place_orphan (asect
|
|
|
381f6c |
EOF
|
|
|
381f6c |
fi
|
|
|
381f6c |
|
|
|
381f6c |
+fragment <
|
|
|
381f6c |
+
|
|
|
381f6c |
+/* Final emulation specific call. */
|
|
|
381f6c |
+
|
|
|
381f6c |
+static void
|
|
|
381f6c |
+gld${EMULATION_NAME}_finish (void)
|
|
|
381f6c |
+{
|
|
|
381f6c |
+EOF
|
|
|
381f6c |
+if test x"$LDEMUL_PLACE_ORPHAN" != xgld"$EMULATION_NAME"_place_orphan; then
|
|
|
381f6c |
+fragment <
|
|
|
381f6c |
+ /* Support the object-only output. */
|
|
|
381f6c |
+ if (link_info.emit_gnu_object_only)
|
|
|
381f6c |
+ orphan_init_done = 0;
|
|
|
381f6c |
+
|
|
|
381f6c |
+EOF
|
|
|
381f6c |
+fi
|
|
|
381f6c |
+fragment <
|
|
|
381f6c |
+ finish_default ();
|
|
|
381f6c |
+}
|
|
|
381f6c |
+EOF
|
|
|
381f6c |
+
|
|
|
381f6c |
if test x"$LDEMUL_AFTER_ALLOCATION" != xgld"$EMULATION_NAME"_after_allocation; then
|
|
|
381f6c |
fragment <
|
|
|
381f6c |
|
|
|
381f6c |
@@ -2503,7 +2534,7 @@ struct ld_emulation_xfer_struct ld_${EMU
|
|
|
381f6c |
${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
|
|
|
381f6c |
"${EMULATION_NAME}",
|
|
|
381f6c |
"${OUTPUT_FORMAT}",
|
|
|
381f6c |
- ${LDEMUL_FINISH-finish_default},
|
|
|
381f6c |
+ ${LDEMUL_FINISH-gld${EMULATION_NAME}_finish},
|
|
|
381f6c |
${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL},
|
|
|
381f6c |
${LDEMUL_OPEN_DYNAMIC_ARCHIVE-gld${EMULATION_NAME}_open_dynamic_archive},
|
|
|
381f6c |
${LDEMUL_PLACE_ORPHAN-gld${EMULATION_NAME}_place_orphan},
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/emultempl/ppc32elf.em binutils-2.26/ld/emultempl/ppc32elf.em
|
|
|
381f6c |
--- binutils-2.26.orig/ld/emultempl/ppc32elf.em 2016-02-19 09:35:36.699003279 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/emultempl/ppc32elf.em 2016-02-19 09:35:54.916106583 +0000
|
|
|
381f6c |
@@ -215,7 +215,7 @@ ppc_finish (void)
|
|
|
381f6c |
{
|
|
|
381f6c |
if (params.ppc476_workaround)
|
|
|
381f6c |
lang_for_each_statement (no_zero_padding);
|
|
|
381f6c |
- finish_default ();
|
|
|
381f6c |
+ gld${EMULATION_NAME}_finish ();
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
EOF
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/emultempl/spuelf.em binutils-2.26/ld/emultempl/spuelf.em
|
|
|
381f6c |
--- binutils-2.26.orig/ld/emultempl/spuelf.em 2016-02-19 09:35:36.699003279 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/emultempl/spuelf.em 2016-02-19 09:35:54.916106583 +0000
|
|
|
381f6c |
@@ -416,7 +416,7 @@ spu_elf_relink (void)
|
|
|
381f6c |
/* Final emulation specific call. */
|
|
|
381f6c |
|
|
|
381f6c |
static void
|
|
|
381f6c |
-gld${EMULATION_NAME}_finish (void)
|
|
|
381f6c |
+spu_finish (void)
|
|
|
381f6c |
{
|
|
|
381f6c |
if (is_spu_target ())
|
|
|
381f6c |
{
|
|
|
381f6c |
@@ -432,7 +432,7 @@ gld${EMULATION_NAME}_finish (void)
|
|
|
381f6c |
einfo (_("%P: --auto-overlay ignored with zero local store range\n"));
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
- finish_default ();
|
|
|
381f6c |
+ gld${EMULATION_NAME}_finish ();
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
static char *
|
|
|
381f6c |
@@ -832,5 +832,5 @@ PARSE_AND_LIST_ARGS_CASES='
|
|
|
381f6c |
|
|
|
381f6c |
LDEMUL_AFTER_OPEN=spu_after_open
|
|
|
381f6c |
LDEMUL_BEFORE_ALLOCATION=spu_before_allocation
|
|
|
381f6c |
-LDEMUL_FINISH=gld${EMULATION_NAME}_finish
|
|
|
381f6c |
+LDEMUL_FINISH=spu_finish
|
|
|
381f6c |
LDEMUL_CHOOSE_TARGET=gld${EMULATION_NAME}_choose_target
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/ldexp.c binutils-2.26/ld/ldexp.c
|
|
|
381f6c |
--- binutils-2.26.orig/ld/ldexp.c 2016-02-19 09:35:36.701003291 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/ldexp.c 2016-02-19 09:35:54.917106588 +0000
|
|
|
381f6c |
@@ -1616,14 +1616,15 @@ align_n (bfd_vma value, bfd_vma align)
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
void
|
|
|
381f6c |
-ldexp_init (void)
|
|
|
381f6c |
+ldexp_init (bfd_boolean object_only)
|
|
|
381f6c |
{
|
|
|
381f6c |
/* The value "13" is ad-hoc, somewhat related to the expected number of
|
|
|
381f6c |
assignments in a linker script. */
|
|
|
381f6c |
- if (!bfd_hash_table_init_n (&definedness_table,
|
|
|
381f6c |
- definedness_newfunc,
|
|
|
381f6c |
- sizeof (struct definedness_hash_entry),
|
|
|
381f6c |
- 13))
|
|
|
381f6c |
+ if (!object_only
|
|
|
381f6c |
+ && !bfd_hash_table_init_n (&definedness_table,
|
|
|
381f6c |
+ definedness_newfunc,
|
|
|
381f6c |
+ sizeof (struct definedness_hash_entry),
|
|
|
381f6c |
+ 13))
|
|
|
381f6c |
einfo (_("%P%F: can not create hash table: %E\n"));
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
@@ -1658,7 +1659,8 @@ ldexp_finalize_syms (void)
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
void
|
|
|
381f6c |
-ldexp_finish (void)
|
|
|
381f6c |
+ldexp_finish (bfd_boolean object_only)
|
|
|
381f6c |
{
|
|
|
381f6c |
- bfd_hash_table_free (&definedness_table);
|
|
|
381f6c |
+ if (!object_only)
|
|
|
381f6c |
+ bfd_hash_table_free (&definedness_table);
|
|
|
381f6c |
}
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/ldexp.h binutils-2.26/ld/ldexp.h
|
|
|
381f6c |
--- binutils-2.26.orig/ld/ldexp.h 2016-02-19 09:35:36.701003291 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/ldexp.h 2016-02-19 09:35:54.917106588 +0000
|
|
|
381f6c |
@@ -229,8 +229,8 @@ fill_type *exp_get_fill
|
|
|
381f6c |
(etree_type *, fill_type *, char *);
|
|
|
381f6c |
bfd_vma exp_get_abs_int
|
|
|
381f6c |
(etree_type *, int, char *);
|
|
|
381f6c |
-void ldexp_init (void);
|
|
|
381f6c |
+void ldexp_init (bfd_boolean);
|
|
|
381f6c |
void ldexp_finalize_syms (void);
|
|
|
381f6c |
-void ldexp_finish (void);
|
|
|
381f6c |
+void ldexp_finish (bfd_boolean);
|
|
|
381f6c |
|
|
|
381f6c |
#endif
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/ldfile.c binutils-2.26/ld/ldfile.c
|
|
|
381f6c |
--- binutils-2.26.orig/ld/ldfile.c 2016-02-19 09:35:36.701003291 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/ldfile.c 2016-02-19 09:35:54.918106594 +0000
|
|
|
381f6c |
@@ -313,7 +313,9 @@ success:
|
|
|
381f6c |
&& !no_more_claiming
|
|
|
381f6c |
&& bfd_check_format (entry->the_bfd, bfd_object))
|
|
|
381f6c |
plugin_maybe_claim (entry);
|
|
|
381f6c |
+ else
|
|
|
381f6c |
#endif /* ENABLE_PLUGINS */
|
|
|
381f6c |
+ cmdline_check_object_only_section (entry->the_bfd, FALSE);
|
|
|
381f6c |
|
|
|
381f6c |
/* It opened OK, the format checked out, and the plugins have had
|
|
|
381f6c |
their chance to claim it, so this is success. */
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/ldlang.c binutils-2.26/ld/ldlang.c
|
|
|
381f6c |
--- binutils-2.26.orig/ld/ldlang.c 2016-02-19 09:35:36.701003291 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/ldlang.c 2016-02-19 09:35:54.921106611 +0000
|
|
|
381f6c |
@@ -36,6 +36,7 @@
|
|
|
381f6c |
#include "ldctor.h"
|
|
|
381f6c |
#include "ldfile.h"
|
|
|
381f6c |
#include "ldemul.h"
|
|
|
381f6c |
+#include "ldwrite.h"
|
|
|
381f6c |
#include "fnmatch.h"
|
|
|
381f6c |
#include "demangle.h"
|
|
|
381f6c |
#include "hashtab.h"
|
|
|
381f6c |
@@ -45,6 +46,9 @@
|
|
|
381f6c |
#include "plugin.h"
|
|
|
381f6c |
#endif /* ENABLE_PLUGINS */
|
|
|
381f6c |
|
|
|
381f6c |
+/* FIXME: Put it here to avoid NAME conflict from ldgram.h. */
|
|
|
381f6c |
+#include "elf-bfd.h"
|
|
|
381f6c |
+
|
|
|
381f6c |
#ifndef offsetof
|
|
|
381f6c |
#define offsetof(TYPE, MEMBER) ((size_t) & (((TYPE*) 0)->MEMBER))
|
|
|
381f6c |
#endif
|
|
|
381f6c |
@@ -86,6 +93,13 @@ static void lang_do_version_exports_sect
|
|
|
381f6c |
static void lang_finalize_version_expr_head
|
|
|
381f6c |
(struct bfd_elf_version_expr_head *);
|
|
|
381f6c |
static void lang_do_memory_regions (void);
|
|
|
381f6c |
+static void cmdline_lists_init (void);
|
|
|
381f6c |
+static void cmdline_get_object_only_input_files (void);
|
|
|
381f6c |
+static void print_cmdline_list (cmdline_union_type *);
|
|
|
381f6c |
+static bfd_boolean cmdline_on_object_only_archive_list_p (bfd *);
|
|
|
381f6c |
+static cmdline_list_type cmdline_object_only_file_list;
|
|
|
381f6c |
+static cmdline_list_type cmdline_object_only_archive_list;
|
|
|
381f6c |
+static cmdline_list_type cmdline_temp_object_only_list;
|
|
|
381f6c |
|
|
|
381f6c |
/* Exported variables. */
|
|
|
381f6c |
const char *output_target;
|
|
|
381f6c |
@@ -1219,14 +1230,17 @@ output_section_statement_table_free (voi
|
|
|
381f6c |
/* Build enough state so that the parser can build its tree. */
|
|
|
381f6c |
|
|
|
381f6c |
void
|
|
|
381f6c |
-lang_init (void)
|
|
|
381f6c |
+lang_init (bfd_boolean object_only)
|
|
|
381f6c |
{
|
|
|
381f6c |
- obstack_begin (&stat_obstack, 1000);
|
|
|
381f6c |
+ if (!object_only)
|
|
|
381f6c |
+ obstack_begin (&stat_obstack, 1000);
|
|
|
381f6c |
|
|
|
381f6c |
stat_ptr = &statement_list;
|
|
|
381f6c |
|
|
|
381f6c |
output_section_statement_table_init ();
|
|
|
381f6c |
|
|
|
381f6c |
+ cmdline_lists_init ();
|
|
|
381f6c |
+
|
|
|
381f6c |
lang_list_init (stat_ptr);
|
|
|
381f6c |
|
|
|
381f6c |
lang_list_init (&input_file_chain);
|
|
|
381f6c |
@@ -2843,6 +2857,12 @@ load_symbols (lang_input_statement_type
|
|
|
381f6c |
loaded = FALSE;
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
+ if (link_info.emitting_gnu_object_only)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ if (!cmdline_on_object_only_archive_list_p (member))
|
|
|
381f6c |
+ continue;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
subsbfd = member;
|
|
|
381f6c |
if (!(*link_info.callbacks
|
|
|
381f6c |
->add_archive_element) (&link_info, member,
|
|
|
381f6c |
@@ -6780,10 +6800,41 @@ lang_process (void)
|
|
|
381f6c |
open_input_bfds (statement_list.head, OPEN_BFD_RESCAN);
|
|
|
381f6c |
}
|
|
|
381f6c |
}
|
|
|
381f6c |
+ else
|
|
|
381f6c |
#endif /* ENABLE_PLUGINS */
|
|
|
381f6c |
+ if (bfd_link_relocatable (&link_info))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ /* Check if .gnu_object_only section should be created. */
|
|
|
381f6c |
+ bfd *p;
|
|
|
381f6c |
+ int object_type;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ object_type = 0;
|
|
|
381f6c |
+ for (p = link_info.input_bfds; p != (bfd *) NULL; p = p->link.next)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ object_type |= 1 << p->lto_type;
|
|
|
381f6c |
+ if ((object_type & (1 << lto_mixed_object)) != 0
|
|
|
381f6c |
+ || ((object_type
|
|
|
381f6c |
+ & (1 << lto_non_ir_object
|
|
|
381f6c |
+ | 1 << lto_ir_object))
|
|
|
381f6c |
+ == (1 << lto_non_ir_object | 1 << lto_ir_object)))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ link_info.emit_gnu_object_only = TRUE;
|
|
|
381f6c |
+ break;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (verbose
|
|
|
381f6c |
+ && (cmdline_object_only_file_list.head
|
|
|
381f6c |
+ || cmdline_object_only_archive_list.head))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ info_msg (_("Object-only input files:\n "));
|
|
|
381f6c |
+ print_cmdline_list (cmdline_object_only_file_list.head);
|
|
|
381f6c |
+ print_cmdline_list (cmdline_object_only_archive_list.head);
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ }
|
|
|
381f6c |
|
|
|
381f6c |
/* Make sure that nobody has tried to add a symbol to this list
|
|
|
381f6c |
before now. */
|
|
|
381f6c |
ASSERT (link_info.gc_sym_list == NULL);
|
|
|
381f6c |
|
|
|
381f6c |
link_info.gc_sym_list = &entry_symbol;
|
|
|
381f6c |
@@ -8275,3 +8326,968 @@ lang_print_memory_usage (void)
|
|
|
381f6c |
printf (" %6.2f%%\n", percent);
|
|
|
381f6c |
}
|
|
|
381f6c |
}
|
|
|
381f6c |
+
|
|
|
381f6c |
+static void
|
|
|
381f6c |
+cmdline_lists_init (void)
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ cmdline_object_only_file_list.tail
|
|
|
381f6c |
+ = &cmdline_object_only_file_list.head;
|
|
|
381f6c |
+ cmdline_object_only_archive_list.tail
|
|
|
381f6c |
+ = &cmdline_object_only_archive_list.head;
|
|
|
381f6c |
+ cmdline_temp_object_only_list.tail
|
|
|
381f6c |
+ = &cmdline_temp_object_only_list.head;
|
|
|
381f6c |
+}
|
|
|
381f6c |
+
|
|
|
381f6c |
+/* Allocate an item with TYPE and DATA. */
|
|
|
381f6c |
+
|
|
|
381f6c |
+static cmdline_union_type *
|
|
|
381f6c |
+cmdline_list_new (cmdline_enum_type type, void *data)
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ cmdline_union_type *new_opt;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ new_opt = (cmdline_union_type *) stat_alloc (sizeof (*new_opt));
|
|
|
381f6c |
+ new_opt->header.type = type;
|
|
|
381f6c |
+ switch (type)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ default:
|
|
|
381f6c |
+ break;
|
|
|
381f6c |
+ case cmdline_is_file_enum:
|
|
|
381f6c |
+ new_opt->file.filename = (const char *) data;
|
|
|
381f6c |
+ break;
|
|
|
381f6c |
+ case cmdline_is_bfd_enum:
|
|
|
381f6c |
+ new_opt->abfd.abfd = (bfd *) data;
|
|
|
381f6c |
+ break;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ return new_opt;
|
|
|
381f6c |
+}
|
|
|
381f6c |
+
|
|
|
381f6c |
+/* Append an item with TYPE and DATA to LIST. */
|
|
|
381f6c |
+
|
|
|
381f6c |
+static void
|
|
|
381f6c |
+cmdline_list_append (cmdline_list_type *list, cmdline_enum_type type,
|
|
|
381f6c |
+ void *data)
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ cmdline_union_type *new_opt = cmdline_list_new (type, data);
|
|
|
381f6c |
+ new_opt->header.next = NULL;
|
|
|
381f6c |
+ *list->tail = new_opt;
|
|
|
381f6c |
+ list->tail = &new_opt->header.next;
|
|
|
381f6c |
+}
|
|
|
381f6c |
+
|
|
|
381f6c |
+static void
|
|
|
381f6c |
+print_cmdline_list (cmdline_union_type *c)
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ for (; c != NULL; c = c->header.next)
|
|
|
381f6c |
+ switch (c->header.type)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ default:
|
|
|
381f6c |
+ abort ();
|
|
|
381f6c |
+ case cmdline_is_file_enum:
|
|
|
381f6c |
+ info_msg (" %s", c->file.filename);
|
|
|
381f6c |
+ break;
|
|
|
381f6c |
+ case cmdline_is_bfd_enum:
|
|
|
381f6c |
+ info_msg (" [%B]", c->abfd.abfd);
|
|
|
381f6c |
+ break;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ info_msg ("\n");
|
|
|
381f6c |
+}
|
|
|
381f6c |
+
|
|
|
381f6c |
+/* Return TRUE if ABFD is on cmdline_object_only_archive_list. */
|
|
|
381f6c |
+
|
|
|
381f6c |
+static bfd_boolean
|
|
|
381f6c |
+cmdline_on_object_only_archive_list_p (bfd *abfd)
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ cmdline_union_type *c, *next;
|
|
|
381f6c |
+ bfd *archive, *obfd, *oarchive;
|
|
|
381f6c |
+ ufile_ptr origin = abfd->origin;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ archive = abfd->my_archive;
|
|
|
381f6c |
+ for (c = cmdline_object_only_archive_list.head; c != NULL; c = next)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ if (c->header.type != cmdline_is_bfd_enum)
|
|
|
381f6c |
+ abort ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+ next = c->header.next;
|
|
|
381f6c |
+ obfd = c->abfd.abfd;
|
|
|
381f6c |
+ oarchive = obfd->my_archive;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* The list is grouped by archive file name and sorted by member
|
|
|
381f6c |
+ origin. */
|
|
|
381f6c |
+ if (strcmp (archive->filename, oarchive->filename) != 0)
|
|
|
381f6c |
+ continue;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (origin == obfd->origin)
|
|
|
381f6c |
+ return TRUE;
|
|
|
381f6c |
+ else if (origin < obfd->origin)
|
|
|
381f6c |
+ return FALSE;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ return FALSE;
|
|
|
381f6c |
+}
|
|
|
381f6c |
+
|
|
|
381f6c |
+/* Append an item with TYPE and DATA to cmdline_object_only_file_list
|
|
|
381f6c |
+ or cmdline_object_only_archive_list if needed. */
|
|
|
381f6c |
+
|
|
|
381f6c |
+static void
|
|
|
381f6c |
+cmdline_object_only_list_append (cmdline_enum_type type, void *data)
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ cmdline_union_type *c;
|
|
|
381f6c |
+ cmdline_union_type *new_opt, *next, **prev;
|
|
|
381f6c |
+ bfd *abfd, *archive;
|
|
|
381f6c |
+ bfd *obfd, *oarchive;
|
|
|
381f6c |
+ bfd *nbfd, *narchive;
|
|
|
381f6c |
+ ufile_ptr origin, norigin;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Put it on cmdline_object_only_file_list if it isn't an archive
|
|
|
381f6c |
+ member. */
|
|
|
381f6c |
+ switch (type)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ default:
|
|
|
381f6c |
+ abort ();
|
|
|
381f6c |
+ case cmdline_is_bfd_enum:
|
|
|
381f6c |
+ abfd = (bfd *) data;
|
|
|
381f6c |
+ archive = abfd->my_archive;
|
|
|
381f6c |
+ if (archive)
|
|
|
381f6c |
+ break;
|
|
|
381f6c |
+ case cmdline_is_file_enum:
|
|
|
381f6c |
+ cmdline_list_append (&cmdline_object_only_file_list, type, data);
|
|
|
381f6c |
+ return;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Put archive member on cmdline_object_only_archive_list and sort
|
|
|
381f6c |
+ the list by archive name and archive member origin. */
|
|
|
381f6c |
+ new_opt = (cmdline_union_type *) stat_alloc (sizeof (*new_opt));
|
|
|
381f6c |
+ new_opt->header.type = cmdline_is_bfd_enum;
|
|
|
381f6c |
+ new_opt->header.next = NULL;
|
|
|
381f6c |
+ new_opt->abfd.abfd = (bfd *) data;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ c = cmdline_object_only_archive_list.head;
|
|
|
381f6c |
+ if (c == NULL)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ cmdline_object_only_archive_list.head = new_opt;
|
|
|
381f6c |
+ cmdline_object_only_archive_list.tail = &new_opt->header.next;
|
|
|
381f6c |
+ return;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ prev = NULL;
|
|
|
381f6c |
+ origin = abfd->origin;
|
|
|
381f6c |
+ for (; c != NULL; c = next)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ if (c->header.type != cmdline_is_bfd_enum)
|
|
|
381f6c |
+ abort ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+ next = c->header.next;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ obfd = c->abfd.abfd;
|
|
|
381f6c |
+ oarchive = abfd->my_archive;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (strcmp (archive->filename, oarchive->filename) == 0)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ bfd_boolean after;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (origin < obfd->origin)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ /* Insert it before the current. */
|
|
|
381f6c |
+ new_opt->header.next = c;
|
|
|
381f6c |
+ if (prev)
|
|
|
381f6c |
+ *prev = new_opt;
|
|
|
381f6c |
+ else
|
|
|
381f6c |
+ cmdline_object_only_archive_list.head = new_opt;
|
|
|
381f6c |
+ return;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ after = TRUE;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Check origin. */
|
|
|
381f6c |
+ while (next)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ if (next->header.type != cmdline_is_bfd_enum)
|
|
|
381f6c |
+ abort ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+ nbfd = next->abfd.abfd;
|
|
|
381f6c |
+ norigin = nbfd->origin;
|
|
|
381f6c |
+ if (origin > norigin)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ /* Insert it after NEXT. */
|
|
|
381f6c |
+ break;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ narchive = nbfd->my_archive;
|
|
|
381f6c |
+ if (strcmp (archive->filename, narchive->filename) != 0)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ /* Insert it befor NEXT. */
|
|
|
381f6c |
+ after = FALSE;
|
|
|
381f6c |
+ break;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ c = next;
|
|
|
381f6c |
+ next = next->header.next;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (after && next)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ c = next;
|
|
|
381f6c |
+ next = next->header.next;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (*cmdline_object_only_archive_list.tail == c->header.next)
|
|
|
381f6c |
+ cmdline_object_only_archive_list.tail
|
|
|
381f6c |
+ = &new_opt->header.next;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ prev = &c->header.next;
|
|
|
381f6c |
+ new_opt->header.next = next;
|
|
|
381f6c |
+ *prev = new_opt;
|
|
|
381f6c |
+ return;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ prev = &c->header.next;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ *cmdline_object_only_archive_list.tail = new_opt;
|
|
|
381f6c |
+ cmdline_object_only_archive_list.tail = &new_opt->header.next;
|
|
|
381f6c |
+}
|
|
|
381f6c |
+
|
|
|
381f6c |
+/* Get object-only input files. */
|
|
|
381f6c |
+
|
|
|
381f6c |
+static void
|
|
|
381f6c |
+cmdline_get_object_only_input_files (void)
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ cmdline_union_type *c, *next;
|
|
|
381f6c |
+ bfd *abfd, *archive;
|
|
|
381f6c |
+ bfd *nbfd, *narchive;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Add files first. */
|
|
|
381f6c |
+ for (c = cmdline_object_only_file_list.head;
|
|
|
381f6c |
+ c != NULL; c = c->header.next)
|
|
|
381f6c |
+ switch (c->header.type)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ default:
|
|
|
381f6c |
+ abort ();
|
|
|
381f6c |
+ case cmdline_is_file_enum:
|
|
|
381f6c |
+ lang_add_input_file (c->file.filename,
|
|
|
381f6c |
+ lang_input_file_is_file_enum, NULL);
|
|
|
381f6c |
+ break;
|
|
|
381f6c |
+ case cmdline_is_bfd_enum:
|
|
|
381f6c |
+ abfd = c->abfd.abfd;
|
|
|
381f6c |
+ if (abfd->my_archive)
|
|
|
381f6c |
+ abort ();
|
|
|
381f6c |
+ lang_add_input_file (abfd->filename,
|
|
|
381f6c |
+ lang_input_file_is_file_enum, NULL);
|
|
|
381f6c |
+ break;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Add archive members next. */
|
|
|
381f6c |
+ for (c = cmdline_object_only_archive_list.head; c != NULL; c = next)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ if (c->header.type != cmdline_is_bfd_enum)
|
|
|
381f6c |
+ abort ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+ next = c->header.next;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ abfd = c->abfd.abfd;
|
|
|
381f6c |
+ archive = abfd->my_archive;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Add the first archive of the archive member group. */
|
|
|
381f6c |
+ lang_add_input_file (archive->filename,
|
|
|
381f6c |
+ lang_input_file_is_file_enum, NULL);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Skip the rest members in the archive member group. */
|
|
|
381f6c |
+ do
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ if (!next)
|
|
|
381f6c |
+ break;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (next->header.type != cmdline_is_bfd_enum)
|
|
|
381f6c |
+ abort ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+ next = next->header.next;
|
|
|
381f6c |
+ if (!next)
|
|
|
381f6c |
+ break;
|
|
|
381f6c |
+ nbfd = next->abfd.abfd;
|
|
|
381f6c |
+ narchive = nbfd->my_archive;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ while (strcmp (archive->filename, narchive->filename) == 0);
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+}
|
|
|
381f6c |
+
|
|
|
381f6c |
+struct cmdline_arg
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ bfd *obfd;
|
|
|
381f6c |
+ asymbol **isympp;
|
|
|
381f6c |
+ int status;
|
|
|
381f6c |
+};
|
|
|
381f6c |
+
|
|
|
381f6c |
+/* Create a section in OBFD with the same
|
|
|
381f6c |
+ name and attributes as ISECTION in IBFD. */
|
|
|
381f6c |
+
|
|
|
381f6c |
+static void
|
|
|
381f6c |
+setup_section (bfd *ibfd, sec_ptr isection, void *p)
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ struct cmdline_arg *arg = (struct cmdline_arg *) p;
|
|
|
381f6c |
+ bfd *obfd = arg->obfd;
|
|
|
381f6c |
+ asymbol **isympp = arg->isympp;
|
|
|
381f6c |
+ const char *name = isection->name;
|
|
|
381f6c |
+ sec_ptr osection;
|
|
|
381f6c |
+ const char *err;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Skip the object-only section. */
|
|
|
381f6c |
+ if (ibfd->object_only_section == isection)
|
|
|
381f6c |
+ return;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* If we have already failed earlier on, do not keep on generating
|
|
|
381f6c |
+ complaints now. */
|
|
|
381f6c |
+ if (arg->status)
|
|
|
381f6c |
+ return;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ osection = bfd_make_section_anyway_with_flags (obfd, name,
|
|
|
381f6c |
+ isection->flags);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (osection == NULL)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = _("failed to create output section");
|
|
|
381f6c |
+ goto loser;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ osection->size = isection->size;
|
|
|
381f6c |
+ osection->vma = isection->vma;
|
|
|
381f6c |
+ osection->lma = isection->lma;
|
|
|
381f6c |
+ osection->alignment_power = isection->alignment_power;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Copy merge entity size. */
|
|
|
381f6c |
+ osection->entsize = isection->entsize;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* This used to be mangle_section; we do here to avoid using
|
|
|
381f6c |
+ bfd_get_section_by_name since some formats allow multiple
|
|
|
381f6c |
+ sections with the same name. */
|
|
|
381f6c |
+ isection->output_section = osection;
|
|
|
381f6c |
+ isection->output_offset = 0;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if ((isection->flags & SEC_GROUP) != 0)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ asymbol *gsym = bfd_group_signature (isection, isympp);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (gsym != NULL)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ gsym->flags |= BSF_KEEP;
|
|
|
381f6c |
+ if (ibfd->xvec->flavour == bfd_target_elf_flavour)
|
|
|
381f6c |
+ elf_group_id (isection) = gsym;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Allow the BFD backend to copy any private data it understands
|
|
|
381f6c |
+ from the input section to the output section. */
|
|
|
381f6c |
+ if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = _("failed to copy private data");
|
|
|
381f6c |
+ goto loser;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* All went well. */
|
|
|
381f6c |
+ return;
|
|
|
381f6c |
+
|
|
|
381f6c |
+loser:
|
|
|
381f6c |
+ arg->status = 1;
|
|
|
381f6c |
+ einfo (_("%P%F: setup_section: %s: %s\n"), err, name);
|
|
|
381f6c |
+}
|
|
|
381f6c |
+
|
|
|
381f6c |
+/* Copy the data of input section ISECTION of IBFD
|
|
|
381f6c |
+ to an output section with the same name in OBFD.
|
|
|
381f6c |
+ If stripping then don't copy any relocation info. */
|
|
|
381f6c |
+
|
|
|
381f6c |
+static void
|
|
|
381f6c |
+copy_section (bfd *ibfd, sec_ptr isection, void *p)
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ struct cmdline_arg *arg = (struct cmdline_arg *) p;
|
|
|
381f6c |
+ bfd *obfd = arg->obfd;
|
|
|
381f6c |
+ asymbol **isympp = arg->isympp;
|
|
|
381f6c |
+ arelent **relpp;
|
|
|
381f6c |
+ long relcount;
|
|
|
381f6c |
+ sec_ptr osection;
|
|
|
381f6c |
+ bfd_size_type size;
|
|
|
381f6c |
+ long relsize;
|
|
|
381f6c |
+ flagword flags;
|
|
|
381f6c |
+ const char *err;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Skip the object-only section. */
|
|
|
381f6c |
+ if (ibfd->object_only_section == isection)
|
|
|
381f6c |
+ return;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* If we have already failed earlier on, do not keep on generating
|
|
|
381f6c |
+ complaints now. */
|
|
|
381f6c |
+ if (arg->status)
|
|
|
381f6c |
+ return;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ flags = bfd_get_section_flags (ibfd, isection);
|
|
|
381f6c |
+ if ((flags & SEC_GROUP) != 0)
|
|
|
381f6c |
+ return;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ osection = isection->output_section;
|
|
|
381f6c |
+ size = bfd_get_section_size (isection);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (size == 0 || osection == 0)
|
|
|
381f6c |
+ return;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ relsize = bfd_get_reloc_upper_bound (ibfd, isection);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (relsize < 0)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ /* Do not complain if the target does not support relocations. */
|
|
|
381f6c |
+ if (relsize == -1
|
|
|
381f6c |
+ && bfd_get_error () == bfd_error_invalid_operation)
|
|
|
381f6c |
+ relsize = 0;
|
|
|
381f6c |
+ else
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = bfd_errmsg (bfd_get_error ());
|
|
|
381f6c |
+ goto loser;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (relsize == 0)
|
|
|
381f6c |
+ bfd_set_reloc (obfd, osection, NULL, 0);
|
|
|
381f6c |
+ else
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ relpp = (arelent **) xmalloc (relsize);
|
|
|
381f6c |
+ relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, isympp);
|
|
|
381f6c |
+ if (relcount < 0)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = _("relocation count is negative");
|
|
|
381f6c |
+ goto loser;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ bfd_set_reloc (obfd, osection,
|
|
|
381f6c |
+ relcount == 0 ? NULL : relpp, relcount);
|
|
|
381f6c |
+ if (relcount == 0)
|
|
|
381f6c |
+ free (relpp);
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (bfd_get_section_flags (ibfd, isection) & SEC_HAS_CONTENTS)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ bfd_byte *memhunk = NULL;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (!bfd_get_full_section_contents (ibfd, isection, &memhunk))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = bfd_errmsg (bfd_get_error ());
|
|
|
381f6c |
+ goto loser;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (!bfd_set_section_contents (obfd, osection, memhunk, 0, size))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = bfd_errmsg (bfd_get_error ());
|
|
|
381f6c |
+ goto loser;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ free (memhunk);
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* All went well. */
|
|
|
381f6c |
+ return;
|
|
|
381f6c |
+
|
|
|
381f6c |
+loser:
|
|
|
381f6c |
+ einfo (_("%P%F: copy_section: %s: %s\n"), err, isection->name);
|
|
|
381f6c |
+}
|
|
|
381f6c |
+/* Open the temporary bfd created in the same directory as PATH. */
|
|
|
381f6c |
+
|
|
|
381f6c |
+static bfd *
|
|
|
381f6c |
+cmdline_fopen_temp (const char *path, const char *target,
|
|
|
381f6c |
+ const char *mode)
|
|
|
381f6c |
+{
|
|
|
381f6c |
+#define template "ldXXXXXX"
|
|
|
381f6c |
+ const char *slash = strrchr (path, '/');
|
|
|
381f6c |
+ char *tmpname;
|
|
|
381f6c |
+ size_t len;
|
|
|
381f6c |
+ int fd;
|
|
|
381f6c |
+
|
|
|
381f6c |
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ /* We could have foo/bar\\baz, or foo\\bar, or d:bar. */
|
|
|
381f6c |
+ char *bslash = strrchr (path, '\\');
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (slash == NULL || (bslash != NULL && bslash > slash))
|
|
|
381f6c |
+ slash = bslash;
|
|
|
381f6c |
+ if (slash == NULL && path[0] != '\0' && path[1] == ':')
|
|
|
381f6c |
+ slash = path + 1;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+#endif
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (slash != (char *) NULL)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ len = slash - path;
|
|
|
381f6c |
+ tmpname = (char *) xmalloc (len + sizeof (template) + 2);
|
|
|
381f6c |
+ memcpy (tmpname, path, len);
|
|
|
381f6c |
+
|
|
|
381f6c |
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
|
|
|
381f6c |
+ /* If tmpname is "X:", appending a slash will make it a root
|
|
|
381f6c |
+ directory on drive X, which is NOT the same as the current
|
|
|
381f6c |
+ directory on drive X. */
|
|
|
381f6c |
+ if (len == 2 && tmpname[1] == ':')
|
|
|
381f6c |
+ tmpname[len++] = '.';
|
|
|
381f6c |
+#endif
|
|
|
381f6c |
+ tmpname[len++] = '/';
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ else
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ tmpname = (char *) xmalloc (sizeof (template));
|
|
|
381f6c |
+ len = 0;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ memcpy (tmpname + len, template, sizeof (template));
|
|
|
381f6c |
+#undef template
|
|
|
381f6c |
+
|
|
|
381f6c |
+#ifdef HAVE_MKSTEMP
|
|
|
381f6c |
+ fd = mkstemp (tmpname);
|
|
|
381f6c |
+#else
|
|
|
381f6c |
+ tmpname = mktemp (tmpname);
|
|
|
381f6c |
+ if (tmpname == NULL)
|
|
|
381f6c |
+ return NULL;
|
|
|
381f6c |
+ fd = open (tmpname, O_RDWR | O_CREAT | O_EXCL, 0600);
|
|
|
381f6c |
+#endif
|
|
|
381f6c |
+ if (fd == -1)
|
|
|
381f6c |
+ return NULL;
|
|
|
381f6c |
+ return bfd_fopen (tmpname, target, mode, fd);
|
|
|
381f6c |
+}
|
|
|
381f6c |
+
|
|
|
381f6c |
+/* Add the object-only section. */
|
|
|
381f6c |
+
|
|
|
381f6c |
+static void
|
|
|
381f6c |
+cmdline_add_object_only_section (bfd_byte *contents, size_t size)
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ bfd_vma start;
|
|
|
381f6c |
+ flagword flags;
|
|
|
381f6c |
+ enum bfd_architecture iarch;
|
|
|
381f6c |
+ unsigned int imach;
|
|
|
381f6c |
+ long symcount;
|
|
|
381f6c |
+ long symsize;
|
|
|
381f6c |
+ asymbol **isympp = NULL;
|
|
|
381f6c |
+ asymbol **osympp = NULL;
|
|
|
381f6c |
+ bfd *obfd = NULL, *ibfd;
|
|
|
381f6c |
+ const char *err;
|
|
|
381f6c |
+ struct arg
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ bfd *obfd;
|
|
|
381f6c |
+ asymbol **isympp;
|
|
|
381f6c |
+ int status;
|
|
|
381f6c |
+ } arg;
|
|
|
381f6c |
+ char **matching;
|
|
|
381f6c |
+ char *ofilename = NULL;
|
|
|
381f6c |
+ asection *sec;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ ibfd = bfd_openr (output_filename, output_target);
|
|
|
381f6c |
+ if (!ibfd)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = bfd_errmsg (bfd_get_error ());
|
|
|
381f6c |
+ goto loser;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (!bfd_check_format_matches (ibfd, bfd_object, &matching))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = bfd_errmsg (bfd_get_error ());
|
|
|
381f6c |
+ goto loser;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ obfd = cmdline_fopen_temp (output_filename, output_target, "w");
|
|
|
381f6c |
+ if (!obfd)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = bfd_errmsg (bfd_get_error ());
|
|
|
381f6c |
+ goto loser;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ /* To be used after bfd_close (). */
|
|
|
381f6c |
+ ofilename = xstrdup (bfd_get_filename (obfd));
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (!bfd_set_format (obfd, bfd_object))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = bfd_errmsg (bfd_get_error ());
|
|
|
381f6c |
+ goto loser;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Copy the start address, flags and architecture of input file to
|
|
|
381f6c |
+ output file. */
|
|
|
381f6c |
+ flags = bfd_get_file_flags (ibfd);
|
|
|
381f6c |
+ start = bfd_get_start_address (ibfd);
|
|
|
381f6c |
+ iarch = bfd_get_arch (ibfd);
|
|
|
381f6c |
+ imach = bfd_get_mach (ibfd);
|
|
|
381f6c |
+ if (!bfd_set_start_address (obfd, start)
|
|
|
381f6c |
+ || !bfd_set_file_flags (obfd, flags)
|
|
|
381f6c |
+ || !bfd_set_arch_mach (obfd, iarch, imach))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = bfd_errmsg (bfd_get_error ());
|
|
|
381f6c |
+ goto loser;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ symsize = bfd_get_symtab_upper_bound (ibfd);
|
|
|
381f6c |
+ if (symsize < 0)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = bfd_errmsg (bfd_get_error ());
|
|
|
381f6c |
+ goto loser;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ isympp = (asymbol **) xmalloc (symsize);
|
|
|
381f6c |
+ symcount = bfd_canonicalize_symtab (ibfd, isympp);
|
|
|
381f6c |
+ if (symcount < 0)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = bfd_errmsg (bfd_get_error ());
|
|
|
381f6c |
+ goto loser;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ arg.obfd = obfd;
|
|
|
381f6c |
+ arg.isympp = isympp;
|
|
|
381f6c |
+ arg.status = 0;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* BFD mandates that all output sections be created and sizes set before
|
|
|
381f6c |
+ any output is done. Thus, we traverse all sections multiple times. */
|
|
|
381f6c |
+ bfd_map_over_sections (ibfd, setup_section, &arg;;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (arg.status)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = _("error setting up sections");
|
|
|
381f6c |
+ goto loser;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Allow the BFD backend to copy any private data it understands
|
|
|
381f6c |
+ from the input section to the output section. */
|
|
|
381f6c |
+ if (! bfd_copy_private_header_data (ibfd, obfd))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = _("error copying private header data");
|
|
|
381f6c |
+ goto loser;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Create the object-only section. */
|
|
|
381f6c |
+ sec = bfd_make_section_with_flags (obfd,
|
|
|
381f6c |
+ GNU_OBJECT_ONLY_SECTION_NAME,
|
|
|
381f6c |
+ (SEC_HAS_CONTENTS
|
|
|
381f6c |
+ | SEC_READONLY
|
|
|
381f6c |
+ | SEC_DATA
|
|
|
381f6c |
+ | SEC_LINKER_CREATED));
|
|
|
381f6c |
+ if (sec == NULL)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = _("can't create object-only section");
|
|
|
381f6c |
+ goto loser;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (! bfd_set_section_size (obfd, sec, size))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = _("can't set object-only section size");
|
|
|
381f6c |
+ goto loser;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (ibfd->object_only_section)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ /* Filter out the object-only section symbol. */
|
|
|
381f6c |
+ long src_count = 0, dst_count = 0;
|
|
|
381f6c |
+ asymbol **from, **to;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ osympp = (asymbol **) xmalloc (symcount * sizeof (asymbol *));
|
|
|
381f6c |
+ from = isympp;
|
|
|
381f6c |
+ to = osympp;
|
|
|
381f6c |
+ for (; src_count < symcount; src_count++)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ asymbol *sym = from[src_count];
|
|
|
381f6c |
+ if (bfd_get_section (sym) != ibfd->object_only_section)
|
|
|
381f6c |
+ to[dst_count++] = sym;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ to[dst_count] = NULL;
|
|
|
381f6c |
+ symcount = dst_count;
|
|
|
381f6c |
+ bfd_set_symtab (obfd, osympp, symcount);
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ else
|
|
|
381f6c |
+ bfd_set_symtab (obfd, isympp, symcount);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* This has to happen after the symbol table has been set. */
|
|
|
381f6c |
+ bfd_map_over_sections (ibfd, copy_section, &arg;;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (arg.status)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = _("error copying sections");
|
|
|
381f6c |
+ goto loser;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Copy the object-only section to the output. */
|
|
|
381f6c |
+ if (! bfd_set_section_contents (obfd, sec, contents, 0, size))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = _("error adding object-only section");
|
|
|
381f6c |
+ goto loser;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Allow the BFD backend to copy any private data it understands
|
|
|
381f6c |
+ from the input BFD to the output BFD. This is done last to
|
|
|
381f6c |
+ permit the routine to look at the filtered symbol table, which is
|
|
|
381f6c |
+ important for the ECOFF code at least. */
|
|
|
381f6c |
+ if (! bfd_copy_private_bfd_data (ibfd, obfd))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = _("error copying private BFD data");
|
|
|
381f6c |
+ goto loser;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (!bfd_close (obfd))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ unlink (ofilename);
|
|
|
381f6c |
+ einfo (_("%P%F: failed to finish output with object-only section\n"));
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Must be freed after bfd_close (). */
|
|
|
381f6c |
+ free (isympp);
|
|
|
381f6c |
+ if (osympp)
|
|
|
381f6c |
+ free (osympp);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (rename (ofilename, output_filename))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ unlink (ofilename);
|
|
|
381f6c |
+ einfo (_("%P%F: failed to rename output with object-only section\n"));
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ free (ofilename);
|
|
|
381f6c |
+ return;
|
|
|
381f6c |
+
|
|
|
381f6c |
+loser:
|
|
|
381f6c |
+ if (isympp)
|
|
|
381f6c |
+ free (isympp);
|
|
|
381f6c |
+ if (osympp)
|
|
|
381f6c |
+ free (osympp);
|
|
|
381f6c |
+ if (obfd)
|
|
|
381f6c |
+ bfd_close (obfd);
|
|
|
381f6c |
+ if (ofilename)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ unlink (ofilename);
|
|
|
381f6c |
+ free (ofilename);
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ einfo (_("%P%F: failed to add object-only section: %s\n"), err);
|
|
|
381f6c |
+}
|
|
|
381f6c |
+
|
|
|
381f6c |
+/* Emit the final output with object-only section. */
|
|
|
381f6c |
+
|
|
|
381f6c |
+void
|
|
|
381f6c |
+cmdline_emit_object_only_section (void)
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ const char *saved_output_filename = output_filename;
|
|
|
381f6c |
+ int fd;
|
|
|
381f6c |
+ size_t size, off;
|
|
|
381f6c |
+ bfd_byte *contents;
|
|
|
381f6c |
+ struct stat st;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Get a temporary object-only file. */
|
|
|
381f6c |
+ output_filename = make_temp_file (".obj-only.o");
|
|
|
381f6c |
+
|
|
|
381f6c |
+ had_output_filename = FALSE;
|
|
|
381f6c |
+ link_info.input_bfds = NULL;
|
|
|
381f6c |
+ link_info.input_bfds_tail = &link_info.input_bfds;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ lang_init (TRUE);
|
|
|
381f6c |
+ ldexp_init (TRUE);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ ld_parse_linker_script ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Set up the object-only output. */
|
|
|
381f6c |
+ lang_final ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Open the object-only file for output. */
|
|
|
381f6c |
+ lang_for_each_statement (ldlang_open_output);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ ldemul_create_output_section_statements ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (!bfd_section_already_linked_table_init ())
|
|
|
381f6c |
+ einfo (_("%P%F: Failed to create hash table\n"));
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Call cmdline_on_object_only_archive_list_p to check which member
|
|
|
381f6c |
+ should be loaded. */
|
|
|
381f6c |
+ input_flags.whole_archive = TRUE;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Set it to avoid adding more to cmdline lists. */
|
|
|
381f6c |
+ link_info.emitting_gnu_object_only = TRUE;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Get object-only input files. */
|
|
|
381f6c |
+ cmdline_get_object_only_input_files ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Open object-only input files. */
|
|
|
381f6c |
+ open_input_bfds (statement_list.head, FALSE);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ ldemul_after_open ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+ bfd_section_already_linked_table_free ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Make sure that we're not mixing architectures. We call this
|
|
|
381f6c |
+ after all the input files have been opened, but before we do any
|
|
|
381f6c |
+ other processing, so that any operations merge_private_bfd_data
|
|
|
381f6c |
+ does on the output file will be known during the rest of the
|
|
|
381f6c |
+ link. */
|
|
|
381f6c |
+ lang_check ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Size up the common data. */
|
|
|
381f6c |
+ lang_common ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Update wild statements. */
|
|
|
381f6c |
+ update_wild_statements (statement_list.head);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Run through the contours of the script and attach input sections
|
|
|
381f6c |
+ to the correct output sections. */
|
|
|
381f6c |
+ map_input_to_output_sections (statement_list.head, NULL, NULL);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Find any sections not attached explicitly and handle them. */
|
|
|
381f6c |
+ lang_place_orphans ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Do anything special before sizing sections. This is where ELF
|
|
|
381f6c |
+ and other back-ends size dynamic sections. */
|
|
|
381f6c |
+ ldemul_before_allocation ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Size up the sections. */
|
|
|
381f6c |
+ lang_size_sections (NULL, ! RELAXATION_ENABLED);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* See if anything special should be done now we know how big
|
|
|
381f6c |
+ everything is. This is where relaxation is done. */
|
|
|
381f6c |
+ ldemul_after_allocation ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+ ldemul_finish ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Make sure that the section addresses make sense. */
|
|
|
381f6c |
+ if (command_line.check_section_addresses)
|
|
|
381f6c |
+ lang_check_section_addresses ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+ lang_end ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+ ldwrite ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+ ldexp_finish (TRUE);
|
|
|
381f6c |
+ lang_finish ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (! bfd_close (link_info.output_bfd))
|
|
|
381f6c |
+ einfo (_("%P%F:%s: final close failed on object-only output: %E\n"),
|
|
|
381f6c |
+ output_filename);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Read in the object-only file. */
|
|
|
381f6c |
+ fd = open (output_filename, O_RDONLY | O_BINARY);
|
|
|
381f6c |
+ if (fd < 0)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ bfd_set_error (bfd_error_system_call);
|
|
|
381f6c |
+ einfo (_("%P%F:%s: cannot open object-only output: %E"),
|
|
|
381f6c |
+ output_filename);
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Get the object-only file size. */
|
|
|
381f6c |
+ if (fstat (fd, &st) != 0)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ bfd_set_error (bfd_error_system_call);
|
|
|
381f6c |
+ einfo (_("%P%F:%s: cannot stat object-only output: %E"),
|
|
|
381f6c |
+ output_filename);
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ size = st.st_size;
|
|
|
381f6c |
+ off = 0;
|
|
|
381f6c |
+ contents = (bfd_byte *) xmalloc (size);
|
|
|
381f6c |
+ while (off != size)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ ssize_t got;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ got = read (fd, contents + off, size - off);
|
|
|
381f6c |
+ if (got < 0)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ bfd_set_error (bfd_error_system_call);
|
|
|
381f6c |
+ einfo (_("%P%F:%s: read failed on object-only output: %E"),
|
|
|
381f6c |
+ output_filename);
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ off += got;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ close (fd);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Remove the temporary object-only file. */
|
|
|
381f6c |
+ unlink (output_filename);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ output_filename = saved_output_filename;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ cmdline_add_object_only_section (contents, size);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ free (contents);
|
|
|
381f6c |
+}
|
|
|
381f6c |
+
|
|
|
381f6c |
+/* Extract the object-only section. */
|
|
|
381f6c |
+
|
|
|
381f6c |
+static const char *
|
|
|
381f6c |
+cmdline_extract_object_only_section (bfd *abfd)
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ const char *name = bfd_extract_object_only_section (abfd);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (name == NULL)
|
|
|
381f6c |
+ einfo (_("%P%F: cannot extract object-only section from %B: %E"),
|
|
|
381f6c |
+ abfd);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* It should be removed after it is done. */
|
|
|
381f6c |
+ cmdline_list_append (&cmdline_temp_object_only_list,
|
|
|
381f6c |
+ cmdline_is_file_enum, (void *) name);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ return name;
|
|
|
381f6c |
+}
|
|
|
381f6c |
+
|
|
|
381f6c |
+/* Check and handle the object-only section. */
|
|
|
381f6c |
+
|
|
|
381f6c |
+void
|
|
|
381f6c |
+cmdline_check_object_only_section (bfd *abfd, bfd_boolean lto)
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ const char *filename;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (link_info.emitting_gnu_object_only
|
|
|
381f6c |
+ || abfd->format != bfd_object)
|
|
|
381f6c |
+ return;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (lto)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ /* For LTO link, we only need to extract object-only section
|
|
|
381f6c |
+ from the mixed object, add it to input, and put it on LTO
|
|
|
381f6c |
+ claimed output. */
|
|
|
381f6c |
+ switch (abfd->lto_type)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ default:
|
|
|
381f6c |
+ abort ();
|
|
|
381f6c |
+ case lto_mixed_object:
|
|
|
381f6c |
+ filename = cmdline_extract_object_only_section (abfd);
|
|
|
381f6c |
+ lang_add_input_file (filename,
|
|
|
381f6c |
+ lang_input_file_is_file_enum, NULL);
|
|
|
381f6c |
+ break;
|
|
|
381f6c |
+ case lto_non_ir_object:
|
|
|
381f6c |
+ case lto_ir_object:
|
|
|
381f6c |
+ break;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ else if (bfd_link_relocatable (&link_info))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ /* For non-LTO relocatable link, we need to append non-IR object
|
|
|
381f6c |
+ file and the object file in object-only section to the object
|
|
|
381f6c |
+ only list. */
|
|
|
381f6c |
+ switch (abfd->lto_type)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ default:
|
|
|
381f6c |
+ abort ();
|
|
|
381f6c |
+ case lto_mixed_object:
|
|
|
381f6c |
+ filename = cmdline_extract_object_only_section (abfd);
|
|
|
381f6c |
+ cmdline_object_only_list_append (cmdline_is_file_enum,
|
|
|
381f6c |
+ (void *) filename);
|
|
|
381f6c |
+ break;
|
|
|
381f6c |
+ case lto_non_ir_object:
|
|
|
381f6c |
+ cmdline_object_only_list_append (cmdline_is_bfd_enum, abfd);
|
|
|
381f6c |
+ break;
|
|
|
381f6c |
+ case lto_ir_object:
|
|
|
381f6c |
+ break;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+}
|
|
|
381f6c |
+
|
|
|
381f6c |
+/* Remove temporary object-only files. */
|
|
|
381f6c |
+
|
|
|
381f6c |
+void
|
|
|
381f6c |
+cmdline_remove_object_only_files (void)
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ cmdline_union_type *c;
|
|
|
381f6c |
+
|
|
|
381f6c |
+#ifdef ENABLE_PLUGINS
|
|
|
381f6c |
+ if (plugin_save_temps)
|
|
|
381f6c |
+ return;
|
|
|
381f6c |
+#endif
|
|
|
381f6c |
+
|
|
|
381f6c |
+ c = cmdline_temp_object_only_list.head;
|
|
|
381f6c |
+ for (; c != NULL; c = c->header.next)
|
|
|
381f6c |
+ switch (c->header.type)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ default:
|
|
|
381f6c |
+ abort ();
|
|
|
381f6c |
+ case cmdline_is_file_enum:
|
|
|
381f6c |
+ unlink (c->file.filename);
|
|
|
381f6c |
+ break;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+}
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/ldlang.h binutils-2.26/ld/ldlang.h
|
|
|
381f6c |
--- binutils-2.26.orig/ld/ldlang.h 2016-02-19 09:35:36.701003291 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/ldlang.h 2016-02-19 09:35:54.921106611 +0000
|
|
|
381f6c |
@@ -517,7 +517,7 @@ extern struct asneeded_minfo **asneeded_
|
|
|
381f6c |
extern void (*output_bfd_hash_table_free_fn) (struct bfd_link_hash_table *);
|
|
|
381f6c |
|
|
|
381f6c |
extern void lang_init
|
|
|
381f6c |
- (void);
|
|
|
381f6c |
+ (bfd_boolean);
|
|
|
381f6c |
extern void lang_finish
|
|
|
381f6c |
(void);
|
|
|
381f6c |
extern lang_memory_region_type * lang_memory_region_lookup
|
|
|
381f6c |
@@ -693,7 +693,48 @@ lang_ld_feature (char *);
|
|
|
381f6c |
extern void
|
|
|
381f6c |
lang_print_memory_usage (void);
|
|
|
381f6c |
|
|
|
381f6c |
extern void
|
|
|
381f6c |
lang_add_gc_name (const char *);
|
|
|
381f6c |
|
|
|
381f6c |
+typedef enum
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ cmdline_is_file_enum,
|
|
|
381f6c |
+ cmdline_is_bfd_enum
|
|
|
381f6c |
+} cmdline_enum_type;
|
|
|
381f6c |
+
|
|
|
381f6c |
+typedef struct cmdline_header_struct
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ union cmdline_union *next;
|
|
|
381f6c |
+ cmdline_enum_type type;
|
|
|
381f6c |
+} cmdline_header_type;
|
|
|
381f6c |
+
|
|
|
381f6c |
+typedef struct cmdline_file_struct
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ cmdline_header_type header;
|
|
|
381f6c |
+ const char *filename;
|
|
|
381f6c |
+} cmdline_file_type;
|
|
|
381f6c |
+
|
|
|
381f6c |
+typedef struct cmdline_bfd_struct
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ cmdline_header_type header;
|
|
|
381f6c |
+ bfd *abfd;
|
|
|
381f6c |
+} cmdline_bfd_type;
|
|
|
381f6c |
+
|
|
|
381f6c |
+typedef union cmdline_union
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ cmdline_header_type header;
|
|
|
381f6c |
+ cmdline_file_type file;
|
|
|
381f6c |
+ cmdline_bfd_type abfd;
|
|
|
381f6c |
+} cmdline_union_type;
|
|
|
381f6c |
+
|
|
|
381f6c |
+typedef struct cmdline_list
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ cmdline_union_type *head;
|
|
|
381f6c |
+ cmdline_union_type **tail;
|
|
|
381f6c |
+} cmdline_list_type;
|
|
|
381f6c |
+
|
|
|
381f6c |
+extern void cmdline_emit_object_only_section (void);
|
|
|
381f6c |
+extern void cmdline_check_object_only_section (bfd *, bfd_boolean);
|
|
|
381f6c |
+extern void cmdline_remove_object_only_files (void);
|
|
|
381f6c |
+
|
|
|
381f6c |
#endif
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/ldlex.h binutils-2.26/ld/ldlex.h
|
|
|
381f6c |
--- binutils-2.26.orig/ld/ldlex.h 2016-02-19 09:35:36.701003291 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/ldlex.h 2016-02-19 09:35:54.921106611 +0000
|
|
|
381f6c |
@@ -134,6 +134,7 @@ enum option_values
|
|
|
381f6c |
#ifdef ENABLE_PLUGINS
|
|
|
381f6c |
OPTION_PLUGIN,
|
|
|
381f6c |
OPTION_PLUGIN_OPT,
|
|
|
381f6c |
+ OPTION_PLUGIN_SAVE_TEMPS,
|
|
|
381f6c |
#endif /* ENABLE_PLUGINS */
|
|
|
381f6c |
OPTION_DEFAULT_SCRIPT,
|
|
|
381f6c |
OPTION_PRINT_OUTPUT_FORMAT,
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/ldmain.c binutils-2.26/ld/ldmain.c
|
|
|
381f6c |
--- binutils-2.26.orig/ld/ldmain.c 2016-02-19 09:35:36.701003291 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/ldmain.c 2016-02-19 09:35:54.922106617 +0000
|
|
|
381f6c |
@@ -219,6 +219,9 @@ main (int argc, char **argv)
|
|
|
381f6c |
|
|
|
381f6c |
xatexit (ld_cleanup);
|
|
|
381f6c |
|
|
|
381f6c |
+ /* Remove temporary object-only files. */
|
|
|
381f6c |
+ xatexit (cmdline_remove_object_only_files);
|
|
|
381f6c |
+
|
|
|
381f6c |
/* Set up the sysroot directory. */
|
|
|
381f6c |
ld_sysroot = get_sysroot (argc, argv);
|
|
|
381f6c |
if (*ld_sysroot)
|
|
|
381f6c |
@@ -291,8 +294,8 @@ main (int argc, char **argv)
|
|
|
381f6c |
default_target = ldemul_choose_target (argc, argv);
|
|
|
381f6c |
config.maxpagesize = bfd_emul_get_maxpagesize (default_target);
|
|
|
381f6c |
config.commonpagesize = bfd_emul_get_commonpagesize (default_target);
|
|
|
381f6c |
- lang_init ();
|
|
|
381f6c |
- ldexp_init ();
|
|
|
381f6c |
+ lang_init (FALSE);
|
|
|
381f6c |
+ ldexp_init (FALSE);
|
|
|
381f6c |
ldemul_before_parse ();
|
|
|
381f6c |
lang_has_input_file = FALSE;
|
|
|
381f6c |
parse_args (argc, argv);
|
|
|
381f6c |
@@ -307,34 +310,7 @@ main (int argc, char **argv)
|
|
|
381f6c |
|
|
|
381f6c |
ldemul_set_symbols ();
|
|
|
381f6c |
|
|
|
381f6c |
- /* If we have not already opened and parsed a linker script,
|
|
|
381f6c |
- try the default script from command line first. */
|
|
|
381f6c |
- if (saved_script_handle == NULL
|
|
|
381f6c |
- && command_line.default_script != NULL)
|
|
|
381f6c |
- {
|
|
|
381f6c |
- ldfile_open_command_file (command_line.default_script);
|
|
|
381f6c |
- parser_input = input_script;
|
|
|
381f6c |
- yyparse ();
|
|
|
381f6c |
- }
|
|
|
381f6c |
-
|
|
|
381f6c |
- /* If we have not already opened and parsed a linker script
|
|
|
381f6c |
- read the emulation's appropriate default script. */
|
|
|
381f6c |
- if (saved_script_handle == NULL)
|
|
|
381f6c |
- {
|
|
|
381f6c |
- int isfile;
|
|
|
381f6c |
- char *s = ldemul_get_script (&isfile);
|
|
|
381f6c |
-
|
|
|
381f6c |
- if (isfile)
|
|
|
381f6c |
- ldfile_open_default_command_file (s);
|
|
|
381f6c |
- else
|
|
|
381f6c |
- {
|
|
|
381f6c |
- lex_string = s;
|
|
|
381f6c |
- lex_redirect (s, _("built in linker script"), 1);
|
|
|
381f6c |
- }
|
|
|
381f6c |
- parser_input = input_script;
|
|
|
381f6c |
- yyparse ();
|
|
|
381f6c |
- lex_string = NULL;
|
|
|
381f6c |
- }
|
|
|
381f6c |
+ ld_parse_linker_script ();
|
|
|
381f6c |
|
|
|
381f6c |
if (verbose)
|
|
|
381f6c |
{
|
|
|
381f6c |
@@ -445,7 +421,7 @@ main (int argc, char **argv)
|
|
|
381f6c |
fprintf (stderr, "lookup = %p val %lx\n", h, h ? h->u.def.value : 1);
|
|
|
381f6c |
}
|
|
|
381f6c |
#endif
|
|
|
381f6c |
- ldexp_finish ();
|
|
|
381f6c |
+ ldexp_finish (FALSE);
|
|
|
381f6c |
lang_finish ();
|
|
|
381f6c |
|
|
|
381f6c |
/* Even if we're producing relocatable output, some non-fatal errors should
|
|
|
381f6c |
@@ -465,6 +441,8 @@ main (int argc, char **argv)
|
|
|
381f6c |
if (!bfd_close (link_info.output_bfd))
|
|
|
381f6c |
einfo (_("%F%B: final close failed: %E\n"), link_info.output_bfd);
|
|
|
381f6c |
|
|
|
381f6c |
+ link_info.output_bfd = NULL;
|
|
|
381f6c |
+
|
|
|
381f6c |
/* If the --force-exe-suffix is enabled, and we're making an
|
|
|
381f6c |
executable file and it doesn't end in .exe, copy it to one
|
|
|
381f6c |
which does. */
|
|
|
381f6c |
@@ -512,6 +490,9 @@ main (int argc, char **argv)
|
|
|
381f6c |
}
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
+ if (link_info.emit_gnu_object_only)
|
|
|
381f6c |
+ cmdline_emit_object_only_section ();
|
|
|
381f6c |
+
|
|
|
381f6c |
END_PROGRESS (program_name);
|
|
|
381f6c |
|
|
|
381f6c |
if (config.stats)
|
|
|
381f6c |
@@ -805,7 +786,9 @@ add_archive_element (struct bfd_link_inf
|
|
|
381f6c |
*subsbfd = input->the_bfd;
|
|
|
381f6c |
}
|
|
|
381f6c |
}
|
|
|
381f6c |
+ else
|
|
|
381f6c |
#endif /* ENABLE_PLUGINS */
|
|
|
381f6c |
+ cmdline_check_object_only_section (input->the_bfd, FALSE);
|
|
|
381f6c |
|
|
|
381f6c |
ldlang_add_file (input);
|
|
|
381f6c |
|
|
|
381f6c |
@@ -1484,3 +1467,38 @@ notice (struct bfd_link_info *info,
|
|
|
381f6c |
|
|
|
381f6c |
return TRUE;
|
|
|
381f6c |
}
|
|
|
381f6c |
+
|
|
|
381f6c |
+/* Parse the linker script. */
|
|
|
381f6c |
+
|
|
|
381f6c |
+void
|
|
|
381f6c |
+ld_parse_linker_script ()
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ /* If we have not already opened and parsed a linker script,
|
|
|
381f6c |
+ try the default script from command line first. */
|
|
|
381f6c |
+ if (saved_script_handle == NULL
|
|
|
381f6c |
+ && command_line.default_script != NULL)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ ldfile_open_command_file (command_line.default_script);
|
|
|
381f6c |
+ parser_input = input_script;
|
|
|
381f6c |
+ yyparse ();
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* If we have not already opened and parsed a linker script
|
|
|
381f6c |
+ read the emulation's appropriate default script. */
|
|
|
381f6c |
+ if (saved_script_handle == NULL)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ int isfile;
|
|
|
381f6c |
+ char *s = ldemul_get_script (&isfile);
|
|
|
381f6c |
+
|
|
|
381f6c |
+ if (isfile)
|
|
|
381f6c |
+ ldfile_open_default_command_file (s);
|
|
|
381f6c |
+ else
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ lex_string = s;
|
|
|
381f6c |
+ lex_redirect (s, _("built in linker script"), 1);
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+ parser_input = input_script;
|
|
|
381f6c |
+ yyparse ();
|
|
|
381f6c |
+ lex_string = NULL;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+}
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/ldmain.h binutils-2.26/ld/ldmain.h
|
|
|
381f6c |
--- binutils-2.26.orig/ld/ldmain.h 2016-02-19 09:35:36.701003291 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/ldmain.h 2016-02-19 09:35:54.922106617 +0000
|
|
|
381f6c |
@@ -59,4 +59,6 @@ extern void add_wrap (const char *);
|
|
|
381f6c |
extern void add_ignoresym (struct bfd_link_info *, const char *);
|
|
|
381f6c |
extern void add_keepsyms_file (const char *);
|
|
|
381f6c |
|
|
|
381f6c |
+extern void ld_parse_linker_script (void);
|
|
|
381f6c |
+
|
|
|
381f6c |
#endif
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/lexsup.c binutils-2.26/ld/lexsup.c
|
|
|
381f6c |
--- binutils-2.26.orig/ld/lexsup.c 2016-02-19 09:35:36.700003285 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/lexsup.c 2016-02-19 09:35:54.923106623 +0000
|
|
|
381f6c |
@@ -169,6 +169,9 @@ static const struct ld_option ld_options
|
|
|
381f6c |
'\0', N_("PLUGIN"), N_("Load named plugin"), ONE_DASH },
|
|
|
381f6c |
{ {"plugin-opt", required_argument, NULL, OPTION_PLUGIN_OPT},
|
|
|
381f6c |
'\0', N_("ARG"), N_("Send arg to last-loaded plugin"), ONE_DASH },
|
|
|
381f6c |
+ { {"plugin-save-temps", no_argument, NULL, OPTION_PLUGIN_SAVE_TEMPS},
|
|
|
381f6c |
+ '\0', NULL, N_("Store plugin intermediate files permanently"),
|
|
|
381f6c |
+ ONE_DASH },
|
|
|
381f6c |
{ {"flto", optional_argument, NULL, OPTION_IGNORE},
|
|
|
381f6c |
'\0', NULL, N_("Ignored for GCC LTO option compatibility"),
|
|
|
381f6c |
ONE_DASH },
|
|
|
381f6c |
@@ -1020,6 +1023,9 @@ parse_args (unsigned argc, char **argv)
|
|
|
381f6c |
if (plugin_opt_plugin_arg (optarg))
|
|
|
381f6c |
einfo (_("%P%F: bad -plugin-opt option\n"));
|
|
|
381f6c |
break;
|
|
|
381f6c |
+ case OPTION_PLUGIN_SAVE_TEMPS:
|
|
|
381f6c |
+ plugin_save_temps = TRUE;
|
|
|
381f6c |
+ break;
|
|
|
381f6c |
#endif /* ENABLE_PLUGINS */
|
|
|
381f6c |
case 'q':
|
|
|
381f6c |
link_info.emitrelocations = TRUE;
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/plugin.c binutils-2.26/ld/plugin.c
|
|
|
381f6c |
--- binutils-2.26.orig/ld/plugin.c 2016-02-19 09:35:36.702003296 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/plugin.c 2016-02-19 09:35:54.923106623 +0000
|
|
|
381f6c |
@@ -57,6 +57,9 @@ extern int errno;
|
|
|
381f6c |
/* Report plugin symbols. */
|
|
|
381f6c |
bfd_boolean report_plugin_symbols;
|
|
|
381f6c |
|
|
|
381f6c |
+/* Store plugin intermediate files permanently. */
|
|
|
381f6c |
+bfd_boolean plugin_save_temps;
|
|
|
381f6c |
+
|
|
|
381f6c |
/* The suffix to append to the name of the real (claimed) object file
|
|
|
381f6c |
when generating a dummy BFD to hold the IR symbols sent from the
|
|
|
381f6c |
plugin. For cosmetic use only; appears in maps, crefs etc. */
|
|
|
381f6c |
@@ -1182,6 +1185,9 @@ plugin_maybe_claim (lang_input_statement
|
|
|
381f6c |
{
|
|
|
381f6c |
bfd *abfd = entry->the_bfd->plugin_dummy_bfd;
|
|
|
381f6c |
|
|
|
381f6c |
+ /* Check object only section. */
|
|
|
381f6c |
+ cmdline_check_object_only_section (entry->the_bfd, TRUE);
|
|
|
381f6c |
+
|
|
|
381f6c |
/* Discard the real file's BFD and substitute the dummy one. */
|
|
|
381f6c |
|
|
|
381f6c |
/* We can't call bfd_close on archives. BFD archive handling
|
|
|
381f6c |
@@ -1227,14 +1233,17 @@ plugin_call_cleanup (void)
|
|
|
381f6c |
{
|
|
|
381f6c |
if (curplug->cleanup_handler && !curplug->cleanup_done)
|
|
|
381f6c |
{
|
|
|
381f6c |
- enum ld_plugin_status rv;
|
|
|
381f6c |
- curplug->cleanup_done = TRUE;
|
|
|
381f6c |
- called_plugin = curplug;
|
|
|
381f6c |
- rv = (*curplug->cleanup_handler) ();
|
|
|
381f6c |
- called_plugin = NULL;
|
|
|
381f6c |
- if (rv != LDPS_OK)
|
|
|
381f6c |
- info_msg (_("%P: %s: error in plugin cleanup: %d (ignored)\n"),
|
|
|
381f6c |
- curplug->name, rv);
|
|
|
381f6c |
+ if (!plugin_save_temps)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ enum ld_plugin_status rv;
|
|
|
381f6c |
+ curplug->cleanup_done = TRUE;
|
|
|
381f6c |
+ called_plugin = curplug;
|
|
|
381f6c |
+ rv = (*curplug->cleanup_handler) ();
|
|
|
381f6c |
+ called_plugin = NULL;
|
|
|
381f6c |
+ if (rv != LDPS_OK)
|
|
|
381f6c |
+ info_msg (_("%P: %s: error in plugin cleanup: %d (ignored)\n"),
|
|
|
381f6c |
+ curplug->name, rv);
|
|
|
381f6c |
+ }
|
|
|
381f6c |
dlclose (curplug->dlhandle);
|
|
|
381f6c |
}
|
|
|
381f6c |
curplug = curplug->next;
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/plugin.h binutils-2.26/ld/plugin.h
|
|
|
381f6c |
--- binutils-2.26.orig/ld/plugin.h 2016-02-19 09:35:36.702003296 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/plugin.h 2016-02-19 09:35:54.924106628 +0000
|
|
|
381f6c |
@@ -24,6 +24,9 @@
|
|
|
381f6c |
/* Report plugin symbols. */
|
|
|
381f6c |
extern bfd_boolean report_plugin_symbols;
|
|
|
381f6c |
|
|
|
381f6c |
+/* Store plugin intermediate files permanently. */
|
|
|
381f6c |
+extern bfd_boolean plugin_save_temps;
|
|
|
381f6c |
+
|
|
|
381f6c |
/* Set at all symbols read time, to avoid recursively offering the plugin
|
|
|
381f6c |
its own newly-added input files and libs to claim. */
|
|
|
381f6c |
extern bfd_boolean no_more_claiming;
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/scripttempl/armbpabi.sc binutils-2.26/ld/scripttempl/armbpabi.sc
|
|
|
381f6c |
--- binutils-2.26.orig/ld/scripttempl/armbpabi.sc 2016-02-19 09:35:36.704003308 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/scripttempl/armbpabi.sc 2016-02-19 09:35:54.924106628 +0000
|
|
|
381f6c |
@@ -36,7 +36,7 @@ INTERP=".interp 0 : { *(.interp) }
|
|
|
381f6c |
PLT=".plt ${RELOCATING-0} : { *(.plt) }"
|
|
|
381f6c |
RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
|
|
|
381f6c |
DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }"
|
|
|
381f6c |
-DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }"
|
|
|
381f6c |
+DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
|
|
|
381f6c |
if test -z "${NO_SMALL_DATA}"; then
|
|
|
381f6c |
SBSS=".sbss ${RELOCATING-0} :
|
|
|
381f6c |
{
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/scripttempl/elf32sh-symbian.sc binutils-2.26/ld/scripttempl/elf32sh-symbian.sc
|
|
|
381f6c |
--- binutils-2.26.orig/ld/scripttempl/elf32sh-symbian.sc 2016-02-19 09:35:36.705003313 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/scripttempl/elf32sh-symbian.sc 2016-02-19 09:35:54.925106634 +0000
|
|
|
381f6c |
@@ -88,7 +88,7 @@ fi
|
|
|
381f6c |
PLT=".plt : { *(.plt) } :dynamic :dyn"
|
|
|
381f6c |
DYNAMIC=".dynamic : { *(.dynamic) } :dynamic :dyn"
|
|
|
381f6c |
RODATA=".rodata ALIGN(4) : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
|
|
|
381f6c |
-DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.directive) *(.gnu.lto_*) }"
|
|
|
381f6c |
+DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.directive) *(.gnu.lto_*) *(.gnu_object_only) }"
|
|
|
381f6c |
test -z "$GOT" && GOT=".got ${RELOCATING-0} : { *(.got.plt) *(.got) } :dynamic :dyn"
|
|
|
381f6c |
INIT_ARRAY=".init_array ${RELOCATING-0} :
|
|
|
381f6c |
{
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/scripttempl/elf64hppa.sc binutils-2.26/ld/scripttempl/elf64hppa.sc
|
|
|
381f6c |
--- binutils-2.26.orig/ld/scripttempl/elf64hppa.sc 2016-02-19 09:35:36.705003313 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/scripttempl/elf64hppa.sc 2016-02-19 09:35:54.925106634 +0000
|
|
|
381f6c |
@@ -132,7 +132,7 @@ fi
|
|
|
381f6c |
DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
|
|
|
381f6c |
RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
|
|
|
381f6c |
DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
|
|
|
381f6c |
-DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }"
|
|
|
381f6c |
+DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
|
|
|
381f6c |
if test -z "${NO_SMALL_DATA}"; then
|
|
|
381f6c |
SBSS=".sbss ${RELOCATING-0} :
|
|
|
381f6c |
{
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/scripttempl/elf.sc binutils-2.26/ld/scripttempl/elf.sc
|
|
|
381f6c |
--- binutils-2.26.orig/ld/scripttempl/elf.sc 2016-02-19 09:35:36.705003313 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/scripttempl/elf.sc 2016-02-19 09:35:54.924106628 +0000
|
|
|
381f6c |
@@ -170,7 +170,7 @@ RELA_IPLT=".rela.iplt ${RELOCATING-0}
|
|
|
381f6c |
DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
|
|
|
381f6c |
RODATA=".${RODATA_NAME} ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }"
|
|
|
381f6c |
DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
|
|
|
381f6c |
-DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }"
|
|
|
381f6c |
+DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
|
|
|
381f6c |
if test -z "${NO_SMALL_DATA}"; then
|
|
|
381f6c |
SBSS=".${SBSS_NAME} ${RELOCATING-0} :
|
|
|
381f6c |
{
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/scripttempl/elfxtensa.sc binutils-2.26/ld/scripttempl/elfxtensa.sc
|
|
|
381f6c |
--- binutils-2.26.orig/ld/scripttempl/elfxtensa.sc 2016-02-19 09:35:36.705003313 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/scripttempl/elfxtensa.sc 2016-02-19 09:35:54.925106634 +0000
|
|
|
381f6c |
@@ -145,7 +145,7 @@ fi
|
|
|
381f6c |
DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
|
|
|
381f6c |
RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
|
|
|
381f6c |
DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
|
|
|
381f6c |
-DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }"
|
|
|
381f6c |
+DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
|
|
|
381f6c |
INIT_LIT=".init.literal 0 : { *(.init.literal) }"
|
|
|
381f6c |
INIT=".init 0 : { *(.init) }"
|
|
|
381f6c |
FINI_LIT=".fini.literal 0 : { *(.fini.literal) }"
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/scripttempl/mep.sc binutils-2.26/ld/scripttempl/mep.sc
|
|
|
381f6c |
--- binutils-2.26.orig/ld/scripttempl/mep.sc 2016-02-19 09:35:36.706003319 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/scripttempl/mep.sc 2016-02-19 09:35:54.926106640 +0000
|
|
|
381f6c |
@@ -119,7 +119,7 @@ fi
|
|
|
381f6c |
DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }"
|
|
|
381f6c |
RODATA=".rodata ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
|
|
|
381f6c |
DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }"
|
|
|
381f6c |
-DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }"
|
|
|
381f6c |
+DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
|
|
|
381f6c |
if test -z "${NO_SMALL_DATA}"; then
|
|
|
381f6c |
SBSS=".sbss ${RELOCATING-0} :
|
|
|
381f6c |
{
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/scripttempl/pep.sc binutils-2.26/ld/scripttempl/pep.sc
|
|
|
381f6c |
--- binutils-2.26.orig/ld/scripttempl/pep.sc 2016-02-19 09:35:36.706003319 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/scripttempl/pep.sc 2016-02-19 09:35:54.926106640 +0000
|
|
|
381f6c |
@@ -178,6 +178,7 @@ SECTIONS
|
|
|
381f6c |
*(.drectve)
|
|
|
381f6c |
${RELOCATING+ *(.note.GNU-stack)}
|
|
|
381f6c |
${RELOCATING+ *(.gnu.lto_*)}
|
|
|
381f6c |
+ ${RELOCATING+ *(.gnu_object_only)}
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
.idata ${RELOCATING+BLOCK(__section_alignment__)} :
|
|
|
381f6c |
diff -rup binutils-2.26.orig/ld/scripttempl/pe.sc binutils-2.26/ld/scripttempl/pe.sc
|
|
|
381f6c |
--- binutils-2.26.orig/ld/scripttempl/pe.sc 2016-02-19 09:35:36.706003319 +0000
|
|
|
381f6c |
+++ binutils-2.26/ld/scripttempl/pe.sc 2016-02-19 09:35:54.926106640 +0000
|
|
|
381f6c |
@@ -165,6 +165,7 @@ SECTIONS
|
|
|
381f6c |
*(.drectve)
|
|
|
381f6c |
${RELOCATING+ *(.note.GNU-stack)}
|
|
|
381f6c |
${RELOCATING+ *(.gnu.lto_*)}
|
|
|
381f6c |
+ ${RELOCATING+ *(.gnu_object_only)}
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
.idata ${RELOCATING+BLOCK(__section_alignment__)} :
|
|
|
381f6c |
--- binutils.orig/bfd/bfd-in2.h 2017-03-02 11:14:48.572979573 +0000
|
|
|
381f6c |
+++ binutils-2.28/bfd/bfd-in2.h 2017-03-02 11:21:39.828458555 +0000
|
|
|
381f6c |
@@ -1118,6 +1118,9 @@ bfd_boolean bfd_fill_in_gnu_debuglink_se
|
|
|
381f6c |
|
|
|
381f6c |
char *bfd_follow_build_id_debuglink (bfd *abfd, const char *dir);
|
|
|
381f6c |
|
|
|
381f6c |
+const char *bfd_extract_object_only_section
|
|
|
381f6c |
+ (bfd *abfd);
|
|
|
381f6c |
+
|
|
|
381f6c |
/* Extracted from libbfd.c. */
|
|
|
381f6c |
|
|
|
381f6c |
/* Byte swapping macros for user section data. */
|
|
|
381f6c |
--- binutils.orig/bfd/opncls.c 2017-03-02 11:14:48.586979385 +0000
|
|
|
381f6c |
+++ binutils-2.28/bfd/opncls.c 2017-03-02 11:23:23.546065945 +0000
|
|
|
381f6c |
@@ -1990,3 +1990,69 @@ bfd_follow_build_id_debuglink (bfd *abfd
|
|
|
381f6c |
get_build_id_name,
|
|
|
381f6c |
check_build_id_file, &build_id);
|
|
|
381f6c |
}
|
|
|
381f6c |
+
|
|
|
381f6c |
+/*
|
|
|
381f6c |
+FUNCTION
|
|
|
381f6c |
+ bfd_extract_object_only_section
|
|
|
381f6c |
+
|
|
|
381f6c |
+SYNOPSIS
|
|
|
381f6c |
+ const char *bfd_extract_object_only_section
|
|
|
381f6c |
+ (bfd *abfd);
|
|
|
381f6c |
+
|
|
|
381f6c |
+DESCRIPTION
|
|
|
381f6c |
+
|
|
|
381f6c |
+ Takes a @var{ABFD} and extract the .gnu_object_only section into
|
|
|
381f6c |
+ a temporary file.
|
|
|
381f6c |
+
|
|
|
381f6c |
+RETURNS
|
|
|
381f6c |
+ The name of the temporary file is returned if all is ok.
|
|
|
381f6c |
+ Otherwise <<NULL>> is returned and bfd_error is set.
|
|
|
381f6c |
+*/
|
|
|
381f6c |
+
|
|
|
381f6c |
+const char *
|
|
|
381f6c |
+bfd_extract_object_only_section (bfd *abfd)
|
|
|
381f6c |
+{
|
|
|
381f6c |
+ asection *sec = abfd->object_only_section;
|
|
|
381f6c |
+ const char *name;
|
|
|
381f6c |
+ FILE *file;
|
|
|
381f6c |
+ bfd_byte *memhunk = NULL;
|
|
|
381f6c |
+ size_t off, size;
|
|
|
381f6c |
+ bfd_error_type err;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Get a temporary object-only file. */
|
|
|
381f6c |
+ name = make_temp_file (".obj-only.o");
|
|
|
381f6c |
+
|
|
|
381f6c |
+ /* Open the object-only file. */
|
|
|
381f6c |
+ file = _bfd_real_fopen (name, FOPEN_WB);
|
|
|
381f6c |
+ if (!bfd_get_full_section_contents (abfd, sec, &memhunk))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = bfd_get_error ();
|
|
|
381f6c |
+
|
|
|
381f6c |
+loser:
|
|
|
381f6c |
+ free (memhunk);
|
|
|
381f6c |
+ fclose (file);
|
|
|
381f6c |
+ unlink (name);
|
|
|
381f6c |
+ bfd_set_error (err);
|
|
|
381f6c |
+ return NULL;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ off = 0;
|
|
|
381f6c |
+ size = sec->size;
|
|
|
381f6c |
+ while (off != size)
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ size_t written, nwrite = size - off;
|
|
|
381f6c |
+
|
|
|
381f6c |
+ written = fwrite (memhunk + off, 1, nwrite, file);
|
|
|
381f6c |
+ if (written < nwrite && ferror (file))
|
|
|
381f6c |
+ {
|
|
|
381f6c |
+ err = bfd_error_system_call;
|
|
|
381f6c |
+ goto loser;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ off += written;
|
|
|
381f6c |
+ }
|
|
|
381f6c |
+
|
|
|
381f6c |
+ free (memhunk);
|
|
|
381f6c |
+ fclose (file);
|
|
|
381f6c |
+ return name;
|
|
|
381f6c |
+}
|
|
|
381f6c |
--- binutils.orig/bfd/plugin.c 2017-03-02 11:37:31.572677260 +0000
|
|
|
381f6c |
+++ binutils-2.28/bfd/plugin.c 2017-03-02 11:40:35.246209573 +0000
|
|
|
381f6c |
@@ -132,10 +132,10 @@ register_claim_file (ld_plugin_claim_fil
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
static asection bfd_plugin_fake_text_section
|
|
|
381f6c |
- = BFD_FAKE_SECTION (bfd_plugin_fake_text_section, 0, 0, ".text", 0);
|
|
|
381f6c |
+= BFD_FAKE_SECTION (bfd_plugin_fake_text_section, 0, ".text", 0, 0);
|
|
|
381f6c |
static asection bfd_plugin_fake_common_section
|
|
|
381f6c |
- = BFD_FAKE_SECTION (bfd_plugin_fake_common_section, SEC_IS_COMMON, 0,
|
|
|
381f6c |
- NULL, 0);
|
|
|
381f6c |
+ = BFD_FAKE_SECTION (bfd_plugin_fake_common_section, 0,
|
|
|
381f6c |
+ NULL, 0, SEC_IS_COMMON);
|
|
|
381f6c |
|
|
|
381f6c |
/* Get symbols from object only section. */
|
|
|
381f6c |
|
|
|
381f6c |
--- binutils.orig/ld/emultempl/armelf.em 2017-03-02 11:58:14.632981042 +0000
|
|
|
381f6c |
+++ binutils-2.28/ld/emultempl/armelf.em 2017-03-02 12:00:55.663819055 +0000
|
|
|
381f6c |
@@ -414,7 +414,7 @@ gld${EMULATION_NAME}_after_allocation (v
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
static void
|
|
|
381f6c |
-gld${EMULATION_NAME}_finish (void)
|
|
|
381f6c |
+arm_finish (void)
|
|
|
381f6c |
{
|
|
|
381f6c |
struct bfd_link_hash_entry * h;
|
|
|
381f6c |
|
|
|
381f6c |
@@ -441,7 +441,7 @@ gld${EMULATION_NAME}_finish (void)
|
|
|
381f6c |
}
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
- finish_default ();
|
|
|
381f6c |
+ gld${EMULATION_NAME}_finish ();
|
|
|
381f6c |
|
|
|
381f6c |
if (params.thumb_entry_symbol)
|
|
|
381f6c |
{
|
|
|
381f6c |
@@ -790,4 +790,4 @@ LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME
|
|
|
381f6c |
LDEMUL_SET_SYMBOLS=gld"${EMULATION_NAME}"_set_symbols
|
|
|
381f6c |
|
|
|
381f6c |
# Call the extra arm-elf function
|
|
|
381f6c |
-LDEMUL_FINISH=gld${EMULATION_NAME}_finish
|
|
|
381f6c |
+LDEMUL_FINISH=arm_finish
|
|
|
381f6c |
--- binutils.orig/ld/emultempl/ppc64elf.em 2017-03-02 11:58:14.632981042 +0000
|
|
|
381f6c |
+++ binutils-2.28/ld/emultempl/ppc64elf.em 2017-03-02 12:01:40.961210895 +0000
|
|
|
381f6c |
@@ -561,7 +561,7 @@ gld${EMULATION_NAME}_after_allocation (v
|
|
|
381f6c |
/* Final emulation specific call. */
|
|
|
381f6c |
|
|
|
381f6c |
static void
|
|
|
381f6c |
-gld${EMULATION_NAME}_finish (void)
|
|
|
381f6c |
+ppc_finish (void)
|
|
|
381f6c |
{
|
|
|
381f6c |
char *msg = NULL;
|
|
|
381f6c |
char *line, *endline;
|
|
|
381f6c |
@@ -592,7 +592,7 @@ gld${EMULATION_NAME}_finish (void)
|
|
|
381f6c |
if (msg != NULL)
|
|
|
381f6c |
free (msg);
|
|
|
381f6c |
|
|
|
381f6c |
- finish_default ();
|
|
|
381f6c |
+ gld${EMULATION_NAME}_finish ();
|
|
|
381f6c |
}
|
|
|
381f6c |
|
|
|
381f6c |
|
|
|
381f6c |
@@ -926,4 +926,4 @@ LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=
|
|
|
381f6c |
LDEMUL_AFTER_OPEN=ppc_after_open
|
|
|
381f6c |
LDEMUL_BEFORE_ALLOCATION=ppc_before_allocation
|
|
|
381f6c |
LDEMUL_AFTER_ALLOCATION=gld${EMULATION_NAME}_after_allocation
|
|
|
381f6c |
-LDEMUL_FINISH=gld${EMULATION_NAME}_finish
|
|
|
381f6c |
+LDEMUL_FINISH=ppc_finish
|
|
|
381f6c |
--- binutils.orig/bfd/format.c 2018-01-22 16:04:36.855155517 +0000
|
|
|
381f6c |
+++ binutils-2.30.0/bfd/format.c 2018-01-22 16:11:36.546253154 +0000
|
|
|
381f6c |
@@ -47,6 +47,7 @@ SUBSECTION
|
|
|
381f6c |
#include "bfd.h"
|
|
|
381f6c |
#include "libbfd.h"
|
|
|
381f6c |
#if BFD_SUPPORTS_PLUGINS
|
|
|
381f6c |
+#include "plugin-api.h"
|
|
|
381f6c |
#include "plugin.h"
|
|
|
381f6c |
#endif
|
|
|
381f6c |
|
|
|
381f6c |
--- binutils.orig/ld/ldlang.c 2018-01-22 16:04:37.271150658 +0000
|
|
|
381f6c |
+++ binutils-2.30.0/ld/ldlang.c 2018-01-22 16:14:10.653453040 +0000
|
|
|
381f6c |
@@ -8954,6 +8954,7 @@ cmdline_object_only_list_append (cmdline
|
|
|
381f6c |
archive = abfd->my_archive;
|
|
|
381f6c |
if (archive)
|
|
|
381f6c |
break;
|
|
|
381f6c |
+ /* Fall through. */
|
|
|
381f6c |
case cmdline_is_file_enum:
|
|
|
381f6c |
cmdline_list_append (&cmdline_object_only_file_list, type, data);
|
|
|
381f6c |
return;
|