Commit Graph

85576 Commits

Author SHA1 Message Date
Simon Marchi 48ffa2b8cd Fix constness problem in ioscm_make_gdb_stdio_port
ioscm_make_gdb_stdio_port passes const char pointers (literal strings) to
scm_mode_bits, which takes a non-const char pointer.  Ideally, we would
change scm_mode_bits to take a const char pointer, but it's not part of
an API we control.

Instead, it's easy enough to build the string to pass to scm_mode_bits in
a (non-const) char array and pass that.

gdb/ChangeLog:

	* guile/scm-ports.c (ioscm_make_gdb_stdio_port): Pass non-const
	char pointer to scm_mode_bits.
2015-10-26 08:41:39 -04:00
Simon Marchi 585a269afb symtab.c: Add cast
gdb/ChangeLog:

	* symtab.c (default_make_symbol_completion_list_break_on_1): Add
	cast.
2015-10-26 08:41:38 -04:00
Simon Marchi e0dd41e967 gdbscm_memory_port_write: use local variable to avoid adding casts
By having a local variable of type (const gdb_byte *), we can avoid adding
two casts.

gdb/ChangeLog:

	* guile/scm-ports.c (gdbscm_memory_port_write): Declare new
	"data" local variable and use it.
2015-10-26 08:41:37 -04:00
Simon Marchi 74ef968fba scm-symbol.c: Add (domain_enum) casts
We currently pass integers as domain_enums to lookup_symbol.  The
most obvious fix is to add casts there.

I first thought of changing the type of the domain variables to
domain_enum.  However, because we pass a pointer to them to
gdbscm_parse_function_args, which expects them to be integers (because
of the format string), I don't think it would be correct.  If the enum
does not have the same size as an int, gdbscm_parse_function_args could
write past the memory of domain, overwriting something else on the
stack.

gdb/ChangeLog:

	* guile/scm-symbol.c (gdbscm_lookup_global_symbol): Add
	domain_enum cast.
	(gdbscm_lookup_symbol): Likewise.
2015-10-26 08:41:36 -04:00
GDB Administrator cdfb4fc32d Automatic date update in version.in 2015-10-26 00:00:08 +00:00
Jan Kratochvil 27dc26ab39 Fix compile.exp error message expectation
commit cdaec3f3e7
Author: Luis Machado <lgustavo@codesourcery.com>
Date:   Thu Aug 27 02:00:16 2015 -0300
    Mention language in compile error message

regressed:

-PASS: gdb.compile/compile.exp: compile code globalvar
+FAIL: gdb.compile/compile.exp: compile code globalvar

Update the expected message.

gdb/testsuite/ChangeLog
2015-10-25  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.compile/compile.exp (compile code globalvar): Update expectation
	for a change by "Mention language in compile error message".
2015-10-25 12:16:10 +01:00
Iain Buclaw 2d5a88dc50 Re-apply change for handling non-local references in nested functions.
gdb/ChangeLog:

	* d-exp.y: Remove an obsolete comment and propagate the block
	information to the produced expression.
2015-10-25 09:17:24 +01:00
Simon Marchi f4ee58bde9 tui-data.c: Remove unnecessary casts
The (void *) casts make the build fail in C++ mode and are unnecessary.

gdb/ChangeLog:

	* tui/tui-data.c (tui_add_to_source_windows): Remove void *
	cast.
	(tui_add_content_elements): Likewise.
2015-10-24 22:40:37 -04:00
Simon Marchi 1650ca1124 cli-setshow.c: Constify variable
Fixes:

/home/simark/src/binutils-gdb/gdb/cli/cli-setshow.c:390:13: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
  p = strchr (arg, ' ');
             ^
gdb/ChangeLog:

	* cli/cli-setshow.c (do_set_command): Constify p.
2015-10-24 22:29:16 -04:00
GDB Administrator a7dbb7d12b Automatic date update in version.in 2015-10-25 00:00:08 +00:00
Simon Marchi 55e5bf59f0 Replace (void *) cast with (gdb_byte *)
Fixes:

/home/simark/src/binutils-gdb/gdb/nat/linux-ptrace.c:207:6: error: invalid conversion from ‘void*’ to ‘gdb_byte* {aka unsigned char*}’ [-fpermissive]
   pc = (void *) (uintptr_t) l;
         ^

gdb/ChangeLog:

	* nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Replace
	(void *) cast with (gdb_byte *).
2015-10-24 18:36:26 -04:00
Simon Marchi 49e66b4deb proc-service.c: Add (gdb_byte *) cast
A cast here is necessary, just as it's necessary in ps_pdwrite just
below.  The type of buf can't be changed, since it's fixed in the ps_pd*
API.

gdb/ChangeLog:

	* proc-service.c (ps_pdread): Add cast.
2015-10-24 18:36:25 -04:00
Simon Marchi cfcb22a541 sparc64-tdep.c: Don't assign using memcpy return
This:

  valbuf = memcpy (buf, valbuf, len);

causes a build failure in C++, because memcpy returns the value of
"buf" as a void *.  Instead of adding a cast, we can just do the
assignment separately.

gdb/ChangeLog:

	* sparc64-tdep.c (sparc64_store_arguments): Split assignment of
	valbuf.
2015-10-24 18:36:24 -04:00
Simon Marchi ce746418ef ia64-tdep.c: Remove (void *) casts
Remove these (void *) casts, which cause a build failure in C++ mode.

gdb/ChangeLog:

	* ia64-tdep.c (ia64_pseudo_register_write): Remove cast.
	(ia64_push_dummy_call): Remove cast and change type of "to" to
	array of gdb_byte.
2015-10-24 18:36:23 -04:00
GDB Administrator 10d43c801e Automatic date update in version.in 2015-10-24 00:00:08 +00:00
Simon Marchi a55515eecb Add mmap casts in linux-btrace.c
gdb/ChangeLog:

	* linux-btrace.c (linux_enable_pt): Add cast to mmap return.
2015-10-23 19:54:09 -04:00
Simon Marchi 6ecf4e06a4 Add cast to observer.sh
gdb/ChangeLog:

	* observer.h (observer_${event}_notification_stub): Add cast.
2015-10-23 16:58:13 -04:00
Antoine Tremblay 3db2885585 Remove set_breakpoint_data definition in GDBServer.
This patch removes the now unused set_breakpoint_data function from mem_break.h

gdb/gdbserver/ChangeLog:

	* mem-break.h (set_breakpoint_data): Remove.
2015-10-23 13:21:33 -04:00
Antoine Tremblay fb78e89c56 Fix nto,spu and win32 builds of GDBServer.
This patch fixes the build that was broken by :
https://sourceware.org/ml/gdb-patches/2015-10/msg00369.html

It implements the sw_breakpoint_from_kind operation on these targets and removes
the calls to set_breakpoint_data.

Compiliation tested on win32.

Not tested : nto, spu.

gdb/gdbserver/ChangeLog:

	* nto-low.c (nto_sw_breakpoint_from_kind): New function.
	(struct target_ops) <sw_breakpoint_from_kind>: Initialize.
	(initialize_low): Remove set_breakpoint_data call.
	* spu-low.c (spu_sw_breakpoint_from_kind): New function.
	(struct target_ops) <sw_breakpoint_from_kind>: Iniitalize.
	(initialize_low): Remove set_breakpoint_data call.
	* win32-low.c (win32_sw_breakpoint_from_kind): New function.
	(struct target_ops) <sw_breakpoint_from_kind>: Initialize.
	(initialize_low): Remove set_breakpoint_data call.
2015-10-23 13:21:11 -04:00
Antoine Tremblay 2e6ee069ae Refactor default_breakpoint_kind_from_pc to be used by all targets in GDBServer.
This patch moves default_breakpoint_kind_from_pc to target.c and creates a macro
so that all targets can easily use it.

This allows the breakpoint_kind_from_pc operation to be left unimplemented in
targets that do not need it.

This is preparation to fix the win32/nto/spu build that was broken by this
patch: https://sourceware.org/ml/gdb-patches/2015-10/msg00369.html

No regression on Ubuntu 14.04 x86-64 with gdbserver-{native-extended}

gdb/gdbserver/ChangeLog:

	* linux-low.c (default_breakpoint_kind_from_pc): Move to target.c.
	* mem-break.c (set_breakpoint_at): Use target_breakpoint_kind_from_pc.
	* target.c (default_breakpoint_kind_from_pc): Moved from linux-low.c
	* target.h (target_breakpoint_kind_from_pc): New macro.
2015-10-23 13:20:39 -04:00
Alan Modra 1cce69b9dc Handle __start_* and __stop_* symbols in --gc-sections
PR ld/11133
	PR ld/19161
	PR ld/19167
	* elflink.c (_bfd_elf_gc_mark_hook): Delete code handling __start_*
	and __stop_* symbol refs.
	(_bfd_elf_gc_mark_rsec): Add start_stop parameter.  Handle __start_*
	and __stop_* symbol refs here..
	(_bfd_elf_gc_mark_reloc): ..and here.
	* elf-bfd.h (_bfd_elf_gc_mark_hook): Update prototype.
	* elf-eh-frame.c (_bfd_elf_parse_eh_frame): Update
	_bfd_elf_gc_mark_rsec call.
2015-10-23 22:26:25 +10:30
H.J. Lu be83aa76d2 Add a test for PR ld/19167
PR ld/19167
	* ld-gc/gc.exp: Run pr19167 test.
	* ld-gc/pr19167.d: New file.
	* ld-gc/pr19167a.s: Likewise.
	* ld-gc/pr19167b.s: Likewise.
2015-10-23 04:23:51 -07:00
Yao Qi 034f1a812d Initialize field insn_count correctly
This patch initialize dsd.insn_count, otherwise, it triggers the assert
below on testings we did recently.

gdb:

2015-10-23  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c (aarch64_displaced_step_copy_insn): Set
	dsd.insn_count to zero.
2015-10-23 09:23:22 +01:00
GDB Administrator e9f3d8639d Automatic date update in version.in 2015-10-23 00:00:08 +00:00
Alan Modra 1e7eae0dcc Re: Always keep sections marked with SEC_KEEP
Revert bba037e0, it breaks the gc-sections model.  Instead fix the
underlying problem which is that _bfd_elf_gc_mark_hook is too late to
be setting SEC_KEEP.

	PR ld/11133
	PR ld/19161
	* elflink.c (elf_gc_sweep): Revert last patch.
	(_bfd_elf_gc_mark_hook): Don't set SEC_KEEP here.
2015-10-23 10:22:26 +10:30
H.J. Lu bba037e0ae Always keep sections marked with SEC_KEEP
SEC_KEEP check in elf_gc_sweep was missing in commit:

commit bde6f3eb6d
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Jan 8 01:43:23 2010 +0000

    Set SEC_KEEP on section XXX for undefined __start_XXX/__stop_XXX

    bfd/

    2010-01-07  H.J. Lu  <hongjiu.lu@intel.com>

      PR ld/11133
      * elflink.c (_bfd_elf_gc_mark_hook): Check section XXX for
      undefined __start_XXX/__stop_XXX in all input files and set
      SEC_KEEP.

This patch adds SEC_KEEP check to elf_gc_sweep.

bfd/

	PR ld/19161
	* elflink.c (elf_gc_sweep): Always keep sections marked with
	SEC_KEEP.

ld/testsuite/

	PR ld/19161
	* ld-gc/gc.exp: Run pr19161 test.
	* ld-gc/pr19161-1.c: New file.
	* ld-gc/pr19161-2.c: Likewise.
	* ld-gc/pr19161.d: Likewise.
2015-10-22 12:23:03 -07:00
Pedro Alves d236ad1955 garbage collect gdb/infrun.c:stop_after_trap
No longer used anywhere.

gdb/ChangeLog:
2015-10-22  Pedro Alves  <palves@redhat.com>

	* infrun.c (stop_after_trap): Delete.
	(clear_proceed_status, handle_signal_stop, struct
	infcall_control_state, save_infcall_control_state)
	(restore_infcall_control_state): Remove references to
	stop_after_trap.
2015-10-22 17:41:10 +01:00
Antoine Tremblay 1652a98612 Fix inconsistent breakpoint kinds between breakpoints and tracepoints in GDBServer.
This patch fixes a regression introduced by :
https://sourceware.org/ml/gdb-patches/2015-10/msg00369.html

Tests : gdb.trace/trace-break.exp and gdb.trace/trace-mt.exp would fail on x86
with gdbserver-{native,extended}.

Before this patch, the breakpoint kind set by GDB with a Z packet and the one
set in the case of a tracepoint would be inconsistent on targets that did not
implement breakpoint_kind_from_pc. On x86 for example a breakpoint set by GDB
would have a kind of 1 but a breakpoint set by a tracepoint would have a kind of
0.

This created a missmatch when trying to insert a tracepoint and a breakpoint at
the same location. One of the two breakpoints would be removed with debug
message : "Inconsistent breakpoint kind".

This patch fixes the issue by changing the default 0 breakpoint kind to be
the size of the breakpoint according to sw_breakpoint_from_kind.

The default breakpoint kind must be the breakpoint length to keep consistency
between breakpoints set via GDB and the ones set internally by GDBServer.

No regression on Ubuntu 14.04 x86-64 with gdbserver-{native-extended}

gdb/gdbserver/ChangeLog:

	* linux-low.c (default_breakpoint_kind_from_pc): New function.
	(linux_breakpoint_kind_from_pc): Use default_breakpoint_kind_from_pc for
	the default breakpoint kind.
2015-10-22 12:23:58 -04:00
Simon Marchi db0f0d0c1d Add cast in python.c
gdb/ChangeLog:

	* python/python.c (_initialize_python): Add cast.
2015-10-22 12:13:19 -04:00
Simon Marchi fb70bc1a74 Add cast in nto-tdep.c
gdb/ChangeLog:

	* nto-tdep.c (nto_inferior_data): Add cast.
2015-10-22 11:58:38 -04:00
Pedro Alves c72f45d16c gdb/Windows: use windows_wait/windows_resume directly in initial startup
Explation below based on what Joel wrote at:

  https://sourceware.org/ml/gdb-patches/2015-10/msg00274.html

The merge async/sync code paths patch broke attaching on Windows.

This is what we observe, after attaching to any process.  At first, it
seems like everything worked fine, since the process stops, and we get
the prompt back:

    (gdb) att 3156
    Attaching to program `C:\[...]\foo.exe', process 3156
    [New Thread 3156.0xcd8]
    [New Thread 3156.0xfe4]
    0x7770000d in ntdll!DbgBreakPoint () from C:\Windows\SysWOW64\ntdll.dll
    (gdb)

However, enter any commands at all, and GDB appears to be hanging.
For instance:

    (gdb) set lang ada
    [nothing happens]

Despite appearances, GDB is not reading from the prompt.  It is
blocked waiting for an event from the inferior.  And since our
inferior is stopped, there aren't going to be any events to read.

In chronological order, what happens is that windows_attach calls
do_initial_windows_stuff, which performs the inferior creation,
and repeatedly waits until we get the first SIGTRAP:

  while (1)
    {
      stop_after_trap = 1;
      wait_for_inferior ();
      tp = inferior_thread ();
      if (tp->suspend.stop_signal != GDB_SIGNAL_TRAP)
        resume (tp->suspend.stop_signal);
      else
        break;
    }

The call to wait_for_inferior triggers a call to do_target_wait to get
the event, followed by handle_inferior_event to process it.  However,
because the first couple of events are "spurious" events, GDB resumes
the execution, and prepares the inferior to wait again:

    case TARGET_WAITKIND_SPURIOUS:
      [...]
      resume (GDB_SIGNAL_0);
      prepare_to_wait (ecs);

And prepare_to_wait just does...

  ecs->wait_some_more = 1;
  if (!target_is_async_p ())
    mark_infrun_async_event_handler ();

... which as a result sets the infrun_async_event_handler "ready"
flag to 1.

We get a couple of spurious events before we get the initial SIGTRAP,
at which point we exit the "while (1)" loop above, after which we
reach the end of the attach_command, followed by the normal
end-of-command processing (normal_stop, bp handling, printing the GDB
prompt), back finally to the root of the event loop.

Notice that, at this point, nothing has unset the "ready" flag for the
infrun_async_event_handler.  So, when another cycle of
gdb_do_one_event from the event loop, we eventually call
check_async_event_handlers, which finds that the infrun async event
handler is "ready", and therefore calls it's associated "proc"
callback, which does...

      inferior_event_handler (INF_REG_EVENT, NULL);

... triggering a blocking call to target_wait, thus hanging forever.

The fix is to use windows_wait and windows_resume directly, similarly
to gdbserver.  This will also allow getting rid of 'stop_after_trap'.

gdb/ChangeLog:
2015-10-22  Pedro Alves  <palves@redhat.com>

	* windows-nat.c (do_initial_windows_stuff): Rewrite loop using
	windows_wait and windows_resume directly instead of
	wait_for_inferior and resume.
2015-10-22 16:40:45 +01:00
Nick Clifton 2213f746d3 Add support for MSP430 silicon errata to the assembler.
* config/tc-msp430.c (PUSH_1X_WORKAROUND): Delete.
	(OPTION_SILICON_ERRATA): Define.
	(OPTION_SILICON_WARN): Define.
	(md_parse_opton): Handle silicon errata options.
	(md_longopts): Add silicon errata options.
	(ms_show_usage): Report silicon errata options.
	(msp430_srcoperand): Handle silicon errata.
	(msp430_operands): Likewise. Improve nop insertion.
	(msp430_fix_adjustable): Update warning generation.
	* doc/c-msp430.texi: Document silicon errata options.

tests	* gas/msp430/errata_fixes.s: New test source file.
	* gas/msp430/errata_fixes.d: New test control file.
	* gas/msp430/errata_warns.s: New test source file.
	* gas/msp430/errata_warns.d: New test control file.
	* gas/msp430/errata_warns.l: New test message file.
	* gas/msp430/msp430.exp: Run the new tests.
	* gas/msp430/bad.l: Update expected warning messages
	* gas/msp430/msp430.exp: Run the new tests.
2015-10-22 16:25:46 +01:00
H.J. Lu 9b4c123c95 Properly check --enable-compressed-debug-sections={yes,all}
gas/

	* configure.ac: Properly check
	--enable-compressed-debug-sections={yes,all}.
	* configure: Regenerated.

ld/

	* configure.ac: Properly check
	--enable-compressed-debug-sections={yes,all}.
	* configure: Regenerated.
2015-10-22 07:44:05 -07:00
Hans-Peter Nilsson c287bfe429 bfd/mmo.c: handle "objcopy --extract-symbols" generating and reading back.
bfd:
	* mmo.c (struct mmo_data_struct): New members
	symbol_consistency_override_calculated and ignore_symbol_consistency.
	(mmo_section_has_contents, mmo_ignore_symbol_consistency): New
	functions.
	(mmo_create_symbol): Check with mmo_ignore_symbol_consistency if to
	report an error for unexpected value of Main.
	(mmo_write_symbols_and_terminator): Similar.
2015-10-22 16:17:32 +02:00
Hans-Peter Nilsson 282b7d7b65 Allow mmix-knuth-mmixware adjustments to objcopy --extract-symbols test.
* ld-scripts/script.exp (extract_symbol_test): Allow nm output of
	objcopy --extract-symbols result to differ from original on
	mmix-knuth-mmixware.
2015-10-22 16:16:09 +02:00
Hans-Peter Nilsson 64e59d8e11 binutils/objcopy.c (setup_section): missing extract_symbol part
* objcopy.c (setup_section): Don't omit bfd_copy_private_bfd_data
	call when extract_symbol.
2015-10-22 16:12:35 +02:00
Simon Marchi 60905b1e2a xtensa: Fix implicit enum conversions
XTREG is used with raw numbers, like:

...
  XTREG( 78,312,32, 4, 4,0x02d7,0x0007,-2, 2,0x1000,excsave7,    0,0,0,0,0,0)
  XTREG( 79,316, 8, 4, 4,0x02e0,0x0007,-2, 2,0x1000,cpenable,    0,0,0,0,0,0)
  XTREG( 80,320,22, 4, 4,0x02e2,0x000b,-2, 2,0x1000,interrupt,   0,0,0,0,0,0)
  XTREG( 81,324,22, 4, 4,0x02e2,0x000d,-2, 2,0x1000,intset,      0,0,0,0,0,0)
...

So just add the explicit cast to the macro.

In file included from /home/pedro/gdb/mygit/src/gdb/xtensa-config.c:25:0:
/home/pedro/gdb/mygit/src/gdb/xtensa-tdep.h:289:2: error: invalid conversion from ‘int’ to ‘call_abi_t’ [-fpermissive]
  }
  ^

gdb/ChangeLog:

	* xtensa-tdep.h (XTREG): Add casts.
	(XTREG_END): Likewise.
2015-10-22 09:47:47 -04:00
Simon Marchi 5af9928d44 solib-spu: Add gdb_byte* cast
Fixes this error:

/home/simark/src/binutils-gdb/gdb/solib-spu.c: In function ‘file_ptr spu_bfd_iovec_pread(bfd*, void*, void*, file_ptr, file_ptr)’:
/home/simark/src/binutils-gdb/gdb/solib-spu.c:299:55: error: invalid conversion from ‘void*’ to ‘gdb_byte* {aka unsigned char*}’ [-fpermissive]
   ret = target_read_memory (addr + offset, buf, nbytes);
                                                       ^
In file included from /home/simark/src/binutils-gdb/gdb/target.h:65:0,
                 from /home/simark/src/binutils-gdb/gdb/exec.h:23,
                 from /home/simark/src/binutils-gdb/gdb/gdbcore.h:29,
                 from /home/simark/src/binutils-gdb/gdb/solib-spu.c:23:
/home/simark/src/binutils-gdb/gdb/target/target.h:35:12: note:   initializing argument 2 of ‘int target_read_memory(CORE_ADDR, gdb_byte*, ssize_t)’
 extern int target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr,

gdb/ChangeLog:

	* solib-spu.c (spu_bfd_iovec_pread): Add (gdb_byte *) cast.
2015-10-22 09:47:46 -04:00
Simon Marchi 3e45d68b70 rs6000: Add cast for int to enum conversion
Fixes this error:

/home/pedro/gdb/mygit/src/gdb/rs6000-tdep.c:3091:1: error: invalid conversion from ‘int’ to ‘bfd_architecture’ [-fpermissive]
 };
 ^
/home/pedro/gdb/mygit/src/gdb/rs6000-tdep.c: In function ‘void powerpc_set_vector_abi(char*, int, cmd_list_element*)’:
/home/pedro/gdb/mygit/src/gdb/rs6000-tdep.c:6063:28: error: invalid conversion from ‘int’ to ‘powerpc_vector_abi’ [-fpermissive]
  powerpc_vector_abi_global = vector_abi;
                            ^

gdb/ChangeLog:

	* rs6000-tdep.c (variants): Add (enum bfd_architecture) cast.
2015-10-22 09:47:44 -04:00
Simon Marchi 709476c3c5 mips: fix void*/gdb_byte* compilation errors
The error in mips64_linux_get_longjmp_target is fixed by changing "buf"
to be a gdb_byte*, as usual.  supply_32bit_reg and mips64_fill_gregset
do some more complicated things however, so it's safer just to add the
explicit cast and avoid changing the code too much.

gdb/ChangeLog:

	* mips-linux-tdep.c (mips64_linux_get_longjmp_target): Change type of
	buf to gdb_byte*.
	(supply_32bit_reg): Add cast.
	(mips64_fill_gregset): Likewise.
2015-10-22 09:47:41 -04:00
H.J. Lu 4894d80b50 Handle --enable-compressed-debug-sections=ld,gas
gas/

	PR gas/19109
	* configure.ac: Handle --enable-compressed-debug-sections=*,gas,*.
	* configure: Regenerated.

ld/

	PR gas/19109
	* configure.ac: Handle --enable-compressed-debug-sections=*,ld,*.
	* configure: Regenerated.
2015-10-22 05:18:21 -07:00
H.J. Lu 2891b49104 Gold: Don't fail on R_X86_64_[REX_]GOTPCRELX relocations
This patch updates gold to treat the R_X86_64_GOTPCRELX and
R_X86_64_REX_GOTPCRELX relocations proposed in

https://groups.google.com/forum/#!topic/x86-64-abi/n9AWHogmVY0

the same as R_X86_64_GOTPCREL.  FIXME: Gold should perform the
transformations as suggested.

elfcpp/

	* x86_64.h (R_X86_64_GOTPCRELX): New.
	(R_X86_64_REX_GOTPCRELX): Likewise.

gold/

	* x86_64.cc (Target_x86_64<size>::Scan::get_reference_flags):
	Treat R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX the same
	as R_X86_64_GOTPCREL.
	(Target_x86_64<size>::Scan::local): Likewise.
	(Target_x86_64<size>::Scan::possible_function_pointer_reloc):
	Likewise.
	(Target_x86_64<size>::Scan::global): Likewise.
	(Target_x86_64<size>::Relocate::relocate): Likewise.
	(Target_x86_64<size>::Relocatable_size_for_reloc::get_size_for_reloc):
	Likewise.
2015-10-22 04:56:57 -07:00
H.J. Lu 493d4b48de Gold: Don't fail on R_386_GOT32X relocation
This patch updates gold to treat the R_386_GOT32X relocation proposed in

https://groups.google.com/forum/#!topic/ia32-abi/GbJJskkid4I

the same as R_386_GOT32.  FIXME: Gold should perform the transformations
as suggested.

elfcpp/

	* i386.h (R_386_GOT32X): New.

gold/

	* i386.cc (Target_i386::Scan::get_reference_flags(): Treat
	R_386_GOT32X the same as R_386_GOT32.
	(Target_i386::Scan::local): Likewise.
	(Target_i386::Scan::possible_function_pointer_reloc): Likewise.
	(Target_i386::Scan::global): Likewise.
	(Target_i386::Relocate::relocate): Likewise.
	(Target_i386::Relocatable_size_for_reloc::get_size_for_reloc):
	Likewise.
2015-10-22 04:56:49 -07:00
H.J. Lu caa65211bb Add "-z call-nop=PADDING" option to ld
The ld linker can transform indirect call to a locally defined function,
foo, via its GOT slot, to either "NOP call foo" or "call foo NOP" where
NOP is a 1-byte NOP padding.  This patch adds a "-z call-nop=PADDING"
option to x86 ld to control 1-byte NOP padding for x86 call instruction.
PADDING is one of prefix-addr, prefix-nop, suffix-nop, prefix-NUMBER or
suffix-NUMBER.

bfd/

	* elf32-i386.c (elf_i386_convert_load): Use call_nop_byte and
	check call_nop_as_suffix for 1-byte NOP padding to pad call.
	* elf64-x86-64.c (elf_x86_64_convert_load): Likewise.

include/

	* bfdlink.h (bfd_link_info): Add call_nop_as_suffix and
	call_nop_byte.

ld/

	* ld/ld.texinfo: Document "-z call-nop=PADDING" option.
	* emulparams/call_nop.sh: New file.
	* emulparams/elf_i386_be.sh: Source
	${srcdir}/emulparams/call_nop.sh.
	* emulparams/elf_i386_chaos.sh: Likewise.
	* emulparams/elf_i386_ldso.sh: Likewise.
	* emulparams/elf_i386_vxworks.sh: Likewise.
	* emulparams/elf_iamcu.sh: Likewise.
	* emulparams/elf_k1om.sh: Likewise.
	* emulparams/elf_l1om.sh: Likewise.
	* emulparams/elf_x86_64.sh: Likewise.
	* emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Set
	link_info.call_nop_byte if $CALL_NOP_BYTE isn't empty.

ld/testsuite/

	* ld-i386/call3.s: New file.
	* ld-i386/call3a.d: Likewise.
	* ld-i386/call3b.d: Likewise.
	* ld-i386/call3c.d: Likewise.
	* ld-i386/call3d.d: Likewise.
	* ld-i386/call3e.d: Likewise.
	* ld-i386/call3f.d: Likewise.
	* ld-i386/call3g.d: Likewise.
	* ld-i386/call3h.d: Likewise.
	* ld-i386/load1-nacl.d: Likewise.
	* ld-x86-64/call1.s: Likewise.
	* ld-x86-64/call1a.d: Likewise.
	* ld-x86-64/call1b.d: Likewise.
	* ld-x86-64/call1c.d: Likewise.
	* ld-x86-64/call1d.d: Likewise.
	* ld-x86-64/call1e.d: Likewise.
	* ld-x86-64/call1f.d: Likewise.
	* ld-x86-64/call1g.d: Likewise.
	* ld-x86-64/call1h.d: Likewise.
	* ld-x86-64/call1i.d: Likewise.
	* ld-x86-64/load1a-nacl.d: Likewise.
	* ld-x86-64/load1b-nacl.d: Likewise.
	* ld-x86-64/load1c-nacl.d: Likewise.
	* ld-x86-64/load1d-nacl.d: Likewise.
2015-10-22 04:56:39 -07:00
H.J. Lu 56ceb5b540 Add R_X86_64_[REX_]GOTPCRELX support to gas and ld
This patch adds support for the R_X86_64_GOTPCRELX and
R_X86_64_REX_GOTPCRELX relocations proposed in

https://groups.google.com/forum/#!topic/x86-64-abi/n9AWHogmVY0

to gas and ld.  It updates gas to generate R_X86_64_GOTPCRELX,
R_X86_64_REX_GOTPCRELX if there is a REX prefix, relocation for memory
operand, foo@GOTPCREL(%rip).  With the locally defined symbol, foo, we
convert

  mov foo@GOTPCREL(%rip), %reg

to

   lea foo(%rip), %reg

and convert

   call/jmp *foo@GOTPCREL(%rip)
to

   nop call foo/jmp foo nop

When PIC is false, convert

   test %reg, foo@GOTPCREL(%rip)
to

test $foo, %reg

and convert

   binop foo@GOTPCREL(%rip), %reg

to

   binop $foo, %reg

where binop is one of adc, add, and, cmp, or, sbb, sub, xor instructions.

bfd/

	* elf64-x86-64.c: Include opcode/i386.h.
	(x86_64_elf_howto_table): Add R_X86_64_GOTPCRELX and
	R_X86_64_REX_GOTPCRELX.
	(R_X86_64_standard): Replace R_X86_64_PLT32_BND with
	R_X86_64_REX_GOTPCRELX.
	(x86_64_reloc_map): Add BFD_RELOC_X86_64_GOTPCRELX and
	BFD_RELOC_X86_64_REX_GOTPCRELX.
	(need_convert_mov_to_lea): Renamed to ...
	(need_convert_load): This.
	(elf_x86_64_check_relocs): Handle R_X86_64_GOTPCRELX and
	R_X86_64_REX_GOTPCRELX.  Replace need_convert_mov_to_lea with
	need_convert_load.
	(elf_x86_64_gc_sweep_hook): Handle R_X86_64_GOTPCRELX and
	R_X86_64_REX_GOTPCRELX.
	(elf_x86_64_size_dynamic_sections): Likewise.
	(elf_x86_64_relocate_section): Likewise.
	(elf_x86_64_convert_mov_to_lea): Renamed to ...
	(elf_x86_64_convert_load): This.  Replace need_convert_mov_to_lea
	with need_convert_load.  Support R_X86_64_GOTPCRELX and
	R_X86_64_REX_GOTPCRELX transformations.
	* reloc.c (BFD_RELOC_X86_64_GOTPCRELX): New.
	(BFD_RELOC_X86_64_REX_GOTPCRELX): Likewise.
	* bfd-in2.h: Regenerated.
	* libbfd.h: Likewise.

gas/

	* config/tc-i386.c (tc_i386_fix_adjustable): Handle
	BFD_RELOC_X86_64_GOTPCRELX and BFD_RELOC_X86_64_REX_GOTPCRELX.
	(tc_gen_reloc): Likewise.
	(i386_validate_fix): Generate BFD_RELOC_X86_64_GOTPCRELX or
	BFD_RELOC_X86_64_REX_GOTPCRELX if fx_tcbit2 is set.
	* config/tc-i386.h (TC_FORCE_RELOCATION_LOCAL): Also return
	true for BFD_RELOC_X86_64_GOTPCRELX and
	BFD_RELOC_X86_64_REX_GOTPCRELX.

gas/testsuite/

	* gas/i386/i386.exp: Run x86-64-gotpcrel.
	* gas/i386/x86-64-gotpcrel.d: New file.
	* gas/i386/x86-64-gotpcrel.s: Likewise.
	* gas/i386/ilp32/x86-64-gotpcrel.d: Likewise.
	* gas/i386/x86-64-localpic.d: Replace R_X86_64_GOTPCREL with
	R_X86_64_REX_GOTPCRELX.
	* gas/i386/ilp32/x86-64-localpic.d: Likewise.

include/elf/

	* x86-64.h (R_X86_64_GOTPCRELX): New.
	(R_X86_64_REX_GOTPCRELX): Likewise.

ld/testsuite/

	* ld-ifunc/ifunc-5r-local-x86-64.d: Replace R_X86_64_GOTPCREL
	with R_X86_64_REX_GOTPCRELX.
	* ld-x86-64/plt-main1.rd: Likewise.
	* ld-x86-64/plt-main3.rd: Likewise.
	* ld-x86-64/plt-main4.rd: Likewise.
	* ld-x86-64/gotpcrel1.dd: New file.
	* ld-x86-64/gotpcrel1.out: Likewise.
	* ld-x86-64/gotpcrel1a.S: Likewise.
	* ld-x86-64/gotpcrel1b.c: Likewise.
	* ld-x86-64/gotpcrel1c.c: Likewise.
	* ld-x86-64/gotpcrel1d.S: Likewise.
	* ld-x86-64/load1.s: Likewise.
	* ld-x86-64/load1a.d: Likewise.
	* ld-x86-64/load1b.d: Likewise.
	* ld-x86-64/load1c.d: Likewise.
	* ld-x86-64/load1d.d: Likewise.
	* ld-x86-64/x86-64.exp: Run load1a, load1b, load1c and load1d
	tests.  Run gotpcrel1 test.
2015-10-22 04:49:38 -07:00
H.J. Lu 02a866936d Add R_386_GOT32X support to gas and ld
This patch adds support for the R_386_GOT32X relocation proposed in

https://groups.google.com/forum/#!topic/ia32-abi/GbJJskkid4I

to gas and ld.  It updates gas to generate R_386_GOT32X relocation for
memory operand, foo@GOT[(%reg)].  We must encode "mov foo@GOT, %eax"
with the 0x8b opcode, instead of the 0xb8 opcode, so that it can be
transformed to "lea foo, %eax".  With the locally defined symbol, foo,
we convert

   mov foo@GOT[(%reg1)], %reg2
to
   lea foo[@GOTOFF(%reg1)], %reg2

and convert

   call/jmp *foo@GOT[(%reg)]
to

   nop call foo/jmp foo nop

When PIC is false, convert

   test %reg1, foo@GOT[(%reg2)]
to
   test $foo, %reg1

and convert

binop foo@GOT[(%reg1)], %reg2

to

binop $foo, %reg2

where binop is one of adc, add, and, cmp, or, sbb, sub, xor instructions.

bfd/

	* elf32-i386.c: Include opcode/i386.h.
	(elf_howto_table): Add R_386_GOT32X.
	(R_386_ext2): Replace R_386_IRELATIVE with R_386_GOT32X.
	(elf_i386_reloc_type_lookup): Handle BFD_RELOC_386_GOT32X.
	(need_convert_mov_to_lea): Renamed to ...
	(need_convert_load): This.
	(elf_i386_check_relocs): Handle R_386_GOT32X.  Replace
	need_convert_mov_to_lea with need_convert_load.
	(elf_i386_gc_sweep_hook): Handle R_386_GOT32X.
	(elf_i386_size_dynamic_sections): Likewise.
	(elf_i386_relocate_section): Likewise.
	(elf_i386_convert_mov_to_lea): Renamed to ...
	(elf_i386_convert_load): This.  Replace need_convert_mov_to_lea
	with need_convert_load.  Support R_386_GOT32X transformations.
	* reloc.c (BFD_RELOC_386_GOT32X): New.
	* bfd-in2.h: Regenerated.
	* libbfd.h: Likewise.

gas/

	* config/tc-i386.c (tc_i386_fix_adjustable): Handle
	BFD_RELOC_386_GOT32X.
	(tc_gen_reloc): Likewise.
	(match_template): Force 0x8b encoding for "mov foo@GOT, %eax".
	(output_disp): Check for "call/jmp *mem", "mov mem, %reg",
	"test %reg, mem" and "binop mem, %reg" where binop is one of
	adc, add, and, cmp, or, sbb, sub, xor instructions.  Set
	fx_tcbit if the REX prefix is generated.  Set fx_tcbit2 if
	BFD_RELOC_386_GOT32X should be generated.
	(i386_validate_fix): Generate BFD_RELOC_386_GOT32X if fx_tcbit2
	is set.

gas/testsuite/

	* gas/i386/got.d: New file.
	* gas/i386/got.s: Likewise.
	* gas/i386/i386.exp: Run got.
	* gas/i386/localpic.d: Replace R_386_GOT32 with R_386_GOT32X.
	* gas/i386/mixed-mode-reloc32.d: Likewise.
	* gas/i386/reloc32.d: Likewise.

include/elf/

	* i386.h (R_386_GOT32X): New relocation.

ld/testsuite/

	* ld-i386/branch1.d: New file.
	* ld-i386/branch1.s: Likewise.
	* ld-i386/call1.d: Likewise.
	* ld-i386/call1.s: Likewise.
	* ld-i386/call2.d: Likewise.
	* ld-i386/call2.s: Likewise.
	* ld-i386/got1.dd: Likewise.
	* ld-i386/got1.out: Likewise.
	* ld-i386/got1a.S: Likewise.
	* ld-i386/got1b.c: Likewise.
	* ld-i386/got1c.c: Likewise.
	* ld-i386/got1d.S: Likewise.
	* ld-i386/jmp1.d: Likewise.
	* ld-i386/jmp1.s: Likewise.
	* ld-i386/jmp2.d: Likewise.
	* ld-i386/jmp2.s: Likewise.
	* ld-i386/load1.d: Likewise.
	* ld-i386/load1.s: Likewise.
	* ld-i386/load2.d: Likewise.
	* ld-i386/load2.s: Likewise.
	* ld-i386/load3.d: Likewise.
	* ld-i386/load3.s: Likewise.
	* ld-i386/load4.s: Likewise.
	* ld-i386/load4a.d: Likewise.
	* ld-i386/load4b.d: Likewise.
	* ld-i386/load5.s: Likewise.
	* ld-i386/load5a.d: Likewise.
	* ld-i386/load5b.d: Likewise.
	* ld-i386/load6.d: Likewise.
	* ld-i386/load6.s: Likewise.
	* ld-i386/i386.exp: Run branch1, call1, call2, jmp1, jmp2,
	load1, load2, load3, load4a, load4b, load5a, load5b and load6
	tests.  Run got1 test.
2015-10-22 04:47:07 -07:00
Andreas Krebbel 99ba512554 S/390: ifunc: Redirect local function calls to the IPLT.
bfd/ChangeLog:

	* elf32-s390.c (elf_s390_check_relocs): Set the non_got_ref marker
	only when linking an executable.
	(elf_s390_relocate_section): Redirect PC-relative relocs to a IPLT
	slot.
	* elf64-s390.c (elf_s390_check_relocs): Set the non_got_ref marker
	only when linking an executable.
	(elf_s390_relocate_section): Redirect PC-relative relocs to a IPLT
	slot.
2015-10-22 10:14:15 +02:00
Andreas Krebbel d8ee9e44cc S/390: ifunc: Fix function pointers to hidden ifunc symbols.
bfd/ChangeLog:
	* elf32-s390.c (elf_s390_adjust_dynamic_symbol): Set the PLT
	reference counters for local IFUNC calls.
	* elf64-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.
2015-10-22 10:13:22 +02:00
Andreas Krebbel 01a5358479 S/390: ifunc: Handle GOTOFF relocs on ifunc symbols.
Normally a GOTOFF reloc only uses the GOT pointer to address something
relativ to it without actually requiring a GOT or PLT slot.  Things
change if the target is an ifunc symbol though.

bfd/ChangeLog:

	* elf32-s390.c (elf_s390_check_relocs): Fallthrough to the PLT
	slot allocating code for GOTOFF relocs on ifunc symbols.
	(elf_s390_gc_sweep_hook): Decrement plt refcount for GOTOFF relocs
	on ifunc symbols.
	(elf_s390_relocate_section): Redirect a GOTOFF reloc to an iplt
	slot.
2015-10-22 10:11:57 +02:00
Andreas Krebbel 0f042c67a0 S/390: ifunc: Fix PR18841.
In order to get the ifunc relocs properly sorted the correct class
needs to be returned.  The code mimics what has been done for x86.

bfd/ChangeLog:

	PR ld/18841
	* elf32-s390.c (elf_s390_reloc_type_class): Return
	reloc_class_ifunc for ifunc symbols.
	* elf64-s390.c (elf_s390_reloc_type_class): Likewise.
2015-10-22 10:11:07 +02:00