|
|
7db648 |
diff -rup binutils.orig/binutils/doc/binutils.texi binutils-2.30/binutils/doc/binutils.texi
|
|
|
7db648 |
--- binutils.orig/binutils/doc/binutils.texi 2020-04-07 16:11:52.164358203 +0100
|
|
|
7db648 |
+++ binutils-2.30/binutils/doc/binutils.texi 2020-04-07 16:14:37.759171936 +0100
|
|
|
7db648 |
@@ -1586,7 +1586,9 @@ recognized names are @samp{alloc}, @samp
|
|
|
7db648 |
for a section which does not have contents, but it is not meaningful
|
|
|
7db648 |
to clear the @samp{contents} flag of a section which does have
|
|
|
7db648 |
contents--just remove the section instead. Not all flags are
|
|
|
7db648 |
-meaningful for all object file formats.
|
|
|
7db648 |
+meaningful for all object file formats. In particular the
|
|
|
7db648 |
+@samp{share} flag is only meaningful for COFF format files and not for
|
|
|
7db648 |
+ELF format files.
|
|
|
7db648 |
|
|
|
7db648 |
@item --add-section @var{sectionname}=@var{filename}
|
|
|
7db648 |
Add a new section named @var{sectionname} while copying the file. The
|
|
|
7db648 |
@@ -1637,7 +1639,8 @@ Rename a section from @var{oldname} to @
|
|
|
7db648 |
changing the section's flags to @var{flags} in the process. This has
|
|
|
7db648 |
the advantage over using a linker script to perform the rename in that
|
|
|
7db648 |
the output stays as an object file and does not become a linked
|
|
|
7db648 |
-executable.
|
|
|
7db648 |
+executable. This option accepts the same set of flags as the
|
|
|
7db648 |
+@option{--sect-section-flags} option.
|
|
|
7db648 |
|
|
|
7db648 |
This option is particularly helpful when the input format is binary,
|
|
|
7db648 |
since this will always create a section called .data. If for example,
|
|
|
7db648 |
diff -rup binutils.orig/binutils/objcopy.c binutils-2.30/binutils/objcopy.c
|
|
|
7db648 |
--- binutils.orig/binutils/objcopy.c 2020-04-07 16:11:52.177358110 +0100
|
|
|
7db648 |
+++ binutils-2.30/binutils/objcopy.c 2020-04-07 16:16:15.736470047 +0100
|
|
|
7db648 |
@@ -2514,6 +2514,23 @@ merge_gnu_build_notes (bfd * ab
|
|
|
7db648 |
return size;
|
|
|
7db648 |
}
|
|
|
7db648 |
|
|
|
7db648 |
+static flagword
|
|
|
7db648 |
+check_new_section_flags (flagword flags, bfd * abfd, const char * secname)
|
|
|
7db648 |
+{
|
|
|
7db648 |
+ /* Only set the SEC_COFF_SHARED flag on COFF files.
|
|
|
7db648 |
+ The same bit value is used by ELF targets to indicate
|
|
|
7db648 |
+ compressed sections, and setting that flag here breaks
|
|
|
7db648 |
+ things. */
|
|
|
7db648 |
+ if ((flags & SEC_COFF_SHARED)
|
|
|
7db648 |
+ && bfd_get_flavour (abfd) != bfd_target_coff_flavour)
|
|
|
7db648 |
+ {
|
|
|
7db648 |
+ non_fatal (_("%s[%s]: Note - dropping 'share' flag as output format is not COFF"),
|
|
|
7db648 |
+ bfd_get_filename (abfd), secname);
|
|
|
7db648 |
+ flags &= ~ SEC_COFF_SHARED;
|
|
|
7db648 |
+ }
|
|
|
7db648 |
+ return flags;
|
|
|
7db648 |
+}
|
|
|
7db648 |
+
|
|
|
7db648 |
/* Copy object file IBFD onto OBFD.
|
|
|
7db648 |
Returns TRUE upon success, FALSE otherwise. */
|
|
|
7db648 |
|
|
|
7db648 |
@@ -2755,7 +2772,10 @@ copy_object (bfd *ibfd, bfd *obfd, const
|
|
|
7db648 |
pset = find_section_list (padd->name, FALSE,
|
|
|
7db648 |
SECTION_CONTEXT_SET_FLAGS);
|
|
|
7db648 |
if (pset != NULL)
|
|
|
7db648 |
- flags = pset->flags | SEC_HAS_CONTENTS;
|
|
|
7db648 |
+ {
|
|
|
7db648 |
+ flags = pset->flags | SEC_HAS_CONTENTS;
|
|
|
7db648 |
+ flags = check_new_section_flags (flags, obfd, padd->name);
|
|
|
7db648 |
+ }
|
|
|
7db648 |
else
|
|
|
7db648 |
flags = SEC_HAS_CONTENTS | SEC_READONLY | SEC_DATA;
|
|
|
7db648 |
|
|
|
7db648 |
@@ -3867,6 +3887,7 @@ setup_section (bfd *ibfd, sec_ptr isecti
|
|
|
7db648 |
flagword flags;
|
|
|
7db648 |
const char *err;
|
|
|
7db648 |
const char * name;
|
|
|
7db648 |
+ const char * new_name;
|
|
|
7db648 |
char *prefix = NULL;
|
|
|
7db648 |
bfd_boolean make_nobits;
|
|
|
7db648 |
|
|
|
7db648 |
@@ -3876,7 +3897,12 @@ setup_section (bfd *ibfd, sec_ptr isecti
|
|
|
7db648 |
/* Get the, possibly new, name of the output section. */
|
|
|
7db648 |
name = bfd_section_name (ibfd, isection);
|
|
|
7db648 |
flags = bfd_get_section_flags (ibfd, isection);
|
|
|
7db648 |
- name = find_section_rename (name, &flags);
|
|
|
7db648 |
+ new_name = find_section_rename (name, &flags);
|
|
|
7db648 |
+ if (new_name != name)
|
|
|
7db648 |
+ {
|
|
|
7db648 |
+ name = new_name;
|
|
|
7db648 |
+ flags = check_new_section_flags (flags, obfd, name);
|
|
|
7db648 |
+ }
|
|
|
7db648 |
|
|
|
7db648 |
/* Prefix sections. */
|
|
|
7db648 |
if ((prefix_alloc_sections_string)
|
|
|
7db648 |
@@ -3900,7 +3926,10 @@ setup_section (bfd *ibfd, sec_ptr isecti
|
|
|
7db648 |
p = find_section_list (bfd_section_name (ibfd, isection), FALSE,
|
|
|
7db648 |
SECTION_CONTEXT_SET_FLAGS);
|
|
|
7db648 |
if (p != NULL)
|
|
|
7db648 |
- flags = p->flags | (flags & (SEC_HAS_CONTENTS | SEC_RELOC));
|
|
|
7db648 |
+ {
|
|
|
7db648 |
+ flags = p->flags | (flags & (SEC_HAS_CONTENTS | SEC_RELOC));
|
|
|
7db648 |
+ flags = check_new_section_flags (flags, obfd, bfd_section_name (ibfd, isection));
|
|
|
7db648 |
+ }
|
|
|
7db648 |
else if (strip_symbols == STRIP_NONDEBUG
|
|
|
7db648 |
&& (flags & (SEC_ALLOC | SEC_GROUP)) != 0
|
|
|
7db648 |
&& !is_nondebug_keep_contents_section (ibfd, isection))
|