Commit Graph

14561 Commits

Author SHA1 Message Date
Faraz Shahbazker 6f20c942c3 MIPS: Add Global INValidate ASE support
Add support for the Global INValidate Application Specific Extension
for Release 6 of the MIPS Architecture.

[1] "MIPS Architecture for Programmers Volume II-A: The MIPS32
    Instruction Set Manual", Imagination Technologies Ltd., Document
    Number: MD00086, Revision 6.06, December 15, 2016, Section 3.2
    "Alphabetical List of Instructions", pp. 187-191

bfd/
	* elfxx-mips.c (print_mips_ases): Add GINV extension.

binutils/
	* readelf.c (print_mips_ases): Add GINV extension.

gas/
	* NEWS: Mention MIPS Global INValidate ASE support.
	* config/tc-mips.c (options): Add OPTION_GINV and OPTION_NO_GINV.
	(md_longopts): Likewise.
	(mips_ases): Define availability for GINV.
	(mips_convert_ase_flags): Map ASE_GINV to AFL_ASE_GINV.
	(md_show_usage): Add help for -mginv and -mno-ginv.
	* doc/as.texinfo: Document -mginv, -mno-ginv.
	* doc/c-mips.texi: Document -mginv, -mno-ginv, .set ginv and
	.set noginv.
	* testsuite/gas/mips/ase-errors-1.s: Add error checks for GINV
	ASE.
	* testsuite/gas/mips/ase-errors-2.s: Likewise.
	* testsuite/gas/mips/ase-errors-1.l: Likewise.
	* testsuite/gas/mips/ase-errors-2.l: Likewise.
	* testsuite/gas/mips/ginv.d: New test.
	* testsuite/gas/mips/ginv-err.d: New test.
	* testsuite/gas/mips/ginv-err.l: New test stderr output.
	* testsuite/gas/mips/ginv.s: New test source.
	* testsuite/gas/mips/ginv-err.s: New test source.
	* testsuite/gas/mips/mips.exp: Run the new tests.

include/
	* elf/mips.h (AFL_ASE_GINV, AFL_ASE_RESERVED1): New macros.
	(AFL_ASE_MASK): Update to include AFL_ASE_GINV.
	* opcode/mips.h: Document "+\" operand format.
	(ASE_GINV): New macro.

opcodes/
	* mips-dis.c (mips_arch_choices): Add GINV to mips32r6 and
	mips64r6 descriptors.
	(parse_mips_ase_option): Handle -Mginv option.
	(print_mips_disassembler_options): Document -Mginv.
	* mips-opc.c (decode_mips_operand) <+\>: New operand format.
	(GINV): New macro.
	(mips_opcodes): Define ginvi and ginvt.
2018-06-14 21:34:49 +01:00
H.J. Lu 1f6f5dba57 elf: Check if the first symbol version is base version
Check VER_FLG_BASE instead of assuming that the first symbol version is
base version.

bfd/

	PR binutils/23267
	* elf.c (_bfd_elf_get_symbol_version_string): Check if the first
	symbol version is base version.

binutils/

	PR binutils/23267
	* readelf.c (get_symbol_version_string): Check if the first
	symbol version is base version.
2018-06-14 05:37:33 -07:00
Alan Modra 7f923b7fd2 ELF dynsyms
Many ELF targets arrange to emit a number of section symbols in
.dynsym for use by dynamic relocations.  This happens before the
dynamic relocations are output, and the need for those symbols
determined.  In most cases they are not needed.  A proper analysis of
the need for dynamic section symbols is target specific and tedious,
so this patch just excludes them in the obvious case when no
dynamic relocations are present.

The patch also runs the new pr23161 and pr23162 tests on more targets.

bfd/
	* elf-bfd.h (struct elf_link_hash_table): Add "dynamic_relocs".
	* elflink.c (_bfd_elf_init_2_index_sections): Comment fix.
	(_bfd_elf_add_dynamic_entry): Set "dynamic_relocs".
	(_bfd_elf_link_renumber_dynsyms): Exclude all section symbols when
	"dynamic_relocs" is not set.
	* elfxx-mips.c (count_section_dynsyms): Likewise.
ld/
	* testsuite/ld-elf/readelf.exp: Delete DUMP and selection of
	variant ver_def.vd.
	* testsuite/ld-elf/ver_def-tic6x.vd: Delete.
	* testsuite/ld-elf/shared.exp: Run most pr23161 and pr23162 tests for
	linux, nacl and gnu targets.
	* testsuite/ld-mips-elf/mips-elf.exp: Set base_syms to 1.
	* testsuite/ld-elf/pr23161a.rd: Don't check reloc type.  Allow any
	order of __bss_start, _edata and _end.
	* testsuite/ld-elf/pr23161b.rd: Don't check plt and dyn relocs.
	Allow and order of __bss_start, _edata and _end.
	* testsuite/ld-elf/pr23162.rd: Fail if __bss_start, _edata or _end
	relocs are present rather than testing for no relocations.
	* testsuite/ld-aarch64/gc-plt-relocs.d,
	* testsuite/ld-aarch64/ifunc-1-local.d,
	* testsuite/ld-aarch64/ifunc-1.d,
	* testsuite/ld-aarch64/ifunc-2-local.d,
	* testsuite/ld-aarch64/ifunc-2.d,
	* testsuite/ld-aarch64/ifunc-21.d,
	* testsuite/ld-aarch64/ifunc-3a.d,
	* testsuite/ld-arm/farcall-mixed-lib-v4t.d,
	* testsuite/ld-arm/farcall-mixed-lib.d,
	* testsuite/ld-arm/gc-hidden-1.d,
	* testsuite/ld-arm/tls-gdesc-got.d,
	* testsuite/ld-arm/tls-lib-loc.d,
	* testsuite/ld-arm/tls-longplt-lib.d,
	* testsuite/ld-arm/tls-thumb1.d,
	* testsuite/ld-cris/libdso-10.d,
	* testsuite/ld-cris/libdso-11.d,
	* testsuite/ld-cris/libdso-13b.d,
	* testsuite/ld-cris/libdso-14.d,
	* testsuite/ld-cris/libdso-15.d,
	* testsuite/ld-cris/pic-gc-72.d,
	* testsuite/ld-cris/pic-gc-73.d,
	* testsuite/ld-cris/tls-gc-71.d,
	* testsuite/ld-mips-elf/mips16-pic-4a.nd,
	* testsuite/ld-mips-elf/pic-and-nonpic-3a.dd,
	* testsuite/ld-mips-elf/pie-n32.d,
	* testsuite/ld-mips-elf/pie-n64.d,
	* testsuite/ld-mips-elf/pie-o32.d: Update for removed dynamic
	section symbols.
2018-06-14 11:32:01 +09:30
Alan Modra ff91d2f0e2 PR23282, Reinstate seek optimization
PR 23282
	* bfdio.c (bfd_seek): Optimize away seeks to current position.
2018-06-14 11:32:01 +09:30
GDB Administrator 7be6cc9284 Automatic date update in version.in 2018-06-14 00:00:36 +00:00
Scott Egerton 730c31740a MIPS: Add CRC ASE support
Add support for the CRC Application Specific Extension for Release 6 of
the MIPS Architecture.

[1] "MIPS Architecture for Programmers Volume II-A: The MIPS32
    Instruction Set Manual", Imagination Technologies Ltd., Document
    Number: MD00086, Revision 6.06, December 15, 2016, Section 3.2
    "Alphabetical List of Instructions", pp. 143-148

[2] "MIPS Architecture for Programmers Volume II-A: The MIPS64
    Instruction Set Manual", Imagination Technologies Ltd., Document
    Number: MD00087, Revision 6.06, December 15, 2016, Section 3.2
    "Alphabetical List of Instructions", pp. 165-170

ChangeLog:

bfd/
2018-06-13  Scott Egerton  <scott.egerton@imgtec.com>
            Faraz Shahbazker  <Faraz.Shahbazker@mips.com>

	* elfxx-mips.c (print_mips_ases): Add CRC.

binutils/
2018-06-13  Scott Egerton  <scott.egerton@imgtec.com>
            Faraz Shahbazker  <Faraz.Shahbazker@mips.com>

	* readelf.c (print_mips_ases): Add CRC.

gas/
2018-06-13  Scott Egerton  <scott.egerton@imgtec.com>
            Faraz Shahbazker  <Faraz.Shahbazker@mips.com>
            Maciej W. Rozycki  <macro@mips.com>

	* config/tc-mips.c (options): Add OPTION_CRC and OPTION_NO_CRC.
	(md_longopts): Likewise.
	(md_show_usage): Add help for -mcrc and -mno-crc.
	(mips_ases): Define availability for CRC and CRC64.
	(mips_convert_ase_flags): Map ASE_CRC to AFL_ASE_CRC.
	* doc/as.texinfo: Document -mcrc, -mno-crc.
	* doc/c-mips.texi: Document -mcrc, -mno-crc, .set crc and
	.set no-crc.
	* testsuite/gas/mips/ase-errors-1.l: Add error checks for CRC
	ASE.
	* testsuite/gas/mips/ase-errors-2.l: Likewise.
	* testsuite/gas/mips/ase-errors-1.s: Likewise.
	* testsuite/gas/mips/ase-errors-2.s: Likewise.
	* testsuite/gas/mips/crc.d: New test.
	* testsuite/gas/mips/crc64.d: New test.
	* testsuite/gas/mips/crc-err.d: New test.
	* testsuite/gas/mips/crc64-err.d: New test.
	* testsuite/gas/mips/crc-err.l: New test stderr output.
	* testsuite/gas/mips/crc64-err.l: New test stderr output.
	* testsuite/gas/mips/crc.s: New test source.
	* testsuite/gas/mips/crc64.s: New test source.
	* testsuite/gas/mips/crc-err.s: New test source.
	* testsuite/gas/mips/crc64-err.s: New test source.
	* testsuite/gas/mips/mips.exp: Run the new tests.

include/
2018-06-13  Scott Egerton  <scott.egerton@imgtec.com>
            Faraz Shahbazker  <Faraz.Shahbazker@mips.com>

	* elf/mips.h (AFL_ASE_CRC): New macro.
	(AFL_ASE_MASK): Update to include AFL_ASE_CRC.
	* opcode/mips.h (ASE_CRC): New macro.
	* opcode/mips.h (ASE_CRC64): Likewise.

opcodes/
2018-06-13  Scott Egerton  <scott.egerton@imgtec.com>
            Faraz Shahbazker  <Faraz.Shahbazker@mips.com>

	* mips-dis.c (mips_arch_choices): Add CRC and CRC64 ASEs.
	* mips-opc.c (CRC, CRC64): New macros.
	(mips_builtin_opcodes): Define crc32b, crc32h, crc32w,
	crc32cb, crc32ch and crc32cw for CRC.  Define crc32d and
	crc32cd for CRC64.
2018-06-13 15:39:05 +01:00
GDB Administrator c75c496d6d Automatic date update in version.in 2018-06-13 00:00:44 +00:00
GDB Administrator 90b345f613 Automatic date update in version.in 2018-06-12 00:00:49 +00:00
GDB Administrator 65a68903e2 Automatic date update in version.in 2018-06-11 00:01:03 +00:00
GDB Administrator 09897e3330 Automatic date update in version.in 2018-06-10 00:01:24 +00:00
GDB Administrator 30d42fef63 Automatic date update in version.in 2018-06-09 00:00:45 +00:00
H.J. Lu ecf99cc092 ld/x86: Remove hidden _edata, __bss_start, and _end
There is no need to put hidden _edata, __bss_start, and _end in dynamic
symbol table in shared libraries.

bfd/

	PR ld/23161
	* elfxx-x86.c (elf_x86_hide_linker_defined): New function.
	(_bfd_x86_elf_link_check_relocs): Use it to hide hidden
	__bss_start, _end and _edata in shared libraries.

ld/

	PR ld/23161
	* testsuite/ld-elf/pr23161d.rd: Remove local _edata, __bss_start,
	and _end from dynamic symbol table.
2018-06-08 12:41:54 -07:00
GDB Administrator 4f652d7b9a Automatic date update in version.in 2018-06-08 00:00:43 +00:00
GDB Administrator 066b621238 Automatic date update in version.in 2018-06-07 00:00:50 +00:00
Alan Modra 527278f336 TIC6X __c6xabi_DSBT_BASE
Adding an undefined __c6xabi_DSBT_BASE via an EXTERN in the linker
script isn't ideal, as the symbol is not always needed.  This patch
adds the undefined symbol on encountering relocations where it is
implicitly referenced.

bfd/
	* elf32-tic6x.c (elf32_tic6x_check_relocs): Reference
	__c6xabi_DSBT_BASE explicitly for R_C6000_SBR_* relocs.
ld/
	* emulparams/elf32_tic6x_le.sh (EXECUTABLE_SYMBOLS): Don't define.
2018-06-07 09:07:32 +09:30
GDB Administrator 773ff7907c Automatic date update in version.in 2018-06-06 00:00:53 +00:00
Alan Modra 5c4ce239a3 Tidy bfdio to consistenly use containing archive
Archive element IO is performed on the file of the containing archive,
which leads to the BFD "where" field of archives and their elements
being out of sync with the real file position.  (We're talking
traditional archives here, not thin archives.)  The old bfd_seek code
recognized this by not attempting to optimize away seeks for
archives.  However, there was other code that could return bogus
results.  For example, cache.c limits the number of open files by
closing a file and remembering its state once the limit is reached.
If bfd_tell is called on an archive element when the containing
archive is closed, it will return an invalid file pointer.

It's possible to have a valid "where" field for archives by always
using and updating the containing archive BFD.  That's what this patch
does.  Note that cache.c used to find the containing archive BFD
anyway for the iostream, so we're not really doing extra work, just
transferring it up to the correct abstraction level.

The patch also gets rid of some hacks.  bfd_tell was called when
bfd_seek failed, in an attempt to correct "where".  That's got to be
papering over another problem, so that code has been removed.
bfd_read also had an "optimiziation" to return early when the number
of bytes was zero, and bfd_seek optimized calls that didn't move the
file pointer.  This was covering for a coff_slurp_line_table bug where
IO was attempted on a pe-dll BFD without an iovec.

	* bfd.c (struct bfd): Update comment on "where" usage.
	* bfdio.c (bfd_bwrite, bfd_stat): Use and update "iovec",
	"iostream", and "where" from containing archive file.  Return
	error on NULL iovec.
	(bfd_bread): Similarly, and return error attempted out of
	bounds archive element access.
	(bfd_tell, bfd_flush): Use and update "iovec", "iostream", and
	"where" from containing archive file.
	(bfd_seek): Likewise.  Return error on NULL iovec.  Don't
	attempt to optimize away seeks.  Don't paper over errors by
	calling bfd_tell.
	(bfd_get_mtime): Call bfd_stat rather than iovec->bstat.
	(bfd_get_size): Likewise.
	(bfd_mmap): Operate on and use iovec of containing archive
	file.  Return error on NULL iovec.
	* cache.c (bfd_cache_lookup_worker): Abort if working on
	archive element bfd.
	(cache_bread_1): Delete bfd parameter, add FILE* parameter.
	Don't ignore zero byte reads.
	(cache_bread): Look up FILE* in cache here.  Error on NULL
	lookup.
	(cache_bwrite): Rename "where" to "from".
	(cache_bmmap): Don't handle archive elements.
	* coffcode.h (coff_slurp_line_table): Exit early on zero
	lineno count.
	* bfd-in2.h: Regenerate.
2018-06-05 22:39:12 +09:30
Alan Modra 27b0767593 PR23254, ld.bfd mishandles file pointers while scanning archive
Best practice is to not mix lseek/read with fseek/fread on the same
underlying file descriptor, as not all stdio implementations will cope.
Since the plugin uses lseek/read while bfd uses fseek/fread this patch
reopens the file for exclusive use by the plugin rather than trying to
restore the file descriptor.  That allows the plugin to read the file
after plugin_call_claim_file too.

bfd/
	PR 23254
	* plugin.c (bfd_plugin_open_input): Allow for possibility of
	nested archives.  Open file again for plugin.
	(try_claim): Don't save and restore file position.  Close file
	if not claimed.
	* sysdep.h (O_BINARY): Define.
ld/
	PR 23254
	* plugin.c (plugin_call_claim_file): Revert 2016-07-19 patch.
	(plugin_object_p): Don't dup file descriptor.
2018-06-05 22:39:11 +09:30
GDB Administrator e6d079c2fb Automatic date update in version.in 2018-06-05 00:00:36 +00:00
Max Filippov 4b8e28c793 xtensa: use property tables for correct disassembly
xtensa disassembler does not use information from the .xt.prop sections
to switch between code/data disassembly in text sections. This may
result in incorrect disassembly when data is interpreted as code and
disassembler loses synchronization with instruction stream. Use .xt.prop
section information to correctly interpret code and data and synchronize
with instruction stream.

2018-06-04  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
	* elf32-xtensa.c (xtensa_read_table_entries): Make global.
	(compute_fill_extra_space): Drop declaration. Rename function to
	xtensa_compute_fill_extra_space.
	(compute_ebb_actions, remove_dead_literal): Update references to
	compute_fill_extra_space.

include/
	* elf/xtensa.h (xtensa_read_table_entries)
	(xtensa_compute_fill_extra_space): New declarations.

opcodes/
	* xtensa-dis.c (bfd.h, elf/xtensa.h): New includes.
	(dis_private): Add new fields for property section tracking.
	(xtensa_coalesce_insn_tables, xtensa_find_table_entry)
	(xtensa_instruction_fits): New functions.
	(fetch_data): Bump minimal fetch size to 4.
	(print_insn_xtensa): Make struct dis_private static.
	Load and prepare property table on section change.
	Don't disassemble literals. Don't disassemble instructions that
	cross property table boundaries.
2018-06-04 10:38:55 -07:00
Max Filippov 8255c61b8a xtensa: add separate property sections option
It is currently not possible to correctly match .xt.prop information
for sections with identical VMA. Allow creation of separate property
sections in the BFD. Add assembler option --separate-prop-tables to
allow creation of separate property sections.

2018-06-04  Volodymyr Arbatov  <arbatov@cadence.com>
bfd/

	* elf32-xtensa.c (elf32xtensa_separate_props): New global
	variable.
	(xtensa_add_names): New function.
	(xtensa_property_section_name): Add new parameter
	separate_sections, use it to choose property section name.
	(xtensa_get_separate_property_section): New function.
	(xtensa_get_property_section): Invoke
	xtensa_get_separate_property_section to get individual property
	section if it exists, common property section otherwise.
	(xtensa_make_property_section): Pass elf32xtensa_separate_props
	to xtensa_property_section_name.

gas/
	* config/tc-xtensa.c (elf32xtensa_separate_props): New
	declaration.
	(option_separate_props, option_no_separate_props): New
	enumeration constants.
	(md_longopts): Add separate-prop-tables option.
	(md_parse_option): Add cases for option_separate_props and
	option_no_separate_props.
	(md_show_usage): Add help for [no-]separate-prop-tables options.
2018-06-04 10:36:39 -07:00
H.J. Lu 95da985446 Use DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION to silence GCC 8.1
GCC 8.1 warns about destination size with -Wstringop-truncation:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643

Use DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION to silence it.

bfd/

	PR binutils/23146
	* bfd-in.h: Include "diagnostics.h".
	* bfd-in2.h: Regenerated.
	* elf32-arm.c (elf32_arm_nabi_write_core_note): Use
	DIAGNOSTIC_PUSH, DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION and
	DIAGNOSTIC_POP to silence GCC 8.1 warnings with
	-Wstringop-truncation.
	* elf32-ppc.c (ppc_elf_write_core_note): Likewse.
	* elf32-s390.c (elf_s390_write_core_note): Likewse.
	* elf64-ppc.c (ppc64_elf_write_core_note): Likewse.
	* elf64-s390.c (elf_s390_write_core_note): Likewse.
	* elfxx-aarch64.c (_bfd_aarch64_elf_write_core_note): Likewse.

include/

	* diagnostics.h (DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION): Always
	define for GCC.
2018-06-04 10:01:46 -07:00
GDB Administrator ff183b0d82 Automatic date update in version.in 2018-06-04 00:00:48 +00:00
Jim Wilson cf7a5066b9 RISC-V: Handle out-of-range calls to undefined weak.
bfd/
	PR ld/23244
	* elfnn-riscv.c (riscv_elf_relocate_section) <R_RISCV_CALL>: Check
	for and handle an undefined weak with no PLT.

	ld/
	* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Run new weak ref tests.
	* testsuite/ld-riscv-elf/weakref.ld: New.
	* testsuite/ld-riscv-elf/weakref32.d: New.
	* testsuite/ld-riscv-elf/weakref32.s: New.
	* testsuite/ld-riscv-elf/weakref64.d: New.
	* testsuite/ld-riscv-elf/weakref64.s: New.
2018-06-03 15:42:29 -07:00
Jim Wilson 137b5cbd20 RISC-V: Fix symbol address problem with versioned symbols.
bfd/
	PR ld/22756
	* elfnn-riscv.c (riscv_relax_delete_bytes): Add versioned_hidden check
	to code that ignores duplicate symbols.
2018-06-03 14:44:44 -07:00
GDB Administrator b15fe636af Automatic date update in version.in 2018-06-03 00:00:49 +00:00
GDB Administrator a131318670 Automatic date update in version.in 2018-06-02 00:00:35 +00:00
H.J. Lu 55e99962b2 Bump version number to 2.30.52
Bump version number to 2.30.52 since _bfd_link_hide_symbol has been added
to bfd_target.

bfd/

	* version.m4: Bump version to 2.30.52
	* configure: Regenerated.

binutils/

	* configure: Regenerated.

gas/

	* configure: Regenerated.

gprof/

	* configure: Regenerated.

ld/

	* configure: Regenerated.

opcodes/

	* configure: Regenerated.
2018-06-01 09:34:16 -07:00
Alan Modra 030157d8a6 Make _bfd_error_handler available outside libbfd
Needed when building libopcodes.so.

bfd/
	* bfd.c (_bfd_error_handler): Arrange for this function to be
	declared in bfd-in2.h.
	* libbfd-in.h (_bfd_error_handler): Don't declare.
	* libbfd.h: Regenerate.
	* bfd-in2.h: Regenerate.
opcodes/
	* sysdep.h (_bfd_error_handler): Don't declare.
	* msp430-decode.opc: Include bfd.h.  Don't include ansidecl.h here.
	* rl78-decode.opc: Likewise.
	* msp430-decode.c: Regenerate.
	* rl78-decode.c: Regenerate.
2018-06-01 13:10:33 +09:30
GDB Administrator 61a9a607b5 Automatic date update in version.in 2018-06-01 00:01:00 +00:00
GDB Administrator 4a4459db18 Automatic date update in version.in 2018-05-31 00:00:35 +00:00
Amaan Cheval 421acf1873 2018-05-30 Amaan Cheval <amaan.cheval@gmail.com>
* config.bfd (x86_64-*-*): Add pei-x86-64 target to x86_64-*-rtems*
	This is needed to generate UEFI application image files from ELFs.
2018-05-30 10:04:28 -05:00
GDB Administrator 51af6fa066 Automatic date update in version.in 2018-05-30 00:01:00 +00:00
GDB Administrator fe1658217f Automatic date update in version.in 2018-05-29 00:00:36 +00:00
H.J. Lu 92e68c1d65 x86-64: Add TLSDESC fields to elf_x86_lazy_plt_layout
ENDBR64 is added to the special TLSDESC entry, which is similar to the
PLT0 entry, in the x86-64 lazy procedure linkage table to support Intel
CET.  The NaCl PLT is different from the normal PLT.  This patch adds
plt_tlsdesc_entry, plt_tlsdesc_entry_size, plt_tlsdesc_got1_offset,
plt_tlsdesc_got2_offset, plt_tlsdesc_got1_insn_end and
plt_tlsdesc_got2_insn_end to elf_x86_lazy_plt_layout to support both
normal and NaCl TLSDESC entries.  This fixed

FAIL: TLS descriptor -fpic -shared transitions

for x86_64-nacl.

	* elf32-i386.c (elf_i386_lazy_plt): Add plt_tlsdesc_entry,
	plt_tlsdesc_entry_size, plt_tlsdesc_got1_offset,
	plt_tlsdesc_got2_offset, plt_tlsdesc_got1_insn_end and
	plt_tlsdesc_got2_insn_end for TLSDESC entry.
	(elf_i386_lazy_ibt_plt): Likewise.
	(elf_i386_nacl_plt): Likewise.
	* elf64-x86-64.c (tlsdesc_plt_entry): Moved and renamed to ...
	(elf_x86_64_tlsdesc_plt_entry): This.
	(elf_x86_64_lazy_plt): Add plt_tlsdesc_entry,
	plt_tlsdesc_entry_size, plt_tlsdesc_got1_offset,
	plt_tlsdesc_got2_offset, plt_tlsdesc_got1_insn_end and
	plt_tlsdesc_got2_insn_end for TLSDESC entry.
	(elf_x86_64_lazy_bnd_plt): Likewise.
	(elf_x86_64_lazy_ibt_plt): Likewise.
	(elf_x32_lazy_ibt_plt): Likewise.
	(elf_x86_64_nacl_plt): Likewise.
	(elf_x86_64_finish_dynamic_sections): Use plt_tlsdesc_entry,
	plt_tlsdesc_entry_size, plt_tlsdesc_got1_offset,
	plt_tlsdesc_got2_offset, plt_tlsdesc_got1_insn_end and
	plt_tlsdesc_got2_insn_end to update TLSDESC entry.
	* elfxx-x86.h (elf_x86_lazy_plt_layout): Update comments.
	Add plt_tlsdesc_entry, plt_tlsdesc_entry_size,
	plt_tlsdesc_got1_offset, plt_tlsdesc_got2_offset,
	plt_tlsdesc_got1_insn_end and plt_tlsdesc_got2_insn_end.
	(elf_x86_non_lazy_plt_layout): Update comments.
	(elf_x86_plt_layout): Likewise.
2018-05-28 10:46:16 -07:00
H.J. Lu ac98f9e227 ld: Unify STT_GNU_IFUNC handling
Take STT_GNU_IFUNC handling scattered across targets and gather it in
the generic ELF linker.

bfd/

	PR ld/23238
	* elf-s390-common.c (elf_s390_add_symbol_hook): Removed.
	* elf32-arc.c (elf_arc_add_symbol_hook): Likewise.
	(elf_backend_add_symbol_hook): Likewise.
	* elf32-m68k.c (elf_m68k_add_symbol_hook): Likewise.
	(elf_backend_add_symbol_hook): Likewise.
	* elf32-s390.c (elf_backend_add_symbol_hook): Likewise.
	* elf32-sparc.c (elf32_sparc_add_symbol_hook): Likewise.
	(elf_backend_add_symbol_hook): Likewise.
	* elf64-s390.c (elf_backend_add_symbol_hook): Likewise.
	* elfxx-aarch64.c (_bfd_aarch64_elf_add_symbol_hook): Likewise.
	* elfxx-aarch64.h (_bfd_aarch64_elf_add_symbol_hook): Likewise.
	(elf_backend_add_symbol_hook): Likewise.
	* elf32-arm.c (elf32_arm_add_symbol_hook): Remove STT_GNU_IFUNC
	handling.
	* elf32-ppc.c (ppc_elf_add_symbol_hook): Likewise.
	* elf64-ppc.c (ppc64_elf_add_symbol_hook): Likewise.
	* elf64-sparc.c (elf64_sparc_add_symbol_hook): Likewise.
	* elflink.c (elf_link_add_object_symbols): Set
	elf_gnu_symbol_ifunc for STT_GNU_IFUNC symbols.

ld/

	PR ld/23238
	* testsuite/ld-ifunc/ifunc-26.d: New file.
	* testsuite/ld-ifunc/ifunc-26.s: Likewise.
	* testsuite/ld-ifunc/ifunc.exp: Run *.d tests without a
	working compiler.
2018-05-28 08:15:21 -07:00
GDB Administrator 46207bf3b5 Automatic date update in version.in 2018-05-28 00:00:23 +00:00
GDB Administrator 121dac5822 Automatic date update in version.in 2018-05-27 00:01:17 +00:00
H.J. Lu 099bb8fb97 ld: Add _bfd_elf_link_hide_sym_by_version
bfd_hide_sym_by_version can't be used to check if a versioned symbol is
hidden.  This patch adds _bfd_elf_link_hide_sym_by_version to support
both versioned and unversioned symbols by extracting versioned symbol
check from _bfd_elf_link_assign_sym_version.

bfd/

	PR ld/23194
	* elf-bfd.h (_bfd_elf_link_hide_sym_by_version): New.
	* elflink.c (_bfd_elf_link_hide_versioned_symbol): New function.
	Extracted from _bfd_elf_link_assign_sym_version.
	(_bfd_elf_link_hide_sym_by_version): New function.
	(_bfd_elf_link_assign_sym_version): Use
	_bfd_elf_link_hide_versioned_symbol.
	* elfxx-x86.c (_bfd_x86_elf_link_symbol_references_local): Call
	_bfd_elf_link_hide_sym_by_version instead of
	bfd_hide_sym_by_version.  Don't check unversioned symbol.

ld/

	PR ld/23194
	* testsuite/ld-i386/pr23194.d: Expect only R_386_GLOB_DAT
	against foobar.
	* testsuite/ld-i386/pr23194.map: Add foobar.
	* testsuite/ld-x86-64/pr23194.map: Likewise.
	* testsuite/ld-i386/pr23194.s: Add a common foobar symbol.
	* testsuite/ld-x86-64/pr23194.s: Likewise.
	* testsuite/ld-x86-64/pr23194.d: Expect only R_X86_64_GLOB_DAT
	against foobar.
2018-05-26 04:27:24 -07:00
GDB Administrator d7460de3ea Automatic date update in version.in 2018-05-26 00:00:34 +00:00
Alan Modra 277eb7f64a s12z regen
This patch regenerates a number of files that either were edited by
hand or not regenerated when s12z support was added to binutils.

bfd/
	* Makefile.in: Regenerate.
	* po/SRC-POTFILES.in: Regenerate.
gas/
	* po/POTFILES.in: Regenerate.
ld/
	* po/BLD-POTFILES.in: Regenerate.
opcodes/
	* Makefile.in: Regenerate.
	* po/POTFILES.in: Regenerate.
2018-05-25 16:05:30 +09:30
Alan Modra 629dabe3b7 Fix hidden visibility compiler test
Warnings from configure tests aren't usually checked.  gcc's
"visibility attribute not supported in this configuration" warning is
enabled by default so we don't need to add any warning flag except
-Werror.

	* configure.ac (bfd_cv_hidden): Run test with -Werror in CFLAGS.
	* configure: Regenerate.
2018-05-25 15:26:47 +09:30
GDB Administrator f9885f5602 Automatic date update in version.in 2018-05-25 00:00:18 +00:00
GDB Administrator 08163f025e Automatic date update in version.in 2018-05-24 00:00:28 +00:00
H.J. Lu 9ef6d1e31f Add ATTRIBUTE_NONSTRING to ppc64_elf_write_core_note
This patch silences gcc8 -Wstringop-truncation warnings.

	* elf64-ppc.c (ppc64_elf_write_core_note): Add ATTRIBUTE_NONSTRING
	to data.
2018-05-23 10:15:11 -07:00
GDB Administrator f2a3bd7da2 Automatic date update in version.in 2018-05-23 00:00:29 +00:00
Alan Modra 215f527155 PR23207, hppa ld SIGSEGVs on invalid object files
The last patch was enough to cure the testcase, but not the original
object file.  This patch does the same for hppa as is done for ppc64,
simply test for the section belonging to a group.  I've also
restricted stubs to load, alloc, code sections.

	PR 23207
	* elf32-hppa.c (hppa_get_stub_entry): Return NULL when link_sec
	is NULL.
	(elf32_hppa_size_stubs): Only create stubs for load, alloc, code
	sections.
	(final_link_relocate): Revert last change.
2018-05-22 19:37:06 +09:30
Alan Modra 7455c018e4 PR23207, hppa ld SIGSEGVs on invalid object files
We don't create PLT call stubs for anything in non-alloc sections,
so it doesn't pay to go looking for them.  The problem is that
non-alloc sections aren't processed by group_sections and thus don't
get a link_sec set up for them.

	PR 23207
	* elf32-hppa.c (final_link_relocate): Don't look for plt call
	stubs in non-alloc sections.
2018-05-22 14:45:15 +09:30
H.J. Lu 34a87bb07a ld: Hide symbols defined by HIDDEN/PROVIDE_HIDDEN
There should be no difference in output for symbols defined by HIDDEN
or PROVIDE_HIDDEN assignments whether they are explicitly marked as
hidden or not.  This patch adds a new BFD function, bfd_link_hide_symbol,
to hide symbols defined by HIDDEN and PROVIDE_HIDDEN assignments.

bfd

	PR ld/23201
	* aout-target.h (MY_bfd_link_hide_symbol): New.
	* aout-tic30.c (MY_bfd_link_hide_symbol): Likewise.
	* binary.c (binary_bfd_link_hide_symbol): Likewise.
	* coff-alpha.c (_bfd_ecoff_bfd_link_hide_symbol): Likewise.
	* coff-mips.c (_bfd_ecoff_bfd_link_hide_symbol): Likewise.
	* coff-rs6000.c (_bfd_xcoff_bfd_link_hide_symbol): Likewise.
	* coffcode.h (coff_bfd_link_hide_symbol): Likewise.
	* elf-bfd.h (_bfd_elf_link_hide_symbol): Likewise.
	* elfxx-target.h (bfd_elfNN_bfd_link_hide_symbol): Likewise.
	* i386msdos.c (msdos_bfd_link_hide_symbol): Likewise.
	* ihex.c (ihex_bfd_link_hide_symbol): Likewise.
	* libbfd-in.h (_bfd_nolink_bfd_link_hide_symbol): Likewise.
	* linker.c (_bfd_generic_link_hide_symbol): Likewise.
	(bfd_link_hide_symbol): Likewise.
	* mach-o-target.c (bfd_mach_o_bfd_link_hide_symbol): Likewise.
	* mmo.c (mmo_bfd_link_hide_symbol): Likewise.
	* pef.c (bfd_pef_bfd_link_hide_symbol): Likewise.
	* plugin.c (bfd_plugin_bfd_link_hide_symbol): Likewise.
	* ppcboot.c (ppcboot_bfd_link_hide_symbol): Likewise.
	* som.c (som_bfd_link_hide_symbol): Likewise.
	* srec.c (srec_bfd_link_hide_symbol): Likewise.
	* tekhex.c (tekhex_bfd_link_hide_symbol): Likewise.
	* vms-alpha.c (vms_bfd_link_hide_symbol): Likewise.
	(alpha_vms_bfd_link_hide_symbol): Likewise.
	* xsym.c (bfd_sym_bfd_link_hide_symbol): Likewise.
	* coff64-rs6000.c (rs6000_xcoff64_vec): Add
	_bfd_generic_link_hide_symbol.
	(rs6000_xcoff64_aix_vec): Likewise.
	* elflink.c (bfd_elf_record_link_assignment): Don't make forced
	local symbol dynamic.
	(_bfd_elf_link_hide_symbol): New function.
	* elfxx-x86.c (_bfd_x86_elf_link_symbol_references_local): Don't
	check root.ldscript_def.
	* targets.c (bfd_target): Add _bfd_link_hide_symbol.
	(BFD_JUMP_TABLE_LINK): Add NAME##_bfd_link_hide_symbol.
	* bfd-in2.h: Regenerated.
	* libbfd.h: Likewise.

ld/

	PR ld/23201
	* ldexp.c (exp_fold_tree_1): Call bfd_link_hide_symbol to hide
	a symbol.
	* testsuite/ld-elf/provide-hidden-dynabs.nd: Removed.
	* testsuite/ld-elf/provide-hidden-dynsec.nd: Likewise.
	* testsuite/ld-elf/provide-hidden.exp: Replace
	provide-hidden-dynsec.nd with provide-hidden-sec.nd and
	provide-hidden-dyn.nd.  Replace provide-hidden-dynabs.nd with
	provide-hidden-abs.nd and provide-hidden-dyn.nd.
	* testsuite/ld-i386/pr23189.d: Expect no dynamic relocation.
	* testsuite/ld-x86-64/pr23189.d: Likewise.
2018-05-21 20:39:30 -07:00
H.J. Lu bae363f114 Mark section in a section group with SHF_GROUP
All sections in a section group should be marked with SHF_GROUP.  But
some tools generate broken objects without SHF_GROUP.  This patch fixes
them up for objcopy and strip.

	PR binutils/23199
	* elf.c (setup_group): Mark section in a section group with
	SHF_GROUP.
2018-05-21 19:25:33 -07:00