]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
6 years agoAutomatic date update in version.in
GDB Administrator [Mon, 12 Feb 2018 00:01:24 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoAutomatic date update in version.in
GDB Administrator [Sun, 11 Feb 2018 00:02:00 +0000 (00:02 +0000)] 
Automatic date update in version.in

6 years agoFix PR gas/22738 (.dc.a directive has wrong size on SPARC 64-bit).
Eric Botcazou [Mon, 29 Jan 2018 23:13:51 +0000 (00:13 +0100)] 
Fix PR gas/22738 (.dc.a directive has wrong size on SPARC 64-bit).

The .dc.a directive has wrong size (32 bits) on SPARC 64-bit because
the assembler sets the correct BFD architecture only at the very end
of the processing and it's too late for the directive.  It's fixed by
defining TARGET_MACH and making it return a sensible default value.

gas/
* config/tc-sparc.h (sparc_mach): Declare.
(TARGET_MACH): Define to above.
* config/tc-sparc.c (sparc_mach): New function.
(sparc_md_end): Minor tweak.
ld/
* testsuite/ld-elf/pr22450.d: Remove reference to SPARC64.

6 years agoFix GOT relocation overflow on SPARC.
Eric Botcazou [Sat, 10 Feb 2018 01:30:25 +0000 (02:30 +0100)] 
Fix GOT relocation overflow on SPARC.

There are 2 failures left in the linker testsuite on SPARC64/Linux and
they are caused by 2 different issues leading to the same end effect:
the overflow of the relocation section for the GOT, i.e. the linker
generates too many dynamic relocations for the GOT wrt the size of the
relocation section, leading to memory corruption and missing relocations
in the final binary.

The first issue was introduced by:
  https://sourceware.org/ml/binutils/2017-06/msg00368.html
which makes the linker generate more R_SPARC_RELATIVE relocations for
the GOT without adjusting the size of the relocation section.  This is
fixed by (1) preventively adjusting this size in allocate_dynrelocs and
(2) generating R_SPARC_NONE if needed when R_SPARC_GOTDATA_OP is relaxed.

The second issue is that we generate a GOT relocation for an undefined
weak symbol with non-default visibility in a PIC binary without accounting
for that  in the size of the relocation section.  Since the address of the
symbol should resolve to 0 at run time, it is fixed by not generating the
relocation at all, i.e. leaving the GOT entry zeroed.

bfd/
* elfxx-sparc.c (UNDEFINED_WEAK_RESOLVED_TO_ZERO): Reorder conditions.
(sparc_elf_append_rela): Assert that there is enough room in section.
(_bfd_sparc_elf_copy_indirect_symbol): Fix formatting.
(_bfd_sparc_elf_adjust_dynamic_symbol): Minor tweak.
(allocate_dynrelocs): Remove outdated comments and reorder conditions.
For a symbol subject to a GOT relocation, reserve a slot in the
relocation section if the symbol isn't dynamic and we are in PIC mode.
(_bfd_sparc_elf_relocate_section) <R_SPARC_GOTDATA_OP>: If relocation
is relaxed and a slot was reserved, generate a R_SPARC_NONE relocation.
<R_SPARC_GOTDATA_OP_HIX22>: Adjust comments.
<R_SPARC_PC10>: Reorder conditions.  Remove always-false assertion.
(_bfd_sparc_elf_finish_dynamic_symbol): Rename local_undefweak into
resolved_to_zero.  Do not generate a dynamic GOT relocation for an
undefined weak symbol with non-default visibility.  Remove superfluous
'else' and fix formatting.

6 years agoAutomatic date update in version.in
GDB Administrator [Sat, 10 Feb 2018 00:01:30 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoImport patch from mainline to fix possible seg-fault whilst parsing corrupt ELF notes...
Nick Clifton [Fri, 9 Feb 2018 09:28:45 +0000 (09:28 +0000)] 
Import patch from mainline to fix possible seg-fault whilst parsing corrupt ELF notes with extravagent alignments.

PR 22788
* elf.c (elf_parse_notes): Reject notes with excessuively large
alignments.

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 9 Feb 2018 00:01:42 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoAutomatic date update in version.in
GDB Administrator [Thu, 8 Feb 2018 00:01:38 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoRevert "PowerPC PLT speculative execution barriers"
Alan Modra [Mon, 5 Feb 2018 02:47:52 +0000 (13:17 +1030)] 
Revert "PowerPC PLT speculative execution barriers"

This reverts most of commit d847d5180e.
Left in place are addition of --no-plt-align to some ppc32 ld tests
and the ld.texinfo --no-plt-thread-safe fix.

6 years agoAutomatic date update in version.in
GDB Administrator [Wed, 7 Feb 2018 00:01:30 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 6 Feb 2018 00:01:17 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years ago[PR22764][LD][AARCH64]Allow R_AARCH64_ABS16 and R_AARCH64_ABS32 against absolution...
Renlin Li [Sat, 3 Feb 2018 13:18:17 +0000 (13:18 +0000)] 
[PR22764][LD][AARCH64]Allow R_AARCH64_ABS16 and R_AARCH64_ABS32 against absolution symbol or undefine symbol in shared object.

backport from mainline

bfd/

2018-02-05  Renlin Li  <renlin.li@arm.com>

PR ld/22764
* elfnn-aarch64.c (elfNN_aarch64_check_relocs): Relax the
R_AARCH64_ABS32 and R_AARCH64_ABS16 for absolute symbol. Apply the
check for writeable section as well.

ld/

2018-02-05  Renlin Li  <renlin.li@arm.com>

PR ld/22764
* testsuite/ld-aarch64/emit-relocs-258.s: Define symbol as an address.
* testsuite/ld-aarch64/emit-relocs-259.s: Likewise.
* testsuite/ld-aarch64/aarch64-elf.exp: Run new test.
* testsuite/ld-aarch64/pr22764.s: New.
* testsuite/ld-aarch64/pr22764.d: New.

6 years agoUpdated Brazillian portuguese and Russian translation
Nick Clifton [Mon, 5 Feb 2018 12:59:09 +0000 (12:59 +0000)] 
Updated Brazillian portuguese and Russian translation

6 years agoImport patch from mainline to remove PROVODE qualifiers around definitions of __CTOR_...
Nick Clifton [Mon, 5 Feb 2018 09:12:42 +0000 (09:12 +0000)] 
Import patch from mainline to remove PROVODE qualifiers around definitions of __CTOR_LIST__ and __DTOR_LIST__ in PE linker scripts.

PR 22762
* scripttempl/pe.sc: Remove PROVIDE()s from __CTOR_LIST__ and
__DTOR_LIST__ symbols.  Add a comment explaining why this is
necessary.
* scripttemp/pep.sc: Likewise.
* ld.texinfo (PROVIDE): Add a note about the effect of common
symbols.

6 years agoAutomatic date update in version.in
GDB Administrator [Mon, 5 Feb 2018 00:01:37 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoAutomatic date update in version.in
GDB Administrator [Sun, 4 Feb 2018 00:02:05 +0000 (00:02 +0000)] 
Automatic date update in version.in

6 years agoAdd support for DWARF-4 line number tables.
Cary Coutant [Sat, 3 Feb 2018 01:44:27 +0000 (17:44 -0800)] 
Add support for DWARF-4 line number tables.

Reads the maximum_operations_per_instruction field, added in DWARF-4 to the
line number program header.

gold/
* PR gold/22776
* dwarf_reader.cc (Sized_dwarf_line_info::read_header_prolog): Add
support for DWARF-4 line number tables.
* dwarf_reader.h (Sized_dwarf_line_info::max_ops_per_insn): New field.

6 years agoAutomatic date update in version.in
GDB Administrator [Sat, 3 Feb 2018 00:01:38 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 2 Feb 2018 00:02:20 +0000 (00:02 +0000)] 
Automatic date update in version.in

6 years agoAutomatic date update in version.in
GDB Administrator [Thu, 1 Feb 2018 00:01:48 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoAutomatic date update in version.in
GDB Administrator [Wed, 31 Jan 2018 00:01:45 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 30 Jan 2018 00:01:45 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoUpdate Russian translation for the gas sub-directory
Nick Clifton [Mon, 29 Jan 2018 13:50:46 +0000 (13:50 +0000)] 
Update Russian translation for the gas sub-directory

6 years agoAutomatic date update in version.in
GDB Administrator [Mon, 29 Jan 2018 00:01:43 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoAutomatic date update in version.in
GDB Administrator [Sun, 28 Jan 2018 00:01:48 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoRevert to development on the 2.30 branch. Set the version number to 2.30.0.
Nick Clifton [Sat, 27 Jan 2018 15:46:38 +0000 (15:46 +0000)] 
Revert to development on the 2.30 branch.  Set the version number to 2.30.0.

bfd * version.m4 (BFD_VERSION): Set to 2.30.0
* development.sh: Set to true.
* configure: Regenerate.
* po/bfd.pot: Regenerate.

binutils* configure: Regenerate.
gas * configure: Regenerate.
gprof * configure: Regenerate.
ld * configure: Regenerate.
opcodes * configure: Regenerate.
* po/opcodes.pot: Regenerate.

6 years agoUpdate version number and development status for the 2.30 release. binutils-2_30
Nick Clifton [Sat, 27 Jan 2018 15:09:19 +0000 (15:09 +0000)] 
Update version number and development status for the 2.30 release.

bfd * version.m4 (BFD_VERSION): Set to 2.30
* development.sh: Set to false.
* configure: Regenerate.
* po/bfd.pot: Regenerate.

binutils* configure: Regenerate.
gas * configure: Regenerate.
gold * configure: Regenerate.
* po/gold.pot: Regenerate.
gprof * configure: Regenerate.
ld * configure: Regenerate.
* po/ld.pot: Regenerate.
opcodes * configure: Regenerate.
* po/opcodes.pot: Regenerate.

6 years agoRevert the optimization of the placement of LTO objects as a temporary solution for...
Nick Clifton [Sat, 27 Jan 2018 14:53:19 +0000 (14:53 +0000)] 
Revert the optimization of the placement of LTO objects as a temporary solution for PR 22751.

PR 22751
Revert this change as a temporary solution for this PR:

2017-09-02  Alan Modra  <amodra@gmail.com>

* ldlang.h (lang_input_statement_type): Expand comments.
(LANG_FOR_EACH_INPUT_STATEMENT): Rewrite without casts.
* ldlang.c (lang_for_each_input_file): Likewise.
(load_symbols): Set usrdata for archives.
(find_rescan_insertion): New function.
(lang_process): Trim off and reinsert entries added to file chain
when rescanning archives for LTO.
* ldmain.c (add_archive_element): Set my_archive input_statement
next pointer to last element added.

6 years agoUpdated Russian translation for the bfd sub-directory
Nick Clifton [Sat, 27 Jan 2018 14:25:02 +0000 (14:25 +0000)] 
Updated Russian translation for the bfd sub-directory

6 years agoAutomatic date update in version.in
GDB Administrator [Sat, 27 Jan 2018 00:02:37 +0000 (00:02 +0000)] 
Automatic date update in version.in

6 years agoMIPS/GAS: Correct default ABI selection for `mips64*-ps2-elf*'
Maciej W. Rozycki [Fri, 26 Jan 2018 22:29:47 +0000 (22:29 +0000)] 
MIPS/GAS: Correct default ABI selection for `mips64*-ps2-elf*'

Correct an issue with the `mips64*-ps2-elf*' target introduced with
commit e407c74b5b60 ("Support for MIPS R5900 (Sony Playstation 2)"),
<https://sourceware.org/ml/binutils/2012-12/msg00240.html> and make
the n32 ABI the default for GAS, consistently with how BFD and LD
are configured for this target.

gas/
* configure.ac: Also set `mips_default_abi' to N32_ABI for
`mips64*-ps2-elf*'.
* configure: Regenerate.

(cherry picked from commit 0984958bd1d20245e4d42888a697b6015dc6172f)

6 years agoPowerPC64 .branch_lt size change leads to "stubs don't match calculated size"
Alan Modra [Fri, 26 Jan 2018 01:55:09 +0000 (12:25 +1030)] 
PowerPC64 .branch_lt size change leads to "stubs don't match calculated size"

https://bugzilla.redhat.com/show_bug.cgi?id=1523457

I haven't analyzed this myself, I'm relying on Nick's excellent
analysis.  What I believe is happening is that after some number of
stub sizing iterations, a long-branch stub needs to be converted to a
plt-branch, but either due to stub alignment or other stubs shrinking
in size, the stub group section size doesn't change.

That means we exit from ppc64_elf_size_stubs after sizing with an
incorrect layout, in fact the additional .branch_lt entry overlays
.got!  Since .TOC. is normally set to .got + 0x8000 the stub sizing
code decides that entry is within +/-32k of the TOC pointer and so a
three insn stub is sufficient.  When we come to build the stubs using
a correct non-overlaying layout, a four insn plt-branch stub is
generated and the stub group size doesn't match that calculated
earlier.

* elf64-ppc.c (ppc64_elf_size_stubs): Iterate sizing when
.branch_lt changes size.

(cherry picked from commit ba21f5646454c418e75eb06f6bf1a00a173641ca)

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 26 Jan 2018 00:01:47 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoFix PR ld/22727 (TLS breakage in PIC/PIE mode on SPARC).
Eric Botcazou [Thu, 25 Jan 2018 11:16:06 +0000 (12:16 +0100)] 
Fix PR ld/22727 (TLS breakage in PIC/PIE mode on SPARC).

There are actually 2 different bugs:
 1. TLS transition is broken in PIE mode.
 2. TLS is broken in PIC/PIE mode when the __tls_get_addr symbol
    is versioned  (as is the case on Linux and Solaris at least).

The 1st bug is fixed by reverting the problematic change for now
(note that the associated test doesn't pass on SPARC because of another
issue so there is  no formal regression in the testsuite). The 2nd bug
is fixed by changing the  call to _bfd_generic_link_add_one_symbol
on __tls_get_addr into a mere lookup in _bfd_sparc_elf_check_relocs.

bfd/
* elfxx-sparc.c (_bfd_sparc_elf_check_relocs) <R_SPARC_TLS_GD_CALL>:
Do a mere lookup of the __tls_get_addr symbol instead of adding it.

Revert
2017-10-19  H.J. Lu  <hongjiu.lu@intel.com>

PR ld/22263
* elfxx-sparc.c (sparc_elf_tls_transition): Replace
bfd_link_pic with !bfd_link_executable, !bfd_link_pic with
bfd_link_executable for TLS check.
(_bfd_sparc_elf_check_relocs): Likewise.
(allocate_dynrelocs): Likewise.
(_bfd_sparc_elf_relocate_section): Likewise.
ld/
* testsuite/ld-sparc/sparc.exp (32-bit: Helper shared library):
Link with a version script.
(32-bit: TLS -fpie): New test.
(64-bit: Helper shared library): Link with a version script.
(64-bit: TLS -fpie): New test.
(64-bit: GOTDATA relocations): Pass -Av9 to the assembler.
* testsuite/ld-sparc/tlslib.ver: New file.
* testsuite/ld-sparc/tlspie32.dd: Likewise.
* testsuite/ld-sparc/tlspie32.s: Likewise.
* testsuite/ld-sparc/tlspie64.dd: Likewise.
* testsuite/ld-sparc/tlspie64.s: Likewise.
* testsuite/ld-sparc/tlssunbin32.dd: Adjust for versioned symbol.
* testsuite/ld-sparc/tlssunbin32.rd: Likewise.
* testsuite/ld-sparc/tlssunbin32.sd: Likewise.
* testsuite/ld-sparc/tlssunbin64.dd: Likewise.
* testsuite/ld-sparc/tlssunbin64.rd: Likewise.
* testsuite/ld-sparc/tlssunbin64.sd: Likewise.

6 years agoAutomatic date update in version.in
GDB Administrator [Thu, 25 Jan 2018 00:01:39 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoFix printing the size of GOLD's memory areana on Cygwin based systems.
Franz Sirl [Wed, 24 Jan 2018 13:39:11 +0000 (13:39 +0000)] 
Fix printing the size of GOLD's memory areana on Cygwin based systems.

I just stumbled over this with 2.29.1 while building a cross-toolchain, on Cygwin64, but it's still the same for 2.30. m.arena has size_t on Cygwin64 and thus errors out due to -Werror=format.

gold * main.cc: Print m.arena as long long.

6 years agoRegenerate configure file in gprof sub-directory
Nick Clifton [Wed, 24 Jan 2018 13:29:18 +0000 (13:29 +0000)] 
Regenerate configure file in gprof sub-directory

6 years agoAutomatic date update in version.in
GDB Administrator [Wed, 24 Jan 2018 00:01:33 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoReset the version number on the 2.30 branch to 2.29.90, since the release has not...
Nick Clifton [Tue, 23 Jan 2018 11:01:03 +0000 (11:01 +0000)] 
Reset the version number on the 2.30 branch to 2.29.90, since the release has not happened yet...

2018-01-23  Nick Clifton  <nickc@redhat.com>

* configure: Regenerate.

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 23 Jan 2018 00:01:38 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoGAS/doc: Correct `.set nomips16e2' directive description syntax
Maciej W. Rozycki [Mon, 22 Jan 2018 21:06:35 +0000 (13:06 -0800)] 
GAS/doc: Correct `.set nomips16e2' directive description syntax

gas/
* doc/c-mips.texi (MIPS ASE Instruction Generation Overrides):
Correct syntax of the `.set nomips16e2' directive description.

(cherry picked from commit 75c80ee120e7d1bfb78570aa89d8d8fec6812d0f)

6 years agobinutils/doc: Fix a "using" typo in `objcopy --rename-section' description
Maciej W. Rozycki [Mon, 22 Jan 2018 21:05:56 +0000 (13:05 -0800)] 
binutils/doc: Fix a "using" typo in `objcopy --rename-section' description

binutils/
* doc/binutils.texi (objcopy): Fix a typo in `--rename-section'
option description.

(cherry picked from commit 1ea332d6931ea097d0128578a578528262df8445)

6 years agoMAINTAINERS: Update my company e-mail address
Maciej W. Rozycki [Mon, 22 Jan 2018 15:38:09 +0000 (07:38 -0800)] 
MAINTAINERS: Update my company e-mail address

Following my recent transition from Imagination Technologies to the
reincarnated MIPS company update MAINTAINERS entries accordingly.

binutils/
* MAINTAINERS: Update my company e-mail address.

gdb/
* MAINTAINERS: Update my company e-mail address.

sim/
* MAINTAINERS: Update my company e-mail address.

(cherry picked from commit d65ce302abcb260e14ca5f201b78e8e6d4a2e720)

6 years agoUpdate Swedish translation for the binutils sub-directory
Nick Clifton [Mon, 22 Jan 2018 13:47:14 +0000 (13:47 +0000)] 
Update Swedish translation for the binutils sub-directory

6 years agoAutomatic date update in version.in
GDB Administrator [Mon, 22 Jan 2018 00:01:33 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoAutomatic date update in version.in
GDB Administrator [Sun, 21 Jan 2018 00:01:38 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agox86: Check the versioned __tls_get_addr symbol
H.J. Lu [Sat, 20 Jan 2018 22:25:24 +0000 (14:25 -0800)] 
x86: Check the versioned __tls_get_addr symbol

We need to check the versioned __tls_get_addr symbol when looking up
"__tls_get_addr".

bfd/

PR ld/22721
* elfxx-x86.c (_bfd_x86_elf_link_check_relocs): Check the
versioned __tls_get_addr symbol.

ld/

PR ld/22721
* testsuite/ld-plugin/lto.exp: Run PR ld/22721 tests.
* testsuite/ld-plugin/pr22721.t: New file.
* testsuite/ld-plugin/pr22721a.s: Likewise.
* testsuite/ld-plugin/pr22721b.c: Likewise.

(cherry picked from commit 8a1b824af786989f879ab1421a4279f60bba141a)

6 years agoAutomatic date update in version.in
GDB Administrator [Sat, 20 Jan 2018 00:01:23 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoUpdate French translation in bfd sub-directory
Nick Clifton [Fri, 19 Jan 2018 10:48:21 +0000 (10:48 +0000)] 
Update French translation in bfd sub-directory

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 19 Jan 2018 00:01:34 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoPowerPC PLT stub alignment fixes
Alan Modra [Thu, 18 Jan 2018 11:36:40 +0000 (22:06 +1030)] 
PowerPC PLT stub alignment fixes

Asking for ppc32 plt call stubs to be aligned at 32 byte boundaries
didn't quite work.  For ld.bfd they were spaced 32 bytes apart, but
only started on a 16 byte boundary.  ld.gold also didn't get it right.

Finding that bug made me check over the ppc64 plt stub alignment,
where I found that negative values for alignment (meaning align to
minimize boundary crossing) were not accepted.  Since no one has
complained about that, I guess I could have removed the feature from
ld.bfd documentation, but I've opted instead to correct the code.

I've also added an optional alignment paramenter for ppc32
--plt-align, for some consistency with gold and ppc64 ld.bfd.

bfd/
* elf32-ppc.c (ppc_elf_create_glink): Correct alignment of .glink.
* elf64-ppc.c (ppc64_elf_size_stubs): Handle negative plt_stub_align.
(ppc64_elf_build_stubs): Likewise.
gold/
* powerpc.cc (param_plt_align): New function supplying default
--plt-align values.  Use it..
(Stub_table::plt_call_align): ..here, and..
(Output_data_glink::global_entry_align): ..here.
(Stub_table::stub_align): Correct 32-bit minimum alignment.
ld/
* emultempl/ppc32elf.em: Support optional --plt-align arg.
* emultempl/ppc64elf.em: Support negative --plt-align arg.

(cherry picked from commit 691d2e9af211ff8dd5fa8c96cb961b73a78394d7)

6 years agoPowerPC PLT speculative execution barriers
Alan Modra [Wed, 17 Jan 2018 03:49:08 +0000 (14:19 +1030)] 
PowerPC PLT speculative execution barriers

Spectre variant 2 mitigation for PowerPC and PowerPC64.

bfd/
* elf32-ppc.c (GLINK_ENTRY_SIZE): Handle speculation barrier.
(CRSETEQ, BEQCTRM): Define.
(is_nonpic_glink_stub): Don't check bctr.
(ppc_elf_link_hash_table_create): Init new ppc_elf_params field.
(ppc_elf_relax_section): Size speculation barrier.
(output_bctr): New function.
(write_glink_stub): Use output_bctr.
(ppc_elf_relocate_section): Use output_bctr for long branch stub.
(ppc_elf_finish_dynamic_symbol): Likewise.
(ppc_elf_finish_dynamic_sections): Use output_bctr.
* elf32-ppc.h (struct ppc_elf_params): Add speculate_indirect_jumps.
* elf64-ppc.c (CRSETEQ, BEQCTRM, BEQCTRLM): Define.
(GLINK_PLTRESOLVE_SIZE): Size speculation barrier.
(size_global_entry_stubs): Handle speculation barrier sizing.
(plt_stub_size): Likewise.
(output_bctr): New function.
(build_plt_stub, build_tls_get_addr_stub): Output speculation
barrier.
(ppc_build_one_stub): Likewise for ppc_stub_plt_branch.
(ppc_size_one_stub): Size speculation barrier in ppc_stub_plt_branch.
(build_global_entry_stubs): Output speculation barrier.
(ppc64_elf_build_stubs): Likewise in __glink_PLTresolve stub.
* elf64-ppc.h (struct ppc64_elf_params): Add speculate_indirect_jumps.
gold/
* options.h (speculate_indirect_jumps): New option.
* powerpc.cc (beqctrm, beqctrlm, crseteq): New insn constants.
(output_bctr): New function.
(Stub_table::plt_call_size): Add space for speculation barrier.
(Stub_table::branch_stub_size): Likewise.
(Output_data_glink::pltresolve_size): Likewise.
(Stub_table::do_write): Output speculation barriers.
ld/
* emultempl/ppc32elf.em (params): Init new field.
(OPTION_SPECULATE_INDIRECT_JUMPS): Define.
(OPTION_NO_SPECULATE_INDIRECT_JUMPS): Define.
(PARSE_AND_LIST_LONGOPTS): Handle new options.
(PARSE_AND_LIST_ARGS_CASES): Likewise.
(PARSE_AND_LIST_OPTIONS): Likewise.
* emultempl/ppc64elf.em (params): Init new field.
(OPTION_SPECULATE_INDIRECT_JUMPS): Define.
(OPTION_NO_SPECULATE_INDIRECT_JUMPS): Define.
(PARSE_AND_LIST_LONGOPTS): Handle --speculate-indirect-jumps.
(PARSE_AND_LIST_OPTIONS): Likewise.
(PARSE_AND_LIST_ARGS_CASES): Likewise.
* ld.texinfo (--no-plt-thread-safe): Correct itemx.
(--speculate-indirect-jumps): Document.
* testsuite/ld-powerpc/elfv2exe.d,
* testsuite/ld-powerpc/elfv2so.d,
* testsuite/ld-powerpc/relbrlt.d,
* testsuite/ld-powerpc/powerpc.exp: Disable plt alignment and
speculation barriers on various tests.

(cherry picked from commit 1be5d8d3bbec4c9a112114993ac5c85b2b26c4c4)

6 years agoWarning fix
Alan Modra [Wed, 17 Jan 2018 10:54:32 +0000 (21:24 +1030)] 
Warning fix

* elf64-ppc.c (ppc64_elf_build_stubs): Silence gcc warning.

(cherry picked from commit c75bc4f76fe456c57ef1e446db5378182692c429)

6 years agoPowerPC PLT stub tidy
Alan Modra [Sat, 13 Jan 2018 08:23:41 +0000 (18:53 +1030)] 
PowerPC PLT stub tidy

This is in preparation for the next patch adding Spectre variant 2
mitigation for PowerPC and PowerPC64.  Besides tidying code involved
in stub output (to reduce the number of places where bctr is output),
the patch adds some user visible features:

1) PowerPC64 ELFv2 global entry stubs now are aligned under the
   control of --plt-align, with a default alignment of 32 bytes.
2) PowerPC64 __glink_PLTresolve is no longer padded out with nops.
3) PowerPC32 PLT stubs are aligned under the control of --plt-align,
   with the default alignment being 16 bytes as before.
4) The PowerPC32 branch/nop table emitted before __glink_PLTresolve
   is now smaller in many cases.  It was sized incorrectly when the
   __tls_get_addr_opt stub was used, and unnecessarily included space
   for local ifuncs.

bfd/
* elf32-ppc.c (GLINK_ENTRY_SIZE): Add parameters, handle
__tls_get_addr_opt, and alignment sizing.
(TLS_GET_ADDR_GLINK_SIZE): Delete.
(is_nonpic_glink_stub): Don't use GLINK_ENTRY_SIZE.
(ppc_elf_get_synthetic_symtab): Recognize stubs spaced at 4, 6,
or 8 insns.
(ppc_elf_link_hash_table_create): Init new ppc_elf_params field.
(allocate_dynrelocs): Use new GLINK_ENTRY_SIZE.
(ppc_elf_size_dynamic_sections): Likewise.  Size branch table
by PLT reloc count.
(write_glink_stub): Handle __tls_get_addr_opt stub.
Pad out to size given by GLINK_ENTRY_SIZE.
(ppc_elf_relocate_section): Adjust write_glink_stub call.
(ppc_elf_finish_dynamic_symbol): Likewise.
(ppc_elf_finish_dynamic_sections): Write PLTresolve without using
insn array since so many need rewriting.
* elf32-ppc.h (struct ppc_elf_params): Add plt_stub_align.
* elf64-ppc.c (GLINK_PLTRESOLVE_SIZE): Rename from
GLINK_CALL_STUB_SIZE.  Add htab param and evaluate to size without
nops.  Adjust all uses.
(ppc64_elf_get_synthetic_symtab): Don't use GLINK_CALL_STUB_SIZE
in glink_vma calculation.
(struct ppc_link_hash_table): Add global_entry section pointer.
(create_linkage_sections): Create separate section for global
entry stubs.
(PPC_LO, PPC_HI, PPC_HA): Move earlier.
(size_global_entry_stubs): Handle sizing for aligned stubs.
(ppc64_elf_size_dynamic_sections): Handle global_entry alloc,
and don't stash end of glink branch table in rawsize.
(ppc_build_one_stub): Rewrite stub size calculations.
(build_global_entry_stubs): Use new section.
(ppc64_elf_build_stubs): Don't pad __glink_PLTresolve with nops.
Build lazy link stubs out to end of section.  Build global entry
stubs in new section.
gold/
* options.h (plt_align): Support for PowerPC32 too.
* powerpc.cc (Stub_table::stub_align): Heed --plt-align for 32-bit.
(Stub_table::plt_call_size, branch_stub_size): Tidy.
(Stub_table::plt_call_align): Implement using stub_align.
(Output_data_glink::global_entry_align): New function.
(Output_data_glink::global_entry_off): New function.
(Output_data_glink::global_entry_address): Use global_entry_off.
(Output_data_glink::pltresolve_size): New function, replacing
pltresolve_size_ constant.  Update all uses.
(Output_data_glink::add_global_entry): Align offset.
(Output_data_glink::set_final_data_size): Use global_entry_align.
(Stub_table::do_write): Don't pad __glink_PLTrelsolve with nops.
Tidy stub output.  Use global_entry_off.
ld/
* emultempl/ppc32elf.em (params): Init new field.
(enum ppc32_opt): New enum to define OPTION_* values.  Add
OPTION_PLT_ALIGN and OPTION_NO_PLT_ALIGN.
(PARSE_AND_LIST_LONGOPTS): Handle new options.
(PARSE_AND_LIST_ARGS_CASES): Likewise.
(PARSE_AND_LIST_OPTIONS): Likewise.  Break up help output.
* emultempl/ppc64elf.em (ppc_add_stub_section): Init alignment
correctly for negative --plt-stub-align.
* testsuite/ld-powerpc/elfv2exe.d,
* testsuite/ld-powerpc/elfv2so.d,
* testsuite/ld-powerpc/relbrlt.d,
* testsuite/ld-powerpc/relbrlt.s,
* testsuite/ld-powerpc/tlsexe.d,
* testsuite/ld-powerpc/tlsexe.r,
* testsuite/ld-powerpc/tlsexe32.d,
* testsuite/ld-powerpc/tlsexe32.g,
* testsuite/ld-powerpc/tlsexe32.r,
* testsuite/ld-powerpc/tlsexetoc.d,
* testsuite/ld-powerpc/tlsexetoc.r,
* testsuite/ld-powerpc/tlsopt5_32.d,
* testsuite/ld-powerpc/tlsso.d,
* testsuite/ld-powerpc/tlstocso.d: Update for changed stub order.

(cherry picked from commit 9e390558cef76767a98123994c422d0642d86cf8)

6 years agoUpdate Bulgarian translation of the binutils sub-directory
Nick Clifton [Thu, 18 Jan 2018 09:38:21 +0000 (09:38 +0000)] 
Update Bulgarian translation of the binutils sub-directory

6 years agoAutomatic date update in version.in
GDB Administrator [Thu, 18 Jan 2018 00:02:45 +0000 (00:02 +0000)] 
Automatic date update in version.in

6 years agoUpdate Ukranian and Russian translations in bfd library
Nick Clifton [Wed, 17 Jan 2018 15:51:06 +0000 (15:51 +0000)] 
Update Ukranian and Russian translations in bfd library

6 years agoAutomatic date update in version.in
GDB Administrator [Wed, 17 Jan 2018 00:01:46 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years ago[ARM] No IT usage deprecation for ARMv8-M
Thomas Preud'homme [Mon, 15 Jan 2018 14:09:28 +0000 (14:09 +0000)] 
[ARM] No IT usage deprecation for ARMv8-M

Deprecations related to the use of the IT instruction introduced in
Armv8-A do not apply to Armv8-M Baseline and mainline. However the
warning logic do not distinguish between the various profiles and warn
whenever the architecture version is 8.

This patch adds a check to exclude M profile architectures from this
warning. This works as expected when -march is specified on the
command-line or a .arch/.cpu directive exist. However, in autodetection
mode the CPU/architecture targeted is only known once the instructions
have been all processed but this code is run when IT instruction is
processed. It is therefore not possible to distinguish between Armv8-M
and Armv8-A in that mode.

The approach chosen here is not to warn in autodetection mode. The udf.d
testcase that relied on that behavior to test deprecation warning for
Armv8-A is therefore updated to explicitely pass -march=armv8-a.

2018-01-16  Thomas Preud'homme  <thomas.preudhomme@arm.com>

Backport from mainline
2018-01-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

gas/
* config/tc-arm.c (it_fsm_post_encode): Do not warn if targeting M
profile architecture or if in autodetection mode.  Clarify that
deprecation is for performance reason and concerns Armv8-A and Armv8-R.
* testsuite/gas/arm/armv8-ar-bad.l: Adapt to new IT deprecation warning
message.
* testsuite/gas/arm/armv8-ar-it-bad.l: Likewise.
* testsuite/gas/arm/sp-pc-validations-bad-t-v8a.l: Likewise.
* testsuite/gas/arm/udf.l: Likewise.
* testsuite/gas/arm/udf.d: Assemble for Armv8-A explicitely.

6 years agoFix -fuse-ld option to accept string argument.
Cary Coutant [Mon, 15 Jan 2018 18:05:54 +0000 (10:05 -0800)] 
Fix -fuse-ld option to accept string argument.

PR 22042 complained that garbage text was being printed in the help
for the -fuse-ld option; this was caused by passing an empty string
to the gettext() function, which sometimes returns garbage when passed
an empty string. The quick fix was to replace "" with NULL as the helparg,
but that changed the parsing of the option, as gold uses the helparg to
determine whether an option takes an argument. This patch adds a
non-empty helparg string to fix both problems.

gold/
PR gold/22694
* options.h (-fuse-ld): Add correct helparg.

6 years agoUpdate translations for various binutils components.
Nick Clifton [Tue, 16 Jan 2018 12:42:20 +0000 (12:42 +0000)] 
Update translations for various binutils components.

ld * po/pt_BR.po: Updated Brazilian Portugese translation.

opcodes * po/pt_BR.po: Updated Brazilian Portugese translation.
* po/de.po: Updated German translation.

gas * po/fr.po: Updated French translation.

binutils* po/fr.po: Updated French translation.

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 16 Jan 2018 00:01:40 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agoUpdate Ukranian translations for bfd, binutils, gas, gold, ld and opcodes
Nick Clifton [Mon, 15 Jan 2018 12:07:47 +0000 (12:07 +0000)] 
Update Ukranian translations for bfd, binutils, gas, gold, ld and opcodes

6 years agoReset version number to 2.30.0
Nick Clifton [Sat, 13 Jan 2018 14:03:53 +0000 (14:03 +0000)] 
Reset version number to 2.30.0

6 years agoUpdate pot file in gprof/po directory
Nick Clifton [Sat, 13 Jan 2018 13:57:25 +0000 (13:57 +0000)] 
Update pot file in gprof/po directory

6 years agoRegenerate po files
Nick Clifton [Sat, 13 Jan 2018 13:53:16 +0000 (13:53 +0000)] 
Regenerate po files

6 years agoAdd note about 2.30 branch creation to changelogs
Nick Clifton [Sat, 13 Jan 2018 13:26:38 +0000 (13:26 +0000)] 
Add note about 2.30 branch creation to changelogs

6 years agoAdd 2.30 markers to NEWS files.
Nick Clifton [Sat, 13 Jan 2018 13:20:55 +0000 (13:20 +0000)] 
Add 2.30 markers to NEWS files.

binutils/
* NEWS: Add marker for 2.30.

gas/
* NEWS: Add marker for 2.30.

ld/
* NEWS: Add marker for 2.30.

6 years agoUpdate gold version number to 1.15.
Cary Coutant [Sat, 13 Jan 2018 02:38:11 +0000 (18:38 -0800)] 
Update gold version number to 1.15.

gold/
* NEWS: Add new features in 1.15.
* version.cc (version_string): Bump to 1.15.

6 years agoAutomatic date update in version.in
GDB Administrator [Sat, 13 Jan 2018 00:00:33 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agogdb/testsuite: Don't attempt tests if they fail to compile
Andrew Burgess [Thu, 11 Jan 2018 18:58:10 +0000 (18:58 +0000)] 
gdb/testsuite: Don't attempt tests if they fail to compile

In the gdb.base/whatis-ptype-typedefs.exp test, if the test program
fails to compile, don't run the tests.

gdb/testsuite/ChangeLog:

* gdb.base/whatis-ptype-typedefs.exp: Don't run tests if we failed
to prepare.
(prepare): Return 0 on error, 1 on success.

6 years agoInstall and generate docs for gdb-add-index
Sergio Durigan Junior [Thu, 11 Jan 2018 21:12:05 +0000 (16:12 -0500)] 
Install and generate docs for gdb-add-index

The "gdb-add-index" script has been resurrected on:

  commit caf26be91a584ef141ac5d3cb31007731af8b8e3
  Author: Samuel Bronson <naesten@gmail.com>
  Date:   Fri Nov 15 16:09:33 2013 -0500

      Resurrect gdb-add-index as a contrib script

However, for some reason (I couldn't find it in the archives), only
the script has been checked-in; the Makefile parts responsible for
installing it in the system were left out.  This commit fixes that, by
also resurrecting the Makefile and documentation bits.

This commit is part of our effort to upstream the local Fedora GDB
changes.  With this commit, we'll only carry a very small
Fedora-specific modification to the script.

gdb/ChangeLog:
2017-01-12  Tom Tromey  <tom@tromey.com>
    Sergio Durigan Junior  <sergiodj@redhat.com>

* Makefile.in (install-only): Install gdb-add-index.

gdb/doc/ChangeLog:
2017-01-12  Tom Tromey  <tom@tromey.com>
    Sergio Durigan Junior  <sergiodj@redhat.com>

* gdb.texinfo (Index Files): Mention gdb-add-index.
(gdb-add-index man): New section.
* Makefile.in (gdb-add-index.1): New rule to generate manpage
from gdb.texinfo.

6 years agoUse the correct value for the offset of 'kve_protection'.
John Baldwin [Fri, 12 Jan 2018 20:05:50 +0000 (12:05 -0800)] 
Use the correct value for the offset of 'kve_protection'.

I had forgotten to convert the decimal output of 'ptype /o' to hex
(but still used a 0x prefix) for the KVE_PROTECTION constant defining
the offset of the 'kve_protection' field in the 'kinfo_vmentry'
structure.  This resulted in garbage permissions for entries in 'info
proc mappings' for FreeBSD core dumps.

gdb/ChangeLog:

* fbsd-tdep.c (KVE_PROTECTION): Correct value.

6 years agoApply:
Eric Christopher [Fri, 12 Jan 2018 19:05:58 +0000 (11:05 -0800)] 
Apply:

2018-01-12 Sterling Augustine <saugustine@google.com>

   * cref.cc (Cref_inputs::Cref_table_compare::operator): Add
   conditionals and calls to is_forwarder.

6 years agoAdd testcase for GDB hang fixed by previous commit
Pedro Alves [Fri, 12 Jan 2018 18:52:39 +0000 (18:52 +0000)] 
Add testcase for GDB hang fixed by previous commit

This adds a testcase for the previous commit.  The regression was
related to in-line step overs.  The reason we didn't see it on native
x86-64/s390 GNU/Linux testing is that native debugging uses displaced
stepping by default (because native debugging defaults to "maint set
target-non-stop on"), unlike remote debugging.

So in order to trigger the bug with native debugging as well, the
testcase disables displaced stepping explicitly.

Also, instead of using watchpoints to trigger the regression, the
testcase uses a breakpoint at address 0, which should be more
portable.

gdb/testsuite/ChangeLog:
2018-01-12  Pedro Alves  <palves@redhat.com>

* gdb.base/continue-after-aborted-step-over.c: New.
* gdb.base/continue-after-aborted-step-over.exp: New.

6 years agoFix GDB hang with remote after error from resume
Andreas Arnez [Fri, 12 Jan 2018 18:52:39 +0000 (18:52 +0000)] 
Fix GDB hang with remote after error from resume

Since this commit --

  Fix PR18360 - internal error when using "interrupt -a"
  (https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=c65d6b55)

-- the testsuite shows long delays on s390 with native-gdbserver when
executing certain tests, such as watchpoints.exp.  These hangs have been
discussed before in the context of buildbot problems, see here:

  https://sourceware.org/ml/gdb-patches/2017-12/msg00413.html

The problem can easily be triggered by stopping on a breakpoint, then
setting impossible watchpoints, and finally doing "continue".  Then, after
having set the step-over state (in keep_going_pass_signal in infrun.c),
GDB tries to insert breakpoints and watchpoints into the inferior.  This
fails, and the "continue" command is aborted.  But the step-over state is
not cleared in this case, which causes future step-over attempts to be
skipped since GDB thinks that "we already have an in-line step-over
operation ongoing" (see start_step_over in infrun.c).  Thus the next
"continue" just goes on to wait for events from the remote, which will
never occur.

The problem can also be reproduced on amd64 with native-gdbserver, using
the following change to watchpoints.exp:

 -- >8 --
 --- a/gdb/testsuite/gdb.base/watchpoints.exp
 +++ b/gdb/testsuite/gdb.base/watchpoints.exp
 @@ -61,2 +61,3 @@ with_test_prefix "before inferior start" {
      gdb_test "watch ival3" ".*" ""
 +    gdb_test "watch *(char \[256\] *) main"

 -- >8 --

To fix the hang, this patch clears the step-over info when
insert_breakpoints has failed.  Of course, with native-gdbserver the
watchpoints.exp test case still causes many FAILs on s390, because
gdbserver does not support watchpoints for that target.  This is a
separate issue.

gdb/ChangeLog:
2018-01-12  Andreas Arnez  <arnez@linux.vnet.ibm.com>

* infrun.c (keep_going_pass_signal): Clear step-over info when
insert_breakpoints fails.

6 years agoAdd notes on how to make a branch and a pre-release snapshot.
Nick Clifton [Fri, 12 Jan 2018 17:52:38 +0000 (17:52 +0000)] 
Add notes on how to make a branch and a pre-release snapshot.

* README-how-to-make-a-release: Add notes on how to make the
branch and prelease snapshot.
* BRANCHES: Add binutils-2_29-branch.

6 years agoOptimize the performance of the group_setup function.
Jens Widell [Fri, 12 Jan 2018 13:16:17 +0000 (13:16 +0000)] 
Optimize the performance of the group_setup function.

When processing a section that is a member of a group, the group
that contains it is looked up using a linear search. The resulting
O(n^2) complexity causes significant performance issues when
dealing with object files with very many groups.

By remembering the index of the last found group and restarting
the next search from that index, the search instead becomes O(n)
in common cases.

* elf.c (setup_group): Optimize search for group by remembering
last found group and restarting search at that index.
* elf-bfd.h (struct elf_obj_tdata): Add group_search_offset field.

6 years agoFix compile time warning building aout targeted architectures.
Gunther Nikl [Fri, 12 Jan 2018 13:12:17 +0000 (13:12 +0000)] 
Fix compile time warning building aout targeted architectures.

Occasionally I build an out-of-tree a.out target (m68k-amigaos). After
a system upgrade which included a newer compiler (clang 4) the build
produces warnings like this:

  warning: macro expansion producing 'defined' has undefined behavior
  [-Wexpansion-to-defined]

This is caused by the macro gas/config/aout_gnu.h:USE_EXTENDED_RELOC.
Since it is in a header file, the warning triggers for several files.
I am unsure what solution is preferable, thus I am suggesting two
patches:

  a) keep the offending macro but define it explicitly to 0 and 1
  b) replace the macro usage with its value where it is used.

Either patch removes the warning for clang. I did not check with a
recent GCC.

* gas/config/aout_gnu.h (USE_EXTENDED_RELOC): Explicitly
define to 0 and 1. Remove a dangling reference to "AMD 29000"
in a comment.

6 years agopr22374 function pointer initialization
Alan Modra [Fri, 12 Jan 2018 10:40:48 +0000 (21:10 +1030)] 
pr22374 function pointer initialization

When I added this test I said I'd look at fixing more targets.
That hasn't happened yet, so xfail to tidy results.

* testsuite/ld-elf/elf.exp: xfail "pr22374 function pointer
initialization" for currently failing targets.

6 years agoFix override of common symbols for a.out
Alan Modra [Fri, 12 Jan 2018 00:07:28 +0000 (10:37 +1030)] 
Fix override of common symbols for a.out

The default should be bfd_link_common_skip_none, as in the original
patch at https://sourceware.org/ml/binutils/2002-07/msg00717.html

* aoutx.h (aout_link_check_ar_symbols): Remove default and handle
bfd_link_common_skip_none in switch.

6 years agoFixes for "Ignore dynamic references on forced local symbols"
Alan Modra [Fri, 12 Jan 2018 06:28:04 +0000 (16:58 +1030)] 
Fixes for "Ignore dynamic references on forced local symbols"

PowerPC64 has its own mark_dynamic_ref, which needs the same change as
made by d664fd41e1 to the generic ELF version.  Some other targets
discard more than just .data, so allow for that too in expected ld
messages.

bfd/
PR ld/22649
* elf64-ppc.c (ppc64_elf_gc_mark_dynamic_ref): Ignore dynamic
references on forced local symbols.
ld/
PR ld/22649
* testsuite/ld-elf/pr22649.msg: Allow other messages.
* testsuite/ld-elf/shared.exp: Check that --gc-sections is
supported before running ld/22649 tests.

6 years ago_bfd_mips_elf_final_link: Notify user about wrong .reginfo size
Vlad Ivanov [Fri, 12 Jan 2018 09:25:11 +0000 (09:25 +0000)] 
_bfd_mips_elf_final_link: Notify user about wrong .reginfo size

One of assertions in _bfd_mips_elf_final_link could be triggered by
a combination of input files and a linker script.  This happens when
either the input doesn't contain .reginfo section or when this section
is oversized.  This patch replaces the assertion with a more useful
error message.

* elfxx-mips.c (_bfd_mips_elf_final_link): Notify user when
.reginfo section has wrong size.

6 years agoAdd -z undefs option to the ELF linker.
Nick Clifton [Fri, 12 Jan 2018 08:15:55 +0000 (08:15 +0000)] 
Add -z undefs option to the ELF linker.

  Currently we have no obvious way to revert the action of the "-z defs"
  command line option.  The "--unresolved-symbols=ignore-in-object-files"
  does pretty much what is needed, but it is non-obvious and it also
  touches the setting for reporting unresolved symbol references from
  shared libraries.  So I am proposing adding a "-z undefs" option to be
  the inverse of "-z defs".  (I thought that "-z nodefs" might be
  confusing since it implies banning all definitions, rather than
  allowing them).

  In addition the description of the "-z defs" option in the linker
  documentation is misleading in one place, where it says:

    'defs'
       Disallows undefined symbols in object files.  Undefined
       symbols in shared libraries are still allowed.

  whereas later on it gets it right:

    '-z defs'
       Report unresolved symbol references from regular object files.
       This is done even if the linker is creating a non-symbolic shared
       library.  The switch '--[no-]allow-shlib-undefined' controls the
       behaviour for reporting unresolved references found in shared
       libraries being linked in.

* emultempl/elf32.em (_handle_option): Add support for "-z undefs"
as the opposite of "-z defs".
* ld.texinfo: Document the new option.  Update the description of
the -z defs option to make it clear that it does generate an error
if an undefined symbol reference is found in an object file whilst
creating a shared library.
* NEWS: Document this new feature.

6 years agold: Replace "-z textonly" with "-z separate-code"
H.J. Lu [Fri, 12 Jan 2018 04:46:01 +0000 (20:46 -0800)] 
ld: Replace "-z textonly" with "-z separate-code"

Although they aren't passed to linker, we should get it right.

* testsuite/ld-elf/pr22393-2a.rd: Replace "-z textonly" with
"-z separate-code".
* testsuite/ld-elf/pr22393-2b.rd: Likewise.
* testsuite/ld-x86-64/pr22393-3a.rd: Likewise.
* testsuite/ld-x86-64/pr22393-3b.rd: Likewise.

6 years agox86-64: Add tests for -z separate-code -z max-page-size=0x1000
H.J. Lu [Fri, 12 Jan 2018 03:19:22 +0000 (19:19 -0800)] 
x86-64: Add tests for -z separate-code -z max-page-size=0x1000

PR ld/22393
* testsuite/ld-x86-64/pr22393-3a.c: New file.
* testsuite/ld-x86-64/pr22393-3a.rd: Likewise.
* testsuite/ld-x86-64/pr22393-3b.c: Likewise.
* testsuite/ld-x86-64/pr22393-3b.rd: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run tests for -z separate-code
-z max-page-size=0x1000.

6 years agold: Add tests for -z separate-code and -z noseparate-code
H.J. Lu [Fri, 12 Jan 2018 03:17:46 +0000 (19:17 -0800)] 
ld: Add tests for -z separate-code and -z noseparate-code

Verify that -z separate-code works and -z noseparate-code doesn't disable
-z relro.

PR ld/22393
* testsuite/ld-elf/pr16322.d: Add -z noseparate-code.
* testsuite/ld-elf/pr22393-1.s: New file.
* testsuite/ld-elf/pr22393-1a.d: Likewise.
* testsuite/ld-elf/pr22393-1b.d: Likewise.
* testsuite/ld-elf/pr22393-1c.d: Likewise.
* testsuite/ld-elf/pr22393-1d.d: Likewise.
* testsuite/ld-elf/pr22393-1e.d: Likewise.
* testsuite/ld-elf/pr22393-1f.d: Likewise.
* testsuite/ld-elf/pr22393-2a.c: Likewise.
* testsuite/ld-elf/pr22393-2a.rd: Likewise.
* testsuite/ld-elf/pr22393-2b.c: Likewise.
* testsuite/ld-elf/pr22393-2b.rd: Likewise.
* testsuite/ld-elf/shared.exp: Run tests for -z separate-code.

6 years agold: Create a new LOAD segment for separate code segment
H.J. Lu [Fri, 12 Jan 2018 03:04:55 +0000 (19:04 -0800)] 
ld: Create a new LOAD segment for separate code segment

When generating separate code LOAD segment, create a new LOAD segment
if the previous section contains text and the current section doesn't
or vice versa:

Elf file type is DYN (Shared object file)
Entry point 0x200020
There are 7 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000000 0x00000000 0x00000000 0x00200 0x00200 R   0x200000
  LOAD           0x200000 0x00200000 0x00200000 0x00036 0x00036 R E 0x200000
  LOAD           0x400000 0x00400000 0x00400000 0x00064 0x00064 R   0x200000
  LOAD           0x400f80 0x00600f80 0x00600f80 0x000a0 0x000a0 RW  0x200000
  DYNAMIC        0x400f80 0x00600f80 0x00600f80 0x00080 0x00080 RW  0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x10
  GNU_RELRO      0x400f80 0x00600f80 0x00600f80 0x00080 0x00080 R   0x1

 Section to Segment mapping:
  Segment Sections...
   00     .hash .gnu.hash .dynsym .dynstr .rela.plt
   01     .plt .text
   02     .rodata .eh_frame
   03     .dynamic .got.plt
   04     .dynamic
   05
   06     .dynamic

to prevent fetching or executing data in code pages as instructions.

Also don't put a writable section in a read-only segment if there is a
RELRO segment.

Since code segment is aligned and padded to the maximum page size on
disk, the minimum file size is bigger than the maximum page size which
is 2MB (0x200000):

-rwxr-xr-x 1 hjl hjl 4201932 Jan 10 10:41 libfoo.so

"-z max-page-size=0x1000" can be used to reduce the maximum page size to
4KB (0x1000):

-rwxr-xr-x 1 hjl hjl   15820 Jan 10 10:44 libfoo.so

PR ld/22393
* elf.c (_bfd_elf_map_sections_to_segments): When generating
separate code and read-only data LOAD segments, create a new
LOAD segment if the previous section contains text and the
current section doesn't or vice versa.  Don't put a writable
section in a read-only segment if there is a RELRO segment.

6 years agold: Add "-z separate-code" option to ELF linker
H.J. Lu [Fri, 12 Jan 2018 03:01:39 +0000 (19:01 -0800)] 
ld: Add "-z separate-code" option to ELF linker

The new "-z separate-code" option will generate separate code LOAD
segment which must be in wholly disjoint pages from any other data.

include/

PR ld/22393
* bfdlink.h (bfd_link_info): Add separate_code.

ld/

PR ld/22393
* NEWS: Mention "-z separate-code".
* emultempl/elf32.em (gld${EMULATION_NAME}_get_script): Get
builtin linker scripts and return linker scripts from disk for
"-z separate-code".
(gld${EMULATION_NAME}_handle_option): Handle "-z separate-code"
and "-z noseparate-code".
* genscripts.sh: Generate linker scripts for "-z separate-code".
(LD_FLAG): Set to *textonly for "-z separate-code".
* ld.texinfo: Document "-z separate-code".
* lexsup.c (elf_shlib_list_options): Add linker help messsages
for "-z separate-code" and "-z noseparate-code".
* scripttempl/elf.sc (SEPARATE_TEXT): New
(TEXT_SEGMENT_ALIGN): Likewise.
Use ${TEXT_SEGMENT_ALIGN} to align and pad text segment to
${MAXPAGESIZE}.

6 years agogdb_compile_shlib: Only consider shlib= options when building executables
Simon Marchi [Fri, 12 Jan 2018 02:08:23 +0000 (21:08 -0500)] 
gdb_compile_shlib: Only consider shlib= options when building executables

Trying to use gdb_compile_shlib with the shlib= option to build a shared
library that depends on another shared library does not work as of
today.  See:

  https://sourceware.org/ml/gdb-patches/2017-10/msg00733.html

The problem is that building the lib is done in two steps, compilation
(.c -> .o) and linking (.o -> .so) and the shlib= options are passed to
both steps.  When compiling the object file (.o), it results in gcc
complaining:

  gcc: warning: .../solib-vanish-lib2.so: linker input file unused because linking not done

The first solution I came up with was to filter the options inside
gdb_compile_shlib to remove the shlib= options from the options we pass
when compiling the .o file.

I then thought it would be simpler to ignore the shlib= options in
gdb_compile when not building an executable (the executable category
includes the shared libraries).  For other compilation types (object
file, preprocess and generate assembly), it doesn't make sense to add
shared libraries to the source file list.

Regtested on the buildbot.

gdb/testsuite/ChangeLog:

* lib/gdb.exp (gdb_compile): Ignore shlib= and shlib_load
options when not creating an executable.

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 12 Jan 2018 00:00:23 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoIgnore dynamic references on forced local symbols
H.J. Lu [Thu, 11 Jan 2018 23:36:40 +0000 (15:36 -0800)] 
Ignore dynamic references on forced local symbols

We should ignore dynamic references on forced local symbols during
garbage collection since they can never be referenced dynamically.

bfd/

PR ld/22649
* elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Ignore dynamic
references on forced local symbols.

ld/

PR ld/22649
* testsuite/ld-elf/pr22649-1.s: New file.
* testsuite/ld-elf/pr22649-2a.s: Likewise.
* testsuite/ld-elf/pr22649-2b.s: Likewise.
* testsuite/ld-elf/pr22649.msg: Likewise.
* testsuite/ld-elf/shared.exp: Run ld/22649 tests.

6 years agogdb.base/breakpoint-in-ro-region.exp regression on sss targets (PR gdb/22583)
Pedro Alves [Thu, 11 Jan 2018 17:50:31 +0000 (17:50 +0000)] 
gdb.base/breakpoint-in-ro-region.exp regression on sss targets (PR gdb/22583)

As Maciej reported at
<https://sourceware.org/ml/gdb-patches/2017-12/msg00212.html>, this
commit:

 commit d930703d68ae160ddfe8ebe5fdcf416fb6090e1e
 Date: Thu Nov 16 18:44:43 2017 +0000
 Subject: Don't ever Quit out of resume

caused regressions on software single-set targets, specifically:

 FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: single-step breakpoint is not left behind
 FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw on: single-step breakpoint is not left behind
 FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw off: step in ro region (cannot insert hw break)
 FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw off: single-step breakpoint is not left behind
 FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw on: single-step breakpoint is not left behind

and indeed detailed logs indicate a breakpoint is left lingering, e.g.:

 (gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: step in ro region (cannot insert sw break)
 maint info breakpoints 0
 Num     Type           Disp Enb Address    What
 0       sw single-step keep y   0x00400774 in main at [...]/gdb/testsuite/gdb.base/breakpoint-in-ro-region.c:24 inf 1 thread 1
 stop only in thread 1
 (gdb) FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: single-step breakpoint is not left behind

vs:

 (gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: step in ro region (cannot insert sw break)
 maint info breakpoints 0
 No breakpoint or watchpoint matching '0'.
 (gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: single-step breakpoint is not left behind

as at commit d930703d68ae^.

Before commit d930703d68ae, we had a cleanup installed in 'resume'
that would delete single-step breakpoints on error:

  /* Resuming.  */

  /* Things to clean up if we QUIT out of resume ().  */
  static void
  resume_cleanups (void *ignore)
  {
    if (!ptid_equal (inferior_ptid, null_ptid))
     delete_single_step_breakpoints (inferior_thread ());

    normal_stop ();
  }

That whole function was removed by d930703d68ae mainly to eliminate
the normal_stop call:

~~~~
    Note that the exception called from within resume ends up calling
    normal_stop via resume_cleanups.  That's very borked though, because
    normal_stop is going to re-handle whatever was the last reported
    event, possibly even re-running a hook stop...
~~~~

But as the regression shows, removing resume_cleanups completely went
a bit too far, as the delete_single_step_breakpoints call is still
necessary.

So fix the regression by reinstating the
delete_single_step_breakpoints call on error.  However, since we're
trying to eliminate cleanups, restore it in a different form (using
TRY/CATCH).

Tested on x86-64 GNU/Linux both top of master and on top of a series
that implements software single-step on x86.

gdb/ChangeLog:
2018-01-11  Pedro Alves  <palves@redhat.com>

PR gdb/22583
* infrun.c (resume): Rename to ...
(resume_1): ... this.
(resume): Reimplement as wrapper around resume_1.

6 years agold: Keep PREINIT_ARRAY/INIT_ARRAY/FINI_ARRAY sections for -r --gc-sections
H.J. Lu [Thu, 11 Jan 2018 17:42:12 +0000 (09:42 -0800)] 
ld: Keep PREINIT_ARRAY/INIT_ARRAY/FINI_ARRAY sections for -r --gc-sections

We must keep all PREINIT_ARRAY, INIT_ARRAY as well as FINI_ARRAY sections
for ld -r --gc-sections.

bfd/

PR ld/22677
* elflink.c (bfd_elf_gc_sections): Keep all PREINIT_ARRAY,
INIT_ARRAY as well as FINI_ARRAY sections for ld -r --gc-sections.

ld/

PR ld/22677
* scripttempl/elf.sc (PREINIT_ARRAY): New.
Don't add .preinit_array for ld -r.
* testsuite/ld-elf/pr22677.d: New file.
* testsuite/ld-elf/pr22677.s: Likewise.

6 years agold: Remove unused expression state
Andrew Burgess [Fri, 5 Jan 2018 14:59:05 +0000 (14:59 +0000)] 
ld: Remove unused expression state

Previous commit removed all uses of the defsym field within the linker
expression union.  This commit cleans up the now redundant state.

ld/ChangeLog:

* ldexp.h (union etree_union): Remove defsym field.
* ldexp.c (exp_assop): Remove defsym parameter, and use of defsym
parameter.
(exp_assign): Remove passing of defsym parameter.
(exp_defsym): Likewise.
(exp_provide): Likewise.

6 years agold: Fix issue where PROVIDE overrides defined symbol
Andrew Burgess [Thu, 27 Apr 2017 17:05:08 +0000 (18:05 +0100)] 
ld: Fix issue where PROVIDE overrides defined symbol

In a linker script, a sequence like this:

  foo = ADDR (.some_section);
  bar = foo;
  PROVIDE (foo = 0);

will result in 'bar = ADDR (.some_section)' and 'foo = 0', which seems
like incorrect behaviour, foo is clearly defined elsewhere, and so the
PROVIDE should not trigger.

The problem is that an expression like this:

    foo = ADDR (.some_section);

can't be evaluated until a late phase of the linker, due to the need
for the section '.some_section' to have been placed, then the PROVIDE
was being marked as being used during an earlier phase.  At the end of
the link, both lines:

    foo = ADDR (.some_section);
    PROVIDE (foo = 0);

are active, and this causes the final value of 'foo' to be 0.

The solution proposed in this commit is that, during earlier phases of
the linker, when we see the expression 'foo = ADDR (.some_section);',
instead of ignoring the expression, we create a "fake" definition of
'foo'.  The existence of this "fake" definition prevents the PROVIDE
from being marked used, and during the final phase the real definition
of 'foo' will replace the "fake" definition.

The new test provide-6 covers the exact case described above.  The
provide-7 test is similar to the above, but using constant
expressions, this was never broken, but is added here to increase
coverage.

The provide-8 case also didn't fail before this commit, but I did
manage to break this case during development of this patch.  This case
was only covered by a mmix test before, so I've added this here to
increase coverage.

ld/ChangeLog:

* ldexp.c (exp_fold_tree_1): Rework condition underwhich provide
nodes are ignored in the tree walk, and move the location at which
we change provide nodes into provided nodes.
(exp_init_os): Add etree_provided.
* testsuite/ld-scripts/provide-6.d: New file.
* testsuite/ld-scripts/provide-6.t: New file.
* testsuite/ld-scripts/provide-7.d: New file.
* testsuite/ld-scripts/provide-7.t: New file.
* testsuite/ld-scripts/provide-8.d: New file.
* testsuite/ld-scripts/provide-8.t: New file.

6 years agold: Find and run some tests using a wildcard pattern
Andrew Burgess [Thu, 27 Apr 2017 16:53:28 +0000 (17:53 +0100)] 
ld: Find and run some tests using a wildcard pattern

Find the ld-script/provide-*.d tests using a wildcard, then run them in
a loop.  This will make it easier to add more tests in the future.  Some
associated clean up is required.

ld/ChangeLog:

* testsuite/ld-scripts/provide-3.d: Add xfail directive.
* testsuite/ld-scripts/provide-4.d: Use new map file name.
* testsuite/ld-scripts/provide-5.d: Use new map file name.
* testsuite/ld-scripts/provide-4-map.d: Renamed to...
* testsuite/ld-scripts/provide-4.map: ...this.
* testsuite/ld-scripts/provide-5-map.d: Renamed to...
* testsuite/ld-scripts/provide-5.map: ...this.
* testsuite/ld-scripts/provide.exp: Move xfail into provide-3.d
file, and run tests in a loop.

6 years agold: In map file use '=' in PROVIDE statements
Andrew Burgess [Fri, 5 Jan 2018 22:41:55 +0000 (22:41 +0000)] 
ld: In map file use '=' in PROVIDE statements

Currently when recording a PROVIDE statement in a linker map file we
display something like:

    PROVIDE (SYMBOL, VALUE)

However, in a linker script we write these statements like this:

    PROVIDE (SYMBOL = VALUE);

This commit changes the output in the map file to be closer to linker
script format, the map file now contains:

    PROVIDE (SYMBOL = VALUE)

The ';' is still missing from the end, but map files are not intended
to be valid linker script input, so adding the ';' just seems like
clutter.

ld/ChangeLog:

* ldexp.c (exp_print_tree): Use '=' instead of ',' when printing
PROVIDE statements.
* testsuite/ld-scripts/provide-4.map: Update expected output.
* testsuite/ld-scripts/provide-5.map: Likewise.

6 years agoFix the order of SHLIB_RODATA_ADDR in elf.sc
H.J. Lu [Thu, 11 Jan 2018 13:05:25 +0000 (05:05 -0800)] 
Fix the order of SHLIB_RODATA_ADDR in elf.sc

elf.sc has

  if test -n "${RODATA_ADDR}"; then
    RODATA_ADDR="\
SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR}) + SIZEOF_HEADERS"
  else
    RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
    ^^^^^^^^^^ Set RODATA_ADDR
    RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR})"
    ^^^^^^^^^^ Set RODATA_ADDR with ${RODATA_ADDR}
  fi
  if test -n "${SHLIB_RODATA_ADDR}"; then
    SHLIB_RODATA_ADDR="\
SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR}) + SIZEOF_HEADERS"
  else
    SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})"
    ^^^^^^^^^^ Set SHLIB_RODATA_ADDR
    SHLIB_RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
    ^^^^^^^^^^ Override SHLIB_RODATA_ADDR
  fi

The order should be:

  if test -n "${SHLIB_RODATA_ADDR}"; then
    SHLIB_RODATA_ADDR="\
SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR}) + SIZEOF_HEADERS"
  else
    SHLIB_RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
    SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})"
  fi

PR ld/22696
* scripttempl/elf.sc: Fix the order of SHLIB_RODATA_ADDR.

6 years agoFix gdb.texinfo for old makeinfo
Szabolcs Nagy [Thu, 11 Jan 2018 12:13:39 +0000 (12:13 +0000)] 
Fix gdb.texinfo for old makeinfo

With old makeinfo (version 4.13) the changes introduced in

commit 2d97a5d9d33aea87c3bd02fd1fa417f5d4e1fa05
Author:     John Baldwin <jhb@FreeBSD.org>

    Document support for 'info proc' on FreeBSD.

fail to build.

gdb/doc/ChangeLog:

* gdb.texinfo (pwd): Fix whitespace.