diff options
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/MAINTAINERS | 4 | ||||
-rw-r--r-- | binutils/NEWS | 37 | ||||
-rwxr-xr-x | binutils/configure | 390 | ||||
-rw-r--r-- | binutils/configure.ac | 2 | ||||
-rw-r--r-- | binutils/defparse.y | 2 | ||||
-rw-r--r-- | binutils/dlltool.c | 98 | ||||
-rw-r--r-- | binutils/doc/binutils.texi | 27 | ||||
-rw-r--r-- | binutils/dwarf.c | 67 | ||||
-rw-r--r-- | binutils/dwarf.h | 7 | ||||
-rw-r--r-- | binutils/elfedit.c | 13 | ||||
-rw-r--r-- | binutils/nm.c | 5 | ||||
-rw-r--r-- | binutils/objcopy.c | 123 | ||||
-rw-r--r-- | binutils/objdump.c | 83 | ||||
-rw-r--r-- | binutils/readelf.c | 108 | ||||
-rw-r--r-- | binutils/resbin.c | 15 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/objcopy.exp | 89 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/riscv/property-cfi-lp-unlabeled.d | 8 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/riscv/property-cfi-ss.d | 8 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/riscv/property.s | 41 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/x86-64/x86-64.exp | 2 |
20 files changed, 577 insertions, 552 deletions
diff --git a/binutils/MAINTAINERS b/binutils/MAINTAINERS index 7b50393..14c24af 100644 --- a/binutils/MAINTAINERS +++ b/binutils/MAINTAINERS @@ -63,7 +63,7 @@ maintainer. The first maintainer is free to devolve that responsibility among the other maintainers. AARCH64 Richard Earnshaw <rearnsha@arm.com> - AARCH64 Marcus Shawcroft <marcus.shawcroft@arm.com> + AARCH64 Alice Carlotti <alice.carlotti@arm.com> ARC Claudiu Zissulescu <claziss@gmail.com> ARM Nick Clifton <nickc@redhat.com> ARM Richard Earnshaw <rearnsha@arm.com> @@ -117,8 +117,8 @@ responsibility among the other maintainers. OR1K Christian Svensson <blue@cmd.nu> OR1K Stefan Kristiansson <stefan.kristiansson@saunalahti.fi> OR1K Stafford Horne <shorne@gmail.com> - PPC Peter Bergner <bergner@linux.ibm.com> PPC Surya Kumari Jangala <jskumari@linux.ibm.com> + PPC Peter Bergner <bergner@tenstorrent.com> PPC vector ext Aldy Hernandez <aldyh@redhat.com> RISC-V Palmer Dabbelt <palmer@dabbelt.com> RISC-V Andrew Waterman <andrew@sifive.com> diff --git a/binutils/NEWS b/binutils/NEWS index a4599d9..89351d7 100644 --- a/binutils/NEWS +++ b/binutils/NEWS @@ -1,8 +1,45 @@ -*- text -*- +* New versioned release of libsframe: libsframe.so.2. This release introduces + versioned symbols with version node name LIBSFRAME_2.0. Some new symbols + have been added to support the new flag SFRAME_F_FDE_FUNC_START_PCREL and + retrieving flags from SFrame decoder and encoder objects: + - Addition of sframe_decoder_get_flags, + sframe_decoder_get_offsetof_fde_start_addr, sframe_encoder_get_flags, + sframe_encoder_get_offsetof_fde_start_addr. + This release also includes backward-incompatible ABI changes: + - Removal of sframe_get_funcdesc_with_addr. + - Change in the behavior of sframe_decoder_get_funcdesc_v2, + sframe_encoder_add_funcdesc_v2 and sframe_encoder_write. + +* On s390 64-bit (s390x), gas, ld, objdump, and readelf now support generating + and processing SFrame V2 stack trace information (.sframe). The assembler + generates SFrame info from CFI directives with option "--gsframe". The + linker generates SFrame info for the linker-generated .plt section and merges + all .sframe sections. Both objdump and readelf dump SFrame info with option + "--sframe[=<section-name>]". + +* For SFrame stack trace format, the function start address in each SFrame + FDE has a changed encoding: The 32-bit signed integer now holds the offset + of the start PC of the associated function from the sfde_func_start_address + field itself (instead of the earlier where it was the offset from the start + of the SFrame section itself). All SFrame sections generated by gas and ld + now default to this new encoding, setting the (new) + SFRAME_F_FDE_FUNC_START_PCREL flag. + + Relocatable SFrame links are now fixed. + +* Readelf now recognizes RISC-V GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS and + GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED for zicfiss and zicfilp + extensions. + * For RISC-V dis-assembler, the definition of mapping symbol $x is changed, so the file needs to be rebuilt since 2.45 once used .option arch directives. +* The LoongArch disassembler now properly accepts multiple disassembly + options given by -M, such as "-M no-aliases,numeric". (Previously only the + first option took effect.) + Changes in 2.44: * Support for Nios II targets has been removed except in the readelf utility, diff --git a/binutils/configure b/binutils/configure index a2a5bf0..4b24376 100755 --- a/binutils/configure +++ b/binutils/configure @@ -14675,287 +14675,6 @@ $as_echo "$LINGUAS" >&6; } fi - - -# Prepare PATH_SEPARATOR. -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - -# Find out how to test for executable files. Don't use a zero-byte file, -# as systems may use methods other than mode bits to determine executability. -cat >conf$$.file <<_ASEOF -#! /bin/sh -exit 0 -_ASEOF -chmod +x conf$$.file -if test -x conf$$.file >/dev/null 2>&1; then - ac_executable_p="test -x" -else - ac_executable_p="test -f" -fi -rm -f conf$$.file - -# Extract the first word of "msgfmt", so it can be a program name with args. -set dummy msgfmt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_MSGFMT+:} false; then : - $as_echo_n "(cached) " >&6 -else - case "$MSGFMT" in - [\\/]* | ?:[\\/]*) - ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path. - ;; - *) - ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$ac_save_IFS" - test -z "$ac_dir" && ac_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then - if $ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 && - (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then - ac_cv_path_MSGFMT="$ac_dir/$ac_word$ac_exec_ext" - break 2 - fi - fi - done - done - IFS="$ac_save_IFS" - test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT=":" - ;; -esac -fi -MSGFMT="$ac_cv_path_MSGFMT" -if test "$MSGFMT" != ":"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSGFMT" >&5 -$as_echo "$MSGFMT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - # Extract the first word of "gmsgfmt", so it can be a program name with args. -set dummy gmsgfmt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_GMSGFMT+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $GMSGFMT in - [\\/]* | ?:[\\/]*) - ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_GMSGFMT="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT" - ;; -esac -fi -GMSGFMT=$ac_cv_path_GMSGFMT -if test -n "$GMSGFMT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GMSGFMT" >&5 -$as_echo "$GMSGFMT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - - -# Prepare PATH_SEPARATOR. -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - -# Find out how to test for executable files. Don't use a zero-byte file, -# as systems may use methods other than mode bits to determine executability. -cat >conf$$.file <<_ASEOF -#! /bin/sh -exit 0 -_ASEOF -chmod +x conf$$.file -if test -x conf$$.file >/dev/null 2>&1; then - ac_executable_p="test -x" -else - ac_executable_p="test -f" -fi -rm -f conf$$.file - -# Extract the first word of "xgettext", so it can be a program name with args. -set dummy xgettext; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_XGETTEXT+:} false; then : - $as_echo_n "(cached) " >&6 -else - case "$XGETTEXT" in - [\\/]* | ?:[\\/]*) - ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path. - ;; - *) - ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$ac_save_IFS" - test -z "$ac_dir" && ac_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then - if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >/dev/null 2>&1 && - (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then - ac_cv_path_XGETTEXT="$ac_dir/$ac_word$ac_exec_ext" - break 2 - fi - fi - done - done - IFS="$ac_save_IFS" - test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":" - ;; -esac -fi -XGETTEXT="$ac_cv_path_XGETTEXT" -if test "$XGETTEXT" != ":"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XGETTEXT" >&5 -$as_echo "$XGETTEXT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - rm -f messages.po - - -# Prepare PATH_SEPARATOR. -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - -# Find out how to test for executable files. Don't use a zero-byte file, -# as systems may use methods other than mode bits to determine executability. -cat >conf$$.file <<_ASEOF -#! /bin/sh -exit 0 -_ASEOF -chmod +x conf$$.file -if test -x conf$$.file >/dev/null 2>&1; then - ac_executable_p="test -x" -else - ac_executable_p="test -f" -fi -rm -f conf$$.file - -# Extract the first word of "msgmerge", so it can be a program name with args. -set dummy msgmerge; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_MSGMERGE+:} false; then : - $as_echo_n "(cached) " >&6 -else - case "$MSGMERGE" in - [\\/]* | ?:[\\/]*) - ac_cv_path_MSGMERGE="$MSGMERGE" # Let the user override the test with a path. - ;; - *) - ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$ac_save_IFS" - test -z "$ac_dir" && ac_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then - if $ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1; then - ac_cv_path_MSGMERGE="$ac_dir/$ac_word$ac_exec_ext" - break 2 - fi - fi - done - done - IFS="$ac_save_IFS" - test -z "$ac_cv_path_MSGMERGE" && ac_cv_path_MSGMERGE=":" - ;; -esac -fi -MSGMERGE="$ac_cv_path_MSGMERGE" -if test "$MSGMERGE" != ":"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSGMERGE" >&5 -$as_echo "$MSGMERGE" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - if test "$GMSGFMT" != ":"; then - if $GMSGFMT --statistics /dev/null >/dev/null 2>&1 && - (if $GMSGFMT --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then - : ; - else - GMSGFMT=`echo "$GMSGFMT" | sed -e 's,^.*/,,'` - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found $GMSGFMT program is not GNU msgfmt; ignore it" >&5 -$as_echo "found $GMSGFMT program is not GNU msgfmt; ignore it" >&6; } - GMSGFMT=":" - fi - fi - - if test "$XGETTEXT" != ":"; then - if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >/dev/null 2>&1 && - (if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then - : ; - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: found xgettext program is not GNU xgettext; ignore it" >&5 -$as_echo "found xgettext program is not GNU xgettext; ignore it" >&6; } - XGETTEXT=":" - fi - rm -f messages.po - fi - - ac_config_commands="$ac_config_commands default-2" - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } # Check whether --enable-maintainer-mode was given. @@ -17613,13 +17332,6 @@ fi # Capture the value of LINGUAS because we need it to compute CATALOGS. LINGUAS="${LINGUAS-%UNSET%}" -# Capture the value of obsolete ALL_LINGUAS because we need it to compute - # POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES, CATALOGS. But hide it - # from automake. - eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"' - # Capture the value of LINGUAS because we need it to compute CATALOGS. - LINGUAS="${LINGUAS-%UNSET%}" - _ACEOF @@ -17633,7 +17345,6 @@ do "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;; "default-1") CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;; - "default-2") CONFIG_COMMANDS="$CONFIG_COMMANDS default-2" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "po/Makefile.in") CONFIG_FILES="$CONFIG_FILES po/Makefile.in:po/Make-in" ;; @@ -19064,107 +18775,6 @@ _LT_EOF ;; esac done ;; - "default-2":C) - for ac_file in $CONFIG_FILES; do - # Support "outfile[:infile[:infile...]]" - case "$ac_file" in - *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - esac - # PO directories have a Makefile.in generated from Makefile.in.in. - case "$ac_file" in */Makefile.in) - # Adjust a relative srcdir. - ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` - ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'` - ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` - # In autoconf-2.13 it is called $ac_given_srcdir. - # In autoconf-2.50 it is called $srcdir. - test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" - case "$ac_given_srcdir" in - .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; - /*) top_srcdir="$ac_given_srcdir" ;; - *) top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac - if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then - rm -f "$ac_dir/POTFILES" - test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" - cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" - POMAKEFILEDEPS="POTFILES.in" - # ALL_LINGUAS, POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES depend - # on $ac_dir but don't depend on user-specified configuration - # parameters. - if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then - # The LINGUAS file contains the set of available languages. - if test -n "$OBSOLETE_ALL_LINGUAS"; then - test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.ac is obsolete" || echo "setting ALL_LINGUAS in configure.ac is obsolete" - fi - ALL_LINGUAS_=`sed -e "/^#/d" "$ac_given_srcdir/$ac_dir/LINGUAS"` - # Hide the ALL_LINGUAS assigment from automake. - eval 'ALL_LINGUAS''=$ALL_LINGUAS_' - POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" - else - # The set of available languages was given in configure.ac. - eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' - fi - case "$ac_given_srcdir" in - .) srcdirpre= ;; - *) srcdirpre='$(srcdir)/' ;; - esac - POFILES= - GMOFILES= - UPDATEPOFILES= - DUMMYPOFILES= - for lang in $ALL_LINGUAS; do - POFILES="$POFILES $srcdirpre$lang.po" - GMOFILES="$GMOFILES $srcdirpre$lang.gmo" - UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" - DUMMYPOFILES="$DUMMYPOFILES $lang.nop" - done - # CATALOGS depends on both $ac_dir and the user's LINGUAS - # environment variable. - INST_LINGUAS= - if test -n "$ALL_LINGUAS"; then - for presentlang in $ALL_LINGUAS; do - useit=no - if test "%UNSET%" != "$LINGUAS"; then - desiredlanguages="$LINGUAS" - else - desiredlanguages="$ALL_LINGUAS" - fi - for desiredlang in $desiredlanguages; do - # Use the presentlang catalog if desiredlang is - # a. equal to presentlang, or - # b. a variant of presentlang (because in this case, - # presentlang can be used as a fallback for messages - # which are not translated in the desiredlang catalog). - case "$desiredlang" in - "$presentlang"*) useit=yes;; - esac - done - if test $useit = yes; then - INST_LINGUAS="$INST_LINGUAS $presentlang" - fi - done - fi - CATALOGS= - if test -n "$INST_LINGUAS"; then - for lang in $INST_LINGUAS; do - CATALOGS="$CATALOGS $lang.gmo" - done - fi - test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" - sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" - for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do - if test -f "$f"; then - case "$f" in - *.orig | *.bak | *~) ;; - *) cat "$f" >> "$ac_dir/Makefile" ;; - esac - fi - done - fi - ;; - esac - done ;; esac done # for ac_tag diff --git a/binutils/configure.ac b/binutils/configure.ac index 75ba9d3..cb65e50 100644 --- a/binutils/configure.ac +++ b/binutils/configure.ac @@ -156,8 +156,8 @@ AC_PROG_YACC AM_PROG_LEX ALL_LINGUAS="bg ca da es fi fr hr id it ja pt ro ru rw sk sr sv tr uk vi zh_CN zh_TW" -ZW_GNU_GETTEXT_SISTER_DIR AM_PO_SUBDIRS +ZW_GNU_GETTEXT_SISTER_DIR AM_MAINTAINER_MODE AM_CONDITIONAL(GENINSRC_NEVER, false) diff --git a/binutils/defparse.y b/binutils/defparse.y index d50739e..a2c4c4b 100644 --- a/binutils/defparse.y +++ b/binutils/defparse.y @@ -213,7 +213,7 @@ opt_name2: ID { $$ = $1; } } ; opt_name: opt_name2 { $$ =$1; } - | { $$=""; } + | { $$ = xstrdup (""); } ; opt_ordinal: diff --git a/binutils/dlltool.c b/binutils/dlltool.c index ef21423..99c651f 100644 --- a/binutils/dlltool.c +++ b/binutils/dlltool.c @@ -2250,7 +2250,7 @@ typedef struct #define DATA_SEC_FLAGS (SEC_ALLOC | SEC_LOAD | SEC_DATA) #define BSS_SEC_FLAGS SEC_ALLOC -static sinfo secdata[NSECS] = +static sinfo secdata_plain[NSECS] = { INIT_SEC_DATA (TEXT, ".text", TEXT_SEC_FLAGS, 2), INIT_SEC_DATA (DATA, ".data", DATA_SEC_FLAGS, 2), @@ -2261,6 +2261,17 @@ static sinfo secdata[NSECS] = INIT_SEC_DATA (IDATA6, ".idata$6", SEC_HAS_CONTENTS, 1) }; +static sinfo secdata_delay[NSECS] = +{ + INIT_SEC_DATA (TEXT, ".text", TEXT_SEC_FLAGS, 2), + INIT_SEC_DATA (DATA, ".data", DATA_SEC_FLAGS, 2), + INIT_SEC_DATA (BSS, ".bss", BSS_SEC_FLAGS, 2), + INIT_SEC_DATA (IDATA7, ".didat$7", SEC_HAS_CONTENTS, 2), + INIT_SEC_DATA (IDATA5, ".didat$5", SEC_HAS_CONTENTS, 2), + INIT_SEC_DATA (IDATA4, ".didat$4", SEC_HAS_CONTENTS, 2), + INIT_SEC_DATA (IDATA6, ".didat$6", SEC_HAS_CONTENTS, 1) +}; + /* This is what we're trying to make. We generate the imp symbols with both single and double underscores, for compatibility. @@ -2323,6 +2334,7 @@ make_imp_label (bfd *abfd, const char *prefix, const char *name) static bfd * make_one_lib_file (export_type *exp, int i, int delay) { + sinfo *const secdata = delay ? secdata_delay : secdata_plain; char *outname = TMP_STUB; size_t name_len = strlen (outname); sprintf (outname + name_len - 7, "%05d.o", i); @@ -2786,7 +2798,7 @@ make_delay_head (void) /* Output the delay import descriptor */ fprintf (f, "\n%s DELAY_IMPORT_DESCRIPTOR\n", ASM_C); - fprintf (f, ".section\t.text$2\n"); + fprintf (f, ".section\t.didat$2\n"); fprintf (f, "%s __DELAY_IMPORT_DESCRIPTOR_%s\n", ASM_GLOBAL,imp_name_lab); fprintf (f, "__DELAY_IMPORT_DESCRIPTOR_%s:\n", imp_name_lab); fprintf (f, "\t%s 1\t%s grAttrs\n", ASM_LONG, ASM_C); @@ -2814,27 +2826,29 @@ make_delay_head (void) if (!no_idata5) { - fprintf (f, "\t.section\t.idata$5\n"); - /* NULL terminating list. */ - if (create_for_pep) - fprintf (f, "\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); - else - fprintf (f, "\t%s\t0\n", ASM_LONG); + fprintf (f, "\t.section\t.didat$5\n"); + if (use_nul_prefixed_import_tables) + { + if (create_for_pep) + fprintf (f, "\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); + else + fprintf (f, "\t%s\t0\n", ASM_LONG); + } fprintf (f, "__IAT_%s:\n", imp_name_lab); } if (!no_idata4) { - fprintf (f, "\t.section\t.idata$4\n"); - fprintf (f, "\t%s\t0\n", ASM_LONG); - if (create_for_pep) - fprintf (f, "\t%s\t0\n", ASM_LONG); - fprintf (f, "\t.section\t.idata$4\n"); + fprintf (f, "\t.section\t.didat$4\n"); + if (use_nul_prefixed_import_tables) + { + fprintf (f, "\t%s\t0\n", ASM_LONG); + if (create_for_pep) + fprintf (f, "\t%s\t0\n", ASM_LONG); + } fprintf (f, "__INT_%s:\n", imp_name_lab); } - fprintf (f, "\t.section\t.idata$2\n"); - fclose (f); assemble_file (TMP_HEAD_S, TMP_HEAD_O); @@ -2900,6 +2914,57 @@ make_tail (void) return abfd; } +static bfd * +make_delay_tail (void) +{ + FILE *f = fopen (TMP_TAIL_S, FOPEN_WT); + bfd *abfd; + + if (f == NULL) + { + fatal (_("failed to open temporary tail file: %s"), TMP_TAIL_S); + return NULL; + } + + temp_file_to_remove[TEMP_TAIL_FILE] = TMP_TAIL_S; + + if (!no_idata4) + { + fprintf (f, "\t.section\t.didat$4\n"); + if (create_for_pep) + fprintf (f, "\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); + else + fprintf (f, "\t%s\t0\n", ASM_LONG); /* NULL terminating list. */ + } + + if (!no_idata5) + { + fprintf (f, "\t.section\t.didat$5\n"); + if (create_for_pep) + fprintf (f, "\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); + else + fprintf (f, "\t%s\t0\n", ASM_LONG); /* NULL terminating list. */ + } + + fprintf (f, "\t.section\t.didat$7\n"); + fprintf (f, "\t%s\t__%s_iname\n", ASM_GLOBAL, imp_name_lab); + fprintf (f, "__%s_iname:\t%s\t\"%s\"\n", + imp_name_lab, ASM_TEXT, dll_name); + + fclose (f); + + assemble_file (TMP_TAIL_S, TMP_TAIL_O); + + abfd = bfd_openr (TMP_TAIL_O, HOW_BFD_READ_TARGET); + if (abfd == NULL) + /* xgettext:c-format */ + fatal (_("failed to open temporary tail file: %s: %s"), + TMP_TAIL_O, bfd_get_errmsg ()); + + temp_file_to_remove[TEMP_TAIL_O_FILE] = TMP_TAIL_O; + return abfd; +} + static void gen_lib_file (int delay) { @@ -2935,12 +3000,13 @@ gen_lib_file (int delay) if (delay) { ar_head = make_delay_head (); + ar_tail = make_delay_tail(); } else { ar_head = make_head (); + ar_tail = make_tail(); } - ar_tail = make_tail(); if (ar_head == NULL || ar_tail == NULL) return; diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi index c74526e..4543341 100644 --- a/binutils/doc/binutils.texi +++ b/binutils/doc/binutils.texi @@ -879,7 +879,7 @@ symbol is defined anywhere, the common symbols are treated as undefined references. @ifclear man For more details on common symbols, see the discussion of ---warn-common in @ref{Options,,Linker options,ld.info,The GNU linker}. +--warn-common in @ref{Options,,Linker options,ld,The GNU linker}. @end ifclear The lower case @var{c} character is used when the symbol is in a special section for small commons. @@ -1362,7 +1362,7 @@ between any two formats may not work as expected. deletes them afterward. @command{objcopy} uses @sc{bfd} to do all its translation work; it has access to all the formats described in @sc{bfd} and thus is able to recognize most formats without being told -explicitly. @xref{BFD,,BFD,ld.info,Using LD}. +explicitly. @xref{BFD,,BFD,ld,Using LD}. @command{objcopy} can be used to generate S-records by using an output target of @samp{srec} (e.g., use @samp{-O srec}). @@ -2720,7 +2720,7 @@ instructions will be represented as such (@code{addi sp,sp,-128} will be @item priv-spec=@var{SPEC} Print the CSR according to the chosen privilege spec version (e.g., -@code{1.10}, @code{1.11}, @code{1.12}). +@code{1.10}, @code{1.11}, @code{1.12}, @code{1.13}). @end table For MIPS, this option controls the printing of instruction mnemonic @@ -3566,6 +3566,7 @@ strip [@option{-F} @var{bfdname} |@option{--target=}@var{bfdname}] [@option{--keep-section-symbols}] [@option{--keep-file-symbols}] [@option{--only-keep-debug}] + [@option{--plugin} @var{name}] [@option{-v} |@option{--verbose}] [@option{-V}|@option{--version}] [@option{--help}] [@option{--info}] @var{objfile}@dots{} @@ -3825,6 +3826,26 @@ currently only supports the presence of one filename containing debugging information, not multiple filenames on a one-per-object-file basis. +@item --plugin @var{name} +@cindex plugins +Load the plugin called @var{name} to add support for extra target +types. This option is only available if the toolchain has been built +with plugin support enabled. + +If @option{--plugin} is not provided, but plugin support has been +enabled then @command{strip} iterates over the files in +@file{$@{libdir@}/bfd-plugins} in alphabetic order and the first +plugin that claims the object in question is used. + +Please note that this plugin search directory is @emph{not} the one +used by @command{ld}'s @option{-plugin} option. In order to make +@command{strip} use the linker plugin it must be copied into the +@file{$@{libdir@}/bfd-plugins} directory. For GCC based compilations +the linker plugin is called @file{liblto_plugin.so.0.0.0}. For Clang +based compilations it is called @file{LLVMgold.so}. The GCC plugin +is always backwards compatible with earlier versions, so it is +sufficient to just copy the newest one. + @item -V @itemx --version Show the version number for @command{strip}. diff --git a/binutils/dwarf.c b/binutils/dwarf.c index 5b3ece5..f4bcb67 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -30,6 +30,7 @@ #include "gdb/gdb-index.h" #include "filenames.h" #include "safe-ctype.h" +#include "sframe-api.h" #include <assert.h> #ifdef HAVE_LIBDEBUGINFOD @@ -102,6 +103,7 @@ int do_debug_str; int do_debug_str_offsets; int do_debug_loc; int do_gdb_index; +int do_sframe; int do_trace_info; int do_trace_abbrevs; int do_trace_aranges; @@ -7689,6 +7691,37 @@ display_trace_info (struct dwarf_section *section, void *file) } static int +display_sframe (struct dwarf_section *section, void *file ATTRIBUTE_UNUSED) +{ + sframe_decoder_ctx *sfd_ctx = NULL; + unsigned char *data = section->start; + size_t sf_size = section->size; + int err = 0; + + if (strcmp (section->name, "") == 0) + { + error (_("Section name must be provided \n")); + return false; + } + + /* Decode the contents of the section. */ + sfd_ctx = sframe_decode ((const char*)data, sf_size, &err); + if (!sfd_ctx || err) + { + error (_("SFrame decode failure: %s\n"), sframe_errmsg (err)); + return false; + } + + printf (_("Contents of the SFrame section %s:"), section->name); + /* Dump the contents as text. */ + dump_sframe (sfd_ctx, section->address); + + sframe_decoder_free (&sfd_ctx); + + return true; +} + +static int display_debug_aranges (struct dwarf_section *section, void *file ATTRIBUTE_UNUSED) { @@ -8549,6 +8582,8 @@ typedef struct Frame_Chunk } Frame_Chunk; +typedef bool (*is_mach_augmentation_ftype) (char c); +static is_mach_augmentation_ftype is_mach_augmentation; typedef const char *(*dwarf_regname_lookup_ftype) (unsigned int); static dwarf_regname_lookup_ftype dwarf_regnames_lookup_func; static const char *const *dwarf_regnames; @@ -8861,9 +8896,22 @@ init_dwarf_regnames_loongarch (void) dwarf_regnames_lookup_func = regname_internal_by_table_only; } +static bool +is_nomach_augmentation (char c ATTRIBUTE_UNUSED) +{ + return false; +} + +static bool +is_aarch64_augmentation (char c) +{ + return (c == 'B' || c == 'G'); +} + void -init_dwarf_regnames_by_elf_machine_code (unsigned int e_machine) +init_dwarf_by_elf_machine_code (unsigned int e_machine) { + is_mach_augmentation = is_nomach_augmentation; dwarf_regnames_lookup_func = NULL; is_aarch64 = false; @@ -8885,6 +8933,7 @@ init_dwarf_regnames_by_elf_machine_code (unsigned int e_machine) case EM_AARCH64: init_dwarf_regnames_aarch64 (); + is_mach_augmentation = is_aarch64_augmentation; break; case EM_S390: @@ -8908,9 +8957,10 @@ init_dwarf_regnames_by_elf_machine_code (unsigned int e_machine) architecture and specific machine type of a BFD. */ void -init_dwarf_regnames_by_bfd_arch_and_mach (enum bfd_architecture arch, - unsigned long mach) +init_dwarf_by_bfd_arch_and_mach (enum bfd_architecture arch, + unsigned long mach) { + is_mach_augmentation = is_nomach_augmentation; dwarf_regnames_lookup_func = NULL; is_aarch64 = false; @@ -8938,6 +8988,7 @@ init_dwarf_regnames_by_bfd_arch_and_mach (enum bfd_architecture arch, case bfd_arch_aarch64: init_dwarf_regnames_aarch64(); + is_mach_augmentation = is_aarch64_augmentation; break; case bfd_arch_s390: @@ -9183,7 +9234,7 @@ read_cie (unsigned char *start, unsigned char *end, fc->fde_encoding = *q++; else if (*p == 'S') ; - else if (*p == 'B') + else if (is_mach_augmentation (*p)) ; else break; @@ -10930,7 +10981,7 @@ display_debug_links (struct dwarf_section * section, (padding) If needed to reach a 4 byte boundary. (uint32_t) CRC32 value. - The .gun_debugaltlink section is formatted as: + The .gnu_debugaltlink section is formatted as: (c-string) Filename. (binary) Build-ID. */ @@ -12330,7 +12381,7 @@ load_build_id_debug_file (const char * main_filename ATTRIBUTE_UNUSED, void * ma + strlen (".debug") /* The next string should be the same as the longest name found in the prefixes[] array below. */ - + strlen ("/usrlib64/debug/usr") + + strlen ("/usr/lib64/debug/usr/") + 1); void * handle; @@ -12341,7 +12392,7 @@ load_build_id_debug_file (const char * main_filename ATTRIBUTE_UNUSED, void * ma "/usr/lib/debug/", "/usr/lib/debug/usr/", "/usr/lib64/debug/", - "/usr/lib64/debug/usr" + "/usr/lib64/debug/usr/" }; long unsigned int i; @@ -12671,6 +12722,7 @@ static const debug_dump_long_opts debug_option_table[] = /* For compatibility with earlier versions of readelf. */ { 'r', "ranges", &do_debug_aranges, 1 }, { 's', "str", &do_debug_str, 1 }, + { '\0', "sframe-internal-only", &do_sframe, 1 }, { 'T', "trace_aranges", &do_trace_aranges, 1 }, { 't', "pubtypes", &do_debug_pubtypes, 1 }, { 'U', "trace_info", &do_trace_info, 1 }, @@ -12829,6 +12881,7 @@ struct dwarf_section_display debug_displays[] = { { ".debug_weaknames", ".zdebug_weaknames", "", NO_ABBREVS }, display_debug_not_supported, NULL, false }, { { ".gdb_index", "", "", NO_ABBREVS }, display_gdb_index, &do_gdb_index, false }, { { ".debug_names", "", "", NO_ABBREVS }, display_debug_names, &do_gdb_index, false }, + { { ".sframe", "", "", NO_ABBREVS }, display_sframe, &do_sframe, true }, { { ".trace_info", "", "", ABBREV (trace_abbrev) }, display_trace_info, &do_trace_info, true }, { { ".trace_abbrev", "", "", NO_ABBREVS }, display_debug_abbrev, &do_trace_abbrevs, false }, { { ".trace_aranges", "", "", NO_ABBREVS }, display_debug_aranges, &do_trace_aranges, false }, diff --git a/binutils/dwarf.h b/binutils/dwarf.h index 3419027..13afb4a 100644 --- a/binutils/dwarf.h +++ b/binutils/dwarf.h @@ -102,6 +102,7 @@ enum dwarf_section_display_enum weaknames, gdb_index, debug_names, + sframe, trace_info, trace_abbrev, trace_aranges, @@ -240,9 +241,9 @@ extern unsigned long dwarf_start_die; extern int dwarf_check; -extern void init_dwarf_regnames_by_elf_machine_code (unsigned int); -extern void init_dwarf_regnames_by_bfd_arch_and_mach (enum bfd_architecture arch, - unsigned long mach); +extern void init_dwarf_by_elf_machine_code (unsigned int); +extern void init_dwarf_by_bfd_arch_and_mach (enum bfd_architecture arch, + unsigned long mach); extern bool load_debug_section (enum dwarf_section_display_enum, void *); extern void free_debug_section (enum dwarf_section_display_enum); diff --git a/binutils/elfedit.c b/binutils/elfedit.c index 1178d8a..43c319f 100644 --- a/binutils/elfedit.c +++ b/binutils/elfedit.c @@ -105,7 +105,18 @@ update_gnu_property (const char *file_name, FILE *file) if (map == MAP_FAILED) { error (_("%s: mmap () failed\n"), file_name); - return 0; + return 1; + } + + if ((elf_header.e_ident[EI_CLASS] == ELFCLASS32 + ? sizeof (Elf32_External_Phdr) + : sizeof (Elf64_External_Phdr)) != elf_header.e_phentsize + || elf_header.e_phoff > (size_t) st_buf.st_size + || (elf_header.e_phnum * (size_t) elf_header.e_phentsize + > st_buf.st_size - elf_header.e_phoff)) + { + error (_("%s: can't read program headers\n"), file_name); + return 1; } phdrs = xmalloc (elf_header.e_phnum * sizeof (*phdrs)); diff --git a/binutils/nm.c b/binutils/nm.c index 7ef5d61..a5d5631 100644 --- a/binutils/nm.c +++ b/binutils/nm.c @@ -801,10 +801,7 @@ filter_symbols (bfd *abfd, bool is_dynamic, void *minisyms, if (sym == NULL) continue; - if (sym->name != NULL - && sym->name[0] == '_' - && sym->name[1] == '_' - && strcmp (sym->name + (sym->name[2] == '_'), "__gnu_lto_slim") == 0 + if (bfd_lto_slim_symbol_p (abfd, sym->name) && report_plugin_err) { report_plugin_err = false; diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 31933e1..8c90773 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -30,6 +30,8 @@ #include "coff/internal.h" #include "libcoff.h" #include "safe-ctype.h" +#include "plugin-api.h" +#include "plugin.h" /* FIXME: See bfd/peXXigen.c for why we include an architecture specific header in generic PE code. */ @@ -165,6 +167,11 @@ static struct section_list *change_sections; /* TRUE if some sections are to be removed. */ static bool sections_removed; +#if BFD_SUPPORTS_PLUGINS +/* TRUE if all GCC LTO sections are to be removed. */ +static bool lto_sections_removed; +#endif + /* TRUE if only some sections are to be copied. */ static bool sections_copied; @@ -359,6 +366,7 @@ enum command_line_switch OPTION_RENAME_SECTION, OPTION_REVERSE_BYTES, OPTION_PE_SECTION_ALIGNMENT, + OPTION_PLUGIN, OPTION_SET_SECTION_FLAGS, OPTION_SET_SECTION_ALIGNMENT, OPTION_SET_START, @@ -402,6 +410,7 @@ static struct option strip_options[] = {"output-file", required_argument, 0, 'o'}, {"output-format", required_argument, 0, 'O'}, /* Obsolete */ {"output-target", required_argument, 0, 'O'}, + {"plugin", required_argument, 0, OPTION_PLUGIN}, {"preserve-dates", no_argument, 0, 'p'}, {"remove-section", required_argument, 0, 'R'}, {"remove-relocations", required_argument, 0, OPTION_REMOVE_RELOCS}, @@ -758,6 +767,10 @@ strip_usage (FILE *stream, int exit_status) --info List object formats & architectures supported\n\ -o <file> Place stripped output into <file>\n\ ")); +#if BFD_SUPPORTS_PLUGINS + fprintf (stream, _("\ + --plugin NAME Load the specified plugin\n")); +#endif list_supported_targets (program_name, stream); if (REPORT_BUGS_TO[0] && exit_status == 0) @@ -1916,20 +1929,11 @@ add_redefine_syms_file (const char *filename) Returns TRUE upon success, FALSE otherwise. */ static bool -copy_unknown_object (bfd *ibfd, bfd *obfd) +copy_unknown_file (bfd *ibfd, bfd *obfd, off_t size, unsigned int mode) { char *cbuf; bfd_size_type tocopy; - off_t size; - struct stat buf; - - if (bfd_stat_arch_elt (ibfd, &buf) != 0) - { - bfd_nonfatal_message (NULL, ibfd, NULL, NULL); - return false; - } - size = buf.st_size; if (size < 0) { non_fatal (_("stat returns negative size for `%s'"), @@ -1974,11 +1978,31 @@ copy_unknown_object (bfd *ibfd, bfd *obfd) /* We should at least to be able to read it back when copying an unknown object in an archive. */ - chmod (bfd_get_filename (obfd), buf.st_mode | S_IRUSR); + chmod (bfd_get_filename (obfd), mode | S_IRUSR); free (cbuf); return true; } +/* Copy unknown object file archive member IBFD onto OBFD. + Returns TRUE upon success, FALSE otherwise. */ + +static bool +copy_unknown_object (bfd *ibfd, bfd *obfd) +{ + struct stat buf; + + if (bfd_stat_arch_elt (ibfd, &buf) != 0) + { + bfd_nonfatal_message (NULL, ibfd, NULL, NULL); + return false; + } + + if (!copy_unknown_file (ibfd, obfd, buf.st_size, buf.st_mode)) + return false; + + return true; +} + typedef struct objcopy_internal_note { Elf_Internal_Note note; @@ -3744,6 +3768,12 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target, goto cleanup_and_exit; } +#if BFD_SUPPORTS_PLUGINS + /* Copy LTO IR file as unknown object. */ + if (bfd_plugin_target_p (this_element->xvec)) + ok_object = false; + else +#endif if (ok_object) { ok = copy_object (this_element, output_element, input_arch); @@ -3845,6 +3875,7 @@ copy_file (const char *input_filename, const char *output_filename, int ofd, char **obj_matching; char **core_matching; off_t size = get_file_size (input_filename); + const char *target = input_target; if (size < 1) { @@ -3855,9 +3886,16 @@ copy_file (const char *input_filename, const char *output_filename, int ofd, return; } +#if BFD_SUPPORTS_PLUGINS + /* Enable LTO plugin in strip unless all LTO sections should be + removed. */ + if (is_strip && !target && !lto_sections_removed) + target = "plugin"; +#endif + /* To allow us to do "strip *" without dying on the first non-object file, failures are nonfatal. */ - ibfd = bfd_openr (input_filename, input_target); + ibfd = bfd_openr (input_filename, target); if (ibfd == NULL || bfd_stat (ibfd, in_stat) != 0) { bfd_nonfatal_message (input_filename, NULL, NULL, NULL); @@ -3974,17 +4012,31 @@ copy_file (const char *input_filename, const char *output_filename, int ofd, return; } - if (! copy_object (ibfd, obfd, input_arch)) - status = 1; - - /* PR 17512: file: 0f15796a. - If the file could not be copied it may not be in a writeable - state. So use bfd_close_all_done to avoid the possibility of - writing uninitialised data into the file. */ - if (! (status ? bfd_close_all_done (obfd) : bfd_close (obfd))) +#if BFD_SUPPORTS_PLUGINS + if (bfd_plugin_target_p (ibfd->xvec)) { - status = 1; - bfd_nonfatal_message (output_filename, NULL, NULL, NULL); + /* Copy LTO IR file as unknown file. */ + if (!copy_unknown_file (ibfd, obfd, in_stat->st_size, + in_stat->st_mode)) + status = 1; + else if (!bfd_close_all_done (obfd)) + status = 1; + } + else +#endif + { + if (! copy_object (ibfd, obfd, input_arch)) + status = 1; + + /* PR 17512: file: 0f15796a. + If the file could not be copied it may not be in a writeable + state. So use bfd_close_all_done to avoid the possibility of + writing uninitialised data into the file. */ + if (! (status ? bfd_close_all_done (obfd) : bfd_close (obfd))) + { + status = 1; + bfd_nonfatal_message (output_filename, NULL, NULL, NULL); + } } if (!bfd_close (ibfd)) @@ -4346,7 +4398,7 @@ setup_section (bfd *ibfd, sec_ptr isection, bfd *obfd) /* Allow the BFD backend to copy any private data it understands from the input section to the output section. */ - if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection)) + if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection, NULL)) err = _("failed to copy private data"); if (make_nobits) @@ -4598,6 +4650,7 @@ copy_section (bfd *ibfd, sec_ptr isection, bfd *obfd) char *to = (char *) memhunk; char *end = (char *) memhunk + size; int i; + bfd_size_type memhunk_size = size; /* If the section address is not exactly divisible by the interleave, then we must bias the from address. If the copy_byte is less than @@ -4617,6 +4670,11 @@ copy_section (bfd *ibfd, sec_ptr isection, bfd *obfd) } size = (size + interleave - 1 - copy_byte) / interleave * copy_width; + + /* Don't extend the output section size. */ + if (size > memhunk_size) + size = memhunk_size; + osection->lma /= interleave; if (copy_byte < extra) osection->lma++; @@ -4837,6 +4895,10 @@ strip_main (int argc, char *argv[]) char *output_file = NULL; bool merge_notes_set = false; +#if BFD_SUPPORTS_PLUGINS + bfd_plugin_set_program_name (argv[0]); +#endif + while ((c = getopt_long (argc, argv, "I:O:F:K:MN:R:o:sSpdgxXHhVvwDU", strip_options, (int *) 0)) != EOF) { @@ -4927,6 +4989,13 @@ strip_main (int argc, char *argv[]) case OPTION_KEEP_SECTION_SYMBOLS: keep_section_symbols = true; break; + case OPTION_PLUGIN: /* --plugin */ +#if BFD_SUPPORTS_PLUGINS + bfd_plugin_set_plugin (optarg); +#else + fatal (_("sorry - this program has been built without plugin support\n")); +#endif + break; case 0: /* We've been given a long option. */ break; @@ -4971,6 +5040,14 @@ strip_main (int argc, char *argv[]) if (output_target == NULL) output_target = input_target; +#if BFD_SUPPORTS_PLUGINS + /* Check if all GCC LTO sections should be removed, assuming all LTO + sections will be removed with -R .gnu.lto_.*. * Remove .gnu.lto_.* + sections will also remove .gnu.debuglto_. sections. */ + lto_sections_removed = !!find_section_list (".gnu.lto_.*", false, + SECTION_CONTEXT_REMOVE); +#endif + i = optind; if (i == argc || (output_file != NULL && (i + 1) < argc)) diff --git a/binutils/objdump.c b/binutils/objdump.c index 8fdbe03..98d3049 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -4206,12 +4206,12 @@ disassemble_data (bfd *abfd) abfd->arch_info = inf; } + const struct bfd_target *old_xvec = NULL; if (endian != BFD_ENDIAN_UNKNOWN) { - struct bfd_target *xvec; - - xvec = (struct bfd_target *) xmalloc (sizeof (struct bfd_target)); - memcpy (xvec, abfd->xvec, sizeof (struct bfd_target)); + struct bfd_target *xvec = xmalloc (sizeof (*xvec)); + old_xvec = abfd->xvec; + memcpy (xvec, old_xvec, sizeof (*xvec)); xvec->byteorder = endian; abfd->xvec = xvec; } @@ -4225,8 +4225,7 @@ disassemble_data (bfd *abfd) non_fatal (_("can't disassemble for architecture %s\n"), bfd_printable_arch_mach (bfd_get_arch (abfd), 0)); exit_status = 1; - free (sorted_syms); - return; + goto out; } disasm_info.flavour = bfd_get_flavour (abfd); @@ -4280,8 +4279,15 @@ disassemble_data (bfd *abfd) free (disasm_info.dynrelbuf); disasm_info.dynrelbuf = NULL; - free (sorted_syms); disassemble_free_target (&disasm_info); + out: + free (sorted_syms); + sorted_syms = NULL; + if (old_xvec) + { + free ((void *) abfd->xvec); + abfd->xvec = old_xvec; + } } static bool @@ -4545,8 +4551,8 @@ dump_dwarf (bfd *abfd, bool is_mainfile) break; } - init_dwarf_regnames_by_bfd_arch_and_mach (bfd_get_arch (abfd), - bfd_get_mach (abfd)); + init_dwarf_by_bfd_arch_and_mach (bfd_get_arch (abfd), + bfd_get_mach (abfd)); bfd_map_over_sections (abfd, dump_dwarf_section, (void *) &is_mainfile); } @@ -4981,44 +4987,20 @@ dump_ctf (bfd *abfd ATTRIBUTE_UNUSED, const char *sect_name ATTRIBUTE_UNUSED, #endif static void -dump_section_sframe (bfd *abfd ATTRIBUTE_UNUSED, - const char * sect_name) -{ - asection *sec; - sframe_decoder_ctx *sfd_ctx = NULL; - bfd_size_type sf_size; - bfd_byte *sframe_data; - bfd_vma sf_vma; - int err = 0; - - if (sect_name == NULL) - sect_name = ".sframe"; - - sec = read_section (abfd, sect_name, &sframe_data); - if (sec == NULL) - { - my_bfd_nonfatal (bfd_get_filename (abfd)); - return; - } - sf_size = bfd_section_size (sec); - sf_vma = bfd_section_vma (sec); +dump_sframe_section (bfd *abfd, const char *sect_name, bool is_mainfile) - /* Decode the contents of the section. */ - sfd_ctx = sframe_decode ((const char*)sframe_data, sf_size, &err); - if (!sfd_ctx) +{ + /* Error checking for user provided SFrame section name, if any. */ + if (sect_name) { - my_bfd_nonfatal (bfd_get_filename (abfd)); - free (sframe_data); - return; + asection *sec = bfd_get_section_by_name (abfd, sect_name); + if (sec == NULL) + { + printf (_("No %s section present\n\n"), sanitize_string (sect_name)); + return; + } } - - printf (_("Contents of the SFrame section %s:"), - sanitize_string (sect_name)); - /* Dump the contents as text. */ - dump_sframe (sfd_ctx, sf_vma); - - sframe_decoder_free (&sfd_ctx); - free (sframe_data); + dump_dwarf (abfd, is_mainfile); } @@ -5840,7 +5822,7 @@ dump_bfd (bfd *abfd, bool is_mainfile) dump_ctf (abfd, dump_ctf_section_name, dump_ctf_parent_name, dump_ctf_parent_section_name); if (dump_sframe_section_info) - dump_section_sframe (abfd, dump_sframe_section_name); + dump_sframe_section (abfd, dump_sframe_section_name, is_mainfile); if (dump_stab_section_info) dump_stabs (abfd); if (dump_reloc_info && ! disassemble) @@ -6304,7 +6286,9 @@ main (int argc, char **argv) seenflag = true; if (optarg) { - if (dwarf_select_sections_by_names (optarg)) + if (strcmp (optarg, "sframe-internal-only") == 0) + warn (_("Unrecognized debug option 'sframe-internal-only'\n")); + else if (dwarf_select_sections_by_names (optarg)) dump_dwarf_section_info = true; } else @@ -6345,8 +6329,15 @@ main (int argc, char **argv) #endif case OPTION_SFRAME: dump_sframe_section_info = true; + if (optarg) dump_sframe_section_name = xstrdup (optarg); + + /* Error checking for user-provided section name is done in + dump_sframe_section (). Initialize for now with the default + internal name: "sframe-internal-only". */ + dwarf_select_sections_by_names ("sframe-internal-only"); + seenflag = true; break; case 'G': diff --git a/binutils/readelf.c b/binutils/readelf.c index dd1871d..cfccdd2 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -2584,9 +2584,12 @@ get_aarch64_dynamic_type (unsigned long type) { switch (type) { - case DT_AARCH64_BTI_PLT: return "AARCH64_BTI_PLT"; - case DT_AARCH64_PAC_PLT: return "AARCH64_PAC_PLT"; + case DT_AARCH64_BTI_PLT: return "AARCH64_BTI_PLT"; + case DT_AARCH64_PAC_PLT: return "AARCH64_PAC_PLT"; case DT_AARCH64_VARIANT_PCS: return "AARCH64_VARIANT_PCS"; + case DT_AARCH64_MEMTAG_MODE: return "AARCH64_MEMTAG_MODE"; + case DT_AARCH64_MEMTAG_STACK: return "AARCH64_MEMTAG_STACK"; + default: return NULL; } @@ -5964,6 +5967,7 @@ get_os_specific_section_type_name (Filedata * filedata, unsigned int sh_type) case SHT_GNU_HASH: return "GNU_HASH"; case SHT_GNU_LIBLIST: return "GNU_LIBLIST"; case SHT_GNU_OBJECT_ONLY: return "GNU_OBJECT_ONLY"; + case SHT_GNU_SFRAME: return "GNU_SFRAME"; case SHT_SUNW_move: return "SUNW_MOVE"; case SHT_SUNW_COMDAT: return "SUNW_COMDAT"; @@ -6538,6 +6542,8 @@ parse_args (struct dump_data *dumpdata, int argc, char ** argv) dump_any_debugging = true; dwarf_select_sections_all (); } + else if (strcmp (optarg, "sframe-internal-only") == 0) + warn (_("Unrecognized debug option 'sframe-internal-only'\n")); else { do_debugging = false; @@ -6583,9 +6589,15 @@ parse_args (struct dump_data *dumpdata, int argc, char ** argv) break; case OPTION_SFRAME_DUMP: do_sframe = true; + /* Fix PR/32589 but keep the error messaging same ? */ + if (optarg != NULL && strcmp (optarg, "") == 0) + { + do_dump = true; + error (_("Section name must be provided\n")); + } /* Providing section name is optional. request_dump (), however, thrives on non NULL optarg. Handle it explicitly here. */ - if (optarg != NULL) + else if (optarg != NULL) request_dump (dumpdata, SFRAME_DUMP); else { @@ -6819,7 +6831,7 @@ process_file_header (Filedata * filedata) return false; if (! filedata->is_separate) - init_dwarf_regnames_by_elf_machine_code (header->e_machine); + init_dwarf_by_elf_machine_code (header->e_machine); if (do_header) { @@ -8359,6 +8371,7 @@ process_section_headers (Filedata * filedata) case SHT_NOTE: case SHT_PROGBITS: + case SHT_GNU_SFRAME: /* Having a zero sized section is not illegal according to the ELF standard, but it might be an indication that something is wrong. So issue a warning if we are running in lint mode. */ @@ -17102,44 +17115,6 @@ dump_section_as_ctf (Elf_Internal_Shdr * section, Filedata * filedata) #endif static bool -dump_section_as_sframe (Elf_Internal_Shdr * section, Filedata * filedata) -{ - void * data = NULL; - sframe_decoder_ctx *sfd_ctx = NULL; - const char *print_name = printable_section_name (filedata, section); - - bool ret = true; - size_t sf_size; - int err = 0; - - if (strcmp (print_name, "") == 0) - { - error (_("Section name must be provided \n")); - ret = false; - return ret; - } - - data = get_section_contents (section, filedata); - sf_size = section->sh_size; - /* Decode the contents of the section. */ - sfd_ctx = sframe_decode ((const char*)data, sf_size, &err); - if (!sfd_ctx) - { - ret = false; - error (_("SFrame decode failure: %s\n"), sframe_errmsg (err)); - goto fail; - } - - printf (_("Contents of the SFrame section %s:"), print_name); - /* Dump the contents as text. */ - dump_sframe (sfd_ctx, section->sh_addr); - - fail: - free (data); - return ret; -} - -static bool load_specific_debug_section (enum dwarf_section_display_enum debug, const Elf_Internal_Shdr * sec, void * data) @@ -17706,7 +17681,7 @@ process_section_contents (Filedata * filedata) #endif if (dump & SFRAME_DUMP) { - if (! dump_section_as_sframe (section, filedata)) + if (! display_debug_section (i, section, filedata)) res = false; } } @@ -17779,13 +17754,17 @@ display_tag_value (signed int tag, else if (tag & 1) { /* PR 17531 file: 027-19978-0.004. */ - size_t maxlen = (end - p) - 1; + size_t maxlen = end - p; putchar ('"'); if (maxlen > 0) { + maxlen -= 1; /* Remove \0 from the character count. */ print_symbol_name ((int) maxlen, (const char *) p); - p += strnlen ((char *) p, maxlen) + 1; + size_t len = strnlen ((char *) p, maxlen); + if (len == maxlen && p[maxlen] != '\0') + printf (_("<corrupt string tag>")); + p += len + 1; } else { @@ -21288,6 +21267,33 @@ decode_aarch64_feature_1_and (unsigned int bitmask) } static void +decode_riscv_feature_1_and (unsigned int bitmask) +{ + while (bitmask) + { + unsigned int bit = bitmask & (- bitmask); + + bitmask &= ~ bit; + switch (bit) + { + case GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED: + printf ("CFI_LP_UNLABELED"); + break; + + case GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS: + printf ("CFI_SS"); + break; + + default: + printf (_("<unknown: %x>"), bit); + break; + } + if (bitmask) + printf (", "); + } +} + +static void decode_1_needed (unsigned int bitmask) { while (bitmask) @@ -21477,6 +21483,18 @@ print_gnu_property_note (Filedata * filedata, Elf_Internal_Note * pnote) goto next; } } + else if (filedata->file_header.e_machine == EM_RISCV) + { + if (type == GNU_PROPERTY_RISCV_FEATURE_1_AND) + { + printf ("RISC-V AND feature: "); + if (datasz != 4) + printf (_("<corrupt length: %#x> "), datasz); + else + decode_riscv_feature_1_and (byte_get (ptr, 4)); + goto next; + } + } } else { diff --git a/binutils/resbin.c b/binutils/resbin.c index 01046ec..889126e 100644 --- a/binutils/resbin.c +++ b/binutils/resbin.c @@ -433,6 +433,11 @@ bin_to_res_menuexitems (windres_bfd *wrbfd, const bfd_byte *data, itemlen = 14 + slen * 2 + 2; itemlen = (itemlen + 3) &~ 3; + /* Don't allow rounding up of itemlen to exceed length. This + is an anti-fuzzer measure to cope with unexpected offsets and + lengths. */ + if (itemlen > length) + itemlen = length; if ((flags & 1) == 0) { @@ -1245,7 +1250,7 @@ bin_to_res_version (windres_bfd *wrbfd, const bfd_byte *data, vst = res_alloc (sizeof (rc_ver_stringtable)); - if (!get_version_header (wrbfd, data, length, (const char *) NULL, + if (!get_version_header (wrbfd, data, length, "version stringtable", &vst->language, &stverlen, &vallen, &type, &off)) return NULL; @@ -1279,9 +1284,9 @@ bin_to_res_version (windres_bfd *wrbfd, const bfd_byte *data, vs = res_alloc (sizeof (rc_ver_stringinfo)); - if (!get_version_header (wrbfd, data, length, - (const char *) NULL, &vs->key, - &sverlen, &vallen, &type, &off)) + if (!get_version_header (wrbfd, data, length, "version string", + &vs->key, &sverlen, &vallen, + &type, &off)) return NULL; data += off; @@ -1343,7 +1348,7 @@ bin_to_res_version (windres_bfd *wrbfd, const bfd_byte *data, data += off; length -= off; - if (!get_version_header (wrbfd, data, length, (const char *) NULL, + if (!get_version_header (wrbfd, data, length, "version varfileinfo", &vi->u.var.key, &verlen, &vallen, &type, &off)) return NULL; diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp index ff93fea..6aa6d2d 100644 --- a/binutils/testsuite/binutils-all/objcopy.exp +++ b/binutils/testsuite/binutils-all/objcopy.exp @@ -180,7 +180,7 @@ proc objcopy_test_verilog {testname} { untested "verilog width-4 and width-8 tests" return } - + foreach width {4 8} { set got [binutils_run $OBJCOPY "-O verilog --verilog-data-width $width $binfile $verilog-$width.hex"] if ![string equal "" $got] then { @@ -194,7 +194,7 @@ proc objcopy_test_verilog {testname} { } } - # Test generating endian correct output. + # Test generating endian correct output. set testname "objcopy (verilog output endian-ness == input endian-ness)" set got [binutils_run $OBJCOPY "-O verilog --verilog-data-width 4 $binfile $verilog-I4.hex"] if ![string equal "" $got] then { @@ -202,9 +202,9 @@ proc objcopy_test_verilog {testname} { } send_log "regexp_diff $verilog-I4.hex $srcdir/$subdir/verilog-I4.hex\n" if {! [regexp_diff "$verilog-I4.hex" "$srcdir/$subdir/verilog-I4.hex"]} { - pass $testname + pass $testname } else { - fail $testname + fail $testname } } @@ -661,6 +661,87 @@ proc strip_test_with_saving_a_symbol { } { strip_test_with_saving_a_symbol +# Test stripping an archive. + +proc strip_test_archive { } { + global AR + global CC + global STRIP + global srcdir + global subdir + + set test "strip -g on archive" + + if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog.o object debug] != "" } { + untested $test + return + } + + set stripobjfile tmpdir/striptestprog.o + set stripobjarchive testprog.o + if [is_remote host] { + set archive libstrip.a + set objfile [remote_download host tmpdir/testprog.o] + remote_file host delete $archive + remote_file host delete $stripobjfile + remote_file host delete $stripobjarchive + } else { + set archive tmpdir/libstrip.a + set objfile tmpdir/testprog.o + remote_file build delete $stripobjfile + remote_file build delete $stripobjarchive + } + + remote_file build delete tmpdir/libstrip.a + + set exec_output [binutils_run $STRIP "-g -o $stripobjfile $objfile"] + set exec_output [prune_warnings $exec_output] + if ![string equal "" $exec_output] { + fail $test + return + } + + set exec_output [binutils_run $AR "rc $archive ${objfile}"] + set exec_output [prune_warnings $exec_output] + if ![string equal "" $exec_output] { + fail $test + return + } + + set exec_output [binutils_run $STRIP "-g $archive"] + set exec_output [prune_warnings $exec_output] + if ![string equal "" $exec_output] { + fail $test + return + } + + set exec_output [binutils_run $AR "x $archive"] + set exec_output [prune_warnings $exec_output] + if ![string equal "" $exec_output] { + fail $test + return + } + + if [is_remote host] { + set stripobjfile [remote_download host $stripobjfile] + set stripobjarchive [remote_download host $stripobjarchive] + } + + send_log "cmp $stripobjarchive $stripobjfile\n" + verbose "cmp $stripobjarchive $stripobjfile" + set status [remote_exec build cmp "$stripobjarchive $stripobjfile"] + set exec_output [lindex $status 1] + set exec_output [prune_warnings $exec_output] + + if [string equal "" $exec_output] then { + pass $test + } else { + fail $test + } +} + +strip_test_archive + # Build a final executable. set exe [exeext] diff --git a/binutils/testsuite/binutils-all/riscv/property-cfi-lp-unlabeled.d b/binutils/testsuite/binutils-all/riscv/property-cfi-lp-unlabeled.d new file mode 100644 index 0000000..396b4cd --- /dev/null +++ b/binutils/testsuite/binutils-all/riscv/property-cfi-lp-unlabeled.d @@ -0,0 +1,8 @@ +#as: -defsym __property_zicfilp_unlabeled__=1 -march=rv64i -mabi=lp64 +#readelf: -n +#source: property.s + +Displaying notes found in: .note.gnu.property +[ ]+Owner[ ]+Data size[ ]+Description +[ ]+GNU[ ]+0x00000010[ ]+NT_GNU_PROPERTY_TYPE_0 +[ ]+Properties: RISC-V AND feature: CFI_LP_UNLABELED diff --git a/binutils/testsuite/binutils-all/riscv/property-cfi-ss.d b/binutils/testsuite/binutils-all/riscv/property-cfi-ss.d new file mode 100644 index 0000000..5bc844a --- /dev/null +++ b/binutils/testsuite/binutils-all/riscv/property-cfi-ss.d @@ -0,0 +1,8 @@ +#as: -defsym __property_zicfiss__=1 -march=rv64i -mabi=lp64 +#readelf: -n +#source: property.s + +Displaying notes found in: .note.gnu.property +[ ]+Owner[ ]+Data size[ ]+Description +[ ]+GNU[ ]+0x00000010[ ]+NT_GNU_PROPERTY_TYPE_0 +[ ]+Properties: RISC-V AND feature: CFI_SS diff --git a/binutils/testsuite/binutils-all/riscv/property.s b/binutils/testsuite/binutils-all/riscv/property.s new file mode 100644 index 0000000..1b62654 --- /dev/null +++ b/binutils/testsuite/binutils-all/riscv/property.s @@ -0,0 +1,41 @@ + .text + .globl _start + .type _start,@function +_start: + ret + +.ifdef __property_zicfilp_unlabeled__ + .section ".note.gnu.property", "a" + .p2align 3 + .long 1f - 0f /* name length */ + .long 5f - 2f /* data length */ + .long 5 /* note type */ +0: .asciz "GNU" /* vendor name */ +1: + .p2align 3 +2: .long 0xc0000000 /* pr_type. */ + .long 4f - 3f /* pr_datasz. */ +3: + .long 0x1 /* GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED. */ +4: + .p2align 3 +5: +.endif + +.ifdef __property_zicfiss__ + .section ".note.gnu.property", "a" + .p2align 3 + .long 1f - 0f /* name length */ + .long 5f - 2f /* data length */ + .long 5 /* note type */ +0: .asciz "GNU" /* vendor name */ +1: + .p2align 3 +2: .long 0xc0000000 /* pr_type. */ + .long 4f - 3f /* pr_datasz. */ +3: + .long 0x2 /* GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS. */ +4: + .p2align 3 +5: +.endif diff --git a/binutils/testsuite/binutils-all/x86-64/x86-64.exp b/binutils/testsuite/binutils-all/x86-64/x86-64.exp index 2df0269..05c7304 100644 --- a/binutils/testsuite/binutils-all/x86-64/x86-64.exp +++ b/binutils/testsuite/binutils-all/x86-64/x86-64.exp @@ -81,7 +81,7 @@ if {[catch "system \"bzip2 -dc $t > $tempfile\""] != 0} { fail $testname } else { send_log "cmp tmpdir/pr27708.out $srcdir/$subdir/pr27708.dump\n" - verbose "cmp tmpdir/pr27708.out $srcdir/$subdir/pr26808.dump" 1 + verbose "cmp tmpdir/pr27708.out $srcdir/$subdir/pr27708.dump" 1 set status [remote_exec build cmp "tmpdir/pr27708.out $srcdir/$subdir/pr27708.dump"] set exec_output [lindex $status 1] set exec_output [prune_warnings $exec_output] |