deliverable/binutils-gdb.git
8 years agoHandle clang naming of function static local variable.
Doug Evans [Tue, 15 Sep 2015 20:21:28 +0000 (13:21 -0700)] 
Handle clang naming of function static local variable.

clang names the local variable t_structs_a.buf.

gdb/testsuite/ChangeLog:

* gdb.base/callfuncs.exp (do_function_calls): Handle clang naming
of function static local variable.

8 years agoxtensa: generate PLT entries for call0 ABI
Max Filippov [Tue, 15 Sep 2015 03:37:14 +0000 (06:37 +0300)] 
xtensa: generate PLT entries for call0 ABI

2015-09-15  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
* elf32-xtensa.c (elf_xtensa_be_plt_entry)
(elf_xtensa_le_plt_entry): Emit 'entry' instruction only for
windowed ABI.
(elf_xtensa_create_plt_entry): Generate 'l32r' offsets and fix
up instructions according to ABI.

8 years agoFix PR/18564 - regression in showing __thread so extern variable
Philippe Waroquiers [Tue, 15 Sep 2015 19:02:15 +0000 (21:02 +0200)] 
Fix PR/18564 - regression in showing __thread so extern variable

Ensure tls variable address is not relocated, as the msym addr
is an offset in the thread local storage of the shared library/object.

8 years agogdb/doc: revert previous vforkdone change
Pedro Alves [Tue, 15 Sep 2015 18:29:37 +0000 (19:29 +0100)] 
gdb/doc: revert previous vforkdone change

The previous manual change was wrong.  The vfork parent thread ID
should be reported with the usual "thread" magic register:

   Sending packet: $vCont;c:p7260.7260#1e...Packet received: OK
 -   Notification received: Stop:T05vforkdone:;
 +   Notification received: Stop:T05vforkdone:;thread:p7260.7260
                                               ^^^^^^^^^^^^^^^^^

This is already how the parent is reported in the vfork/fork events,
and is actually what the fix made gdbserver do.  Following the
documentation change, the event would have been reported like this
instead:

    Notification received: Stop:T05vforkdone:p7260.7260

gdb/doc/ChangeLog:
2015-09-15  Pedro Alves  <palves@redhat.com>

PR remote/18965
* gdb.texinfo (Stop Reply Packets): Revert previous change to
the vforkdone description.

8 years ago[AArch64] Use debug_printf instead of fprintf_unfiltered
Pierre Langlois [Tue, 15 Sep 2015 17:38:57 +0000 (18:38 +0100)] 
[AArch64] Use debug_printf instead of fprintf_unfiltered

GDBserver uses debug_printf to print debugging output.  This patch makes
GDB use this too so we can share some of this code with GDBserver later.

gdb/ChangeLog:

* aarch64-tdep.c (decode_add_sub_imm): Use debug_printf.
(decode_adrp): Likewise.
(decode_b): Likewise.
(decode_bcond): Likewise.
(decode_br): Likewise.
(decode_cb): Likewise.
(decode_eret): Likewise.
(decode_movz): Likewise.
(decode_orr_shifted_register_x): Likewise.
(decode_ret): Likewise.
(decode_stp_offset): Likewise.
(decode_stp_offset_wb): Likewise.
(decode_stur): Likewise.
(decode_tb): Likewise.
(aarch64_analyze_prologue): Likewise.
(pass_in_x): Likewise.
(pass_in_v): Likewise.
(pass_on_stack): Likewise.
(aarch64_push_dummy_call): Likewise.
(aarch64_extract_return_value): Likewise.
(aarch64_store_return_value): Likewise.
(aarch64_return_value): Likewise.
(aarch64_record_asimd_load_store): Likewise.
(aarch64_record_load_store): Likewise.
(aarch64_record_data_proc_simd_fp): Likewise.

8 years ago[ppc64le] Use skip_entrypoint for skip_trampoline_code
Jan Kratochvil [Tue, 15 Sep 2015 17:08:04 +0000 (19:08 +0200)] 
[ppc64le] Use skip_entrypoint for skip_trampoline_code

ppc64le loses control when stepping between two PLT-called functions inside
a shared library:

29        shlib_second (); /* first-hit */^M
(gdb) PASS: gdb.base/solib-intra-step.exp: first-hit
step^M
^M
Program received signal SIGABRT, Aborted.^M
0x00003fffb7cbe578 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56^M
56        return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);^M
(gdb) FAIL: gdb.base/solib-intra-step.exp: second-hit
->
29        shlib_second (); /* first-hit */^M
(gdb) PASS: gdb.base/solib-intra-step.exp: first-hit
step^M
shlib_second () at ./gdb.base/solib-intra-step-lib.c:23^M
23        abort (); /* second-hit */^M
(gdb) PASS: gdb.base/solib-intra-step.exp: second-hit

This is because gdbarch_skip_trampoline_code() will resolve the final function
as shlib_second+0 and place there the breakpoint, but ld.so will jump after
the breakpoint - at shlib_second+8 - as it is ELFv2 local symbol optimization:

Dump of assembler code for function shlib_second:
   0x0000000000000804 <+0>:     addis   r2,r12,2
   0x0000000000000808 <+4>:     addi    r2,r2,30668
   0x000000000000080c <+8>:     mflr    r0

Currently gdbarch_skip_entrypoint() has been called in skip_prologue_sal() and
fill_in_stop_func() but that is not enough.  I believe
gdbarch_skip_entrypoint() should be called after every
gdbarch_skip_trampoline_code().

gdb/ChangeLog
2015-09-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

* linespec.c (minsym_found): Call gdbarch_skip_entrypoint.
* ppc64-tdep.c (ppc64_skip_trampoline_code): Rename to ...
(ppc64_skip_trampoline_code_1): ... here.
(ppc64_skip_trampoline_code): New wrapper function.
* symtab.c (find_function_start_sal): Call gdbarch_skip_entrypoint.

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

* gdb.opt/solib-intra-step-lib.c: New file.
* gdb.opt/solib-intra-step-main.c: New file.
* gdb.opt/solib-intra-step.exp: New file.

8 years agogdbserver: Fix exec stop reply reporting conditions
Pedro Alves [Tue, 15 Sep 2015 16:38:05 +0000 (17:38 +0100)] 
gdbserver: Fix exec stop reply reporting conditions

gdb/gdbserver/ChangeLog:
2015-09-15  Pedro Alves  <palves@redhat.com>

* remote-utils.c (prepare_resume_reply) <TARGET_WAITKIND_EXECD>:
Check whether to report exec events instead of checking whether
multiprocess is enabled.

8 years agoMove ChangeLog entry to proper place
Pedro Alves [Tue, 15 Sep 2015 16:35:21 +0000 (17:35 +0100)] 
Move ChangeLog entry to proper place

gdb/ChangeLog -> gdb/gdbserver/ChangeLog

2015-09-15  Pedro Alves  <palves@redhat.com>

PR remote/18965
* remote-utils.c (prepare_resume_reply): Merge
TARGET_WAITKIND_VFORK_DONE switch case with the
TARGET_WAITKIND_FORKED case.

8 years agoPR remote/18965: vforkdone stop reply should indicate parent PID
Pedro Alves [Tue, 15 Sep 2015 16:32:45 +0000 (17:32 +0100)] 
PR remote/18965: vforkdone stop reply should indicate parent PID

The vforkdone stop reply misses indicating the thread ID of the vfork
parent which the event relates to:

 @cindex vfork events, remote reply
 @item vfork
 The packet indicates that @code{vfork} was called, and @var{r}
 is the thread ID of the new child process. Refer to
 @ref{thread-id syntax} for the format of the @var{thread-id}
 field.  This packet is only applicable to targets that support
 vfork events.

 @cindex vforkdone events, remote reply
 @item vforkdone
 The packet indicates that a child process created by a vfork
 has either called @code{exec} or terminated, so that the
 address spaces of the parent and child process are no longer
 shared. The @var{r} part is ignored.  This packet is only
 applicable to targets that support vforkdone events.

Unfortunately, this is not just a documentation issue.  GDBserver
is really not specifying the thread ID.  I noticed because
in non-stop mode, gdb complains:

 [Thread 6089.6089] #1 stopped.
 #0  0x0000003615a011f0 in ?? ()
 0x0000003615a011f0 in ?? ()
 (gdb) set debug remote 1
 (gdb) c
 Continuing.
 Sending packet: $QPassSignals:e;10;14;17;1a;1b;1c;21;24;25;2c;4c;#5f...Packet received: OK
 Sending packet: $vCont;c:p17c9.17c9#88...Packet received: OK
   Notification received: Stop:T05vfork:p17ce.17ce;06:40d7ffffff7f0000;07:30d7ffffff7f0000;10:e4c9eb1536000000;thread:p17c9.17c9;core:2;
 Sending packet: $vStopped#55...Packet received: OK
 Sending packet: $D;17ce#af...Packet received: OK
 Sending packet: $vCont;c:p17c9.17c9#88...Packet received: OK
   Notification received: Stop:T05vforkdone:;
 No process or thread specified in stop reply: T05vforkdone:;
 (gdb)

This is not non-stop-mode-specific, however.  Consider e.g., that in
all-stop, you may be debugging more than one process at the same time.
You continue, and both processes vfork.  So when you next get a
T05vforkdone, there's no way to tell which of the parent processes is
done with the vfork.

Tests will be added later.

Tested on x86_64 Fedora 20.

gdb/ChangeLog:
2015-09-15  Pedro Alves  <palves@redhat.com>

PR remote/18965
* remote-utils.c (prepare_resume_reply): Merge
TARGET_WAITKIND_VFORK_DONE switch case with the
TARGET_WAITKIND_FORKED case.

gdb/doc/ChangeLog:
2015-09-15  Pedro Alves  <palves@redhat.com>

PR remote/18965
* gdb.texinfo (Stop Reply Packets): Explain that vforkdone's 'r'
part indicates the thread ID of the parent process.

8 years agoFix typo
Yao Qi [Tue, 15 Sep 2015 16:29:22 +0000 (17:29 +0100)] 
Fix typo

gdb/gdbserver:

2015-09-15  Yao Qi  <yao.qi@linaro.org>

* server.c (handle_query): Check string comparison using
"else if" instead of "if".

8 years agoFix gdb.threads/non-ldr-exc-3.exp race
Pedro Alves [Tue, 15 Sep 2015 16:01:59 +0000 (17:01 +0100)] 
Fix gdb.threads/non-ldr-exc-3.exp race

gdb.threads/non-ldr-exc-3.exp is sometimes failing like this:

 [Switching to Thread 6831.6832]

 Breakpoint 2, thread_execler (arg=0x0) at /home/pedro/gdb/mygit/build/../src/gdb/testsuite/gdb.threads/non-ldr-exc-3.c:41
 41        if (execl (image, image, argv1, NULL) == -1) /* break-here */
 PASS: gdb.threads/non-ldr-exc-3.exp: lock-sched=on,non-stop=off: continue to breakpoint
 (gdb) set scheduler-locking on
 (gdb) FAIL: gdb.threads/non-ldr-exc-3.exp: lock-sched=on,non-stop=off: set scheduler-locking on

The problem is that the gdb_test_multiple is missing the prompt
anchor.  The problem was introduced by 2fd33e9448.  This reverts the
hunk that introduced the problem, reverting back to
gdb_continue_to_breakpoint.

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

* gdb.threads/non-ldr-exc-3.exp (do_test): Use
gdb_continue_to_breakpoint instead of gdb_test_multiple.

8 years agoSupport single step by arch or target
Yao Qi [Tue, 15 Sep 2015 13:09:18 +0000 (14:09 +0100)] 
Support single step by arch or target

Nowadays, GDB only knows whether architecture supports hardware single
step or software single step (through gdbarch hook software_single_step),
and for a given instruction or instruction sequence, GDB knows how to
do single step (hardware or software).  However, GDB doesn't know whether
the target supports hardware single step.  It is possible that the
architecture doesn't support hardware single step, such as arm, but
the target supports, such as simulator.  This was discussed in this
thread https://www.sourceware.org/ml/gdb/2009-12/msg00033.html before.

I encounter this problem for aarch64 multi-arch support.  When aarch64
debugs arm program, gdbarch is arm, so software single step is still
used.  However, the underneath linux kernel does support hardware
single step, so IWBN to use it.

This patch is to add a new target_ops hook to_can_do_single_step, and
only use it in arm_linux_software_single_step to decide whether or not
to use hardware single step.  On the native aarch64 linux target, 1 is
returned.  On other targets, -1 is returned.  On the remote target, if
the target supports s and S actions in the vCont? reply, then target
can do single step.  However,  old GDBserver will send s and S in the
reply to vCont?, which will confuse new GDB.  For example, old GDBserver
on arm-linux will send s and S in the reply to vCont?, but it doesn't
support hardware single step.  On the other hand, new GDBserver, on
arm-linux for example, will not send s and S in the reply to vCont?,
but old GDB thinks it doesn't support vCont packet at all.  In order
to address this problem, I add a new qSupported feature vContSupported,
which indicates GDB wants to know the supported actions in the reply
to vCont?, and qSupported response contains vContSupported if the
stub is able tell supported vCont actions in the reply of vCont?.

If the patched GDB talks with patched GDBserver on x86, the RSP traffic
is like this:

 -> $qSupported:...+;vContSupported+
 <- ...+;vContSupported+
 ...
 -> $vCont?
 <- vCont;c;C;t;s;S;r

then, GDB knows the stub can do single step, and may stop using software
single step even the architecture doesn't support hardware single step.

If the patched GDB talks with patched GDBserver on arm, the last vCont?
reply will become:

 <- vCont;c;C;t

GDB thinks the target doesn't support single step, so it will use software
single step.

If the patched GDB talks with unpatched GDBserver, the RSP traffic is like
this:

 -> $qSupported:...+;vContSupported+
 <- ...+
 ...
 -> $vCont?
 <- vCont;c;C;t;s;S;r

although GDBserver returns s and S, GDB still thinks GDBserver may not
support single step because it doesn't support vContSupported.

If the unpatched GDB talks with patched GDBserver on x86, the RSP traffic
is like:

 -> $qSupported:...+;
 <- ...+;vContSupported+
 ...
 -> $vCont?
 <- vCont;c;C;t;s;S;r

Since GDB doesn't sent vContSupported in the qSupported feature, GDBserver
sends s and S regardless of the support of hardware single step.

gdb:

2015-09-15  Yao Qi  <yao.qi@linaro.org>

* aarch64-linux-nat.c (aarch64_linux_can_do_single_step): New
function.
(_initialize_aarch64_linux_nat): Install it to to_can_do_single_step.
* arm-linux-tdep.c (arm_linux_software_single_step): Return 0
if target_can_do_single_step returns 1.
* remote.c (struct vCont_action_support) <s, S>: New fields.
(PACKET_vContSupported): New enum.
(remote_protocol_features): New element for vContSupported.
(remote_query_supported): Append "vContSupported+".
(remote_vcont_probe): Remove support_s and support_S, use
rs->supports_vCont.s and rs->supports_vCont.S instead.  Disable
vCont packet if c and C actions are not supported.
(remote_can_do_single_step): New function.
(init_remote_ops): Install it to to_can_do_single_step.
(_initialize_remote): Call add_packet_config_cmd.
* target.h (struct target_ops) <to_can_do_single_step>: New field.
(target_can_do_single_step): New macro.
* target-delegates.c: Re-generated.

gdb/gdbserver:

2015-09-15  Yao Qi  <yao.qi@linaro.org>

* server.c (vCont_supported): New global variable.
(handle_query): Set vCont_supported to 1 if "vContSupported+"
matches.  Append ";vContSupported+" to own_buf.
(handle_v_requests): Append ";s;S" to own_buf if target supports
hardware single step or vCont_supported is false.
(capture_main): Set vCont_supported to zero.

gdb/doc:

2015-09-15  Yao Qi  <yao.qi@linaro.org>

* gdb.texinfo (General Query Packets): Add vContSupported to
tables of 'gdbfeatures' and 'stub features' supported in the
qSupported packet, as well as to the list containing stub
feature details.

8 years ago[gdbserver] Rename supports_conditional_breakpoints to supports_hardware_single_step
Yao Qi [Tue, 15 Sep 2015 13:09:18 +0000 (14:09 +0100)] 
[gdbserver] Rename supports_conditional_breakpoints to supports_hardware_single_step

In my patch https://sourceware.org/ml/gdb-patches/2015-04/msg01110.html
a new target_ops hook supports_conditional_breakpoints was added to
disable conditional breakpoints if target doesn't have hardware single
step.  This patch is to generalize this hook from
supports_conditional_breakpoints to supports_hardware_single_step,
so that the following patch can use it.

gdb/gdbserver:

2015-09-15  Yao Qi  <yao.qi@linaro.org>

* linux-low.c (linux_supports_conditional_breakpoints): Rename
it to ...
(linux_supports_hardware_single_step): ... New function.
(linux_target_ops): Update.
* lynx-low.c (lynx_target_ops): Set field
supports_hardware_single_step to target_can_do_hardware_single_step.
* nto-low.c (nto_target_ops): Likewise.
* spu-low.c (spu_target_ops): Likewise.
* win32-low.c (win32_target_ops): Likewise.
* target.c (target_can_do_hardware_single_step): New function.
* target.h (struct target_ops) <supports_conditional_breakpoints>:
Remove.  <supports_hardware_single_step>: New field.
(target_supports_conditional_breakpoints): Remove.
(target_supports_hardware_single_step): New macro.
(target_can_do_hardware_single_step): Declare.
* server.c (handle_query): Use target_supports_hardware_single_step
instead of target_supports_conditional_breakpoints.

8 years agoaarch64 multi-arch support (part 2): siginfo fixup
Yao Qi [Tue, 15 Sep 2015 09:25:51 +0000 (10:25 +0100)] 
aarch64 multi-arch support (part 2): siginfo fixup

This patch is to fixup the siginfo_t when aarch64 gdb or gdbserver
read from or write to the arm inferior.  It is to convert the
"struct siginfo_t" between aarch64 and arm, which is quite mechanical.

gdb/gdbserver:

2015-09-15  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c (aarch64_linux_siginfo_fixup): New
function.
(struct linux_target_ops the_low_target): Install
aarch64_linux_siginfo_fixup.

gdb:

2015-09-15  Yao Qi  <yao.qi@linaro.org>

* aarch64-linux-nat.c (aarch64_linux_siginfo_fixup): New function.
(_initialize_aarch64_linux_nat): Call linux_nat_set_siginfo_fixup.
* nat/aarch64-linux.c (aarch64_compat_siginfo_from_siginfo):
New function.
(aarch64_siginfo_from_compat_siginfo): New function.
* nat/aarch64-linux.h: Include signal.h.
(compat_int_t, compat_uptr_t, compat_time_t): Typedef.
(compat_timer_t, compat_clock_t): Likewise.
(struct compat_timeval): New.
(union compat_sigval): New.
(struct compat_siginfo): New.
(cpt_si_pid, cpt_si_uid, cpt_si_timerid): New macros.
(cpt_si_overrun, cpt_si_status, cpt_si_utime): Likewise.
(cpt_si_stime, cpt_si_ptr, cpt_si_addr): Likewise.
(cpt_si_band, cpt_si_fd): Likewise.

8 years agoAutomatic date update in version.in
GDB Administrator [Tue, 15 Sep 2015 00:00:09 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agoFix the SH behavior for EF_SH_PIC flag in FDPIC ABI
Rich Felker [Mon, 14 Sep 2015 23:16:27 +0000 (08:16 +0900)] 
Fix the SH behavior for EF_SH_PIC flag in FDPIC ABI

Fix it so that it's compatible with the kernel and other FDPIC targets.

* elf32-sh.c (sh_elf_relocate_section): Set EF_SH_PIC flag
instead of clearing it on cross-section relocations.
(sh_elf_merge_private_data): Clear EF_SH_PIC flag by default.

8 years agoBail out of processing stop if hook-stop resumes target / changes context
Pedro Alves [Mon, 14 Sep 2015 14:45:14 +0000 (15:45 +0100)] 
Bail out of processing stop if hook-stop resumes target / changes context

This patch, relative to a tree with
https://sourceware.org/ml/gdb-patches/2015-08/msg00295.html, fixes
issues/crashes that trigger if something unexpected happens during a
hook-stop.

E.g., if the inferior disappears while running the hook-stop, we hit
failed assertions:

 (gdb) define hook-stop
 Type commands for definition of "hook-stop".
 End with a line saying just "end".
 >kill
 >end
 (gdb) si
 Kill the program being debugged? (y or n) [answered Y; input not from terminal]
 /home/pedro/gdb/mygit/build/../src/gdb/thread.c:88: internal-error: inferior_thread: Assertion `tp' failed.
 A problem internal to GDB has been detected,
 further debugging may prove unreliable.
 Quit this debugging session? (y or n)

I noticed that if a hook-stop issues a synchronous execution command,
we print the same stop event twice:

 (gdb) define hook-stop
 Type commands for definition of "hook-stop".
 End with a line saying just "end".
 >si
 >end
 (gdb) si
 0x000000000040074a      42          args[i] = 1; /* Init value.  */  <<<<<<< once
 0x000000000040074a      42          args[i] = 1; /* Init value.  */  <<<<<<< twice
 (gdb)

In MI:

 *stopped,reason="end-stepping-range",frame={addr="0x000000000040074a",func="main",args=[],file="threads.c",fullname="/home/pedro/gdb/tests/threads.c",line="42"},thread-id="1",stopped-threads="all",core="0"
 *stopped,reason="end-stepping-range",frame={addr="0x000000000040074a",func="main",args=[],file="threads.c",fullname="/home/pedro/gdb/tests/threads.c",line="42"},thread-id="1",stopped-threads="all",core="0"
 (gdb)

The fix has GDB stop processing the event if the context changed.  I
don't expect people to be doing crazy things from the hook-stop.
E.g., it gives me headaches to try to come up a proper behavior for
handling a thread change from a hook-stop... (E.g., imagine the
hook-stop does thread N; step, with scheduler-locing on).  I think the
most important bit here is preventing crashes.

The patch adds a new hook-stop.exp test that covers the above and also
merges in the old hook-stop-continue.exp and hook-stop-frame.exp into
the same framework.

gdb/ChangeLog:
2015-09-14  Pedro Alves  <palves@redhat.com>

* infrun.c (current_stop_id): New global.
(get_stop_id, new_stop_id): New functions.
(fetch_inferior_event): Handle normal_stop proceeding the target.
(struct stop_context): New.
(save_stop_context, release_stop_context_cleanup)
(stop_context_changed): New functions.
(normal_stop): Return true if the hook-stop changes the stop
context.
* infrun.h (get_stop_id): Declare.
(normal_stop): Now returns int.  Add documentation.

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

* gdb.base/hook-stop-continue.c: Delete.
* gdb.base/hook-stop-continue.exp: Delete.
* gdb.base/hook-stop-frame.c: Delete.
* gdb.base/hook-stop-frame.exp: Delete.
* gdb.base/hook-stop.c: New file.
* gdb.base/hook-stop.exp: New file.

8 years ago[Ada] Fix the evaluation of access to packed array subscript
Pierre-Marie de Rodat [Fri, 4 Sep 2015 11:09:00 +0000 (13:09 +0200)] 
[Ada] Fix the evaluation of access to packed array subscript

This change is relevant only for standard DWARF (as opposed to the GNAT
encodings extensions): at the time of writing it only makes a difference
with GCC patches that are to be integrated: see in particular
<https://gcc.gnu.org/ml/gcc-patches/2015-07/msg01364.html>.

Given the following Ada declarations:

    type Small is mod 2 ** 6;
    type Array_Type is array (0 .. 9) of Small
       with Pack;
    type Array_Access is access all Array_Type;

    A  : aliased Array_Type := (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
    AA : constant Array_Type := A'Access;

Before this change, we would get the following GDB session:

    (gdb) print aa.all(2)
    $1 = 3
    (gdb) print aa(2)
    $2 = 16

This is wrong: both expression should yield the same value: 3.  The
problem is simply that the routine which handles accesses to arrays lack
general handling for packed arrays.  After this patch, we have the
expected output:

    (gdb) print aa.all(2)
    $1 = 3
    (gdb) print aa(2)
    $2 = 3

gdb/ChangeLog:

* ada-lang.c (ada_value_ptr_subscript): Update the heading
comment.  Handle packed arrays.

gdb/testsuite/ChangeLog:

* gdb.ada/access_to_packed_array.exp: New testcase.
* gdb.ada/access_to_packed_array/foo.adb: New file.
* gdb.ada/access_to_packed_array/pack.adb: New file.
* gdb.ada/access_to_packed_array/pack.ads: New file.

Tested on x86_64-linux, no regression.

8 years agoRemove duplicate gdb/NEWS entry
Pedro Alves [Mon, 14 Sep 2015 13:43:53 +0000 (14:43 +0100)] 
Remove duplicate gdb/NEWS entry

Commit fbea99ea8a06 added this to both the "Changes in GDB 7.10" and
"Changes since GDB 7.10" sections by mistake.

gdb/ChangeLog:
2015-09-14  Pedro Alves  <palves@redhat.com>

* NEWS (Changes in GDB 7.10, New commands>: Remove duplicate
mention of maint set/show target-non-stop.

8 years agobtrace, test: remove buffer-size test with unlimited buffer size
Markus Metzger [Fri, 11 Sep 2015 07:26:21 +0000 (09:26 +0200)] 
btrace, test: remove buffer-size test with unlimited buffer size

The gdb.btrace/buffer-size.exp test starts recording with an unlimited
buffer size.  This will, for a short time, use up most if not all BTS
resources.

I don' think this test is necessary.  Remove it.

testsuite/
* gdb.btrace/buffer-size.exp: Remove recording with unlimited BTS
buffer size test.

8 years agoAutomatic date update in version.in
GDB Administrator [Mon, 14 Sep 2015 00:00:09 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agoAutomatic date update in version.in
GDB Administrator [Sun, 13 Sep 2015 00:00:11 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agoSet .plt entry size to 0 in elf32-hppa.c
John David Anglin [Sat, 12 Sep 2015 16:50:55 +0000 (12:50 -0400)] 
Set .plt entry size to 0 in elf32-hppa.c

8 years agoAutomatic date update in version.in
GDB Administrator [Sat, 12 Sep 2015 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agoExtended-remote exec documentation
Don Breazeal [Fri, 11 Sep 2015 18:06:03 +0000 (11:06 -0700)] 
Extended-remote exec documentation

This patch adds documentation of support for exec events on
extended-remote Linux targets.

gdb/ChangeLog:

* NEWS: Announce new remote packets for the exec-events
feature and the exec-events feature and associated commands.

gdb/doc/ChangeLog:

* gdb.texinfo (Remote Configuration): Add exec event
feature to table of packet settings.
(Stop Reply Packets): Add exec events to the list of stop
reasons.
(General Query Packets): Add exec events to tables of
'gdbfeatures' and 'stub features' supported in the qSupported
packet, as well as to the list containing stub feature
details.

8 years agoExtended-remote exec test
Don Breazeal [Fri, 11 Sep 2015 18:06:02 +0000 (11:06 -0700)] 
Extended-remote exec test

This patch updates several exec-related tests and some of the library
functions in order to get them running with extended-remote.  There were
three changes that were required, as follows:

In gdb.base/foll-exec.exp, use 'clean_start' in place of proc 'zap_session'
to reset the state of the debugger between tests.  This sets 'remote
exec-file' to execute the correct binary file in each subsequent test.

In gdb.base/pie-execl.exp, there is an expect statement with an expression
that is used to match output from both gdb and the program under debug.
For the remote target, this had to be split into two expressions, using
$inferior_spawn_id to match the output from the program.

Because I had encountered problems with extended-remote exec events in
non-stop mode in my manual testing, I added non-stop testing to the
non-ldr-exc-[1234].exp tests.  In order to set non-stop mode for remote
targets, it is necessary to 'set non-stop on' after gdb has started, but
before it connects to gdbserver.  This is done using 'save_vars' to set
non-stop mode in GDBFLAGS, so GDB sets non-stop mode on startup.

gdb/testsuite/ChangeLog:

* gdb.base/foll-exec.c: Add copyright header.  Fix
formatting issues.
* gdb.base/foll-exec.exp (zap_session): Delete proc.
(do_exec_tests): Use clean_restart in place of zap_session,
and for test initialization.  Fix formatting issues.  Use
fail in place of perror.
* gdb.base/pie-execl.exp (main): Use 'inferior_spawn_id' in
an expect statement to match an expression with output from
the program under debug.
* gdb.threads/non-ldr-exc-1.exp (do_test, main): Add
non-stop tests and pass stop mode argument to clean_restart.
Use save_vars to enable non-stop in GDBFLAGS.
* gdb.threads/non-ldr-exc-2.exp: Likewise.
* gdb.threads/non-ldr-exc-3.exp: Likewise.
* gdb.threads/non-ldr-exc-4.exp: Likewise.

8 years agoExtended-remote catch exec
Don Breazeal [Fri, 11 Sep 2015 18:06:02 +0000 (11:06 -0700)] 
Extended-remote catch exec

This patch implements exec catchpoints for extended-remote Linux
targets.  The implementation follows the same approach used for
fork catchpoints, implementing extended-remote target routines for
inserting and removing the catchpoints by just checking if exec events
are supported.  Existing host-side code and previous support for
extended-remote exec events takes care of the rest.

gdb/ChangeLog:

* remote.c (remote_exec_event_p): New function.
(remote_insert_exec_catchpoint): New function.
(remote_remove_exec_catchpoint): New function.
(init_extended_remote_ops): Initialize extended_remote_ops
members to_insert_exec_catchpoint and
to_remove_exec_catchpoint.

8 years agoExtended-remote follow-exec
Don Breazeal [Fri, 11 Sep 2015 18:06:02 +0000 (11:06 -0700)] 
Extended-remote follow-exec

This patch implements support for exec events on extended-remote Linux
targets.  Follow-exec-mode and rerun behave as expected.  Catchpoints and
test updates are implemented in subsequent patches.

This patch was derived from a patch posted last October:
https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html.
It was originally based on some work done by Luis Machado in 2013.

IMPLEMENTATION
----------------
Exec events are enabled via ptrace options.

When an exec event is detected by gdbserver, the existing process
data, along with all its associated lwp and thread data, is deleted
and replaced by data for a new single-threaded process.  The new
process data is initialized with the appropriate parts of the state
of the execing process.  This approach takes care of several potential
pitfalls, including:

 * deleting the data for an execing non-leader thread before any
   wait/sigsuspend occurs
 * correctly initializing the architecture of the execed process

We then report the exec event using a new RSP stop reason, "exec".

When GDB receives an "exec" event, it saves the status in the event
structure's target_waitstatus field, like what is done for remote fork
events.  Because the original and execed programs may have different
architectures, we skip parsing the section of the stop reply packet
that contains register data.  The register data will be retrieved
later after the inferior's architecture has been set up by
infrun.c:follow_exec.

At that point the exec event is handled by the existing event handling
in GDB.  However, a few changes were necessary so that
infrun.c:follow_exec could accommodate the remote target.

 * Where follow-exec-mode "new" is handled, we now call
   add_inferior_with_spaces instead of add_inferior with separate calls
   to set up the program and address spaces.  The motivation for this
   is that add_inferior_with_spaces also sets up the initial architecture
   for the inferior, which is needed later by target_find_description
   when it calls target_gdbarch.

 * We call a new target function, target_follow_exec.  This function
   allows us to store the execd_pathname in the inferior, instead of
   using the static string remote_exec_file from remote.c.  The static
   string didn't work for follow-exec-mode "new", since once you switched
   to the execed program, the original remote exec-file was lost.  The
   execd_pathname is now stored in the inferior's program space as a
   REGISTRY field.  All of the requisite mechanisms for this are
   defined in remote.c.

gdb/gdbserver/ChangeLog:

* linux-low.c (linux_mourn): Static declaration.
(linux_arch_setup): Move in front of
handle_extended_wait.
(linux_arch_setup_thread): New function.
(handle_extended_wait): Handle exec events.  Call
linux_arch_setup_thread.  Make event_lwp argument a
pointer-to-a-pointer.
(check_zombie_leaders): Do not check stopped threads.
(linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC.
(linux_low_filter_event): Add lwp and thread for exec'ing
non-leader thread if leader thread has been deleted.
Refactor code into linux_arch_setup_thread and call it.
Pass child lwp pointer by reference to handle_extended_wait.
(linux_wait_for_event_filtered): Update comment.
(linux_wait_1): Prevent clobbering exec event status.
(linux_supports_exec_events): New function.
(linux_target_ops) <supports_exec_events>: Initialize new member.
* lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize
new member.
* remote-utils.c (prepare_resume_reply): New stop reason 'exec'.
* server.c (report_exec_events): New global variable.
(handle_query): Handle qSupported query for exec-events feature.
(captured_main): Initialize report_exec_events.
* server.h (report_exec_events): Declare new global variable.
* target.h (struct target_ops) <supports_exec_events>: New
member.
(target_supports_exec_events): New macro.
* win32-low.c (win32_target_ops) <supports_exec_events>:
Initialize new member.

gdb/ChangeLog:

* infrun.c (follow_exec): Use process-style ptid for
exec message.  Call add_inferior_with_spaces and
target_follow_exec.
* nat/linux-ptrace.c (linux_supports_traceexec): New function.
* nat/linux-ptrace.h (linux_supports_traceexec): Declare.
* remote.c (remote_pspace_data): New static variable.
(remote_pspace_data_cleanup): New function.
(get_remote_exec_file): New function.
(set_remote_exec_file_1): New function.
(set_remote_exec_file): New function.
(show_remote_exec_file): New function.
(remote_exec_file): Delete static variable.
(anonymous enum) <PACKET_exec_event_feature> New
enumeration constant.
(remote_protocol_features): Add entry for exec-events feature.
(remote_query_supported): Add client side of qSupported query
for exec-events feature.
(remote_follow_exec): New function.
(remote_parse_stop_reply): Handle 'exec' stop reason.
(extended_remote_run, extended_remote_create_inferior): Call
get_remote_exec_file and set_remote_exec_file_1.
(init_extended_remote_ops) <to_follow_exec>: Initialize new
member.
(_initialize_remote): Call
register_program_space_data_with_cleanup.  Call
add_packet_config_cmd for remote exec-events feature.
Modify call to add_setshow_string_noescape_cmd for exec-file
to use new functions set_remote_exec_file and
show_remote_exec_file.
* target-debug.h, target-delegates.c: Regenerated.
* target.c (target_follow_exec): New function.
* target.h (struct target_ops) <to_follow_exec>: New member.
(target_follow_exec): Declare new function.

8 years agoAdd "ld -r" tests for PR ld/15323
H.J. Lu [Fri, 11 Sep 2015 17:02:57 +0000 (10:02 -0700)] 
Add "ld -r" tests for PR ld/15323

Weak defined function is turned into non-weak defined function by
"ld -r -flto" with GCC 5 due to a GCC 5 regression:

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

Add "ld -r" tests for PR ld/15323 to make sure that any linker change
won't introduce linker regression for PR ld/15323.

* ld-plugin/lto.exp (lto_link_tests): Add a "ld -r" test for
PR ld/15323.
(lto_run_tests): Add a "ld -r" test for PR ld/15323.

8 years ago[AArch64] Cleanup comments in instruction decoding functions
Pierre Langlois [Fri, 11 Sep 2015 16:00:55 +0000 (17:00 +0100)] 
[AArch64] Cleanup comments in instruction decoding functions

gdb/ChangeLog:

* aarch64-tdep.c (decode_cb): Move up comment describing the
encoding.
(decode_tb): Fix a typo in comment above the function.  Move up
comment describing the encoding.

8 years ago[AArch64] Fix incorrect mask when decoding b.cond instruction
Pierre Langlois [Fri, 11 Sep 2015 15:47:20 +0000 (16:47 +0100)] 
[AArch64] Fix incorrect mask when decoding b.cond instruction

The encoding of the b.cond instruction is described in the architecture
reference manual as:

b.cond  0101 0100 iiii iiii iiii iiii iii0 cccc

So the mask should be 0xff000010.

gdb/ChangeLog:

* aarch64-tdep.c (decode_bcond): Fix incorrect mask.

8 years agogdb/18947: [aarch64]Step into shared library is very slow.
Mihail-Marian Nistor [Fri, 11 Sep 2015 14:22:11 +0000 (15:22 +0100)] 
gdb/18947: [aarch64]Step into shared library is very slow.

Install gdbarch_skip_solib_resolver on aarch64 GNU/Linux

gdb/ChangeLog:

2015-09-11  Mihail-Marian Nistor  <mihail.nistor@freescale.com>

PR gdb/18947
* aarch64-linux-tdep.c: (aarch64_linux_init_abi): Install
glibc_skip_solib_resolver as gdbarch_skip_solib_resolver callback.

Signed-off-by: Mihail-Marian Nistor <mihail.nistor@freescale.com>
8 years agoAutomatic date update in version.in
GDB Administrator [Fri, 11 Sep 2015 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agoSmall refactor in ada-lang.c:scan_discrim_bound
Simon Marchi [Thu, 10 Sep 2015 15:48:47 +0000 (11:48 -0400)] 
Small refactor in ada-lang.c:scan_discrim_bound

Factor out common arithmetic operations for clarity.

gdb/ChangeLog:

* ada-lang.c (scan_discrim_bound): Factor out arithmetic
operations.

8 years agoConstify variables in ada-lang.c
Simon Marchi [Thu, 10 Sep 2015 15:12:51 +0000 (11:12 -0400)] 
Constify variables in ada-lang.c

I found this const/not const mixup found by building in C++ mode.

gdb/ChangeLog:

* ada-lang.c (ada_search_struct_field): Constify parameters
and/or variables..
(xget_renaming_scope): Likewise.
(ada_is_redundant_range_encoding): Likewise.
(scan_discrim_bound): Likewise.
(to_fixed_range_type): Likewise.

8 years agoS/390: Fix instruction format of crj*, clrj*, and clgrj*.
Andreas Krebbel [Thu, 10 Sep 2015 13:18:00 +0000 (15:18 +0200)] 
S/390: Fix instruction format of crj*, clrj*, and clgrj*.

This fixes the instruction format for 3 of the compare and branch
extended mnemonics.  That way the extended mnemonics are actually
being found by objdump.

gas/testsuite/ChangeLog:

2015-09-10  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* gas/s390/zarch-z10.d: Fix testcase for some of the compare and
branch extended mnemonics.

opcodes/ChangeLog:

2015-09-10  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* s390-opc.txt: Fix instruction format of crj*, clrj*, and clgrj*.

8 years agoS/390: Remove F_20 and FE_20. Adjust comments.
Andreas Krebbel [Thu, 10 Sep 2015 12:27:02 +0000 (14:27 +0200)] 
S/390: Remove F_20 and FE_20. Adjust comments.

This is cleanup only.

opcodes/ChangeLog:

2015-09-10  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* s390-opc.c: Remove unused (and broken) F_20 and FE_20 operand
types and adjust numbering accordingly.  Fix some comments.

8 years agoS/390: Fix MASK_RIE_R0PI and MASK_RIE_R0PU.
Andreas Krebbel [Thu, 10 Sep 2015 12:18:14 +0000 (14:18 +0200)] 
S/390: Fix MASK_RIE_R0PI and MASK_RIE_R0PU.

This makes objdump to be able to recognize some of the extended
mnemonics more often.  It does not lead to wrong being generated.

opcodes/ChangeLog:

2015-09-10  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* s390-opc.c: Fix MASK_RIE_R0PI and MASK_RIE_R0PU.

gas/testsuite/ChangeLog:

2015-09-10  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* gas/s390/zarch-z10.d: Fix testcase for compare and branch
extended mnemonics.

8 years agoAnother updated version of the simplified Chinese translation.
Nick Clifton [Thu, 10 Sep 2015 11:50:34 +0000 (12:50 +0100)] 
Another updated version of the simplified Chinese translation.

* po/zh_CN.po: Updated simplified Chinese translation.

8 years agoCall target_can_download_tracepoint if there are tracepoints to download
Yao Qi [Thu, 10 Sep 2015 11:31:36 +0000 (12:31 +0100)] 
Call target_can_download_tracepoint if there are tracepoints to download

Nowadays, GDB calls target_can_download_tracepoint at the entry of
download_tracepoint_locations, which is called by.
update_global_location_list.  Sometimes, it is not needed to call
target_can_download_tracepoint at all because there is no tracepoint
created.  In remote target, target_can_download_tracepoint send
qTStatus to the remote in order to know whether tracepoint can be
downloaded or not.  This means some redundant qTStatus packets are
sent.

This patch is to teach GDB to call target_can_download_tracepoint
lazily, only on the moment there are tracepoint to download.
gdb.perf/single-step.exp (with a local patch to measure RSP packets)
shows the number of RSP packets is reduced because there is no
tracepoint at all, so GDB doesn't send qTStatus any more.

                       # of RSP packets
                       original  patched
single-step rsp 1000   7000      6000
single-step rsp 2000   14000     12000
single-step rsp 3000   21000     18000
single-step rsp 4000   28000     24000

gdb:

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

* breakpoint.c (download_tracepoint_locations): New local
can_download_tracepoint.  Check the result of
target_can_download_tracepoint and save it in
can_download_tracepoint if there are tracepoints to download.
* linux-nat.h (enum tribool): Move it to ...
* common/common-types.h: ... here.

8 years agoAdds an option to the strings program to specify a separator between the emitted...
Erik Ackermann [Thu, 10 Sep 2015 08:29:13 +0000 (09:29 +0100)] 
Adds an option to the strings program to specify a separator between the emitted pieces of text.

* strings.c: Add -s/--output-separator option to specify custom
separator string.
* NEWS: Mention the new feature.
* doc/binutils.text (strings): Document the new command line
option.

8 years agoAutomatic date update in version.in
GDB Administrator [Thu, 10 Sep 2015 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years ago* gdb.python/py-prettyprint.exp: Check result of run_lang_tests.
Doug Evans [Wed, 9 Sep 2015 18:42:52 +0000 (11:42 -0700)] 
* gdb.python/py-prettyprint.exp: Check result of run_lang_tests.

gdb/testsuite/ChangeLog:

* gdb.python/py-prettyprint.exp: Check result of run_lang_tests.

8 years ago* gdb.base/pie-execl.exp: Fix result test of build_executable.
Doug Evans [Wed, 9 Sep 2015 18:17:36 +0000 (11:17 -0700)] 
* gdb.base/pie-execl.exp: Fix result test of build_executable.

gdb/testsuite/ChangeLog:

* gdb.base/pie-execl.exp: Fix result test of build_executable.

8 years ago* gdb.base/savedregs.exp: Fix typo.
Doug Evans [Wed, 9 Sep 2015 18:00:55 +0000 (11:00 -0700)] 
* gdb.base/savedregs.exp: Fix typo.

gdb/testsuite/ChangeLog:

* gdb.base/savedregs.exp: Fix typo.

8 years agoDelete enum inferior_event_handler::INF_TIMER
Pedro Alves [Wed, 9 Sep 2015 17:23:25 +0000 (18:23 +0100)] 
Delete enum inferior_event_handler::INF_TIMER

Nothing ever uses this.

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

* inf-loop.c (inferior_event_handler): Delete INF_TIMER case.
* target.h (enum inferior_event_type) <INF_TIMER>: Delete.

8 years agoGarbage collect thread continuations
Pedro Alves [Wed, 9 Sep 2015 17:23:25 +0000 (18:23 +0100)] 
Garbage collect thread continuations

Nothing uses thread continuations anymore.

(inferior continuations are still used by the attach command.)

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

* continuations.c (add_continuation, restore_thread_cleanup)
(do_all_continuations_ptid, do_all_continuations_thread_callback)
(do_all_continuations_thread, do_all_continuations)
(discard_all_continuations_thread_callback)
(discard_all_continuations_thread, discard_all_continuations)
(add_intermediate_continuation)
(do_all_intermediate_continuations_thread_callback)
(do_all_intermediate_continuations_thread)
(do_all_intermediate_continuations)
(discard_all_intermediate_continuations_thread_callback)
(discard_all_intermediate_continuations_thread)
(discard_all_intermediate_continuations): Delete.
* continuations.h (add_continuation, do_all_continuations)
(do_all_continuations_thread, discard_all_continuations)
(discard_all_continuations_thread, add_intermediate_continuation)
(do_all_intermediate_continuations)
(do_all_intermediate_continuations_thread)
(discard_all_intermediate_continuations)
(discard_all_intermediate_continuations_thread): Delete
declarations.
* event-top.c (stdin_event_handler): Delete references to
continuations.
* gdbthread.h (struct thread_info): Delete continuations and
intermediate_continuations fields.
* inf-loop.c (inferior_event_handler): Remove references to
continuations.
* infrun.c (infrun_thread_stop_requested_callback): Remove
references to continuations.
* target.h (enum inferior_event_type) <INF_EXEC_CONTINUE>: Delete.
* thread.c: Don't include "continuations.h".
(clear_thread_inferior_resources): Remove references to
continuations.

8 years agoGarbage collect dummy_frame_ctx_saver
Pedro Alves [Wed, 9 Sep 2015 17:23:25 +0000 (18:23 +0100)] 
Garbage collect dummy_frame_ctx_saver

Since the "finish" command and infcall's FSMs are now responsible for
saving the return value, the dummy_frame_ctx_saver is no longer needed
anywhere.

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

* infcall.c (struct dummy_frame_context_saver): Delete.
(dummy_frame_context_saver_free, dummy_frame_context_saver_dtor)
(dummy_frame_context_saver_drop)
(dummy_frame_context_saver_cleanup)
(dummy_frame_context_saver_get_regs)
(dummy_frame_context_saver_setup): Delete.
* infcall.h (dummy_frame_context_saver_drop)
(dummy_frame_context_saver_cleanup)
(dummy_frame_context_saver_get_regs, dummy_frame_context_saver):
Delete.
(get_return_value): Remove 'ctx_saver' paremeter.  Adjust.
* inferior.h (get_return_value): Remove 'ctx_saver' paremeter.
* python/py-finishbreakpoint.c (bpfinishpy_pre_stop_hook): Adjust.

8 years agoConvert the until/advance commands to thread_fsm mechanism
Pedro Alves [Wed, 9 Sep 2015 17:23:24 +0000 (18:23 +0100)] 
Convert the until/advance commands to thread_fsm mechanism

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

* breakpoint.c: Include "thread-fsm.h".
(struct until_break_command_continuation_args): Delete.
(struct until_break_fsm): New.
(until_break_fsm_ops): New global.
(new_until_break_fsm, until_break_fsm_should_stop): New functions.
(until_break_command_continuation): Delete.
(until_break_fsm_clean_up): New function.
(until_break_fsm_async_reply_reason): New function.
(until_break_command): Adjust to create an until_break_fsm instead
of a continuation.
(momentary_bkpt_print_it): No longer print MI's async-stop-reason
here.
* infcmd.c (struct until_next_fsm): New.
(until_next_fsm_ops): New global.
(new_until_next_fsm, until_next_fsm_should_stop): New function.
(until_next_continuation): Delete.
(until_next_fsm_clean_up, until_next_fsm_async_reply_reason): New
functions.
(until_next_command): Adjust to create a new until_next_fsm
instead of a continuation.

8 years agoConvert infcalls to thread_fsm mechanism
Pedro Alves [Wed, 9 Sep 2015 17:23:24 +0000 (18:23 +0100)] 
Convert infcalls to thread_fsm mechanism

This removes infcall-specific special casing from normal_stop,
simplifying it.

Like the "finish" command's, the FSM is responsible for storing the
function's return value.

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

* infcall.c: Include thread_fsm.h.
(struct call_return_meta_info): New.
(get_call_return_value): New function, factored out from
call_function_by_hand_dummy.
(struct call_thread_fsm): New.
(call_thread_fsm_ops): New global.
(new_call_thread_fsm, call_thread_fsm_should_stop)
(call_thread_fsm_should_notify_stop): New functions.
(run_inferior_call): Add 'sm' parameter.  Associate the FSM with
the thread.
(call_function_by_hand_dummy): Create a new call_thread_fsm
instance, associate it with the thread, and wait for the FSM to
finish.  If finished successfully, fetch the function's result
value out of the FSM.
* infrun.c (fetch_inferior_event): If the FSM says the stop
shouldn't be notified, don't call normal_stop.
(maybe_remove_breakpoints): New function, factored out from ...
(normal_stop): ... here.  Simplify.
* infrun.h (maybe_remove_breakpoints): Declare.
* thread-fsm.c (thread_fsm_should_notify_stop): New function.
(thread-fsm.h) <struct thread_fsm_ops>: New field.
(thread_fsm_should_notify_stop): Declare.

8 years agoReplace "struct continuation" mechanism by something more extensible
Pedro Alves [Wed, 9 Sep 2015 17:23:24 +0000 (18:23 +0100)] 
Replace "struct continuation" mechanism by something more extensible

This adds an object oriented replacement for the "struct continuation"
mechanism, and converts the stepping commands (step, next, stepi,
nexti) and the "finish" commands to use it.

It adds a new thread "class" (struct thread_fsm) that contains the
necessary info and callbacks to manage the state machine of a thread's
execution command.

This allows getting rid of some hacks.  E.g., in fetch_inferior_event
and normal_stop we no longer need to know whether a thread is doing a
multi-step (e.g., step N).  This effectively makes the
intermediate_continuations unused -- they'll be garbage collected in a
separate patch.  (They were never a proper abstraction, IMO.  See how
fetch_inferior_event needs to check step_multi before knowing whether
to call INF_EXEC_CONTINUE or INF_EXEC_COMPLETE.)

The target async vs !async uiout hacks in mi_on_normal_stop go away
too.

print_stop_event is no longer called from normal_stop.  Instead it is
now called from within each interpreter's normal_stop observer.  This
clears the path to make each interpreter print a stop event the way it
sees fit.  Currently we have some hacks in common code to
differenciate CLI vs TUI vs MI around this area.

The "finish" command's FSM class stores the return value plus that
value's position in the value history, so that those can be printed to
both MI and CLI's streams.  This fixes the CLI "finish" command when
run from MI -- it now also includes the function's return value in the
CLI stream:

  (gdb)
  ~"callee3 (strarg=0x400730 \"A string argument.\") at src/gdb/testsuite/gdb.mi/basics.c:35\n"
  ~"35\t}\n"
 +~"Value returned is $1 = 0\n"
  *stopped,reason="function-finished",frame=...,gdb-result-var="$1",return-value="0",thread-id="1",stopped-threads="all",core="0"
 -FAIL: gdb.mi/mi-cli.exp: CLI finish: check CLI output
 +PASS: gdb.mi/mi-cli.exp: CLI finish: check CLI output

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

* Makefile.in (COMMON_OBS): Add thread-fsm.o.
* breakpoint.c (handle_jit_event): Print debug output.
(bpstat_what): Split event callback handling to ...
(bpstat_run_callbacks): ... this new function.
(momentary_bkpt_print_it): No longer handle bp_finish here.
* breakpoint.h (bpstat_run_callbacks): Declare.
* gdbthread.h (struct thread_info) <step_multi>: Delete field.
<thread_fsm>: New field.
(thread_cancel_execution_command): Declare.
* infcmd.c: Include thread-fsm.h.
(struct step_command_fsm): New.
(step_command_fsm_ops): New global.
(new_step_command_fsm, step_command_fsm_prepare): New functions.
(step_1): Adjust to use step_command_fsm_prepare and
prepare_one_step.
(struct step_1_continuation_args): Delete.
(step_1_continuation): Delete.
(step_command_fsm_should_stop): New function.
(step_once): Delete.
(step_command_fsm_clean_up, step_command_fsm_async_reply_reason)
(prepare_one_step): New function, based on step_once.
(until_next_command): Remove step_multi reference.
(struct return_value_info): New.
(print_return_value): Rename to ...
(print_return_value_1): ... this.  New struct return_value_info
parameter.  Adjust.
(print_return_value): Reimplement as wrapper around
print_return_value_1.
(struct finish_command_fsm): New.
(finish_command_continuation): Delete.
(finish_command_fsm_ops): New global.
(new_finish_command_fsm, finish_command_fsm_should_stop): New
functions.
(finish_command_fsm_clean_up, finish_command_fsm_return_value):
New.
(finish_command_continuation_free_arg): Delete.
(finish_command_fsm_async_reply_reason): New.
(finish_backward, finish_forward): Change symbol parameter to a
finish_command_fsm.  Adjust.
(finish_command): Create a finish_command_fsm.  Adjust.
* infrun.c: Include "thread-fsm.h".
(clear_proceed_status_thread): Delete the thread's FSM.
(infrun_thread_stop_requested_callback): Cancel the thread's
execution command.
(clean_up_just_stopped_threads_fsms): New function.
(fetch_inferior_event): Handle the event_thread's should_stop
method saying the command isn't done yet.
(process_event_stop_test): Run breakpoint callbacks here.
(print_stop_event): Rename to ...
(print_stop_location): ... this.
(restore_current_uiout_cleanup): New function.
(print_stop_event): Reimplement.
(normal_stop): No longer notify the end_stepping_range observers
here handle "step N" nor "finish" here.  No longer call
print_stop_event here.
* infrun.h (struct return_value_info): Forward declare.
(print_return_value): Declare.
(print_stop_event): Change prototype.
* thread-fsm.c: New file.
* thread-fsm.h: New file.
* thread.c: Include "thread-fsm.h".
(thread_cancel_execution_command): New function.
(clear_thread_inferior_resources): Call it.
* cli/cli-interp.c (cli_on_normal_stop): New function.
(cli_interpreter_init): Install cli_on_normal_stop as normal_stop
observer.
* mi/mi-interp.c: Include "thread-fsm.h".
(restore_current_uiout_cleanup): Delete.
(mi_on_normal_stop): If the thread has an FSM associated, and it
finished, ask it for the async-reply-reason to print.  Always call
print_stop_event here, regardless of the top-level interpreter.
Check bpstat_what to tell whether an asynchronous breakpoint hit
triggered.
* tui/tui-interp.c (tui_on_normal_stop): New function.
(tui_init): Install tui_on_normal_stop as normal_stop observer.

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

* gdb.mi/mi-cli.exp: Add CLI finish tests.

8 years agoMerge async and sync code paths some more
Pedro Alves [Wed, 9 Sep 2015 17:23:23 +0000 (18:23 +0100)] 
Merge async and sync code paths some more

This patch makes the execution control code use largely the same
mechanisms in both sync- and async-capable targets.  This means using
continuations and use the event loop to react to target events on sync
targets as well.  The trick is to immediately mark infrun's event loop
source after resume instead of calling wait_for_inferior.  Then
fetch_inferior_event is adjusted to do a blocking wait on sync
targets.

Tested on x86_64 Fedora 20, native and gdbserver, with and without
"maint set target-async off".

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

* breakpoint.c (bpstat_do_actions_1, until_break_command): Don't
check whether the target can async.
* inf-loop.c (inferior_event_handler): Only call target_async if
the target can async.
* infcall.c: Include top.h and interps.h.
(run_inferior_call): For the interpreter to sync mode while
running the infcall.  Call wait_sync_command_done instead of
wait_for_inferior plus normal_stop.
* infcmd.c (prepare_execution_command): Don't check whether the
target can async when running in the foreground.
(step_1): Delete synchronous case handling.
(step_once): Always install a continuation, even in sync mode.
(until_next_command, finish_forward): Don't check whether the
target can async.
(attach_command_post_wait, notice_new_inferior): Always install a
continuation, even in sync mode.
* infrun.c (mark_infrun_async_event_handler): New function.
(proceed): In sync mode, mark infrun's event source instead of
waiting for events here.
(fetch_inferior_event): If the target can't async, do a blocking
wait.
(prepare_to_wait): In sync mode, mark infrun's event source.
(infrun_async_inferior_event_handler): No longer bail out if the
target can't async.
* infrun.h (mark_infrun_async_event_handler): New declaration.
* linux-nat.c (linux_nat_wait_1): Remove calls to
set_sigint_trap/clear_sigint_trap.
(linux_nat_terminal_inferior): No longer check whether the target
can async.
* mi/mi-interp.c (mi_on_sync_execution_done): Update and simplify
comment.
(mi_execute_command_input_handler): No longer check whether the
target is async.  Update and simplify comment.
* target.c (default_target_wait): New function.
* target.h (struct target_ops) <to_wait>: Now defaults to
default_target_wait.
(default_target_wait): Declare.
* top.c (wait_sync_command_done): New function, factored out from
...
(maybe_wait_sync_command_done): ... this.
* top.h (wait_sync_command_done): Declare.
* target-delegates.c: Regenerate.

8 years agoFT32 linker script now parameterized for flash and RAM size.
jamesbowman [Wed, 9 Sep 2015 16:44:44 +0000 (09:44 -0700)] 
FT32 linker script now parameterized for flash and RAM size.

2015-09-09  James Bowman  <james.bowman@ftdichip.com>

ld/
    * scripttempl/ft32.sc: default linker script RAM and
    FLASH size symbols

8 years agoMake register name tables in visium.h static in order to prevent multiple definitions.
Nick Clifton [Wed, 9 Sep 2015 13:50:08 +0000 (14:50 +0100)] 
Make register name tables in visium.h static in order to prevent multiple definitions.

* visium.h (gen_reg_table): Make static.
(fp_reg_table): Likewise.
(cc_table): Likewise.

8 years agoRemove sentance in binutils documentation saying that thin archives cannot contain...
Nick Clifton [Wed, 9 Sep 2015 13:33:31 +0000 (14:33 +0100)] 
Remove sentance in binutils documentation saying that thin archives cannot contain absolute paths or paths outside of the current directory - they can.

* doc/binutils.texi (ar): Remove bogus sentance concerning thin
archives and invalid paths.

8 years ago[AArch64] Sort IS_AARCH64_TLS_RELAX_RELOC in alphabetic order
Jiong Wang [Wed, 9 Sep 2015 13:25:33 +0000 (14:25 +0100)] 
[AArch64] Sort IS_AARCH64_TLS_RELAX_RELOC in alphabetic order

This can also speedup the check as TLSDESC is the default model for
global/local dynamic that the big "||" check can finish more quickly
than putting them at the bottom.

2015-09-09  Jiong. Wang  <jiong.wang@arm.com>

bfd/
  * elfnn-aarch64.c (IS_AARCH64_TLS_RELAX_RELOC): Sort alphabetically.

8 years ago[AArch64] Relax TLS local dynamic traditional into local executable
Jiong Wang [Wed, 9 Sep 2015 13:19:28 +0000 (14:19 +0100)] 
[AArch64] Relax TLS local dynamic traditional into local executable

The linker relaxation logic will be:

Code sequence I (tiny):

    0x00 adr  x0, :tlsldm:x
    0x04 bl   __tls_get_addr
         |
         V
    0x00 mrs  x0, tpidr_el0
    0x04 add  x0, x0, TCB_SIZE

Code sequence II (small):

    0x00 adrp a0, :tlsldm:x
    0x04 add  a0, #:tlsldm_lo12:x
    0x08 bl   __tls_get_addr
         |
         V
    0x00 mrs  x0, tpidr_el0
    0x04 add  x0, x0, TCB_SIZE
    0x08 nop

2015-09-09  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * elfnn-aarch64.c (aarch64_tls_transition_without_check): Support
  three TLS local dynamic traditional relocations types.
  (elfNN_aarch64_tls_relax): Support TLS local dynamic traditional to
  local executable relaxation.

ld/testsuite/
  * ld-aarch64/tls-relax-ld-le-tiny.s: New testcase.
  * ld-aarch64/tls-relax-ld-le-small.s: Likewise.
  * ld-aarch64/tls-relax-ld-le-tiny.d: New expectation file.
  * ld-aarch64/tls-relax-ld-le-small.d: Likewise.
  * ld-aarch64/aarch64-elf.exp: Run new testcases.

8 years agoS/390: Remove trailing zeros on 4-bytes opcodes.
Andreas Krebbel [Mon, 7 Sep 2015 08:25:58 +0000 (10:25 +0200)] 
S/390: Remove trailing zeros on 4-bytes opcodes.

This is a NOP change only relevant when reading the file or parsing it
with other tools.

opcodes/ChangeLog:

2015-09-09  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* s390-opc.c: Add OP32 definition.
* s390-opc.txt: Reduce the opcode padding of some extended
mnemonics from 6 to the actual length (which is 4).

8 years agoS/390: Fix opcode of ppno.
Andreas Krebbel [Mon, 7 Sep 2015 08:25:17 +0000 (10:25 +0200)] 
S/390: Fix opcode of ppno.

opcodes/ChangeLog:

2015-09-09  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* s390-opc.txt: Fix opcode of ppno instruction.

gas/testsuite/ChangeLog:

2015-09-09  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* gas/s390/zarch-z13.d: Fix opcode of ppno instruction.

8 years agoUpdate the simplified Chinese translation.
Nick Clifton [Wed, 9 Sep 2015 08:55:07 +0000 (09:55 +0100)] 
Update the simplified Chinese translation.

* po/zh_CN.po: Updated simplified Chinese translation.

8 years agobtrace: kernel address filtering
Markus Metzger [Tue, 11 Aug 2015 09:05:58 +0000 (11:05 +0200)] 
btrace: kernel address filtering

For the BTS recording format, we sometimes get a FROM->TO record where the
FROM address lies in the kernel and the TO address lies in user space at
whatever address the user process was resumed.

GDB has a heuristic to filter out such records based on looking at the most
significant bit in the PC.  This works fine for 64-bit systems but it doesn't
always work for 32-bit systems.  Libraries that are loaded at fairly high
addresses might be mistaken for kernel code and branches inside the library
are filtered out.

Change the heuristic to (again heuristically) try to determine the lowest
address in kernel space.  Any PC that is smaller than that should be in
user space.

On today's systems, there should be a symbol "_text" at that address.
Read /proc/kallsyms and search for that symbol.

It is not guaranteed that /proc/kallsyms is readable on all systems.  On
64-bit systems, we fall back to check the most significant bit.  On 32-bit
systems, we refrain from filtering out addresses.

The filtering should really be done by the kernel.  And it soon will be:
https://lkml.org/lkml/2015/8/31/212.

gdb/
* nat/linux-btrace.h (struct btrace_target_info) <ptr_bits>: Remove.
* nat/linux-btrace.c: Include filestuff.h and inttypes.h.
Remove include of sys/utsname.h.
(linux_determine_kernel_ptr_bits): Remove.
(linux_determine_kernel_start): New.
(perf_event_is_kernel_addr): Remove tinfo argument.  Update users.
Update check.
(perf_event_skip_bts_record): Remove tinfo argument.  Update users.
(linux_enable_bts, linux_enable_pt): Remove tinfo->ptr_bits
initialization.
* x86-linux-nat.c (x86_linux_enable_btrace): Remove ptr_bits
assignment.

gdbserver/
* linux-low.c (linux_low_enable_btrace): Remove.
(linux_target_ops): Replace linux_low_enable_btrace with
linux_enable_btrace.

8 years agoImprove hand-call-in-threads.exp failure handling.
Sandra Loosemore [Wed, 9 Sep 2015 02:49:04 +0000 (19:49 -0700)] 
Improve hand-call-in-threads.exp failure handling.

2015-09-08  Sandra Loosemore  <sandra@codesourcery.com>

gdb/testsuite/
* gdb.threads/hand-call-in-threads.exp: Make sure the thread
command actually switches threads.  Give up on remaining
tests if target fails to stop at breakpoint.

8 years agoAutomatic date update in version.in
GDB Administrator [Wed, 9 Sep 2015 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agoconfig/tc-avr.c (md_section_align): Append UL for -1 to avoid the latest gcc's warning
Chen Gang [Sat, 5 Sep 2015 08:02:08 +0000 (16:02 +0800)] 
config/tc-avr.c (md_section_align): Append UL for -1 to avoid the latest gcc's warning

The related warning is:

  gcc -DHAVE_CONFIG_H -I. -I../../binutils-gdb/gas  -I. -I../../binutils-gdb/gas -I../bfd -I../../binutils-gdb/gas/config -I../../binutils-gdb/gas/../include -I../../binutils-gdb/gas/.. -I../../binutils-gdb/gas/../bfd -DLOCALEDIR="\"/upstream/release-avr32/share/locale\""  -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I../../binutils-gdb/gas/../zlib -g -O2 -MT tc-avr.o -MD -MP -MF .deps/tc-avr.Tpo -c -o tc-avr.o `test -f 'config/tc-avr.c' || echo '../../binutils-gdb/gas/'`config/tc-avr.c
../../binutils-gdb/gas/config/tc-avr.c: In function â€˜md_section_align’:
../../binutils-gdb/gas/config/tc-avr.c:1233:43: error: left shift of negative value [-Werror=shift-negative-value]
     return ((addr + (1 << align) - 1) & (-1 << align));
                                             ^

2015-09-05  Chen Gang  <gang.chen.5i5j@gmail.com>

* config/tc-avr.c (md_section_align): Append UL for -1 to avoid
the latest gcc's warning.

8 years agoExtend the descriptiopn of how to access linker defined symbols from C.
Nick Clifton [Tue, 8 Sep 2015 08:36:02 +0000 (09:36 +0100)] 
Extend the descriptiopn of how to access linker defined symbols from C.

* ld.texinfo (Source Code Reference): Extend description to
include an example using arrays.

8 years agoAutomatic date update in version.in
GDB Administrator [Tue, 8 Sep 2015 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agold: Fix failures in new orphan handling tests.
Andrew Burgess [Mon, 7 Sep 2015 14:39:12 +0000 (15:39 +0100)] 
ld: Fix failures in new orphan handling tests.

The new orphan handling tests added in commit c005eb9 fail on a range of
targets.  Some of the failures were fixed in commit e32aa93 but not
all.  This commit should address the remaining failures.

Update results to account for orphan sections being placed in different
orders, and for other, target specific sections, being discarded.

ld/testsuite/ChangeLog:

* ld-elf/orphan-7.map: Allow for other discarded sections.
* ld-elf/orphan-8.map: Updated to allow for different section
ordering on different targets.
* ld-elf/orphan.ld: Place .sbss section.

8 years agoguile: Add as_a_scm_t_subr
Pedro Alves [Mon, 7 Sep 2015 18:34:31 +0000 (19:34 +0100)] 
guile: Add as_a_scm_t_subr

Building GDB in C++ mode on Fedora 20, the gdb/guile/ code shows ~280
errors like:

 src/gdb/guile/guile.c:515:1: error: invalid conversion from â€˜scm_unused_struct* (*)(SCM, SCM) {aka scm_unused_struct* (*)(scm_unused_struct*, scm_unused_struct*)}’ to â€˜scm_t_subr {aka void*}’ [-fpermissive]

This commit fixes them all.

gdb/ChangeLog:
2015-09-07  Pedro Alves  <palves@redhat.com>

* guile/guile-internal.h (as_a_scm_t_subr): New.
* guile/guile.c (misc_guile_functions): Use it.
* guile/scm-arch.c (arch_functions): Use it.
* guile/scm-block.c (block_functions, gdbscm_initialize_blocks):
Use it.
* guile/scm-breakpoint.c (breakpoint_functions): Use it.
* guile/scm-cmd.c (command_functions): Use it.
* guile/scm-disasm.c (disasm_functions): Use it.
* guile/scm-exception.c (exception_functions)
(private_exception_functions): Use it.
* guile/scm-frame.c (frame_functions)
* guile/scm-gsmob.c (gsmob_functions): Use it.
* guile/scm-iterator.c (iterator_functions): Use it.
* guile/scm-lazy-string.c (lazy_string_functions): Use it.
* guile/scm-math.c (math_functions): Use it.
* guile/scm-objfile.c (objfile_functions): Use it.
* guile/scm-param.c (parameter_functions): Use it.
* guile/scm-ports.c (port_functions, private_port_functions): Use
it.
* guile/scm-pretty-print.c (pretty_printer_functions): Use it.
* guile/scm-progspace.c (pspace_functions): Use it.
* guile/scm-string.c (string_functions): Use it.
* guile/scm-symbol.c (symbol_functions): Use it.
* guile/scm-symtab.c (symtab_functions): Use it.
* guile/scm-type.c (type_functions, gdbscm_initialize_types): Use
it.
* guile/scm-value.c (value_functions): Use it.

8 years agoFix internal error caused by IFUNC patch.
Cary Coutant [Mon, 7 Sep 2015 16:44:11 +0000 (09:44 -0700)] 
Fix internal error caused by IFUNC patch.

The previous commit to fix PR gold/18886 converted STT_IFUNC
to STT_FUNC when resolving to a symbol defined in a shared library.
This leads to an internal error if the shared library symbol is
seen first, as we do not convert the symbol at all.

We need to override the STT_IFUNC in add_from_dynobj() instead of
in override_base().

gold/
PR gold/18930
PR gold/18886
* resolve.cc (Symbol::override_base): Don't convert IFUNC symbols here.
* symtab.cc (Symbol_table::add_from_dynobj): Convert them here instead.

8 years agoAutomatic date update in version.in
GDB Administrator [Mon, 7 Sep 2015 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agoAutomatic date update in version.in
GDB Administrator [Sun, 6 Sep 2015 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agoUpdate ld-elf/orphan-8.map to support 32-bit targets
H.J. Lu [Sat, 5 Sep 2015 13:44:53 +0000 (06:44 -0700)] 
Update ld-elf/orphan-8.map to support 32-bit targets

* ld-elf/orphan-8.map: Updated to support 32-bit targets.

8 years agoAutomatic date update in version.in
GDB Administrator [Sat, 5 Sep 2015 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agold: Extend options for altering orphan handling behaviour.
Andrew Burgess [Tue, 28 Jul 2015 18:20:37 +0000 (19:20 +0100)] 
ld: Extend options for altering orphan handling behaviour.

Replace the options --warn-orphan and --no-warn-orphan with a single
option --orphan-handling=MODE, where mode can be place, warn, error, and
discard.

Mode 'place' is the default, and is the current behaviour, placing the
orphan section into a suitable output section.

Mode 'warn' is the same as '--warn-orphan'.  The orphan is also placed
using the same algorithm as for 'place'.

Mode 'error' is the same as '--warn-orphan' and '--fatal-warnings'.

Mode 'discard' assigns all output sections to the /DISCARD/ section.

ld/ChangeLog:

* ld.h (enum orphan_handling_enum): New.
(ld_config_type): Remove warn_orphan, add orphan_handling.
* ldemul.c (ldemul_place_orphan): Remove warning about orphan
sections.
* ldlang.c (ldlang_place_orphan): New function.
(lang_place_orphans): Call ldlang_place_orphan.
* ldlex.h (enum option_values): Remove OPTION_WARN_ORPHAN and
OPTION_NO_WARN_ORPHAN, add OPTION_ORPHAN_HANDLING.
* lexsup.c (ld_options): Remove 'warn-orphan' and
'no-warn-orphan', add 'orphan-handling'.
(parse_args): Remove handling for OPTION_WARN_ORPHAN and
OPTION_NO_WARN_ORPHAN, add handling for OPTION_ORPHAN_HANDLING.
* NEWS: Replace text about --warn-orphan with --orphan-handling.
* ld.texinfo (Options): Remove --warn-orphan entry and add
entry on --orphan-handling.
(Orphan Sections): Add reference to relevant command line options.

ld/testsuite/ChangeLog:

* ld-elf/elf.exp: Switch to rely on run_dump_test.
* ld-elf/orphan-5.l: Update expected output.
* ld-elf/orphan-5.d: New file.
* ld-elf/orphan-6.d: New file.
* ld-elf/orphan-6.l: New file.
* ld-elf/orphan-7.d: New file.
* ld-elf/orphan-7.map: New file.
* ld-elf/orphan-8.d: New file.
* ld-elf/orphan-8.map: New file.

8 years agogdb/tui: Remove casts of NULL during assignment.
Andrew Burgess [Mon, 31 Aug 2015 20:32:11 +0000 (21:32 +0100)] 
gdb/tui: Remove casts of NULL during assignment.

In the following code:

    struct symbol *wsym = (struct symbol *) NULL;

the cast of NULL is redundant, it adds noise, and is just one more thing
to change if the type of wsym ever changes.  There are a relatively
small number of places in gdb where the above code pattern is used.
Usually the cast is removed like this:

    struct symbol *wsym = NULL;

This commit updates all the places within the gdb/tui directory where we
cast NULL during assignment, removing the cast.

gdb/ChangeLog:

* tui/tui-data.c (win_with_focus): Remove cast of NULL pointer.
(tui_next_win): Likewise.
(tui_prev_win): Likewise.
(tui_partial_win_by_name): Likewise.
(tui_init_generic_part): Likewise.
(init_content_element): Likewise.
(tui_del_window): Likewise.
(tui_free_window): Likewise.
(tui_del_data_windows): Likewise.
(tui_free_data_content): Likewise.
* tui/tui-layout.c (make_source_or_disasm_window): Likewise.
* tui/tui-regs.c (tui_show_register_group): Likewise.
* tui/tui-win.c (tui_resize_all): Likewise.
(tui_set_focus): Likewise.
(tui_set_win_height): Likewise.
(make_invisible_and_set_new_height): Likewise.
* tui/tui-windata.c (tui_delete_data_content_windows): Likewise.
* tui/tui-wingeneral.c (make_visible): Likewise.

8 years agogdb/cli: Remove casts of NULL during assignment.
Andrew Burgess [Mon, 31 Aug 2015 20:25:37 +0000 (21:25 +0100)] 
gdb/cli: Remove casts of NULL during assignment.

In the following code:

    struct symbol *wsym = (struct symbol *) NULL;

the cast of NULL is redundant, it adds noise, and is just one more thing
to change if the type of wsym ever changes.  There are a relatively
small number of places in gdb where the above code pattern is used.
Usually the cast is removed like this:

    struct symbol *wsym = NULL;

This commit updates all the places within the gdb/cli directory where we
cast NULL during assignment, removing the cast.

gdb/ChangeLog:

* cli/cli-decode.c (find_cmd): Remove cast of NULL pointer.

8 years agogdb: Remove casts of NULL during assignment.
Andrew Burgess [Mon, 31 Aug 2015 20:19:49 +0000 (21:19 +0100)] 
gdb: Remove casts of NULL during assignment.

In the following code:

    struct symbol *wsym = (struct symbol *) NULL;

the cast of NULL is redundant, it adds noise, and is just one more thing
to change if the type of wsym ever changes.  There are a relatively
small number of places in gdb where the above code pattern is used.
Usually the cast is removed like this:

    struct symbol *wsym = NULL;

This commit updates all the places within the gdb/ directory where we
cast NULL during assignment, removing the cast.

gdb/ChangeLog:

* c-valprint.c (print_unpacked_pointer): Remove cast of NULL
pointer.
* dbxread.c (dbx_end_psymtab): Likewise.
* gnu-nat.c (gnu_write_inferior): Likewise.
* mdebugread.c (cross_ref): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
* xcoffread.c (xcoff_end_psymtab): Likewise.

8 years agoMention multi-arch debugging support in NEWS
Yao Qi [Fri, 4 Sep 2015 14:26:21 +0000 (15:26 +0100)] 
Mention multi-arch debugging support in NEWS

gdb:

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

* NEWS: Mention the aarch64 multi-arch debugging support.

8 years agoAutomatic date update in version.in
GDB Administrator [Fri, 4 Sep 2015 00:00:09 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years ago[Ada] Make string_char_type a true TYPE_CODE_CHAR type in Ada
Pierre-Marie de Rodat [Wed, 2 Sep 2015 16:18:15 +0000 (18:18 +0200)] 
[Ada] Make string_char_type a true TYPE_CODE_CHAR type in Ada

Before this change, trying to call an overloaded function with at least
one character literal in argument would fail.  For instance, given these
two functions:

   function F (C : Character) return Integer is
   begin
      return Character'Pos (C);
   end F;

   function F (I : Integer) return Integer is
   begin
      return -I;
   end F;

We would get the following GDB session:

    (gdb) p f('A')
    $1 = -65
    (gdb) p f(1)
    $1 = -1

This is wrong because the first call should select the first F function
and thus return 65.

The root problem is that ada-lang.c:ada_language_arch_info stores in
string_char_type a type whose code is TYPE_CODE_INT instead of
TYPE_CODE_CHAR.  As a result, all parsed character literals are turned
into integer values and during overload matching, the TYPE_CODE_CHAR
formal rejects the TYPE_CODE_INT actual.

This change turns string_char_type into a true TYPE_CODE_CHAR type in
ada-lang.c so that we have instead the expected:

    (gdb) p f('A')
    $1 = 65

gdb/ChangeLog:

* ada-lang.c (ada_language_arch_info): Create a TYPE_CODE_CHAR
type instead of a TYPE_CODE_INT one for the string_char_type
and the ada_primitive_type_char types.

gdb/testsuite/ChangeLog:

* gdb.ada/funcall_char.exp: New testcase.
* gdb.ada/funcall_char/foo.adb: New file.

Tested on x86_64-linux, no regression.

8 years agoFix typo in desription of linker script symbols.
Nick Clifton [Thu, 3 Sep 2015 15:49:18 +0000 (16:49 +0100)] 
Fix typo in desription of linker script symbols.

(Source Code Reference): Fix off-by-one typo in example of how to
use linker script symbols in C source code.

8 years agoFix seg-fault in readelf when scanniing a corrupt binary.
Nick Clifton [Thu, 3 Sep 2015 15:15:49 +0000 (16:15 +0100)] 
Fix seg-fault in readelf when scanniing a corrupt binary.

PR binutils/18879
* readelf.c (get_unwind_section_word): Check for negative offsets
and very small sections.
(dump_arm_unwind): Warn if the table offset is too large.

8 years ago[aarch64] Check region OK for HW watchpoint in GDBserver
Yao Qi [Thu, 3 Sep 2015 13:01:49 +0000 (14:01 +0100)] 
[aarch64] Check region OK for HW watchpoint in GDBserver

Nowadays, if user requests HW watchpoint to monitor a large memory area
or unaligned area, aarch64 GDB will split into multiple aligned areas,
and use multiple debugging registers to watch them.  However, the
registers are not updated in a transaction way.  GDBserver doesn't revert
updates in previous iterations if some debugging registers fail to update
due to some reason, like no free debugging registers available, in the
latter iteration.  For example, if we have a char buf[34], and watch buf
in gdb,

(gdb) watch buf
Hardware watchpoint 2: buf
(gdb) c
Continuing.
infrun: clear_proceed_status_thread (Thread 13466)
infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: step-over queue now empty
infrun: resuming [Thread 13466] for step-over
Sending packet: $m410838,22#35...Packet received: 00000000000000000000000000000000000000000000000000000000000000000000
infrun: skipping breakpoint: stepping past insn at: 0x400524
infrun: skipping breakpoint: stepping past insn at: 0x400524
Sending packet: $Z2,410838,22#80...Packet received: E01 <----- [1]
Packet Z2 (write-watchpoint) is supported
Sending packet: $Z0,7fb7fe0a8c,4#43...Packet received: OK
Warning:
Could not insert hardware watchpoint 2.
Could not insert hardware breakpoints:
You may have requested too many hardware breakpoints/watchpoints.

GDB receives E01 for Z2 packet [1] but GDBserver updates the debugging
register status,

insert_point (addr=0x00410838, len=34, type=hw-write-watchpoint):
BREAKPOINTs:
BP0: addr=0x0, ctrl=0x00000000, ref.count=0
BP1: addr=0x0, ctrl=0x00000000, ref.count=0
BP2: addr=0x0, ctrl=0x00000000, ref.count=0
BP3: addr=0x0, ctrl=0x00000000, ref.count=0
BP4: addr=0x0, ctrl=0x00000000, ref.count=0
BP5: addr=0x0, ctrl=0x00000000, ref.count=0
WATCHPOINTs:
WP0: addr=0x410850, ctrl=0x00001ff5, ref.count=1
WP1: addr=0x410848, ctrl=0x00001ff5, ref.count=1
WP2: addr=0x410840, ctrl=0x00001ff5, ref.count=1
WP3: addr=0x410838, ctrl=0x00001ff5, ref.count=1

four debugging registers can not monitor 34-byte long area, so the last
iteration of updating debugging register state fails but previous
iterations succeed.  This makes GDB think no HW watchpoint is inserted
but some debugging registers are used.

This problem was exposed by "watch buf" gdb.base/watchpoint.exp with
aarch64 GDBserver debugging arm 32-bit program.  The buf is 30-byte long
but 4-byte aligned, and four debugging registers can't cover 34-byte
(extend 4 bytes to be 8-byte aligned) area.  However, this problem
does exist on non-multi-arch debugging scenario as well.

This patch moves code in aarch64_linux_region_ok_for_hw_watchpoint to
aarch64_linux_region_ok_for_watchpoint in nat/aarch64-linux-hw-point.c.
Then, checks with aarch64_linux_region_ok_for_watchpoint, like what we
are doing in GDB.  If the region is OK, call aarch64_handle_watchpoint.

Regression tested on aarch64 with both 64-bit program and 32-bit
program.  Some fails in gdb.base/watchpoint.exp are fixed.

gdb:

2015-09-03  Yao Qi  <yao.qi@linaro.org>

* aarch64-linux-nat.c (aarch64_linux_region_ok_for_hw_watchpoint):
Move code to aarch64_linux_region_ok_for_watchpoint.  Call
aarch64_linux_region_ok_for_watchpoint.
* nat/aarch64-linux-hw-point.c (aarch64_linux_region_ok_for_watchpoint):
New function.
* nat/aarch64-linux-hw-point.h (aarch64_linux_region_ok_for_watchpoint):
Declare it.

gdb/gdbserver:

2015-09-03  Yao Qi  <yao.qi@linaro.org>

* linux-aarch64-low.c (aarch64_insert_point): Call
aarch64_handle_watchpoint if aarch64_linux_region_ok_for_watchpoint
returns true.

8 years agoFix a typo in the linker documentation: The COFF section .build-id should be .buildid.
Nick Clifton [Thu, 3 Sep 2015 11:55:57 +0000 (12:55 +0100)] 
Fix a typo in the linker documentation: The COFF section .build-id should be .buildid.

8 years agoRemove convert_mov_to_lea
H.J. Lu [Thu, 3 Sep 2015 11:13:21 +0000 (04:13 -0700)] 
Remove convert_mov_to_lea

* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Remove
convert_mov_to_lea.

8 years agoAdd ifunc tests for call, jmp, add, test
H.J. Lu [Thu, 3 Sep 2015 11:03:13 +0000 (04:03 -0700)] 
Add ifunc tests for call, jmp, add, test

* ld-ifunc/ifunc-21-i386.s: Add tests for call, jmp, add, test.
* ld-ifunc/ifunc-21-x86-64.s: Likewise.
* ld-ifunc/ifunc-22-i386.s: Likewise.
* ld-ifunc/ifunc-22-x86-64.s: Likewise.
* ld-ifunc/ifunc-21-i386.d: Updated.
* ld-ifunc/ifunc-21-x86-64.d: Likewise.
* ld-ifunc/ifunc-22-i386.d: Likewise.
* ld-ifunc/ifunc-22-x86-64.d: Likewise.

8 years agoUse gdbarch obstack to allocate the TYPE_NAME string in arch_type
Patrick Palka [Sat, 29 Aug 2015 22:07:50 +0000 (18:07 -0400)] 
Use gdbarch obstack to allocate the TYPE_NAME string in arch_type

Since the type whose name is being set is now being allocated on the
gdbarch obstack, we should allocate its TYPE_NAME on the obstack too.
This reduces the number of individual valgrind warnings for the command
"gdb gdb" from ~300 to ~150.

Tested on x86_64-unknown-linux-gnu.

gdb/ChangeLog:

* gdb_obstack.h (obstack_strdup): Declare.
* gdb_obstack.c (obstack_strdup): Define.
* gdbarch.sh (gdbarch_obstack_strdup): Declare and define.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbtypes.c (arch_type): Use gdbarch_obstack_strdup.

8 years agoUpdate documentation of function copy_type_recursive
Patrick Palka [Sat, 29 Aug 2015 22:16:40 +0000 (18:16 -0400)] 
Update documentation of function copy_type_recursive

Following commit 8f57eec2fb3 ("Use gdbarch obstack to allocate types in
alloc_type_arch") it is no longer the case that the type returned by
copy_type_recursive is allocated using malloc.  Because the function
uses alloc_type_arch internally, the new type is now allocated on the
gdbarch associated with the type, and is thus owned by that gdbarch.

gdb/ChangeLog:

* gdbtypes.c (copy_type_recursive): Update documentation.

8 years agoAutomatic date update in version.in
GDB Administrator [Thu, 3 Sep 2015 00:00:11 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agoAdd 2 ifunc tests for i386 and x86-64
H.J. Lu [Wed, 2 Sep 2015 22:30:32 +0000 (15:30 -0700)] 
Add 2 ifunc tests for i386 and x86-64

* ld-ifunc/ifunc-21-i386.d: Likewise.
* ld-ifunc/ifunc-21-i386.s: Likewise.
* ld-ifunc/ifunc-21-x86-64.d: Likewise.
* ld-ifunc/ifunc-21-x86-64.s: Likewise.
* ld-ifunc/ifunc-22-i386.d: Likewise.
* ld-ifunc/ifunc-22-i386.s: Likewise.
* ld-ifunc/ifunc-22-x86-64.d: Likewise.
* ld-ifunc/ifunc-22-x86-64.s: Likewise.

8 years agoRename R_386_irelative to R_386_ext2
H.J. Lu [Wed, 2 Sep 2015 12:13:08 +0000 (05:13 -0700)] 
Rename R_386_irelative to R_386_ext2

* elf32-i386.c (R_386_irelative): Renamed to ...
(R_386_ext2): This.
(R_386_vt_offset): Updated.
(elf_i386_rtype_to_howto): Likewise.
(elf_i386_relocate_section): Likewise.

8 years agoTurn IFUNC symbols from shared libraries into normal FUNC symbols
H.J. Lu [Wed, 2 Sep 2015 11:14:21 +0000 (04:14 -0700)] 
Turn IFUNC symbols from shared libraries into normal FUNC symbols

Turn IFUNC symbols from shared libraries into normal FUNC symbols when
we are resolving symbol references, instead of when we are writing out
the symbol table.

PR gold/18886
* resolve.cc (Symbol::override_base): Turn IFUNC symbols from
shared libraries into normal FUNC symbols.
* symtab.cc (Symbol_table::sized_write_symbol): Assert IFUNC
symbols aren't from shared libraries.

8 years ago[GOLD] ppc64 out-of-line register save/restore functions
Alan Modra [Wed, 2 Sep 2015 06:21:59 +0000 (15:51 +0930)] 
[GOLD] ppc64 out-of-line register save/restore functions

Gold version of a4b6fadd.  Don't emit long branch or plt branch stubs
to save/restore functions.  Copy them instead.

PR 18878
* powerpc.cc (Target_powerpc): Add savres_section_ and accessor.
(Target_powerpc::Branch_info::make_stub): Determine whether long
branch stub is for save/restore function.
(Branch_stub_ent): Add save_res_, and extra parm to constructor.
(Stub_table): Add need_save_res_.
(Stub_table:clear_stubs): Clear need_save_res_.
(Stub_table:set_address_and_size): Add save/restore section size.
(Stub_table::add_long_branch_entry): Add save_res param.  Set
need_save_res_, but don't add space for save/restore stubs.
(Stub_table::find_long_branch_entry): Return offset to local copy
of save/restore func.
(Stub_table::do_write): Don't output save/restore stubs.  Instead
copy the save/restore functions.
(Output_data_save_res:contents): New accessor.
(Target_powerpc::define_save_restore_funcs): Set savres_section_.

8 years agoInitialize yet another variable to silence GCC warning from last-but-one commit
Sergio Durigan Junior [Wed, 2 Sep 2015 04:46:43 +0000 (00:46 -0400)] 
Initialize yet another variable to silence GCC warning from last-but-one commit

Yet another BuildBot e-mail, yet another breakage on RHEL-7.1 s390x
(which uses an older GCC).  This time,
solib-svr4.c:solib_event_probe_action has the probe_argc variable,
which is now inside a TRY..CATCH and therefore needs to be
initialized.  Pushed as obvious.

gdb/ChangeLog:
2015-09-01  Sergio Durigan Junior  <sergiodj@redhat.com>

* solib-svr4.c (solib_event_probe_action): Initialize 'probe_argc'
as zero.

8 years agoInitialize variable and silence GCC warning from last commit
Sergio Durigan Junior [Wed, 2 Sep 2015 04:34:22 +0000 (00:34 -0400)] 
Initialize variable and silence GCC warning from last commit

BuildBot e-mailed me to let me know that my last commit broke GDB on
RHEL-7.1 s390x.  On solib-svr4.c:svr4_handle_solib_event, 'val' now
needs to be initialized as NULL because it is inside a TRY..CATCH
block.  This patch does that.  Pushed as obvious.

gdb/ChangeLog:
2015-09-01  Sergio Durigan Junior  <sergiodj@redhat.com>

* solib-svr4.c (svr4_handle_solib_event): Initialize 'val' as NULL

8 years agoCatching errors on probes-based dynamic linker interface
Sergio Durigan Junior [Fri, 21 Aug 2015 22:28:07 +0000 (18:28 -0400)] 
Catching errors on probes-based dynamic linker interface

This patch is intended to make the interaction between the
probes-based dynamic linker interface and the SystemTap SDT probe code
on GDB more robust.  It does that by wrapping the calls to the probe
API with TRY...CATCH'es, so that any exception thrown will be caught
and handled properly.

The idea for this patch came from
<https://bugzilla.redhat.com/show_bug.cgi?id=1196181>, which is a bug
initially filed against Fedora GDB (but now under Fedora GLIBC).  This
bug happens on armhfp (although it could happen on other targets as
well), and is triggered because GCC generates a strange argument for
one of the probes used by GDB in the dynamic linker interface.  As can
be seen in the bug, this argument is "-4@.L1052".

I don't want to discuss the reasons for this argument to be there
(this discussion belongs to the bug, or to another thread), but GDB
could definitely do a better error handling here.  Currently, one sees
the following message when there is an error in the probes-based
dynamic linker interface:

  (gdb) run
  Starting program: /bin/inferior
  warning: Probes-based dynamic linker interface failed.
  Reverting to original interface.

  Cannot parse expression `.L976 4@r4'.
  (gdb)

Which means that one needs to explicitly issue a "continue" command to
make GDB continue running the inferior, even though this error is not
fatal and GDB will fallback to the old interface automatically.

This is where this patch helps: it makes GDB still print the necessary
warnings or error messages, but it *also* does not stop the inferior
unnecessarily.

I have tested this patch on the systems where this error happens, but
I could not come up with a way to create a testcase for it.
Nevertheless, it should be straightforward to see that this patch does
improve the current situation.

gdb/ChangeLog:
2015-09-01  Sergio Durigan Junior  <sergiodj@redhat.com>

* solib-svr4.c (solib_event_probe_action): Call
get_probe_argument_count using TRY...CATCH.
(svr4_handle_solib_event): Likewise, for evaluate_probe_argument.

8 years agoImprove error reporting when handling SystemTap SDT probes
Sergio Durigan Junior [Fri, 21 Aug 2015 22:13:46 +0000 (18:13 -0400)] 
Improve error reporting when handling SystemTap SDT probes

This patch improves the error reporting when handling SystemTap SDT
probes.  "Handling", in this case, mostly means "parsing".

On gdb/probe.h, only trivial changes on functions' comments in order
to explicitly mention that some of them can throw exceptions.  This is
just to make the API a bit more clear.

On gdb/stap-probe.c, I have s/internal_error/error/ on two functions
that are responsible for parsing specific bits of the probes'
arguments: stap_get_opcode and stap_get_expected_argument_type.  It is
not correct to call internal_error on such situations because it is
not really GDB's fault if the probes have malformed arguments.  I also
improved the error reported on stap_get_expected_argument_type by also
including the probe name on it.

Aside from that, and perhaps most importantly, I added a check on
stap_get_arg to make sure that we don't try to extract an argument
from a probe that has no arguments.  This check issues an
internal_error, because it really means that GDB is doing something it
shouldn't.

Although it can be considered almost trivial, and despite the fact
that I am the maintainer for this part of the code, I am posting this
patch for review.  I will wait a few days, and if nobody has anything
to say, I will go ahead and push it.

gdb/ChangeLog:
2015-09-01  Sergio Durigan Junior  <sergiodj@redhat.com>

* probe.h (struct probe_ops) <get_probe_argument_count,
evaluate_probe_argument, enable_probe, disable_probe>: Mention in
the comment that the function can throw an exception.
(get_probe_argument_count): Likewise.
(evaluate_probe_argument): Likewise.
* stap-probe.c (stap_get_opcode): Call error instead of
internal_error.
(stap_get_expected_argument_type): Likewise.  Add argument
'probe'.  Improve error message by mentioning the probe's name.
(stap_parse_probe_arguments): Adjust call to
stap_get_expected_argument_type.
(stap_get_arg): Add comment.  Assert that 'probe->args_parsed' is
not zero.  Call internal_error if GDB requests an argument but the
probe has no arguments.

8 years agoAutomatic date update in version.in
GDB Administrator [Wed, 2 Sep 2015 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years ago[Ada] Fix completion for multiple function matches
Pierre-Marie de Rodat [Mon, 31 Aug 2015 14:04:07 +0000 (16:04 +0200)] 
[Ada] Fix completion for multiple function matches

Before this change, trying to complete an expression ending with an
ambiguous function name (i.e. for which there are multiple matches)
would display a menu with a prompt for the user to pick one. For
instance:

    (gdb) p func<tab>Multiple matches for func
    [0] cancel
    [1] pack2.func at pack2.adb:5
    [2] pack.func at pack.adb:5
    >

This is not user friendly and actually triggered a segmentation fault
after the user did pick one. It is not clear whether the segmentation
fault needs a separate fix, but this is the only known case which
exhibits it at the moment, and this case must be fixed itself.

The problem lies in ada-lang.c (ada_resolve_function): when we got
multiple matches, we should not display the menu if we are in completion
mode. This patch adjusts the corresponding condition accordingly.

gdb/ChangeLog:

* ada-lang.c (ada_resolve_function): Do not ask the user what
match to use when in completion mode.

gdb/testsuite/ChangeLog:

* gdb.ada/complete.exp: Add "pck.ambiguous_func" to the relevant
expected outputs.  Add two testcases for completing ambiguous
functions.
* gdb.ada/complete/aux_pck.adb: New file.
* gdb.ada/complete/aux_pck.ads: New file.
* gdb.ada/complete/foo.adb: Pull Aux_Pck and call the two
Ambiguous_Func functions.
* gdb.ada/complete/pck.ads: Add an Ambiguous_Func function.
* gdb.ada/complete/pck.adb: Likewise.

Tested on x86_64-linux, no regression.

8 years agoSkip PLT for function pointer initialization
H.J. Lu [Tue, 1 Sep 2015 12:06:16 +0000 (05:06 -0700)] 
Skip PLT for function pointer initialization

We use its PLT entry to initialize function pointer at run-time.  If
there is no other usage for the PLT entry, we can generate run-time
function pointer relocations in read-write section, which can be
resolved by dynamic linker, to initialize function pointers.  It avoids
the extra indirect branch overhead in PLT.

bfd/

PR ld/18900
* elf32-i386.c (elf_i386_link_hash_entry): Add
func_pointer_refcount.
(elf_i386_link_hash_newfunc): Clear func_pointer_refcount.
(elf_i386_get_local_sym_hash): Likewise.
(elf_i386_copy_indirect_symbol): Also copy
func_pointer_refcount.
(elf_i386_check_relocs): Increment func_pointer_refcount.
(elf_i386_gc_sweep_hook): Decrement func_pointer_refcount.
(elf_i386_allocate_dynrelocs): Don't create the PLT entry if
there are only function pointer relocations which can be
resolved at run-time.  Keep dynanamic relocations for run-time
function pointer initialization.
(elf_i386_relocate_section): Copy dynamic function pointer
relocations.
* elf64-x86-64.c (elf_x86_64_link_hash_entry): Add
func_pointer_refcount.
(elf_x86_64_link_hash_newfunc): Clear func_pointer_refcount.
(elf_x86_64_get_local_sym_hash): Likewise.
(elf_x86_64_copy_indirect_symbol): Also copy
func_pointer_refcount.
(elf_x86_64_check_relocs): Increment func_pointer_refcount.
(elf_x86_64_gc_sweep_hook): Decrement func_pointer_refcount.
(elf_x86_64_allocate_dynrelocs): Don't create the PLT entry if
there are only function pointer relocations which can be
resolved at run-time.  Keep dynanamic relocations for run-time
function pointer initialization.
(elf_x86_64_relocate_section): Copy dynamic function pointer
relocations.

ld/testsuite/

PR ld/18900
* ld-i386/i386.exp: Run tests for PR ld/18900.
* ld-x86-64/x86-64.exp: Likewise.
* ld-i386/pr18900.out: New file.
* ld-i386/pr18900a.c: Likewise.
* ld-i386/pr18900a.c: Likewise.
* ld-i386/pr18900a.rd: Likewise.
* ld-i386/pr18900b.c: Likewise.
* ld-i386/pr18900b.rd: Likewise.
* ld-i386/pr18900c.c: Likewise.
* ld-x86-64/pr18900.out: Likewise.
* ld-x86-64/pr18900a.c: Likewise.
* ld-x86-64/pr18900a.rd: Likewise.
* ld-x86-64/pr18900b.c: Likewise.
* ld-x86-64/pr18900b.rd: Likewise.
* ld-x86-64/pr18900c.c: Likewise.
* ld-x86-64/mpx3.dd: Updated.

This page took 0.069648 seconds and 4 git commands to generate.