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