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