|
|
13ae24 |
diff -rup binutils.orig/binutils/readelf.c binutils-2.30/binutils/readelf.c
|
|
|
13ae24 |
--- binutils.orig/binutils/readelf.c 2018-04-26 15:14:17.220464639 +0100
|
|
|
13ae24 |
+++ binutils-2.30/binutils/readelf.c 2018-04-26 15:14:31.927287474 +0100
|
|
|
13ae24 |
@@ -12294,7 +12294,8 @@ is_32bit_abs_reloc (Filedata * filedata,
|
|
|
13ae24 |
case EM_OR1K:
|
|
|
13ae24 |
return reloc_type == 1; /* R_OR1K_32. */
|
|
|
13ae24 |
case EM_PARISC:
|
|
|
13ae24 |
- return (reloc_type == 1 /* R_PARISC_DIR32. */
|
|
|
13ae24 |
+ return (reloc_type == 1 /* R_PARISC_DIR32. */
|
|
|
13ae24 |
+ || reloc_type == 2 /* R_PARISC_DIR21L. */
|
|
|
13ae24 |
|| reloc_type == 41); /* R_PARISC_SECREL32. */
|
|
|
13ae24 |
case EM_PJ:
|
|
|
13ae24 |
case EM_PJ_OLD:
|
|
|
13ae24 |
Only in binutils-2.30/binutils: readelf.c.orig
|
|
|
13ae24 |
diff -rup binutils.orig/binutils/testsuite/binutils-all/objcopy.exp binutils-2.30/binutils/testsuite/binutils-all/objcopy.exp
|
|
|
13ae24 |
--- binutils.orig/binutils/testsuite/binutils-all/objcopy.exp 2018-04-26 15:14:17.215464699 +0100
|
|
|
13ae24 |
+++ binutils-2.30/binutils/testsuite/binutils-all/objcopy.exp 2018-04-26 15:14:31.927287474 +0100
|
|
|
13ae24 |
@@ -1062,6 +1062,7 @@ if [is_elf_format] {
|
|
|
13ae24 |
run_dump_test "note-3-32"
|
|
|
13ae24 |
run_dump_test "note-4-32"
|
|
|
13ae24 |
}
|
|
|
13ae24 |
+ run_dump_test "note-5"
|
|
|
13ae24 |
}
|
|
|
13ae24 |
|
|
|
13ae24 |
run_dump_test "copy-2"
|
|
|
13ae24 |
Only in binutils-2.30/binutils/testsuite/binutils-all: objcopy.exp.orig
|
|
|
13ae24 |
diff -rup binutils.orig/gas/as.c binutils-2.30/gas/as.c
|
|
|
13ae24 |
--- binutils.orig/gas/as.c 2018-04-26 15:14:17.646459507 +0100
|
|
|
13ae24 |
+++ binutils-2.30/gas/as.c 2018-04-26 15:14:31.927287474 +0100
|
|
|
13ae24 |
@@ -97,6 +97,7 @@ int verbose = 0;
|
|
|
13ae24 |
|
|
|
13ae24 |
#if defined OBJ_ELF || defined OBJ_MAYBE_ELF
|
|
|
13ae24 |
int flag_use_elf_stt_common = DEFAULT_GENERATE_ELF_STT_COMMON;
|
|
|
13ae24 |
+bfd_boolean flag_generate_build_notes = DEFAULT_GENERATE_BUILD_NOTES;
|
|
|
13ae24 |
#endif
|
|
|
13ae24 |
|
|
|
13ae24 |
/* Keep the output file. */
|
|
|
13ae24 |
@@ -304,8 +305,19 @@ Options:\n\
|
|
|
13ae24 |
generate ELF common symbols with STT_COMMON type\n"));
|
|
|
13ae24 |
fprintf (stream, _("\
|
|
|
13ae24 |
--sectname-subst enable section name substitution sequences\n"));
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ fprintf (stream, _("\
|
|
|
13ae24 |
+ --generate-missing-build-notes=[no|yes] "));
|
|
|
13ae24 |
+#if DEFAULT_GENERATE_BUILD_NOTES
|
|
|
13ae24 |
+ fprintf (stream, _("(default: yes)\n"));
|
|
|
13ae24 |
+#else
|
|
|
13ae24 |
+ fprintf (stream, _("(default: no)\n"));
|
|
|
13ae24 |
#endif
|
|
|
13ae24 |
fprintf (stream, _("\
|
|
|
13ae24 |
+ generate GNU Build notes if none are present in the input\n"));
|
|
|
13ae24 |
+#endif /* OBJ_ELF */
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ fprintf (stream, _("\
|
|
|
13ae24 |
-f skip whitespace and comment preprocessing\n"));
|
|
|
13ae24 |
fprintf (stream, _("\
|
|
|
13ae24 |
-g --gen-debug generate debugging information\n"));
|
|
|
13ae24 |
@@ -470,6 +482,7 @@ parse_args (int * pargc, char *** pargv)
|
|
|
13ae24 |
OPTION_NOEXECSTACK,
|
|
|
13ae24 |
OPTION_SIZE_CHECK,
|
|
|
13ae24 |
OPTION_ELF_STT_COMMON,
|
|
|
13ae24 |
+ OPTION_ELF_BUILD_NOTES,
|
|
|
13ae24 |
OPTION_SECTNAME_SUBST,
|
|
|
13ae24 |
OPTION_ALTERNATE,
|
|
|
13ae24 |
OPTION_AL,
|
|
|
13ae24 |
@@ -508,6 +521,7 @@ parse_args (int * pargc, char *** pargv)
|
|
|
13ae24 |
,{"size-check", required_argument, NULL, OPTION_SIZE_CHECK}
|
|
|
13ae24 |
,{"elf-stt-common", required_argument, NULL, OPTION_ELF_STT_COMMON}
|
|
|
13ae24 |
,{"sectname-subst", no_argument, NULL, OPTION_SECTNAME_SUBST}
|
|
|
13ae24 |
+ ,{"generate-missing-build-notes", required_argument, NULL, OPTION_ELF_BUILD_NOTES}
|
|
|
13ae24 |
#endif
|
|
|
13ae24 |
,{"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL}
|
|
|
13ae24 |
,{"gdwarf-2", no_argument, NULL, OPTION_GDWARF2}
|
|
|
13ae24 |
@@ -900,7 +914,19 @@ This program has absolutely no warranty.
|
|
|
13ae24 |
case OPTION_SECTNAME_SUBST:
|
|
|
13ae24 |
flag_sectname_subst = 1;
|
|
|
13ae24 |
break;
|
|
|
13ae24 |
-#endif
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ case OPTION_ELF_BUILD_NOTES:
|
|
|
13ae24 |
+ if (strcasecmp (optarg, "no") == 0)
|
|
|
13ae24 |
+ flag_generate_build_notes = FALSE;
|
|
|
13ae24 |
+ else if (strcasecmp (optarg, "yes") == 0)
|
|
|
13ae24 |
+ flag_generate_build_notes = TRUE;
|
|
|
13ae24 |
+ else
|
|
|
13ae24 |
+ as_fatal (_("Invalid --generate-missing-build-notes option: `%s'"),
|
|
|
13ae24 |
+ optarg);
|
|
|
13ae24 |
+ break;
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+#endif /* OBJ_ELF */
|
|
|
13ae24 |
+
|
|
|
13ae24 |
case 'Z':
|
|
|
13ae24 |
flag_always_generate_output = 1;
|
|
|
13ae24 |
break;
|
|
|
13ae24 |
diff -rup binutils.orig/gas/as.h binutils-2.30/gas/as.h
|
|
|
13ae24 |
--- binutils.orig/gas/as.h 2018-04-26 15:14:17.654459410 +0100
|
|
|
13ae24 |
+++ binutils-2.30/gas/as.h 2018-04-26 15:14:31.927287474 +0100
|
|
|
13ae24 |
@@ -585,6 +585,10 @@ COMMON int flag_allow_nonconst_size;
|
|
|
13ae24 |
/* If we should generate ELF common symbols with the STT_COMMON type. */
|
|
|
13ae24 |
extern int flag_use_elf_stt_common;
|
|
|
13ae24 |
|
|
|
13ae24 |
+/* TRUE iff GNU Build attribute notes should
|
|
|
13ae24 |
+ be generated if none are in the input files. */
|
|
|
13ae24 |
+extern bfd_boolean flag_generate_build_notes;
|
|
|
13ae24 |
+
|
|
|
13ae24 |
/* If section name substitution sequences should be honored */
|
|
|
13ae24 |
COMMON int flag_sectname_subst;
|
|
|
13ae24 |
#endif
|
|
|
13ae24 |
Only in binutils-2.30/gas: as.h.orig
|
|
|
13ae24 |
diff -rup binutils.orig/gas/config.in binutils-2.30/gas/config.in
|
|
|
13ae24 |
--- binutils.orig/gas/config.in 2018-04-26 15:14:17.645459519 +0100
|
|
|
13ae24 |
+++ binutils-2.30/gas/config.in 2018-04-26 15:14:31.927287474 +0100
|
|
|
13ae24 |
@@ -39,6 +39,10 @@
|
|
|
13ae24 |
/* Define if you want compressed debug sections by default. */
|
|
|
13ae24 |
#undef DEFAULT_FLAG_COMPRESS_DEBUG
|
|
|
13ae24 |
|
|
|
13ae24 |
+/* Define to 1 if you want to generate GNU Build attribute notes by default,
|
|
|
13ae24 |
+ if none are contained in the input. */
|
|
|
13ae24 |
+#undef DEFAULT_GENERATE_BUILD_NOTES
|
|
|
13ae24 |
+
|
|
|
13ae24 |
/* Define to 1 if you want to generate ELF common symbols with the STT_COMMON
|
|
|
13ae24 |
type by default. */
|
|
|
13ae24 |
#undef DEFAULT_GENERATE_ELF_STT_COMMON
|
|
|
13ae24 |
diff -rup binutils.orig/gas/configure binutils-2.30/gas/configure
|
|
|
13ae24 |
--- binutils.orig/gas/configure 2018-04-26 15:14:17.645459519 +0100
|
|
|
13ae24 |
+++ binutils-2.30/gas/configure 2018-04-26 15:14:31.928287462 +0100
|
|
|
13ae24 |
@@ -771,6 +771,7 @@ enable_checking
|
|
|
13ae24 |
enable_compressed_debug_sections
|
|
|
13ae24 |
enable_x86_relax_relocations
|
|
|
13ae24 |
enable_elf_stt_common
|
|
|
13ae24 |
+enable_generate_build_notes
|
|
|
13ae24 |
enable_werror
|
|
|
13ae24 |
enable_build_warnings
|
|
|
13ae24 |
with_cpu
|
|
|
13ae24 |
@@ -1426,6 +1427,9 @@ Optional Features:
|
|
|
13ae24 |
generate x86 relax relocations by default
|
|
|
13ae24 |
--enable-elf-stt-common generate ELF common symbols with STT_COMMON type by
|
|
|
13ae24 |
default
|
|
|
13ae24 |
+ --enable-generate-build-notes
|
|
|
13ae24 |
+ generate GNU Build notes if none are provided by the
|
|
|
13ae24 |
+ input
|
|
|
13ae24 |
--enable-werror treat compile warnings as errors
|
|
|
13ae24 |
--enable-build-warnings enable build-time compiler warnings
|
|
|
13ae24 |
--disable-nls do not use Native Language Support
|
|
|
13ae24 |
@@ -11011,7 +11015,7 @@ else
|
|
|
13ae24 |
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
|
|
13ae24 |
lt_status=$lt_dlunknown
|
|
|
13ae24 |
cat > conftest.$ac_ext <<_LT_EOF
|
|
|
13ae24 |
-#line 10990 "configure"
|
|
|
13ae24 |
+#line 10994 "configure"
|
|
|
13ae24 |
#include "confdefs.h"
|
|
|
13ae24 |
|
|
|
13ae24 |
#if HAVE_DLFCN_H
|
|
|
13ae24 |
@@ -11117,7 +11121,7 @@ else
|
|
|
13ae24 |
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
|
|
|
13ae24 |
lt_status=$lt_dlunknown
|
|
|
13ae24 |
cat > conftest.$ac_ext <<_LT_EOF
|
|
|
13ae24 |
-#line 11096 "configure"
|
|
|
13ae24 |
+#line 11100 "configure"
|
|
|
13ae24 |
#include "confdefs.h"
|
|
|
13ae24 |
|
|
|
13ae24 |
#if HAVE_DLFCN_H
|
|
|
13ae24 |
@@ -11771,6 +11775,20 @@ if test "${enable_elf_stt_common+set}" =
|
|
|
13ae24 |
esac
|
|
|
13ae24 |
fi
|
|
|
13ae24 |
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+# Decide if the ELF assembler should default to generating
|
|
|
13ae24 |
+# GNU Build notes if none are provided by the input.
|
|
|
13ae24 |
+ac_default_generate_build_notes=0
|
|
|
13ae24 |
+# Provide a configuration option to override the default.
|
|
|
13ae24 |
+# Check whether --enable-generate_build_notes was given.
|
|
|
13ae24 |
+if test "${enable_generate_build_notes+set}" = set; then :
|
|
|
13ae24 |
+ enableval=$enable_generate_build_notes; case "${enableval}" in
|
|
|
13ae24 |
+ yes) ac_default_generate_build_notes=1 ;;
|
|
|
13ae24 |
+ no) ac_default_generate_build_notes=0 ;;
|
|
|
13ae24 |
+esac
|
|
|
13ae24 |
+fi
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+
|
|
|
13ae24 |
using_cgen=no
|
|
|
13ae24 |
|
|
|
13ae24 |
|
|
|
13ae24 |
@@ -12713,6 +12731,12 @@ cat >>confdefs.h <<_ACEOF
|
|
|
13ae24 |
_ACEOF
|
|
|
13ae24 |
|
|
|
13ae24 |
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+cat >>confdefs.h <<_ACEOF
|
|
|
13ae24 |
+#define DEFAULT_GENERATE_BUILD_NOTES $ac_default_generate_build_notes
|
|
|
13ae24 |
+_ACEOF
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+
|
|
|
13ae24 |
if test x$ac_default_compressed_debug_sections = xyes ; then
|
|
|
13ae24 |
|
|
|
13ae24 |
$as_echo "#define DEFAULT_FLAG_COMPRESS_DEBUG 1" >>confdefs.h
|
|
|
13ae24 |
diff -rup binutils.orig/gas/configure.ac binutils-2.30/gas/configure.ac
|
|
|
13ae24 |
--- binutils.orig/gas/configure.ac 2018-04-26 15:14:17.645459519 +0100
|
|
|
13ae24 |
+++ binutils-2.30/gas/configure.ac 2018-04-26 15:14:31.928287462 +0100
|
|
|
13ae24 |
@@ -100,6 +100,20 @@ AC_ARG_ENABLE(elf_stt_common,
|
|
|
13ae24 |
yes) ac_default_elf_stt_common=1 ;;
|
|
|
13ae24 |
esac])dnl
|
|
|
13ae24 |
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+# Decide if the ELF assembler should default to generating
|
|
|
13ae24 |
+# GNU Build notes if none are provided by the input.
|
|
|
13ae24 |
+ac_default_generate_build_notes=0
|
|
|
13ae24 |
+# Provide a configuration option to override the default.
|
|
|
13ae24 |
+AC_ARG_ENABLE(generate_build_notes,
|
|
|
13ae24 |
+ AS_HELP_STRING([--enable-generate-build-notes],
|
|
|
13ae24 |
+ [generate GNU Build notes if none are provided by the input]),
|
|
|
13ae24 |
+[case "${enableval}" in
|
|
|
13ae24 |
+ yes) ac_default_generate_build_notes=1 ;;
|
|
|
13ae24 |
+ no) ac_default_generate_build_notes=0 ;;
|
|
|
13ae24 |
+esac])dnl
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+
|
|
|
13ae24 |
using_cgen=no
|
|
|
13ae24 |
|
|
|
13ae24 |
AM_BINUTILS_WARNINGS
|
|
|
13ae24 |
@@ -610,6 +624,11 @@ AC_DEFINE_UNQUOTED(DEFAULT_GENERATE_ELF_
|
|
|
13ae24 |
[Define to 1 if you want to generate ELF common symbols with the
|
|
|
13ae24 |
STT_COMMON type by default.])
|
|
|
13ae24 |
|
|
|
13ae24 |
+AC_DEFINE_UNQUOTED(DEFAULT_GENERATE_BUILD_NOTES,
|
|
|
13ae24 |
+ $ac_default_generate_build_notes,
|
|
|
13ae24 |
+ [Define to 1 if you want to generate GNU Build attribute notes
|
|
|
13ae24 |
+ by default, if none are contained in the input.])
|
|
|
13ae24 |
+
|
|
|
13ae24 |
if test x$ac_default_compressed_debug_sections = xyes ; then
|
|
|
13ae24 |
AC_DEFINE(DEFAULT_FLAG_COMPRESS_DEBUG, 1, [Define if you want compressed debug sections by default.])
|
|
|
13ae24 |
fi
|
|
|
13ae24 |
Only in binutils-2.30/gas: configure.ac.orig
|
|
|
13ae24 |
Only in binutils-2.30/gas: configure.orig
|
|
|
13ae24 |
diff -rup binutils.orig/gas/doc/as.texinfo binutils-2.30/gas/doc/as.texinfo
|
|
|
13ae24 |
--- binutils.orig/gas/doc/as.texinfo 2018-04-26 15:14:17.665459278 +0100
|
|
|
13ae24 |
+++ binutils-2.30/gas/doc/as.texinfo 2018-04-26 15:14:31.929287450 +0100
|
|
|
13ae24 |
@@ -244,6 +244,7 @@ gcc(1), ld(1), and the Info entries for
|
|
|
13ae24 |
[@b{-Z}] [@b{@@@var{FILE}}]
|
|
|
13ae24 |
[@b{--sectname-subst}] [@b{--size-check=[error|warning]}]
|
|
|
13ae24 |
[@b{--elf-stt-common=[no|yes]}]
|
|
|
13ae24 |
+ [@b{--generate-missing-build-notes=[no|yes]}]
|
|
|
13ae24 |
[@b{--target-help}] [@var{target-options}]
|
|
|
13ae24 |
[@b{--}|@var{files} @dots{}]
|
|
|
13ae24 |
@c
|
|
|
13ae24 |
@@ -754,6 +755,14 @@ Issue an error or warning for invalid EL
|
|
|
13ae24 |
These options control whether the ELF assembler should generate common
|
|
|
13ae24 |
symbols with the @code{STT_COMMON} type. The default can be controlled
|
|
|
13ae24 |
by a configure option @option{--enable-elf-stt-common}.
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+@item --generate-missing-build-notes=yes
|
|
|
13ae24 |
+@itemx --generate-missing-build-notes=no
|
|
|
13ae24 |
+These options control whether the ELF assembler should generate GNU Build
|
|
|
13ae24 |
+attribute notes if none are present in the input sources.
|
|
|
13ae24 |
+The default can be controlled by the @option{--enable-generate-build-notes}
|
|
|
13ae24 |
+configure option.
|
|
|
13ae24 |
+
|
|
|
13ae24 |
@end ifset
|
|
|
13ae24 |
|
|
|
13ae24 |
@item --help
|
|
|
13ae24 |
Only in binutils-2.30/gas/doc: as.texinfo.orig
|
|
|
13ae24 |
diff -rup binutils.orig/gas/NEWS binutils-2.30/gas/NEWS
|
|
|
13ae24 |
--- binutils.orig/gas/NEWS 2018-04-26 15:14:17.646459507 +0100
|
|
|
13ae24 |
+++ binutils-2.30/gas/NEWS 2018-04-26 15:15:32.276560482 +0100
|
|
|
13ae24 |
@@ -1,5 +1,11 @@
|
|
|
13ae24 |
-*- text -*-
|
|
|
13ae24 |
|
|
|
13ae24 |
+* Add --generate-missing-build-notes=[yes|no] option to create (or not) GNU
|
|
|
13ae24 |
+ Build Attribute notes if none are present in the input sources. Add a
|
|
|
13ae24 |
+ --enable-generate-build-notes=[yes|no] configure time option to set the
|
|
|
13ae24 |
+ default behaviour. Set the default if the configure option is not used
|
|
|
13ae24 |
+ to "no".
|
|
|
13ae24 |
+
|
|
|
13ae24 |
Changes in 2.30:
|
|
|
13ae24 |
|
|
|
13ae24 |
* Add support for loaction views in DWARF debug line information.
|
|
|
13ae24 |
Only in binutils-2.30/gas: NEWS.orig
|
|
|
13ae24 |
Only in binutils-2.30/gas: NEWS.rej
|
|
|
13ae24 |
diff -rup binutils.orig/gas/symbols.c binutils-2.30/gas/symbols.c
|
|
|
13ae24 |
--- binutils.orig/gas/symbols.c 2018-04-26 15:14:17.667459254 +0100
|
|
|
13ae24 |
+++ binutils-2.30/gas/symbols.c 2018-04-26 15:14:31.929287450 +0100
|
|
|
13ae24 |
@@ -108,6 +108,7 @@ save_symbol_name (const char *name)
|
|
|
13ae24 |
size_t name_length;
|
|
|
13ae24 |
char *ret;
|
|
|
13ae24 |
|
|
|
13ae24 |
+ gas_assert (name != NULL);
|
|
|
13ae24 |
name_length = strlen (name) + 1; /* +1 for \0. */
|
|
|
13ae24 |
obstack_grow (¬es, name, name_length);
|
|
|
13ae24 |
ret = (char *) obstack_finish (¬es);
|
|
|
13ae24 |
diff -rup binutils.orig/gas/write.c binutils-2.30/gas/write.c
|
|
|
13ae24 |
--- binutils.orig/gas/write.c 2018-04-26 15:14:18.296451677 +0100
|
|
|
13ae24 |
+++ binutils-2.30/gas/write.c 2018-04-26 15:14:31.929287450 +0100
|
|
|
13ae24 |
@@ -1822,25 +1822,200 @@ create_obj_attrs_section (void)
|
|
|
13ae24 |
const char *name;
|
|
|
13ae24 |
|
|
|
13ae24 |
size = bfd_elf_obj_attr_size (stdoutput);
|
|
|
13ae24 |
- if (size)
|
|
|
13ae24 |
+ if (size == 0)
|
|
|
13ae24 |
+ return;
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ name = get_elf_backend_data (stdoutput)->obj_attrs_section;
|
|
|
13ae24 |
+ if (!name)
|
|
|
13ae24 |
+ name = ".gnu.attributes";
|
|
|
13ae24 |
+ s = subseg_new (name, 0);
|
|
|
13ae24 |
+ elf_section_type (s)
|
|
|
13ae24 |
+ = get_elf_backend_data (stdoutput)->obj_attrs_section_type;
|
|
|
13ae24 |
+ bfd_set_section_flags (stdoutput, s, SEC_READONLY | SEC_DATA);
|
|
|
13ae24 |
+ frag_now_fix ();
|
|
|
13ae24 |
+ p = frag_more (size);
|
|
|
13ae24 |
+ bfd_elf_set_obj_attr_contents (stdoutput, (bfd_byte *)p, size);
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ subsegs_finish_section (s);
|
|
|
13ae24 |
+ relax_segment (seg_info (s)->frchainP->frch_root, s, 0);
|
|
|
13ae24 |
+ size_seg (stdoutput, s, NULL);
|
|
|
13ae24 |
+}
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+#include "struc-symbol.h"
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+/* Create a relocation against an entry in a GNU Build attribute section. */
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+static void
|
|
|
13ae24 |
+create_note_reloc (segT sec,
|
|
|
13ae24 |
+ symbolS * sym,
|
|
|
13ae24 |
+ bfd_size_type offset,
|
|
|
13ae24 |
+ int reloc_type,
|
|
|
13ae24 |
+ bfd_vma addend,
|
|
|
13ae24 |
+ char * note)
|
|
|
13ae24 |
+{
|
|
|
13ae24 |
+ struct reloc_list * reloc;
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ reloc = XNEW (struct reloc_list);
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ /* We create a .b type reloc as resolve_reloc_expr_symbols() has already been called. */
|
|
|
13ae24 |
+ reloc->u.b.sec = sec;
|
|
|
13ae24 |
+ reloc->u.b.s = sym->bsym;
|
|
|
13ae24 |
+ reloc->u.b.r.sym_ptr_ptr = & reloc->u.b.s;
|
|
|
13ae24 |
+ reloc->u.b.r.address = offset;
|
|
|
13ae24 |
+ reloc->u.b.r.addend = addend;
|
|
|
13ae24 |
+ reloc->u.b.r.howto = bfd_reloc_type_lookup (stdoutput, reloc_type);
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ if (reloc->u.b.r.howto == NULL)
|
|
|
13ae24 |
{
|
|
|
13ae24 |
- name = get_elf_backend_data (stdoutput)->obj_attrs_section;
|
|
|
13ae24 |
- if (!name)
|
|
|
13ae24 |
- name = ".gnu.attributes";
|
|
|
13ae24 |
- s = subseg_new (name, 0);
|
|
|
13ae24 |
- elf_section_type (s)
|
|
|
13ae24 |
- = get_elf_backend_data (stdoutput)->obj_attrs_section_type;
|
|
|
13ae24 |
- bfd_set_section_flags (stdoutput, s, SEC_READONLY | SEC_DATA);
|
|
|
13ae24 |
- frag_now_fix ();
|
|
|
13ae24 |
- p = frag_more (size);
|
|
|
13ae24 |
- bfd_elf_set_obj_attr_contents (stdoutput, (bfd_byte *)p, size);
|
|
|
13ae24 |
-
|
|
|
13ae24 |
- subsegs_finish_section (s);
|
|
|
13ae24 |
- relax_segment (seg_info (s)->frchainP->frch_root, s, 0);
|
|
|
13ae24 |
- size_seg (stdoutput, s, NULL);
|
|
|
13ae24 |
+ as_bad (_("unable to create reloc for build note"));
|
|
|
13ae24 |
+ return;
|
|
|
13ae24 |
+ }
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ reloc->file = N_("<gnu build note>");
|
|
|
13ae24 |
+ reloc->line = 0;
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ reloc->next = reloc_list;
|
|
|
13ae24 |
+ reloc_list = reloc;
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ /* For REL relocs, store the addend in the section. */
|
|
|
13ae24 |
+ if (! sec->use_rela_p
|
|
|
13ae24 |
+ /* The SH target is a special case that uses RELA relocs
|
|
|
13ae24 |
+ but still stores the addend in the word being relocated. */
|
|
|
13ae24 |
+ || strstr (bfd_get_target (stdoutput), "-sh") != NULL)
|
|
|
13ae24 |
+ {
|
|
|
13ae24 |
+ if (target_big_endian)
|
|
|
13ae24 |
+ {
|
|
|
13ae24 |
+ if (bfd_arch_bits_per_address (stdoutput) <= 32)
|
|
|
13ae24 |
+ note[offset + 3] = addend;
|
|
|
13ae24 |
+ else
|
|
|
13ae24 |
+ note[offset + 7] = addend;
|
|
|
13ae24 |
+ }
|
|
|
13ae24 |
+ else
|
|
|
13ae24 |
+ note[offset] = addend;
|
|
|
13ae24 |
}
|
|
|
13ae24 |
}
|
|
|
13ae24 |
-#endif
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+static void
|
|
|
13ae24 |
+maybe_generate_build_notes (void)
|
|
|
13ae24 |
+{
|
|
|
13ae24 |
+ segT sec;
|
|
|
13ae24 |
+ char * note;
|
|
|
13ae24 |
+ offsetT note_size;
|
|
|
13ae24 |
+ offsetT desc_size;
|
|
|
13ae24 |
+ offsetT desc2_offset;
|
|
|
13ae24 |
+ int desc_reloc;
|
|
|
13ae24 |
+ symbolS * sym;
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ if (! flag_generate_build_notes
|
|
|
13ae24 |
+ || bfd_get_section_by_name (stdoutput,
|
|
|
13ae24 |
+ GNU_BUILD_ATTRS_SECTION_NAME) != NULL)
|
|
|
13ae24 |
+ return;
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ /* Create a GNU Build Attribute section. */
|
|
|
13ae24 |
+ sec = subseg_new (GNU_BUILD_ATTRS_SECTION_NAME, FALSE);
|
|
|
13ae24 |
+ elf_section_type (sec) = SHT_NOTE;
|
|
|
13ae24 |
+ bfd_set_section_flags (stdoutput, sec,
|
|
|
13ae24 |
+ SEC_READONLY | SEC_HAS_CONTENTS | SEC_DATA);
|
|
|
13ae24 |
+ bfd_set_section_alignment (stdoutput, sec, 2);
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ /* Create a version note. */
|
|
|
13ae24 |
+ if (bfd_arch_bits_per_address (stdoutput) <= 32)
|
|
|
13ae24 |
+ {
|
|
|
13ae24 |
+ note_size = 28;
|
|
|
13ae24 |
+ desc_size = 8; /* Two 4-byte offsets. */
|
|
|
13ae24 |
+ desc2_offset = 24;
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ /* FIXME: The BFD backend for the CRX target does not support the
|
|
|
13ae24 |
+ BFD_RELOC_32, even though it really should. Likewise for the
|
|
|
13ae24 |
+ CR16 target. So we have special case code here... */
|
|
|
13ae24 |
+ if (strstr (bfd_get_target (stdoutput), "-crx") != NULL)
|
|
|
13ae24 |
+ desc_reloc = BFD_RELOC_CRX_NUM32;
|
|
|
13ae24 |
+ else if (strstr (bfd_get_target (stdoutput), "-cr16") != NULL)
|
|
|
13ae24 |
+ desc_reloc = BFD_RELOC_CR16_NUM32;
|
|
|
13ae24 |
+ else
|
|
|
13ae24 |
+ desc_reloc = BFD_RELOC_32;
|
|
|
13ae24 |
+ }
|
|
|
13ae24 |
+ else
|
|
|
13ae24 |
+ {
|
|
|
13ae24 |
+ note_size = 36;
|
|
|
13ae24 |
+ desc_size = 16; /* Two 8-byte offsets. */
|
|
|
13ae24 |
+ desc2_offset = 28;
|
|
|
13ae24 |
+ /* FIXME: The BFD backend for the IA64 target does not support the
|
|
|
13ae24 |
+ BFD_RELOC_64, even though it really should. The HPPA backend
|
|
|
13ae24 |
+ has a similar issue, although it does not support BFD_RELOCs at
|
|
|
13ae24 |
+ all! So we have special case code to handle these targets. */
|
|
|
13ae24 |
+ if (strstr (bfd_get_target (stdoutput), "-ia64") != NULL)
|
|
|
13ae24 |
+ desc_reloc = target_big_endian ? BFD_RELOC_IA64_DIR32MSB : BFD_RELOC_IA64_DIR32LSB;
|
|
|
13ae24 |
+ else if (strstr (bfd_get_target (stdoutput), "-hppa") != NULL)
|
|
|
13ae24 |
+ desc_reloc = 80; /* R_PARISC_DIR64. */
|
|
|
13ae24 |
+ else
|
|
|
13ae24 |
+ desc_reloc = BFD_RELOC_64;
|
|
|
13ae24 |
+ }
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ frag_now_fix ();
|
|
|
13ae24 |
+ note = frag_more (note_size);
|
|
|
13ae24 |
+ memset (note, 0, note_size);
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ if (target_big_endian)
|
|
|
13ae24 |
+ {
|
|
|
13ae24 |
+ note[3] = 8; /* strlen (name) + 1. */
|
|
|
13ae24 |
+ note[7] = desc_size; /* Two 8-byte offsets. */
|
|
|
13ae24 |
+ note[10] = NT_GNU_BUILD_ATTRIBUTE_OPEN >> 8;
|
|
|
13ae24 |
+ note[11] = NT_GNU_BUILD_ATTRIBUTE_OPEN & 0xff;
|
|
|
13ae24 |
+ }
|
|
|
13ae24 |
+ else
|
|
|
13ae24 |
+ {
|
|
|
13ae24 |
+ note[0] = 8; /* strlen (name) + 1. */
|
|
|
13ae24 |
+ note[4] = desc_size; /* Two 8-byte offsets. */
|
|
|
13ae24 |
+ note[8] = NT_GNU_BUILD_ATTRIBUTE_OPEN & 0xff;
|
|
|
13ae24 |
+ note[9] = NT_GNU_BUILD_ATTRIBUTE_OPEN >> 8;
|
|
|
13ae24 |
+ }
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ /* The a1 version number indicates that this note was
|
|
|
13ae24 |
+ generated by the assembler and not the gcc annobin plugin. */
|
|
|
13ae24 |
+ memcpy (note + 12, "GA$?3a1", 8);
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ /* Find the first code section symbol. */
|
|
|
13ae24 |
+ for (sym = symbol_rootP; sym != NULL; sym = sym->sy_next)
|
|
|
13ae24 |
+ if (sym->bsym != NULL
|
|
|
13ae24 |
+ && sym->bsym->flags & BSF_SECTION_SYM
|
|
|
13ae24 |
+ && sym->bsym->section != NULL
|
|
|
13ae24 |
+ && sym->bsym->section->flags & SEC_CODE)
|
|
|
13ae24 |
+ {
|
|
|
13ae24 |
+ /* Found one - now create a relocation against this symbol. */
|
|
|
13ae24 |
+ create_note_reloc (sec, sym, 20, desc_reloc, 0, note);
|
|
|
13ae24 |
+ break;
|
|
|
13ae24 |
+ }
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ /* Find the last code section symbol. */
|
|
|
13ae24 |
+ if (sym)
|
|
|
13ae24 |
+ {
|
|
|
13ae24 |
+ for (sym = symbol_lastP; sym != NULL; sym = sym->sy_previous)
|
|
|
13ae24 |
+ if (sym->bsym != NULL
|
|
|
13ae24 |
+ && sym->bsym->flags & BSF_SECTION_SYM
|
|
|
13ae24 |
+ && sym->bsym->section != NULL
|
|
|
13ae24 |
+ && sym->bsym->section->flags & SEC_CODE)
|
|
|
13ae24 |
+ {
|
|
|
13ae24 |
+ /* Create a relocation against the end of this symbol. */
|
|
|
13ae24 |
+ create_note_reloc (sec, sym, desc2_offset, desc_reloc,
|
|
|
13ae24 |
+ bfd_get_section_size (sym->bsym->section),
|
|
|
13ae24 |
+ note);
|
|
|
13ae24 |
+ break;
|
|
|
13ae24 |
+ }
|
|
|
13ae24 |
+ }
|
|
|
13ae24 |
+ /* else - if we were unable to find any code section symbols then
|
|
|
13ae24 |
+ probably there is no code in the output. So leaving the start
|
|
|
13ae24 |
+ and end values as zero in the note is OK. */
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ /* FIXME: Maybe add a note recording the assembler command line and version ? */
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ /* Install the note(s) into the section. */
|
|
|
13ae24 |
+ bfd_set_section_contents (stdoutput, sec, (bfd_byte *) note, 0, note_size);
|
|
|
13ae24 |
+ subsegs_finish_section (sec);
|
|
|
13ae24 |
+ relax_segment (seg_info (sec)->frchainP->frch_root, sec, 0);
|
|
|
13ae24 |
+ size_seg (stdoutput, sec, NULL);
|
|
|
13ae24 |
+}
|
|
|
13ae24 |
+#endif /* OBJ_ELF */
|
|
|
13ae24 |
|
|
|
13ae24 |
/* Write the object file. */
|
|
|
13ae24 |
|
|
|
13ae24 |
@@ -2052,6 +2227,11 @@ write_object_file (void)
|
|
|
13ae24 |
resolve_local_symbol_values ();
|
|
|
13ae24 |
resolve_reloc_expr_symbols ();
|
|
|
13ae24 |
|
|
|
13ae24 |
+#ifdef OBJ_ELF
|
|
|
13ae24 |
+ if (IS_ELF)
|
|
|
13ae24 |
+ maybe_generate_build_notes ();
|
|
|
13ae24 |
+#endif
|
|
|
13ae24 |
+
|
|
|
13ae24 |
PROGRESS (1);
|
|
|
13ae24 |
|
|
|
13ae24 |
#ifdef tc_frob_file_before_adjust
|
|
|
13ae24 |
Only in binutils-2.30/gas: write.c.orig
|
|
|
13ae24 |
Only in binutils-2.30: testsuite
|
|
|
13ae24 |
--- /dev/null 2018-04-26 08:07:19.307057583 +0100
|
|
|
13ae24 |
+++ binutils-2.30/binutils/testsuite/binutils-all/note-5.d 2018-04-26 15:17:06.318427614 +0100
|
|
|
13ae24 |
@@ -0,0 +1,11 @@
|
|
|
13ae24 |
+#PROG: objcopy
|
|
|
13ae24 |
+#as: --generate-missing-build-notes=yes
|
|
|
13ae24 |
+#readelf: --notes --wide
|
|
|
13ae24 |
+#name: assembler generated build notes
|
|
|
13ae24 |
+#source: note-5.s
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+#...
|
|
|
13ae24 |
+Displaying notes found in: .gnu.build.attributes
|
|
|
13ae24 |
+[ ]+Owner[ ]+Data size[ ]+Description
|
|
|
13ae24 |
+[ ]+GA\$<version>3a1[ ]+0x000000(08|10)[ ]+OPEN[ ]+Applies to region from 0 to 0x.. \(note_5.s\)
|
|
|
13ae24 |
+#...
|
|
|
13ae24 |
--- /dev/null 2018-04-26 08:07:19.307057583 +0100
|
|
|
13ae24 |
+++ binutils-2.30/binutils/testsuite/binutils-all/note-5.s 2018-04-26 15:17:06.318427614 +0100
|
|
|
13ae24 |
@@ -0,0 +1,14 @@
|
|
|
13ae24 |
+ .text
|
|
|
13ae24 |
+ .global note_5.s
|
|
|
13ae24 |
+note_5.s:
|
|
|
13ae24 |
+ .dc.l 2
|
|
|
13ae24 |
+ .dc.l 4
|
|
|
13ae24 |
+ .dc.l 6
|
|
|
13ae24 |
+ .dc.l 8
|
|
|
13ae24 |
+ .dc.l 8
|
|
|
13ae24 |
+ .dc.l 8
|
|
|
13ae24 |
+ .dc.l 8
|
|
|
13ae24 |
+ .dc.l 8
|
|
|
13ae24 |
+ .dc.l 8
|
|
|
13ae24 |
+ .dc.l 8
|
|
|
13ae24 |
+
|
|
|
13ae24 |
\ No newline at end of file
|