Commit Graph

91685 Commits

Author SHA1 Message Date
Pedro Alves 7c44b49cb6 Introduce gdb::array_view
An array_view is an abstraction that provides a non-owning view over a
sequence of contiguous objects.

A way to put it is that array_view is to std::vector (and std::array
and built-in arrays with rank==1) like std::string_view is to
std::string.

The main intent of array_view is to use it as function input parameter
type, making it possible to pass in any sequence of contiguous
objects, irrespective of whether the objects live on the stack or heap
and what actual container owns them.  Implicit construction from the
element type is supported too, making it easy to call functions that
expect an array of elements when you only have one element (usually on
the stack).  For example:

 struct A { .... };
 void function (gdb::array_view<A> as);

 std::vector<A> std_vec = ...;
 std::array<A, N> std_array = ...;
 A array[] = {...};
 A elem;

 function (std_vec);
 function (std_array);
 function (array);
 function (elem);

Views can be either mutable or const.  A const view is simply created
by specifying a const T as array_view template parameter, in which
case operator[] of non-const array_view objects ends up returning
const references.  (Making the array_view itself const is analogous to
making a pointer itself be const.  I.e., disables re-seating the
view/pointer.)  Normally functions will pass around array_views by
value.

Uses of gdb::array_view (other than the ones in the unit tests) will
be added in a follow up patch.

gdb/ChangeLog
2017-09-04  Pedro Alves  <palves@redhat.com>

	* Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
	unittests/array-view-selftests.c.
	(SUBDIR_UNITTESTS_OBS): Add array-view-selftests.o.
	* common/array-view.h: New file.
	* unittests/array-view-selftests.c: New file.
2017-09-04 17:10:12 +01:00
Pedro Alves e439fa140a Clarify "list" output when specified lines are ambiguous
Currently, with "list LINESPEC1,LINESPEC2", if one of the linespecs is
ambiguous, i.e., if it expands to multiple locations, you get this
seemingly odd output:

 (gdb) list foo,bar
 file: "file0.c", line number: 26
 file: "file1.c", line number: 29

Since "foo" above expands to multiple locations, the specified range
is indeterminate, and GDB is trying to be helpful by showing you what
was ambiguous.  It looks confusing to me, though.  I think it'd be
much more user friendly if GDB actually told you that, like this:

 (gdb) list foo,bar
 Specified first line 'foo' is ambiguous:
 file: "file0.c", line number: 26
 file: "file1.c", line number: 29

 (gdb) list bar,foo
 Specified last line 'foo' is ambiguous:
 file: "file0.c", line number: 26
 file: "file1.c", line number: 29

Note, I'm using "first" and "last" in the output because that's what
the manual uses:

 ~~~
 list first,last

     Print lines from first to last. [...]
 ~~~

Tested on x86-64 GNU/Linux.

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* cli/cli-cmds.c (edit_command): Pass message to
	ambiguous_line_spec.
	(list_command): Pass message to ambiguous_line_spec.  Say
	"first"/"last" instead of "start" and "end" to be consistent with
	the manual.
	(ambiguous_line_spec): Add 'format' and vararg parameters.  Use
	them to print formatted message.

gdb/testsuite/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* gdb.base/list-ambiguous.exp: New file.
	* gdb.base/list-ambiguous0.c: New file.
	* gdb.base/list-ambiguous1.c: New file.
	* gdb.base/list.exp (test_list_range): Adjust expected output.
2017-09-04 16:49:29 +01:00
Pedro Alves 7525b645df Fix build breakage when libipt is available
Fix build regression introduced by 0860c437cb ("btrace: Store
btrace_insn in an std::vector"):

  src/gdb/btrace.c: In function ‘void ftrace_add_pt(btrace_thread_info*, pt_insn_decoder*, int*, std::vector<unsigned int>&)’:
  src/gdb/btrace.c:1329:38: error: invalid initialization of reference of type ‘const btrace_insn&’ from expression of type ‘btrace_insn*’
      ftrace_update_insns (bfun, &btinsn);
					^
  src/gdb/btrace.c:648:1: note: in passing argument 2 of ‘void ftrace_update_insns(btrace_function*, const btrace_insn&)’
   ftrace_update_insns (struct btrace_function *bfun, const btrace_insn &insn)
   ^

gdb/ChangeLog:
2017-09-04  Pedro Alves  <palves@redhat.com>

	* btrace.c (ftrace_add_pt): Pass btrace_insn to
	ftrace_update_insns by reference instead of pointer.
2017-09-04 16:01:17 +01:00
Anthony Green 6c869779da Fix simulator 2017-09-04 10:00:37 -04:00
Yao Qi badc002020 Let i386_target_description return tdesc_i386_mmx
This patch remove the usage of tdesc_i386_mmx in i386-go32-tdep.c, and use
i386_target_description to get it instead.

gdb:

2017-09-04  Yao Qi  <yao.qi@linaro.org>

	* i386-go32-tdep.c: Include x86-xstate.h.
	(i386_go32_init_abi): Call i386_target_description.
	* i386-tdep.c (i386_target_description): Return tdesc_i386_mmx
	if xcr0 is X86_XSTATE_X87_MASK.
	* i386-tdep.h (tdesc_i386): Remove the declaration.
	(tdesc_i386_mmx): Likewise.
2017-09-04 11:33:56 +01:00
Yao Qi d78bdb54ac Return X86_XSTATE_SSE_MASK instead of 0 in i386fbsd_core_read_xcr0
i386fbsd_core_read_xcr0 reads the value of xcr0 from the corefile.  If
it fails, returns 0.  This makes its caller {i386,amd64}_target_description
has to handle this special value.  IMO, i386fbsd_core_read_xcr0 should
return the default xcr0 in case of error.

gdb:

2017-09-04  Yao Qi  <yao.qi@linaro.org>

	* i386-fbsd-tdep.c (i386fbsd_core_read_xcr0): Return
	X86_XSTATE_SSE_MASK instead of 0.
2017-09-04 11:33:56 +01:00
Yao Qi ca1fa5eef2 Use i386_target_description to get tdesc_i386
GDB can call function i386_target_description to get the right target
description rather than tdesc_i386

gdb:

2017-09-04  Yao Qi  <yao.qi@linaro.org>

	* amd64-fbsd-nat.c (amd64fbsd_read_description): Call
	i386_target_description.
	* i386-fbsd-nat.c (i386fbsd_read_description): Call
	i386_target_description.
	* i386-tdep.c (i386_gdbarch_init): Likewise.
2017-09-04 11:33:56 +01:00
Yao Qi 2434b0199d Use amd64_target_description to get tdesc_amd64
This patch changes amd64-*-tdep.c files to use function
amd64_target_description to get the right target description rather than
use the variable tdesd_amd64.

gdb:

2017-09-04  Yao Qi  <yao.qi@linaro.org>

	* amd64-darwin-tdep.c: Include "x86-xstate.h".
	(x86_darwin_init_abi_64): Call amd64_target_description.
	* amd64-dicos-tdep.c: Likewise.
	* amd64-fbsd-nat.c: Likewise.
	* amd64-fbsd-tdep.c: Likewise.
	* amd64-nbsd-tdep.c: Likewise.
	* amd64-obsd-tdep.c: Likewise.
	* amd64-sol2-tdep.c: Likewise.
	* amd64-windows-tdep.c: Likewise.
	* amd64-tdep.h (tdesc_amd64): Remove the declaration.
2017-09-04 11:33:56 +01:00
Simon Marchi 0860c437cb btrace: Store btrace_insn in an std::vector
Because it contains a non-POD type field (flags), the type btrace_insn
should be new'ed/delete'd.  Replace the VEC (btrace_insn_s) in
btrace_function with an std::vector.

gdb/ChangeLog:

	* btrace.h (btrace_insn_s, DEF_VEC_O (btrace_insn_s)): Remove.
	(btrace_function) <insn>: Change type to use std::vector.
	* btrace.c (ftrace_debug, ftrace_call_num_insn,
	ftrace_find_call, ftrace_new_gap, ftrace_update_function,
	ftrace_update_insns, ftrace_compute_global_level_offset,
	btrace_stitch_bts, btrace_clear, btrace_insn_get,
	btrace_insn_end, btrace_insn_next, btrace_insn_prev): Adjust to
	change to std::vector.
	(ftrace_update_insns): Adjust to change to std::vector, change
	type of INSN parameter.
	(btrace_compute_ftrace_bts): Adjust call to ftrace_update_insns.
	* record-btrace.c (btrace_call_history_insn_range,
	btrace_compute_src_line_range,
	record_btrace_frame_prev_register): Adjust to change to
	std::vector.
	* python/py-record-btrace.c (recpy_bt_func_instructions): Adjust
	to change to std::vector.
2017-09-04 10:46:36 +02:00
GDB Administrator a826403eb6 Automatic date update in version.in 2017-09-04 00:00:29 +00:00
Tom Tromey 0638b7f902 Use std::string in reopen_exec_file
This changes reopen_exec_file to use a std::string, removing a
cleanup.

ChangeLog
2017-09-03  Tom Tromey  <tom@tromey.com>

	* corefile.c (reopen_exec_file): Use std::string.
2017-09-03 13:03:11 -06:00
Tom Tromey 8f84fb0ee8 Use std::string and unique_xmalloc_ptr in compile/ code
Change various things in the compile/ code to use std::string or
unique_xmalloc_ptr as appropriate.  This allows the removal of some
cleanups.

ChangeLog
2017-09-03  Tom Tromey  <tom@tromey.com>

	* compile/compile.c (compile_register_name_mangled): Return
	std::string.
	* compile/compile-loc2c.c (pushf_register_address): Update.
	(pushf_register): Update.
	* compile/compile-c-types.c (convert_array): Update.
	* compile/compile-c-symbols.c (generate_vla_size): Update.
	(error_symbol_once): Use a gdb::unique_xmalloc_ptr.
	(symbol_substitution_name): Return a gdb::unique_xmalloc_ptr.
	(convert_one_symbol): Update.
	(generate_c_for_for_one_variable): Update.
	* compile/compile-c-support.c (c_get_range_decl_name): Return a
	std::string.
	(generate_register_struct): Update.
	* compile/compile-internal.h (c_get_range_decl_name): Return a
	std::string.
	(compile_register_name_mangled): Return std::string.
2017-09-03 13:03:10 -06:00
Tom Tromey 18e9961f02 Return std::string from perror_string
Change perror_string to return a std::string, removing a cleanup in
the process.

ChangeLog
2017-09-03  Tom Tromey  <tom@tromey.com>

	* utils.c (perror_string): Return a std::string.
	(throw_perror_with_name, perror_warning_with_name): Update.
2017-09-03 13:03:09 -06:00
Tom Tromey 453437863c Use std::string and unique_xmalloc_ptr in demangle_command
Change demangle_command to use std::string and unique_xmalloc_ptr,
removing some cleanups.

ChangeLog
2017-09-03  Tom Tromey  <tom@tromey.com>

	* demangle.c (demangle_command): Use std::string,
	unique_xmalloc_ptr.
2017-09-03 13:03:08 -06:00
Tom Tromey b57af50345 Use std::string in do_set_command
Change do_set_command to use std::string, removing a cleanup and some
manual resizing code.

ChangeLog
2017-09-03  Tom Tromey  <tom@tromey.com>

	* cli/cli-setshow.c (do_set_command): Use std::string.
2017-09-03 13:03:07 -06:00
Tom Tromey 6eecf35f97 Use unique_xmalloc_ptr in cd_command
Change cd_command to use unique_xmalloc_ptr, removing a cleanup.

ChangeLog
2017-09-03  Tom Tromey  <tom@tromey.com>

	* cli/cli-cmds.c (cd_command): Use gdb::unique_xmalloc_ptr.
2017-09-03 13:03:06 -06:00
Tom Tromey 56496dd4d6 Use std::string in mi_cmd_interpreter_exec
Change mi_cmd_interpreter_exec to use std::string, removing a cleanup.

ChangeLog
2017-09-03  Tom Tromey  <tom@tromey.com>

	* mi/mi-interp.c (mi_cmd_interpreter_exec): Use std::string.
2017-09-03 13:03:05 -06:00
Tom Tromey e91a1fa7d4 Use unique_xmalloc_ptr in env_execute_cli_command
Change env_execute_cli_command to use unique_xmalloc_ptr, removing a
cleanup.

ChangeLog
2017-09-03  Tom Tromey  <tom@tromey.com>

	* mi/mi-cmd-env.c (env_execute_cli_command): Use
	gdb::unique_xmalloc_ptr.
2017-09-03 13:03:04 -06:00
Tom Tromey 7ffd83d70f Use std::string thread.c
This changes a few spots in thread.c to use std::string, removing some
cleanups.

ChangeLog
2017-09-03  Tom Tromey  <tom@tromey.com>

	* thread.c (print_thread_info_1): Use string_printf.
	(thread_apply_command, thread_apply_all_command): Use
	std::string.
2017-09-03 13:03:03 -06:00
Tom Tromey 1ccbe9985f Return std::string from memory_error_message
This changes memory_error_message to return a std::string and fixes up
the callers.  This removes some cleanups.

ChangeLog
2017-09-03  Tom Tromey  <tom@tromey.com>

	* valprint.c (val_print_string): Update.
	* gdbcore.h (memory_error_message): Return std::string.
	* corefile.c (memory_error_message): Return std::string.
	(memory_error): Update.
	* breakpoint.c (insert_bp_location): Update.
2017-09-03 13:03:02 -06:00
H.J. Lu 0e30d99180 x86-64: Set tlsdesc_plt if GOT_TLS_GDESC_P is true
We need to set tlsdesc_plt for x86-64 if GOT_TLS_GDESC_P is true when
allocating dynamic relocations so that _bfd_x86_elf_size_dynamic_sections
will generate TLSDESC_PLT and TLSDESC_GOT in x86-64 output.

bfd/

	PR ld/22071
	* elfxx-x86.c (elf_x86_allocate_dynrelocs): Set tlsdesc_plt
	for x86-64 if GOT_TLS_GDESC_P is true.

ld/

	PR ld/22071
	* testsuite/ld-x86-64/pr22071.d: New file.
	* testsuite/ld-x86-64/pr22071.s: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run pr22071.
2017-09-03 10:18:38 -07:00
Alan Modra 1cf58434bf PR22067, x86 check_relocs invalid read
PR 22067
	* elfxx-x86.h (elf_x86_hash_table): Check is_elf_hash_table first.
2017-09-03 22:09:38 +09:30
Simon Marchi 23fdd69e42 Make target_waitstatus_to_string return an std::string
A quite straightforward change.  It does "fix" leaks in record-btrace.c,
although since this is only used in debug printing code, it has no real
world impact.

gdb/ChangeLog:

	* target/waitstatus.h (target_waitstatus_to_string): Change
	return type to std::string.
	* target/waitstatus.c (target_waitstatus_to_string): Return
	std::string.
	* target.h (target_waitstatus_to_string): Remove declaration.
	* infrun.c (resume, clear_proceed_status_thread,
	print_target_wait_results, do_target_wait, save_waitstatus,
	stop_all_threads): Adjust.
	* record-btrace.c (record_btrace_wait): Adjust.
	* target-debug.h
	(target_debug_print_struct_target_waitstatus_p): Adjust.

gdb/gdbserver/ChangeLog:

	* linux-low.c (linux_wait_1): Adjust.
	* server.c (queue_stop_reply_callback): Adjust.
2017-09-03 10:23:31 +02:00
H.J. Lu f04bdfa7b2 Initialize tls_get_addr for x86-64 in one place
* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Initialize
	tls_get_addr for x86-64 in one place.
2017-09-02 22:14:58 -07:00
H.J. Lu d47a80260c Add missing ChangeLog entries 2017-09-02 22:10:39 -07:00
H.J. Lu 2ac3a7f5ce Add elf64-x86-64.lo together with elfxx-x86.lo for 64-bit BFD
Since elfxx-x86.lo needs elf64-x86-64.lo with 64-bit BFD now, add
elf64-x86-64.lo together with elfxx-x86.lo to bfd_backends for 64-bit
BFD.

	* configure.ac (bfd_backends): Add elf64-x86-64.lo together
	with elfxx-x86.lo for 64-bit BFD.
	* configure: Regenerated.
2017-09-02 22:04:27 -07:00
GDB Administrator aed02419fb Automatic date update in version.in 2017-09-03 00:00:30 +00:00
H.J. Lu 5e2ac45d56 x86: Add _bfd_x86_elf_size_dynamic_sections
elf_i386_size_dynamic_sections and elf_x86_64_size_dynamic_sections are
very similar, except for the followings:

1. elf_i386_size_dynamic_sections checks GOT_TLS_IE and GOT_TLS_IE_BOTH.
elf_x86_64_size_dynamic_sections checks only GOT_TLS_IE.  Since
GOT_TLS_IE_BOTH is never true for x86-64, it is OK to check GOT_TLS_IE
for both i386 and x86-64.
2, x86-64 sets tlsdesc_plt, but i386 doesn't.  We set tlsdesc_plt only
if target_id == X86_64_ELF_DATA.
3. x86-64 has

	  if (s != htab->elf.srelplt)
	    s->reloc_count = 0;

and i386 has

	  s->reloc_count = 0;

i386 did have

	  if (s != htab->srelplt)
	    s->reloc_count = 0;

in the original commit:

commit 67a4f2b710
Author: Alexandre Oliva <aoliva@redhat.com>
Date:   Wed Jan 18 21:07:51 2006 +0000

But it was removed by

commit 5ae0bfb60a
Author: Richard Sandiford <rdsandiford@googlemail.com>
Date:   Tue Feb 28 07:16:12 2006 +0000

    bfd/
            * elf32-i386.c (elf_i386_link_hash_table): Add next_tls_desc_index.
            (elf_i386_link_hash_table_create): Initialize it.
            (elf_i386_compute_jump_table_size): Use it instead of
            srelplt->reloc_count.
            (allocate_dynrelocs): Likewise.
            (elf_i386_size_dynamic_sections): Likewise.
            (elf_i386_relocate_section): Likewise.

A later commit:

commit e1f987424b
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Oct 21 15:13:37 2011 +0000

    Put IRELATIVE relocations after JUMP_SLOT.

    bfd/

    2011-10-21  H.J. Lu  <hongjiu.lu@intel.com>

            PR ld/13302
            * elf32-i386.c (elf_i386_link_hash_table): Add next_jump_slot_index
            and next_irelative_index.
            (elf_i386_link_hash_table_create): Initialize next_jump_slot_index
            and next_irelative_index.
            (elf_i386_allocate_dynrelocs): Increment reloc_count instead of
            next_tls_desc_index.
            (elf_i386_size_dynamic_sections): Set next_tls_desc_index and
            next_irelative_index from reloc_count.
            (elf_i386_finish_dynamic_symbol): Put R_386_IRELATIVE after
            R_386_JUMP_SLOT.

changed it back to use reloc_count again. So it is correct to use

	  if (s != htab->elf.srelplt)
	    s->reloc_count = 0;

for both i386 and x86-64 now.
4. i386 and x86-64 use different DT_XXXs.  They are handled by adding
them to elf_x86_link_hash_table.

With these changes, we can share _bfd_x86_elf_size_dynamic_sections in
elf32-i386.c and elf64-x86-64.c.

	* elf32-i386.c (elf_i386_convert_load): Renamed to ...
	(_bfd_i386_elf_convert_load): This.  Remove static.
	(elf_i386_size_dynamic_sections): Removed.
	(elf_backend_size_dynamic_sections): Likewise.
	* elf64-x86-64.c (elf_x86_64_convert_load): Renamed to ...
	(_bfd_x86_64_elf_convert_load): This.  Remove static.
	(elf_x86_64_size_dynamic_sections): Removed.
	(elf_backend_size_dynamic_sections): Likewise.
	* elfxx-x86.c (_bfd_x86_elf_allocate_dynrelocs): Renamed to ...
	(elf_x86_allocate_dynrelocs): This.  Make it static.
	(_bfd_x86_elf_allocate_local_dynrelocs): Renamed to ...
	(elf_x86_allocate_local_dynreloc): This.  Make it static.
	(elf_i386_is_reloc_section): New function.
	(elf_x86_64_is_reloc_section): Likewise.
	(_bfd_x86_elf_link_hash_table_create): Initialize convert_load,
	is_reloc_section, dt_reloc, dt_reloc_sz and dt_reloc_ent.
	Rearrange got_entry_size initialization.
	(_bfd_x86_elf_size_dynamic_sections): New function.
	* elfxx-x86.h (elf_x86_link_hash_table): Add convert_load,
	is_reloc_section, dt_reloc, dt_reloc_sz and dt_reloc_ent.
	(_bfd_i386_elf_convert_load): New.
	(_bfd_x86_64_elf_convert_load): Likewise.
	(_bfd_x86_elf_size_dynamic_sections): Likewise.
	(elf_backend_size_dynamic_sections): Likewise.
	(_bfd_x86_elf_allocate_dynrelocs): Removed.
	(_bfd_x86_elf_allocate_local_dynrelocs): Likewise.
2017-09-02 15:12:04 -07:00
H.J. Lu 2926eb2c32 x86: Rearrange fields and update comments
* elfxx-x86.h (elf_x86_link_hash_table): Rearrange fields and
	update comments.
2017-09-02 13:05:49 -07:00
H.J. Lu 92c10f5f61 i386: Update sgotplt_jump_table_size setting
elf_i386_size_dynamic_sections has

      htab->next_tls_desc_index = htab->elf.srelplt->reloc_count;
      htab->sgotplt_jump_table_size = htab->next_tls_desc_index * 4;

This patch changes it to

      htab->sgotplt_jump_table_size
	= elf_x86_compute_jump_table_size (htab)

Since elf_x86_compute_jump_table_size is defined as

  ((htab)->elf.srelplt->reloc_count * (htab)->got_entry_size)

there is no change in output.  It makes elf_i386_size_dynamic_sections
the same as elf_x86_64_size_dynamic_sections.

	* elf32-i386.c (elf_i386_size_dynamic_sections): Set
	sgotplt_jump_table_size with elf_x86_compute_jump_table_size.
2017-09-02 11:18:30 -07:00
H.J. Lu aa595247af x86: Define PLT_CIE_LENGTH and PLT_FDE_* in elfxx-x86.h
Since PLT_CIE_LENGTH, PLT_FDE_LENGTH, PLT_FDE_START_OFFSET and
PLT_FDE_LEN_OFFSET are identical in elf32-i386.c and elf64-x86-64.c,
they can be defined in elfxx-x86.h.

	* elf32-i386.c (PLT_CIE_LENGTH, PLT_FDE_LENGTH,
	PLT_FDE_START_OFFSET, PLT_FDE_LEN_OFFSET): Moved to ...
	* elfxx-x86.h (PLT_CIE_LENGTH, PLT_FDE_LENGTH,
	PLT_FDE_START_OFFSET, PLT_FDE_LEN_OFFSET): Here.
	* elf64-x86-64.c (PLT_CIE_LENGTH, PLT_FDE_LENGTH,
	PLT_FDE_START_OFFSET, PLT_FDE_LEN_OFFSET): Removed.
2017-09-02 11:10:51 -07:00
H.J. Lu b9ce864ca8 x86: Add _bfd_x86_elf_allocate_dynrelocs
Share _bfd_x86_elf_allocate_dynrelocs in elf32-i386.c and elf64-x86-64.c.

	* elf32-i386.c (elf_i386_allocate_dynrelocs): Removed.
	(elf_i386_allocate_local_dynrelocs): Likewise.
	(elf_i386_size_dynamic_sections): Replace
	elf_i386_allocate_dynrelocs/elf_i386_allocate_local_dynrelocs
	with _bfd_x86_elf_allocate_dynrelocs and
	_bfd_x86_elf_allocate_local_dynrelocs.
	* elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): Removed.
	(elf_x86_64_allocate_local_dynrelocs): Likewise.
	(elf_x86_64_size_dynamic_sections): Replace
	elf_x86_64_allocate_dynrelocs/elf_x86_64_allocate_local_dynrelocs
	with _bfd_x86_elf_allocate_dynrelocs and
	_bfd_x86_elf_allocate_local_dynrelocs.
	* elfxx-x86.c (_bfd_x86_elf_allocate_dynrelocs): New function.
	(_bfd_x86_elf_allocate_local_dynrelocs): Likewise.
	* elfxx-x86.h (_bfd_x86_elf_allocate_dynrelocs): New prototype.
	(_bfd_x86_elf_allocate_local_dynrelocs): Likewise.
2017-09-02 07:27:40 -07:00
H.J. Lu fe53b4a4c4 x86: Add is_x86_elf
Share is_x86_elf in elf32-i386.c and elf64-x86-64.c.

	* elf32-i386.c (is_i386_elf): Removed.
	(elf_i386_check_relocs): Replace is_i386_elf with is_x86_elf.
	(elf_i386_size_dynamic_sections): Likewise.
	(elf_i386_relocate_section): Likewise.
	* elf64-x86-64.c (is_x86_64_elf): Removed.
	(elf_x86_64_check_relocs): Replace is_x86_64_elf with
	is_x86_elf.
	(elf_x86_64_size_dynamic_sections): Likewise.
	(elf_x86_64_relocate_section): Likewise.
	* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Initialize
	target_id.
	* elfxx-x86.h (elf_x86_link_hash_table): Add target_id.
	(is_x86_elf): New.
2017-09-02 07:24:42 -07:00
H.J. Lu 9ff114ca5d x86: Add elf_x86_compute_jump_table_size
Share elf_x86_compute_jump_table_size in elf32-i386.c and
elf64-x86-64.c.

	* elf32-i386.c (elf_i386_compute_jump_table_size): Removed.
	(elf_i386_allocate_dynrelocs): Replace
	elf_i386_compute_jump_table_size with
	elf_x86_compute_jump_table_size.
	(elf_i386_size_dynamic_sections): Likewise.
	* elf64-x86-64.c (elf_x86_64_compute_jump_table_size): Removed.
	(elf_x86_64_allocate_dynrelocs): Replace
	elf_x86_64_compute_jump_table_size with
	elf_x86_compute_jump_table_size.
	(elf_x86_64_size_dynamic_sections): Likewise.
	* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Initialize
	got_entry_size.
	* elfxx-x86.h (elf_x86_link_hash_table): Add got_entry_size.
	(elf_x86_compute_jump_table_size): New.
2017-09-02 07:18:55 -07:00
H.J. Lu 503294e755 x86: Add sizeof_reloc to elf_x86_link_hash_table
Initialize htab->sizeof_reloc once, instead of computing it every time.

	* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Initialize
	sizeof_reloc.
	(_bfd_x86_elf_adjust_dynamic_symbol): Use sizeof_reloc.
	* elfxx-x86.h (elf_x86_link_hash_table): Add sizeof_reloc.
2017-09-02 05:55:25 -07:00
H.J. Lu 9a742a902f i386: Check VxWorks with htab->is_vxworks
* elf32-i386.c (elf_i386_allocate_dynrelocs): Check VxWorks
	with htab->is_vxworks.
	(elf_i386_size_dynamic_sections): Likewise.
	(elf_i386_relocate_section): Likewise.
	(elf_i386_finish_dynamic_symbol): Likewise.
	(elf_i386_finish_dynamic_sections): Likewise.
2017-09-02 05:05:30 -07:00
H.J. Lu 6b9553e2a5 x86: Move GOT_TLS_* in elf32-i386.c to elfxx-x86.h
elf64-x86-64.c can use GOT_TLS_* definitions in elf32-i386.c with
GOT_TLS_IE_POS, GOT_TLS_IE_NEG and GOT_TLS_IE_BOTH unused.

	* elf32-i386.c (GOT_TLS_IE, GOT_TLS_IE_POS, GOT_TLS_IE_NEG,
	GOT_TLS_IE_BOTH, GOT_TLS_GDESC, GOT_TLS_GD_BOTH_P,
	GOT_TLS_GD_P, GOT_TLS_GDESC_P, GOT_TLS_GD_ANY_P): Moved to ...
	* elfxx-x86.h (GOT_TLS_IE, GOT_TLS_IE_POS, GOT_TLS_IE_NEG,
	GOT_TLS_IE_BOTH, GOT_TLS_GDESC, GOT_TLS_GD_BOTH_P,
	GOT_TLS_GD_P, GOT_TLS_GDESC_P, GOT_TLS_GD_ANY_P): Here.
	* elf64-x86-64.c (GOT_TLS_IE, GOT_TLS_GDESC, GOT_TLS_GD_BOTH_P,
	GOT_TLS_GD_P, GOT_TLS_GDESC_P, GOT_TLS_GD_ANY_P): Removed.
2017-09-02 04:52:15 -07:00
Alan Modra 1fa4ec6ae7 LTO rescan archives
ld ought to be more clever about where it puts LTO recompiled objects.
Ideally the recompiled objects ought to be ordered to the same place
their IR objects were, and files extracted from archives on the second
pass ought to go in the same place as they would if extracted on the
first pass.  This patch addresses the archive problem.  Without this
fix, objects extracted from archives might be placed after the crt
files intended to go at the end of an executable or shared library,
possibly causing exception handling failures.

	* 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.
2017-09-02 17:39:04 +09:30
H.J. Lu ad71ce8de7 x86-64: Check ELF_COMMON_DEF_P for common symbols
bfd/

	PR ld/22064
	* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Check
	ELF_COMMON_DEF_P for common symbols.

ld/

	PR ld/22064
	* testsuite/ld-x86-64/pr22064a.S: New file.
	* testsuite/ld-x86-64/pr22064b.c: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run PR ld/22064 test.
2017-09-01 18:55:55 -07:00
Alan Modra 96d01d93c4 -Og warning fixes
Found when building with gcc 4.9.4 using -Og.

bfd/
	* elf-eh-frame.c (offset_adjust): Avoid false positive gcc warning.
	* elflink.c (bfd_elf_size_dynsym_hash_dynstr): Likewise.
	* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Likewise.
ld/
	* emultempl/msp430.em (eval_upper_either_sections): Make base_sec_name
	a const char*.
	(eval_lower_either_sections): Likewise.
	(msp430_elf_after_allocation): Likewise, and don't needlessly concat
	and free.  Warning fix.
2017-09-02 11:00:02 +09:30
GDB Administrator 96fbe52eaa Automatic date update in version.in 2017-09-02 00:00:25 +00:00
H.J. Lu 4f501a245f x86: Add _bfd_x86_elf_gc_mark_hook
Since R_X86_64_GNU_VTINHERIT == R_386_GNU_VTINHERIT and
R_X86_64_GNU_VTENTRY == R_386_GNU_VTENTRY, we can share
_bfd_x86_elf_gc_mark_hook in elf32-i386.c and elf64-x86-64.c.

	* elf32-i386.c (elf_i386_gc_mark_hook): Removed.
	(elf_backend_gc_mark_hook): Likewise.
	* elf64-x86-64.c (elf_x86_64_gc_mark_hook): Likewise.
	(elf_backend_gc_mark_hook): Likewise.
	* elfxx-x86.c (_bfd_x86_elf_gc_mark_hook): New function.
	* elfxx-x86.h (_bfd_x86_elf_gc_mark_hook): New.
	(elf_backend_gc_mark_hook): Likewise.
2017-09-01 14:51:58 -07:00
H.J. Lu eeb2f20a76 x86: Add _bfd_x86_elf_adjust_dynamic_symbol
Share _bfd_x86_elf_adjust_dynamic_symbol in elf32-i386.c and
elf64-x86-64.c.

	* elf32-i386.c (elf_i386_adjust_dynamic_symbol): Removed.
	(elf_backend_adjust_dynamic_symbol): Likewise.
	* elf64-x86-64.c (elf_x86_64_adjust_dynamic_symbol): Likewise.
	(elf_backend_adjust_dynamic_symbol): Likewise.
	* elfxx-x86.c (_bfd_x86_elf_adjust_dynamic_symbol): New function.
	(_bfd_x86_elf_link_setup_gnu_properties): Copy is_vxworks.
	* elfxx-x86.h (elf_x86_link_hash_table): Add is_vxworks.
	(_bfd_x86_elf_adjust_dynamic_symbol): New.
	(elf_backend_adjust_dynamic_symbol): Likewise.
2017-09-01 13:03:40 -07:00
H.J. Lu 18da07cd12 Correct ChangeLog entry 2017-09-01 13:01:23 -07:00
H.J. Lu c6295c2290 elfxx-x86.h: Fix a typo in comments
* elfxx-x86.h (elf_x86_plt_layout_table): Fix a typo in
	comments.
2017-09-01 12:39:38 -07:00
H.J. Lu 39946cc227 x86: Add _bfd_x86_elf_mkobject
Share _bfd_x86_elf_mkobject in elf32-i386.c and elf64-x86-64.c.

	* elf32-i386.c (elf_i386_mkobject): Removed.
	(bfd_elf32_mkobject): Likewise.
	* elf64-x86-64.c (elf_x86_64_mkobject): Likewise.
	(bfd_elf64_mkobject): Likewise.
	(bfd_elf32_mkobject): Likewise.
	* elfxx-x86.c (_bfd_x86_elf_mkobject): New function.
	(_bfd_x86_elf_mkobject): New.
	(bfd_elf64_mkobject): Likewise.
	(bfd_elf32_mkobject): Likewise.
2017-09-01 12:09:03 -07:00
H.J. Lu a6798baba2 x86: Add _bfd_x86_elf_link_setup_gnu_properties
Extract the common parts of elf_i386_link_setup_gnu_properties and
elf_x86_64_link_setup_gnu_properties into a new function.

For x86-64, since PIC PLT layouts are the same as non-PIC PLT layouts,
initialize pic_plt0_entry and pic_plt_entry fields in PLT layouts with
the non-PIC PLT entries.

	* elf32-i386.c (elf_i386_link_setup_gnu_properties): Updated.
	Call _bfd_x86_elf_link_setup_gnu_properties.
	* elf64-x86-64.c (elf_x86_lazy_plt_layout): Initialize
	pic_plt0_entry and pic_plt_entry fields with the non-PIC PLT
	entries.
	(elf_x86_64_non_lazy_plt): Likewise.
	(elf_x86_64_lazy_bnd_plt): Likewise.
	(elf_x86_64_non_lazy_bnd_plt): Likewise.
	(elf_x86_64_lazy_ibt_plt): Likewise.
	(elf_x32_lazy_ibt_plt): Likewise.
	(elf_x86_64_non_lazy_ibt_plt): Likewise.
	(elf_x32_non_lazy_ibt_plt): Likewise.
	(elf_x86_64_nacl_plt): Likewise.
	(elf_x86_64_link_setup_gnu_properties): Updated.  Call
	_bfd_x86_elf_link_setup_gnu_properties.
	* elfxx-x86.c: Include elf-vxworks.h".
	(_bfd_x86_elf_link_setup_gnu_properties): New function.
	* elfxx-x86.h (elf_x86_lazy_plt_layout): Remove "for i386 only"
	comments for pic_plt0_entry and pic_plt_entry.
	(elf_x86_non_lazy_plt_layout): Likewise.
	(elf_x86_plt_layout_table): New.
	(_bfd_x86_elf_link_setup_gnu_properties): Likewise.
2017-09-01 08:00:51 -07:00
H.J. Lu 376dc015f2 Import latest fixes to libiberty from GCC
Fix warning for simple-object-elf.c.

2017-09-01  Martin Liska  <mliska@suse.cz>

	* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
	Remove duplicite declaration.
2017-09-01 06:14:39 -07:00
H.J. Lu e10c9c620c x86: Correct unwind information for the second PLT
For i386, generate unwind information for the second PLT.  For x32,
correct alignment of .eh_frame section for the second PLT.

bfd/

	PR ld/22061
	* elf32-i386.c (elf_i386_link_setup_gnu_properties): Create
	.eh_frame section for the second PLT.
	* elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties): Correct
	alignment of .eh_frame section for the second PLT.

ld/

	PR ld/22061
	* testsuite/ld-i386/ibt-plt-1.d: Updated.
	* testsuite/ld-i386/ibt-plt-2a.d: Likewise.
	* testsuite/ld-i386/ibt-plt-2c.d: Likewise.
	* testsuite/ld-i386/ibt-plt-3a.d: Likewise.
	* testsuite/ld-i386/ibt-plt-3c.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-1-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2a-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2c-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3a-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3c-x32.d: Likewise.
	* testsuite/ld-i386/ibt-plt-2b.d: Pass --hash-style=sysv to ld
	and dump unwind information.
	* testsuite/ld-i386/ibt-plt-2d.d: Likewise.
	* testsuite/ld-i386/ibt-plt-3b.d: Likewise.
	* testsuite/ld-i386/ibt-plt-3d.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2b-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2b.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2d-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2d.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3b-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3b.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3d-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3d.d: Likewise.
2017-09-01 06:12:06 -07:00
Tamar Christina 1c5c938ad8 Enable support for the AArch64 dot-prod instruction in the Cortex A55 and A75 cpus.
* config/tc-aarch64.c (aarch64_cpus): Enable DOTPROD for
	cortex-a55 and cortx-a75.
2017-09-01 11:43:51 +01:00