GDB Administrator [Mon, 22 Jan 2018 00:00:29 +0000 (00:00 +0000)]
Automatic date update in version.in
Andrew Burgess [Thu, 19 Oct 2017 10:27:48 +0000 (11:27 +0100)]
gdb: Don't store a thread-id for floating varobj
When creating a varobj with -var-create a user can create either fixed
varobj, or floating varobj.
A fixed varobj will always be evaluated within the thread/frame/block in
which the varobj was created, if that thread/frame/block is no longer
available then the varobj is considered out of scope.
A floating varobj will always be evaluated within the current
thread/frame/block.
Despite never using them GDB was storing the thread/frame/block into a
floating varobj, and the thread-id would then be displayed when GDB
reported on the state of the varobj, this could confuse a user into
thinking that the thread-id was relevant.
This commit prevents GDB storing the thread/frame/block onto floating
varobj, and updates the few tests where this impacts the results.
gdb/ChangeLog:
* varobj.c (varobj_create): Don't set valid_block when creating a
floating varobj.
gdb/testsuite/ChangeLog:
* gdb.python/py-mi.exp: Don't expect a thread-id for floating
varobj.
* gdb.mi/mi-var-create-rtti.exp: Likewise.
Andrew Burgess [Thu, 19 Oct 2017 09:59:22 +0000 (10:59 +0100)]
gdb: Remove out of date comment
Comment clean up.
gdb/ChangeLog:
* varobj.c (varobj_create): Remove out of date comment.
Andrew Burgess [Wed, 18 Oct 2017 19:07:19 +0000 (20:07 +0100)]
gdb: PR mi/20395: Fix -var-update for registers in frames 1 and up
This patch fixes a problem with using the MI -var-update command
to access the values of registers in frames other than the current
frame. The patch includes a test that demonstrates the problem:
* run so there are several frames on the stack
* create a fixed varobj for $pc in each frame, #'s 1 and above
* step one instruction, to modify the value of $pc
* call -var-update for each of the previously created varobjs
to verify that they are not reported as having changed.
Without the patch, the -var-update command reported that $pc for all
frames 1 and above had changed to the value of $pc in frame 0.
A varobj is created as either fixed, the expression is evaluated within
the context of a specific frame, or floating, the expression is
evaluated within the current frame, whatever that may be.
When a varobj is created by -var-create we set two fields of the varobj
to track the context in which the varobj was created, these two fields
are varobj->root->frame and var->root->valid_block.
If a varobj is of type fixed, then, when we subsequently try to
reevaluate the expression associated with the varobj we must determine
if the original frame (and block) is still available, if it is not then
the varobj can no longer be evaluated.
The problem is that for register expressions varobj->root->valid_block
is not set correctly. This block tracking is done using the global
'innermost_block' which is set in the various parser files (for example
c-exp.y). However, this is not set for register expressions.
The fix then seems like it should be to just update the innermost block
when parsing register expressions, however, that solution causes several
test regressions.
The problem is that in some cases we rely on the expression parsing
code not updating the innermost block for registers, one example is
when we parse the expression for a 'display' command. The display
commands treats registers like floating varobjs, but symbols are
treated like fixed varobjs. So 'display $reg_name' will always show
the value of '$reg_name' even as the user moves from frame to frame,
while 'display my_variable' will only show 'my_variable' while it is
in the current frame and/or block, when the user moves to a new frame
and/or block (even one with a different 'my_variable' in) then the
display of 'my_variable' stops. For the case of 'display', without
the option to force fixed or floating expressions, the current
behaviour is probably the best choice. For the varobj system though,
we can choose between floating and fixed, and we should try to make
this work for registers.
There's only one existing test case that needs to be updated, in that
test a fixed varobj is created using a register, the MI output now
include the thread-id in which the varobj should be evaluated, which I
believe is correct behaviour. I also added a new floating test case
into the same test script, however, right now this also includes the
thread-id in the expected output, which I believe is an existing gdb
bug, which I plan to fix next.
Tested on x86_64 Linux native and native-gdbserver, no regressions.
gdb/ChangeLog:
PR mi/20395
* ada-exp.y (write_var_from_sym): Pass extra parameter when
updating innermost block.
* parse.c (innermost_block_tracker::update): Take extra type
parameter, and check types match before updating innermost block.
(write_dollar_variable): Update innermost block for registers.
* parser-defs.h (enum innermost_block_tracker_type): New enum.
(innermost_block_tracker::innermost_block_tracker): Initialise
m_types member.
(innermost_block_tracker::reset): Take type parameter.
(innermost_block_tracker::update): Take type parameter, and pass
type through as needed.
(innermost_block_tracker::m_types): New member.
* varobj.c (varobj_create): Pass type when reseting innermost
block.
gdb/testsuite/ChangeLog:
* gdb.mi/basics.c: Add new global.
* gdb.mi/mi-frame-regs.exp: New file.
* gdb.mi/mi-var-create-rtti.exp: Update expected results, add new
case.
Andrew Burgess [Wed, 18 Oct 2017 18:53:21 +0000 (19:53 +0100)]
gdb: New API for tracking innermost block
This commit is preparation for a later change, at this point there
should be no user visible change.
We currently maintain a global innermost_block which tracks the most
inner block encountered when parsing an expression.
This commit wraps the innermost_block into a new class, and switches all
direct accesses to the variable to use the class API.
gdb/ChangeLog:
* ada-exp.y (write_var_from_sym): Switch to innermost_block API.
* ada-lang.c (resolve_subexp): Likewise.
* breakpoint.c (set_breakpoint_condition) Likewise.
(watch_command_1) Likewise.
* c-exp.y (variable): Likewise.
* d-exp.y (PrimaryExpression): Likewise.
* f-exp.y (variable): Likewise.
* go-exp.y (variable): Likewise.
* m2-exp.y (variable): Likewise.
* objfiles.c (objfile::~objfile): Likewise.
* p-exp.y (variable): Likewise.
* parse.c (innermost_block): Change type.
* parser-defs.h (class innermost_block_tracker): New.
(innermost_block): Change to innermost_block_tracker.
* printcmd.c (display_command): Switch to innermost_block API.
(do_one_display): Likewise.
* rust-exp.y (do_one_display): Likewise.
* symfile.c (clear_symtab_users): Likewise.
* varobj.c (varobj_create): Switch to innermost_block API, replace
use of innermost_block with block stored on varobj object.
Andrew Burgess [Wed, 18 Oct 2017 18:04:17 +0000 (19:04 +0100)]
gdb: Remove duplicate declaration of global innermost_block
The global 'innermost_block' is declared in two header files. Remove
one of the declarations, and add an include of the other header into
the one source file that could no longer see a declaration of
'innermost_block'.
gdb/ChangeLog:
* expression.h (innermost_block): Remove declaration.
* varobj.c: Add 'parser-defs.h' include.
Andrew Burgess [Sat, 20 Jan 2018 23:56:37 +0000 (23:56 +0000)]
gdb: Add test for some error cases of @entry usage
Adds a test that using @entry for a non-parameter, or for an unknown
symbol, both give the expected error. This error message was
previously untested.
gdb/testsuite/ChangeLog:
* gdb.arch/amd64-entry-value.exp: Test using @entry on a
non-parameter, and on an unknown symbol.
GDB Administrator [Sun, 21 Jan 2018 00:00:35 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Sat, 20 Jan 2018 22:25:24 +0000 (14:25 -0800)]
x86: Check the versioned __tls_get_addr symbol
We need to check the versioned __tls_get_addr symbol when looking up
"__tls_get_addr".
bfd/
PR ld/22721
* elfxx-x86.c (_bfd_x86_elf_link_check_relocs): Check the
versioned __tls_get_addr symbol.
ld/
PR ld/22721
* testsuite/ld-plugin/lto.exp: Run PR ld/22721 tests.
* testsuite/ld-plugin/pr22721.t: New file.
* testsuite/ld-plugin/pr22721a.s: Likewise.
* testsuite/ld-plugin/pr22721b.c: Likewise.
GDB Administrator [Sat, 20 Jan 2018 00:00:22 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Fri, 19 Jan 2018 22:25:19 +0000 (15:25 -0700)]
Fix qualified name lookup for Rust
In https://github.com/rust-lang/rust/pull/46457, "m4b" pointed out
that the Rust support in gdb doesn't properly handle the lookup of
qualified names.
In particular, as shown in the test case in this patch, something like
"::NAME" should be found in the global scope, but is not.
This turns out to happen because rust_lookup_symbol_nonlocal does not
search the global scope unless the name in question is unqualified.
However, lookup_symbol_aux does not search the global scope, and
appears to search the static scope only as a fallback (I wonder if
this is needed?).
This patch fixes the problem by changing rust_lookup_symbol_nonlocal
to search the static and global blocks in more cases.
Regression tested against various versions of the rust compiler on
Fedora 26 x86-64. (Note that there are unrelated failures with newer
versions of rustc; I will be addressing those separately.)
2018-01-19 Tom Tromey <tom@tromey.com>
* rust-lang.c (rust_lookup_symbol_nonlocal): Look up qualified
symbols in the static and global blocks.
2018-01-19 Tom Tromey <tom@tromey.com>
* gdb.rust/modules.rs (TWENTY_THREE): New global.
* gdb.rust/modules.exp: Add ::-qualified lookup test.
Andreas Arnez [Fri, 19 Jan 2018 18:59:53 +0000 (19:59 +0100)]
S390: Fix infcalls in s390-vregs test case
GDB used to assume that functions without debug info return int. It
accepted an expression containing such a function call and silently
interpreted the function's return value as int. But nowadays GDB yields
an error message instead, see
https://sourceware.org/ml/gdb-patches/2017-07/msg00139.html
This affects the s390-vregs test case, because it contains calls to
setrlimit64 and chdir. When no glibc debug info is installed, these lead
to unnecessary FAILs. Fix this by adding appropriate casts to the
inferior function calls.
gdb/testsuite/ChangeLog:
* gdb.arch/s390-vregs.exp: Explicitly cast the return values of
setrlimit and chdir to int.
James Clarke [Fri, 19 Jan 2018 17:22:50 +0000 (17:22 +0000)]
gdb: Add missing #ifdef USE_THREAD_DB to gdbserver
Otherwise, linking fails with:
[...]/linux-low.c:664: undefined reference to `thread_db_notice_clone(thread_info*, ptid_t)'
gdb/gdbserver/ChangeLog:
* linux-low.c (handle_extended_wait): Surround call to
thread_db_notice_clone with #ifdef USE_THREAD_DB.
James Clarke [Fri, 19 Jan 2018 17:22:49 +0000 (17:22 +0000)]
gdb: Fix ia64 defining TRAP_HWBKPT before including gdb_wait.h
On ia64, gdb_wait.h eventually includes siginfo-consts-arch.h, which
contains an enum with TRAP_HWBKPT, along with a #define. Thus we cannot
define TRAP_HWBKPT to 4 beforehand, and so gdb_wait.h must be included
earlier; include it from linux-ptrace.h so it can never come afterwards.
gdb/ChangeLog:
* nat/linux-ptrace.c: Remove unnecessary reinclusion of
gdb_ptrace.h, and move including gdb_wait.h ...
* nat/linux-ptrace.h: ... to here.
Simon Marchi [Fri, 19 Jan 2018 16:48:11 +0000 (11:48 -0500)]
Make linux_nat_detach/thread_db_detach use the inferior parameter
This patch makes these two functions actually use the inferior parameter
added by the previous patch, instead of reading inferior_ptid. I chose
these two, because they are the one actually used when I detach on my
GNU/Linux system, so they were easy to test.
I took the opportunity to pass the inferior being detached to
inf_ptrace_detach_success, so it could use it too. From there, it made
sense to add an overload of detach_inferior that takes the inferior
directly rather than the pid, to avoid having to pass inf->pid only for
the callee to look up the inferior structure by pid.
gdb/ChangeLog:
* inf-ptrace.c (inf_ptrace_detach): Adjust call to
inf_ptrace_detach_success.
(inf_ptrace_detach_success): Add inferior parameter, use it
instead of inferior_ptid, pass it to detach_inferior.
* inf-ptrace.h (inf_ptrace_detach_success): Add inferior
parameter.
* inferior.c (detach_inferior): Add overload that takes an
inferior object.
* inferior.h (detach_inferior): Likewise.
* linux-nat.c (linux_nat_detach): Use the inf parameter, don't
use inferior_ptid, adjust call to inf_ptrace_detach_success.
* linux-thread-db.c (thread_db_detach): Use inf parameter.
Simon Marchi [Fri, 19 Jan 2018 16:47:57 +0000 (11:47 -0500)]
Pass inferior down to target_detach and to_detach
The to_detach target_ops method implementations are currently expected
to work on current_inferior/inferior_ptid. In order to make things more
explicit, and remove some "shadow" parameter passing through globals,
this patch adds an "inferior" parameter to to_detach. Implementations
will be expected to use this instead of relying on the global. However,
to keep things simple, this patch only does the minimum that is
necessary to add the parameter. The following patch gives an example of
how one such implementation would be adapted. If the approach is deemed
good, we can then look into adapting more implementations. Until then,
they'll continue to work as they do currently.
gdb/ChangeLog:
* target.h (struct target_ops) <to_detach>: Add inferior
parameter.
(target_detach): Likewise.
* target.c (dispose_inferior): Pass inferior down.
(target_detach): Pass inferior down. Assert that it is equal to
the current inferior.
* aix-thread.c (aix_thread_detach): Pass inferior down.
* corefile.c (core_file_command): Pass current_inferior() down.
* corelow.c (core_detach): Add inferior parameter.
* darwin-nat.c (darwin_detach): Likewise.
* gnu-nat.c (gnu_detach): Likewise.
* inf-ptrace.c (inf_ptrace_detach): Likewise.
* infcmd.c (detach_command): Pass current_inferior() down to
target_detach.
* infrun.c (follow_fork_inferior): Pass parent_inf to
target_detach.
(handle_vfork_child_exec_or_exit): Pass inf->vfork_parent to
target_detach.
* linux-nat.c (linux_nat_detach): Add inferior parameter.
* linux-thread-db.c (thread_db_detach): Likewise.
* nto-procfs.c (procfs_detach): Likewise.
* procfs.c (procfs_detach): Likewise.
* record.c (record_detach): Likewise.
* record.h (struct inferior): Forward-declare.
(record_detach): Add inferior parameter.
* remote-sim.c (gdbsim_detach): Likewise.
* remote.c (remote_detach_1): Likewise.
(remote_detach): Likewise.
(extended_remote_detach): Likewise.
* sol-thread.c (sol_thread_detach): Likewise.
* target-debug.h (target_debug_print_inferior_p): New macro.
* target-delegates.c: Re-generate.
* top.c (kill_or_detach): Pass inferior down to target_detach.
* windows-nat.c (windows_detach): Add inferior parameter.
Simon Marchi [Fri, 19 Jan 2018 16:47:24 +0000 (11:47 -0500)]
Remove args from target detach
I was looking into adding a parameter to target_detach, and was
wondering what the args parameter was. It seems like in the distant
past, it was possible to specify a signal number when detaching. That
signal was injected in the process before it was detached. There is an
example of code handling this in linux_nat_detach. With today's GDB, I
can't get this to work. Doing "detach 15" (15 == SIGTERM) doesn't work,
because detach is a prefix command and doesn't recognize the sub-command
15. Doing "detach inferiors 15" doesn't work because it expects a list
of inferior id to detach. Therefore, I don't think there's a way of
invoking detach_command with a non-NULL args. I also didn't find any
documentation related to this feature.
I assume that this feature stopped working when detach was made a prefix
command, which is in
f73adfeb8bae36885e6ea248d12223ab0d5eb9cb (sorry,
there's no commit title) from 2006. Given that this feature was broken
for such a long time and we haven't heard anything (AFAIK, I did not
find any related bug), I think it's safe to remove it, as well as the
args parameter to target_detach. If someone wants to re-introduce it, I
would suggest rethinking the user interface, and in particular would
suggest using signal name instead of numbers.
I tried to fix all the impacted code, but I might have forgotten some
spots. It shouldn't be hard to fix if that's the case. I also couldn't
build-test everything I changed, especially the nto and solaris stuff.
gdb/ChangeLog:
* target.h (struct target_ops) <to_detach>: Remove args
parameter.
(target_detach): Likewise.
* target.c (dispose_inferior): Adjust.
(target_detach): Remove args parameter, adjust.
* aix-thread.c (aix_thread_detach): Adjust.
* corefile.c (core_file_command): Adjust.
* corelow.c (core_detach): Adjust.
* darwin-nat.c (darwin_detach): Adjust.
* gnu-nat.c (gnu_detach): Adjust.
* inf-ptrace.c (inf_ptrace_detach): Adjust.
* infcmd.c (detach_command): Adjust
* infrun.c (follow_fork_inferior): Adjust.
(handle_vfork_child_exec_or_exit): Adjust.
* linux-fork.c (linux_fork_detach): Remove args parameter.
* linux-fork.h (linux_fork_detach): Likewise.
* linux-nat.c (linux_nat_detach): Likewise, and adjust.
* linux-thread-db.c (thread_db_detach): Likewise.
* nto-procfs.c (procfs_detach): Likewise.
* procfs.c (procfs_detach): Likewise.
(do_detach): Remove signo parameter.
* record.c (record_detach): Remove args parameter.
* record.h (record_detach): Likewise.
* remote-sim.c (gdbsim_detach): Likewise.
* remote.c (remote_detach_1): Likewise.
(remote_detach): Likewise.
(extended_remote_detach): Likewise.
* sol-thread.c (sol_thread_detach): Likewise.
* target-delegates.c: Re-generate.
* top.c (struct qt_args) <args>: Remove field.
(kill_or_detach): Don't pass args.
(quit_force): Don't set args.
* windows-nat.c (windows_detach): Remove args parameter.
Thomas Preud'homme [Fri, 19 Jan 2018 14:17:24 +0000 (14:17 +0000)]
[gas/ARM] Remove spurious comments
Remove spurious comments after the definition of ToC and ToU.
2018-01-19 Thomas Preud'homme <thomas.preudhomme@arm.com>
gas/
* config/tc-arm.c (ToC macro): Remove spurious comment.
(ToU macro): Likewise.
Andreas Arnez [Fri, 19 Jan 2018 13:14:07 +0000 (14:14 +0100)]
S390: Improve comments for s390-tdbregs test case
This adds more explanation as to why the test case must be compiled with
the -msoft-float option. It also documents the my_tbegin and my_tend
functions.
gdb/testsuite/ChangeLog:
* gdb.arch/s390-tdbregs.c (my_tbegin): Add comment documenting the
function.
(my_tend): Likewise.
* gdb.arch/s390-tdbregs.exp: Enhance comment; explain the
rationale of avoiding FP- and vector instructions.
Nick Clifton [Fri, 19 Jan 2018 10:50:06 +0000 (10:50 +0000)]
Update French translation in bfd sub-directory
Yao Qi [Fri, 19 Jan 2018 09:16:45 +0000 (09:16 +0000)]
Don't pass -m32 to libcc1 on arm-linux
When I run gdb.compile/ tests on arm-linux, I get the following fails,
(gdb) compile code -- ;^M
arm-none-linux-gnueabihf-gcc: error: unrecognized command line option '-m32'; did you mean '-mbe32'?^M
Compilation failed.^M
(gdb) compile code (void) param^M
arm-none-linux-gnueabihf-gcc: error: unrecognized command line option '-m32'; did you mean '-mbe32'?^M
Compilation failed.^M
(gdb) FAIL: gdb.compile/compile-ops.exp: compile code (void) param
This patch fixes it by implementing gcc_target_options gdbarch method
for arm-linux to override option "-m32".
gdb:
2018-01-19 Yao Qi <yao.qi@linaro.org>
* arm-linux-tdep.c (arm_linux_gcc_target_options): New function.
(arm_linux_init_abi): Install it.
Yao Qi [Fri, 19 Jan 2018 09:08:36 +0000 (09:08 +0000)]
Find arm-linux-gnueabi(hf)?-gcc in compile
GCC for arm-linux has different names on different distros. It is
arm-linux-gnu-gcc on fedora. Debian/Ubuntu has arm-linux-gnueabihf-gcc
and arm-linux-gnueabi-gcc. So when I run gdb.compile/ tests on arm-linux,
I get,
(gdb) compile code -- ;
Could not find a compiler matching "^arm(-[^-]*)?-linux(-gnu)?-gcc$"
This patch extend the regexp to match both arm-linux-gnu-gcc and
arm-linux-gnueabihf-gcc.
gdb:
2018-01-19 Yao Qi <yao.qi@linaro.org>
* osabi.c (gdb_osabi_names): Extend the regexp for
arm-linux-gnueabihf and arm-linux-gnueabi.
Ruslan Kabatsayev [Sun, 7 Jan 2018 21:59:13 +0000 (00:59 +0300)]
Make tests expect [ \t]+ pattern instead of \t for "info reg" command
This will allow to format output of "info reg" command as we wish,
without breaking the tests. In particular, it'll let us correctly align
raw and natural values of the registers using spaces instead of current
badly-working approach with tabs.
This change is forwards- and backwards-compatible, so that the amended
tests will work in the same way before and after reformatting patches
(unless the tests check formatting, of course, but I've not come across
any such tests).
Some tests already used this expected pattern, so they didn't
even have to be modified. Others are changed by this patch.
I've checked this on a i386 system, with no noticeable differences in
test results, so at least on i386 nothing seems to be broken by this.
gdb/testsuite/ChangeLog:
* gdb.arch/powerpc-d128-regs.exp: Replace expected "\[\t\]*" from
"info reg" with "\[ \t\]*".
* gdb.arch/altivec-regs.exp: Replace expected "\t" from "info reg" with
"\[ \t\]+".
* gdb.arch/s390-multiarch.exp: Ditto.
* gdb.base/pc-fp.exp: Ditto.
* gdb.reverse/i386-precsave.exp: Ditto.
* gdb.reverse/i386-reverse.exp: Ditto.
* gdb.reverse/i387-env-reverse.exp: Ditto.
* gdb.reverse/i387-stack-reverse.exp: Ditto.
H.J. Lu [Fri, 19 Jan 2018 01:21:13 +0000 (17:21 -0800)]
Also xfail ld-elf/group1.d for Solaris
Also xfail ld-elf/group1.d for Solaris since _GLOBAL_OFFSET_TABLE_ is
always generated for Solaris as a global symbol after
.*: 0+1000 +0 +(NOTYPE|OBJECT) +WEAK +DEFAULT +. foo
instead of appending "#..." which will weaken the test.
* testsuite/ld-elf/group1.d: Also xfail Solaris.
H.J. Lu [Fri, 19 Jan 2018 00:23:33 +0000 (16:23 -0800)]
x86: Update ld-elf/linkinfo1[ab].d for Solaris/x86
Update ld-elf/linkinfo1[ab].d to accommodate slightly different PLT/GOT
order/layout for Solaris/x86 targets.
* testsuite/ld-elf/linkinfo1a.d: Updated for slightly different
PLT/GOT order/layout for Solaris/x86 targets.
* testsuite/ld-elf/linkinfo1b.d: Likewise.
H.J. Lu [Fri, 19 Jan 2018 00:21:46 +0000 (16:21 -0800)]
solaris2.em: Fold after_allocation into before_allocation
Since all ELF linkers call check_relocs after opening all inputs, we
can fold after_allocation into before_allocation so that local dynamic
symbols will be placed before global dynamic symbols in .dynsym section.
This fixed:
FAIL: Common symbol override test (auxiliary shared object build)
FAIL: ld-elf/pr19617a
FAIL: ld-elf/pr19698
for i386-solaris2.12 and x86_64-solaris2.12 targets.
PR ld/22728
* emultempl/solaris2.em (elf_solaris2_after_allocation): Fold
into ...
(elf_solaris2_before_allocation): This.
(LDEMUL_AFTER_ALLOCATION): Removed.
GDB Administrator [Fri, 19 Jan 2018 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in
Andreas Arnez [Thu, 18 Jan 2018 18:42:46 +0000 (19:42 +0100)]
GDB testsuite: Re-enable -fdiagnostics-color=never
In August 2017 the GDB test suite was changed to always add the compile
option "-fdiagnostics-color=never", see:
https://sourceware.org/ml/gdb-patches/2017-08/msg00150.html
Since this option is not understood by rustc, a commit from 09/2017
dropped its use in that case:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=
5eb5f850
("Don't use -fdiagnostics-color=never for rustc")
But that change goes overboard and stops using the option for other
languages as well. Thus compiler diagnostics written into gdb.log may
contain colored output again. This is fixed.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (gdb_compile): Re-enable use of
universal_compile_options for languages other than Rust.
Andreas Arnez [Thu, 18 Jan 2018 18:41:16 +0000 (19:41 +0100)]
S390: Use soft float in s390-tdbregs test case
The GDB test case s390-tdbregs.exp verifies GDB's handling of the
"transaction diagnostic block". For simplicity, the test case uses the
"transaction begin" (TBEGIN) instruction with the "allow floating-point
operation" flag set to zero. But some GCC versions may indeed emit
floating point or vector instructions for this test case. If this happens
in the transaction, it aborts, and an endless loop results.
This change tells the compiler to produce a soft-float binary, so no
floating-point or vector registers are touched.
gdb/testsuite/ChangeLog:
* gdb.arch/s390-tdbregs.exp: Add the compile option -msoft-float.
Yao Qi [Thu, 18 Jan 2018 15:29:31 +0000 (15:29 +0000)]
Make abbrev_table::abbrevs private
abbrev_table::abbrevs is only access within abbrev_table's methods, so
it can be private. Add "m_" prefix.
gdb:
2018-01-18 Yao Qi <yao.qi@linaro.org>
* dwarf2read.c (abbrev_table) <abbrevs>: Rename it to
m_abbrevs.
(abbrev_table::add_abbrev): Update.
(abbrev_table::lookup_abbrev): Update.
Yao Qi [Thu, 18 Jan 2018 12:21:01 +0000 (12:21 +0000)]
Call cooked_read in ppu2spu_prev_register
The code in ppu2spu_prev_register is in fact regcache_cooked_read,
because spu doesn't have gdbarch method pseudo_register_read_value.
gdb:
2018-01-18 Yao Qi <yao.qi@linaro.org>
* ppc-linux-tdep.c (ppu2spu_prev_register): Call cooked_read.
Alan Modra [Thu, 18 Jan 2018 11:36:40 +0000 (22:06 +1030)]
PowerPC PLT stub alignment fixes
Asking for ppc32 plt call stubs to be aligned at 32 byte boundaries
didn't quite work. For ld.bfd they were spaced 32 bytes apart, but
only started on a 16 byte boundary. ld.gold also didn't get it right.
Finding that bug made me check over the ppc64 plt stub alignment,
where I found that negative values for alignment (meaning align to
minimize boundary crossing) were not accepted. Since no one has
complained about that, I guess I could have removed the feature from
ld.bfd documentation, but I've opted instead to correct the code.
I've also added an optional alignment paramenter for ppc32
--plt-align, for some consistency with gold and ppc64 ld.bfd.
bfd/
* elf32-ppc.c (ppc_elf_create_glink): Correct alignment of .glink.
* elf64-ppc.c (ppc64_elf_size_stubs): Handle negative plt_stub_align.
(ppc64_elf_build_stubs): Likewise.
gold/
* powerpc.cc (param_plt_align): New function supplying default
--plt-align values. Use it..
(Stub_table::plt_call_align): ..here, and..
(Output_data_glink::global_entry_align): ..here.
(Stub_table::stub_align): Correct 32-bit minimum alignment.
ld/
* emultempl/ppc32elf.em: Support optional --plt-align arg.
* emultempl/ppc64elf.em: Support negative --plt-align arg.
Nick Clifton [Thu, 18 Jan 2018 09:38:59 +0000 (09:38 +0000)]
Update Bulgarian translation of the binutils sub-directory
GDB Administrator [Thu, 18 Jan 2018 00:00:24 +0000 (00:00 +0000)]
Automatic date update in version.in
Sergio Durigan Junior [Tue, 16 Jan 2018 19:41:17 +0000 (14:41 -0500)]
Fix warning on gdb/compile/compile.c (C++-ify "triplet_rx")
This fixes a GCC warning that happens when compiling
gdb/compile/compile.c on some GCC versions (e.g., "gcc (GCC) 7.2.1
20180104 (Red Hat 7.2.1-6)"):
../../gdb/compile/compile.c: In function 'void eval_compile_command(command_line*, const char*, compile_i_scope_types, void*)':
../../gdb/compile/compile.c:548:19: warning: 'triplet_rx' may be used uninitialized in this function [-Wmaybe-uninitialized]
error_message = compiler->fe->ops->set_arguments_v0 (compiler->fe, triplet_rx,
~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
argc, argv);
~~~~~~~~~~~
../../gdb/compile/compile.c:466:9: note: 'triplet_rx' was declared here
char *triplet_rx;
^~~~~~~~~~
It's a simple patch that converts "triplet_rx" from "char *" to
"std::string", thus guaranteeing that it will be always initialized.
I've regtested this patch and did not find any regressions. OK to
apply on both master and 8.1 (after creating a bug for it)?
gdb/ChangeLog:
2018-01-17 Sergio Durigan Junior <sergiodj@redhat.com>
* compile/compile.c (compile_to_object): Convert "triplet_rx"
to "std::string".
Jim Wilson [Wed, 17 Jan 2018 22:04:16 +0000 (14:04 -0800)]
RISC-V: Fix bug in prior addi/c.nop patch.
gas/
* config/tc-riscv.c (validate_riscv_insn) <'z'>: New.
(riscv_ip) <'z'>: New.
opcodes/
* riscv-opc.c (riscv_opcodes) <addi>: Use z instead of 0.
Tom Tromey [Sat, 6 Jan 2018 00:26:21 +0000 (17:26 -0700)]
Remove symbolp typedef
This removes the symbolp typedef from dwarf2read.c. It is no longer
used.
2018-01-17 Tom Tromey <tom@tromey.com>
* dwarf2read.c (symbolp): Remove typedef. Don't instantiate VEC.
Tom Tromey [Sat, 6 Jan 2018 00:26:20 +0000 (17:26 -0700)]
Remove objfile argument from add_dyn_prop
The objfile argument to add_dyn_prop is redundant, so this patch
removes it.
2018-01-17 Tom Tromey <tom@tromey.com>
* gdbtypes.h (add_dyn_prop): Remove objfile parameter.
* gdbtypes.c (add_dyn_prop): Remove objfile parameter.
(create_array_type_with_stride): Update.
* dwarf2read.c (set_die_type): Update.
Tom Tromey [Sat, 6 Jan 2018 00:26:19 +0000 (17:26 -0700)]
Change dwarf2_cu::method_info to be a std::vector
This changes the type of dwarf2_cu::method_info and fixes up the uses.
In order to remove cleanups from process_full_comp_unit and
process_full_type_unit, psymtab_include_file_name also had to be
changed to avoid leaving dangling cleanups.
2018-01-17 Tom Tromey <tom@tromey.com>
* dwarf2read.c (delayed_method_info): Remove typedef.
(dwarf2_cu::method_info): Now a std::vector.
(add_to_method_list): Update.
(free_delayed_list): Remove.
(compute_delayed_physnames): Update.
(process_full_comp_unit, process_full_type_unit): Clear the method
list. Remove cleanups.
(psymtab_include_file_name): Add name_holder parameter. Use
unique_xmalloc_ptr.
(dwarf_decode_lines): Update.
Simon Marchi [Sun, 7 Jan 2018 16:41:09 +0000 (11:41 -0500)]
Allocate dwarf2_cu with new
This changes dwarf2_cu to be allocated with new, and fixes up the
users.
2018-01-17 Tom Tromey <tom@tromey.com>
Simon Marchi <simon.marchi@ericsson.com>
* dwarf2read.c (struct dwarf2_cu): Add constructor, destructor.
(dwarf2_per_objfile::free_cached_comp_units)
(init_tu_and_read_dwo_dies, init_cutu_and_read_dies)
(init_cutu_and_read_dies_no_follow): Update.
(dwarf2_cu::dwarf2_cu): Rename from init_one_comp_unit.
(dwarf2_cu::~dwarf2_cu): New.
(free_heap_comp_unit, free_stack_comp_unit): Remove.
(age_cached_comp_units, free_one_cached_comp_unit): Update.
Tom Tromey [Sat, 6 Jan 2018 00:26:17 +0000 (17:26 -0700)]
Allocate abbrev_table with new
This changes dwarf2read.c to allocate abbrev tables using "new", and
then updates the users.
This version of the patch incorporates the changes that Simon
implemented. These changes simplify the ownership rules for abbrev
tables.
2018-01-17 Tom Tromey <tom@tromey.com>
Simon Marchi <simon.marchi@ericsson.com>
* dwarf2read.c (struct dwarf2_cu) <abbrev_table>: Remove.
(struct die_reader_specs) <abbrev_table>: New member.
(struct abbrev_table): Add constructor.
<alloc_abbrev, add_abbrev, lookup_abbrev>: Declare.
<abbrev_obstack>: Now an auto_obstack.
(abbrev_table_up): New typedef.
(init_cu_die_reader): Add abbrev_table parameter.
(read_cutu_die_from_dwo): Remove abbrev_table_provided parameter.
Add result_dwo_abbrev_table.
(init_tu_and_read_dwo_dies, init_cutu_and_read_dies)
(init_cutu_and_read_dies_no_follow, build_type_psymtabs_1):
Update.
(peek_die_abbrev): Take die_reader_specs, not dwarf_cu as
parameter.
(skip_children): Update.
(abbrev_table::alloc_abbrev): Rename from
abbrev_table_alloc_abbrev.
(abbrev_table::add_abbrev): Rename from abbrev_table_add_abbrev.
(abbrev_table::lookup_abbrev): Rename from
abbrev_table_lookup_abbrev.
(abbrev_table_read_table): Return abbrev_table_up.
(abbrev_table_free, abbrev_table_free_cleanup)
(dwarf2_read_abbrevs, dwarf2_free_abbrev_table): Remove.
(load_partial_dies): Update.
Tom Tromey [Sat, 6 Jan 2018 00:26:16 +0000 (17:26 -0700)]
Unify new_symbol and new_symbol_full
This patch unifies new_symbol with new_symbol_full, replacing a
wrapper function with a default parameter.
2018-01-17 Tom Tromey <tom@tromey.com>
* dwarf2read.c (dwarf2_compute_name): Update comment.
(read_func_scope, read_variable): Update.
(new_symbol): Remove.
(new_symbol_full): Rename to new_symbol.
Simon Marchi [Wed, 17 Jan 2018 17:59:51 +0000 (12:59 -0500)]
Fix ChangeLog dates of previous commit
Mike Gulick [Mon, 30 Oct 2017 22:13:44 +0000 (18:13 -0400)]
Fix gdb segv when objfile can't be opened
This fixes PR 16577.
This patch changes gdb_bfd_map_section to issue a warning rather than an error
if it is unable to read the object file, and sets the size of the section/frame
that it attempted to read to 0 on error.
The description of gdb_bfd_map_section states that it will try to read or map
the contents of the section SECT, and if successful, the section data is
returned and *SIZE is set to the size of the section data. This function was
throwing an error and leaving *SIZE as-is. Setting the section size to 0
indicates to dwarf2_build_frame_info that there is no data to read, otherwise
it will try to read from an invalid frame pointer.
Changing the error to a warning allows this to be handled gracefully.
Additionally, the error was clobbering the breakpoint output indicating the
current frame (function name, arguments, source file, and line number). E.g.
Thread 3 "foo" hit Breakpoint 1, BFD: reopening /tmp/jna-
1013829440/jna2973250704389291330.tmp: No such file or directory
BFD: reopening /tmp/jna-
1013829440/jna2973250704389291330.tmp: No such file or directory
(gdb)
While the "BFD: reopening ..." messages will still appear interspersed in the
breakpoint output, the current frame info is now displayed:
Thread 3 "foo" hit Breakpoint 1, BFD: reopening /tmp/jna-
1013829440/jna1875755897659885075.tmp: No such file or directory
BFD: reopening /tmp/jna-
1013829440/jna1875755897659885075.tmp: No such file or directory
warning: Can't read data for section '.eh_frame' in file '/tmp/jna-
1013829440/jna1875755897659885075.tmp'
do_something () at file.cpp:80
80 {
(gdb)
Simon Marchi [Wed, 17 Jan 2018 17:33:57 +0000 (12:33 -0500)]
Make linux_ptrace_attach_fail_reason return an std::string
This patch makes linux_ptrace_attach_fail_reason and
linux_ptrace_attach_fail_reason_string return std::string. It also
replaces usages of struct buffer with std::string. This allows getting
rid of a cleanup in in linux_ptrace_attach_fail_reason_string and
simplifies the code in general.
Something that looks odd to me is that in
linux_ptrace_attach_fail_reason, if the two messages are appended, there
is no separating space or \n, so the result won't be very nice. I left
it as-is for now though.
gdb/ChangeLog:
* nat/linux-ptrace.h (linux_ptrace_attach_fail_reason): Return
std::string.
(linux_ptrace_attach_fail_reason_string): Likewise.
* nat/linux-ptrace.c (linux_ptrace_attach_fail_reason):
Likewise.
(linux_ptrace_attach_fail_reason_string): Likewise.
* linux-nat.c (attach_proc_task_lwp_callback): Adjust.
gdb/gdbserver/ChangeLog:
* linux-low.c (attach_proc_task_lwp_callback): Adjust to
linux_ptrace_attach_fail_reason_string now returning an
std::string.
(linux_attach): Likewise.
* thread-db.c (attach_thread): Likewise.
Simon Marchi [Wed, 17 Jan 2018 17:33:45 +0000 (12:33 -0500)]
linux-nat: Remove unnecessary xstrdup
I think this xstrdup is not useful. We can pass ex.message directly to
throw_error instead.
gdb/ChangeLog:
* linux-nat.c (linux_nat_attach): Remove xstrdup.
Igor Tsimbalist [Wed, 17 Jan 2018 16:45:52 +0000 (19:45 +0300)]
Replace CET bit with IBT and SHSTK bits.
The latest specification for Intel CET technology defined two
new bits instead of previously used CET bit. These are IBT and
SHSTK bits. The patch replaces CET bit with IBT and SHSTK bits.
gas/
* config/tc-i386.c (cpu_arch): Delete .cet. Add .ibt, .shstk.
(cpu_noarch): Add noibt, noshstk.
(parse_insn): Change cpucet to cpuibt.
* doc/c-i386.texi: Delete .cet. Add .ibt, .shstk.
* testsuite/gas/i386/cet-ibt-inval.l: New test.
* testsuite/gas/i386/cet-ibt-inval.s: Likewise.
* testsuite/gas/i386/cet-shstk-inval.l: Likewise.
* testsuite/gas/i386/cet-shstk-inval.s: Likewise.
* testsuite/gas/i386/x86-64-cet-ibt-inval.l: Likewise.
* testsuite/gas/i386/x86-64-cet-ibt-inval.s: Likewise.
* testsuite/gas/i386/x86-64-cet-shstk-inval.l: Likewise.
* testsuite/gas/i386/x86-64-cet-shstk-inval.s: Likewise.
opcodes/
* i386-gen.c (cpu_flag_init): Delete CPU_CET_FLAGS,
CpuCET. Add CPU_IBT_FLAGS, CPU_SHSTK_FLAGS, CPY_ANY_IBT_FLAGS,
CPU_ANY_SHSTK_FLAGS, CpuIBT, CpuSHSTK.
(cpu_flags): Add CpuIBT, CpuSHSTK.
* i386-opc.h (enum): Add CpuIBT, CpuSHSTK.
(i386_cpu_flags): Add cpuibt, cpushstk.
* i386-opc.tbl: Change CpuCET to CpuSHSTK and CpuIBT.
* i386-init.h: Regenerate.
* i386-tbl.h: Likewise.
Nick Clifton [Wed, 17 Jan 2018 15:52:37 +0000 (15:52 +0000)]
Update Ukranian and Russian translations in bfd library
Eldar Abusalimov [Mon, 15 Jan 2018 13:57:42 +0000 (16:57 +0300)]
configure: Fix test for fs_base/gs_base in <sys/user.h>
Make <sys/types.h> be included prior to including <sys/user.h>.
glibc versions older than 2.14 use __uintNN_t types within certain
structures defined in <sys/user.h> probably assuming these types are
defined prior to including the header. This results in the following
`configure` feature test compilation error that makes it think that
`struct user_regs_struct` doesn't have `fs_base`/`gs_base` fields,
althouh it does.
configure:13617: checking for struct user_regs_struct.fs_base
configure:13617: gcc -c -g -O2 -I/linux/include conftest.c >&5
In file included from conftest.c:158:0:
/usr/include/sys/user.h:32:3: error: unknown type name '__uint16_t'
__uint16_t cwd;
^
/usr/include/sys/user.h:33:3: error: unknown type name '__uint16_t'
__uint16_t swd;
^
/usr/include/sys/user.h:34:3: error: unknown type name '__uint16_t'
__uint16_t ftw;
^
/usr/include/sys/user.h:35:3: error: unknown type name '__uint16_t'
__uint16_t fop;
^
/usr/include/sys/user.h:36:3: error: unknown type name '__uint64_t'
__uint64_t rip;
^
/usr/include/sys/user.h:37:3: error: unknown type name '__uint64_t'
__uint64_t rdp;
^
/usr/include/sys/user.h:38:3: error: unknown type name '__uint32_t'
__uint32_t mxcsr;
^
/usr/include/sys/user.h:39:3: error: unknown type name '__uint32_t'
__uint32_t mxcr_mask;
^
/usr/include/sys/user.h:40:3: error: unknown type name '__uint32_t'
__uint32_t st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
^
/usr/include/sys/user.h:41:3: error: unknown type name '__uint32_t'
__uint32_t xmm_space[64]; /* 16*16 bytes for each XMM-reg = 256 bytes */
^
/usr/include/sys/user.h:42:3: error: unknown type name '__uint32_t'
__uint32_t padding[24];
^
configure:13617: $? = 1
configure: failed program was:
| /* confdefs.h */
...
| /* end confdefs.h. */
| #include <sys/user.h>
|
| int
| main ()
| {
| static struct user_regs_struct ac_aggr;
| if (ac_aggr.fs_base)
| return 0;
| ;
| return 0;
| }
Recent glibc versions don't use typedef'ed int types in <sys/user.h>,
thus allowing it to be included as is
(glibc commit
d79a9c949c84e7f0ba33e87447c47af833e9f11a).
However there're still some distros alive that use older glibc,
for instance, RHEL/CentOS 6 package glibc 2.12.
Also affects PR gdb/21559:
../../gdb/regcache.c:1087: internal-error: void regcache_raw_supply(regcache, int, const void): Assertion `regnum >= 0 && regnum < regcache->descr->nr_raw_registers' failed.
As noted by Andrew Paprocki, who submitted the PR
(https://sourceware.org/bugzilla/show_bug.cgi?id=21559#c3):
> It should be noted that modifying `configure` to force on
> `HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE` and
> `HAVE_STRUCT_USER_REGS_STRUCT_GS_BASE` fixes this issue. For some
> reason the `configure` tests for `fs_base` and `gs_base` fail
> even though `sys/user.h` on RHEL5 has the fields defined in
> `user_regs_struct`.
Note that this patch does NOT fix the root cause of PR gdb/21559,
although now that `configure` properly detects the presence of the
fields and sets HAVE_XXX accordingly, the execution takes another
path, which doesn't lead to the assertion failure in question.
gdb/ChangeLog:
2018-01-17 Eldar Abusalimov <eldar.abusalimov@jetbrains.com>
PR gdb/21559
* configure.ac: Include <sys/types.h> prior to <sys/user.h> when
checking for fs_base/gs_base fields in struct user_regs_struct.
* configure: Regenerate.
gdb/gdbserver/ChangeLog:
2018-01-17 Eldar Abusalimov <eldar.abusalimov@jetbrains.com>
PR gdb/21559
* configure.ac: Include <sys/types.h> prior to <sys/user.h> when
checking for fs_base/gs_base fields in struct user_regs_struct.
* configure: Regenerate.
Yao Qi [Wed, 17 Jan 2018 12:48:52 +0000 (12:48 +0000)]
Don't pass -m64 to libcc1 on aarch64-linux.
Nowadays, if we use "compile" on aarch64-linux, we'll get the following
error,
(gdb) compile code -- ;
aarch64-none-linux-gnu-gcc: error: unrecognized command line option '-m64'
because the default gcc_target_options returns "-m64" and
"-mcmodel=large", neither is useful to aarch64-linux.
gdb:
2018-01-17 Yao Qi <yao.qi@linaro.org>
* aarch64-linux-tdep.c (aarch64_linux_gcc_target_options): New
function.
(aarch64_linux_init_abi): Install it to gdbarch hook
gcc_target_options.
Yao Qi [Wed, 17 Jan 2018 11:19:03 +0000 (11:19 +0000)]
Relax gdb.compile/compile.exp to match the address printed for frame
One test in gdb.compile/compile.exp passes on one fedora builder,
bt
#0 0x00007ffff7ff43f6 in _gdb_expr (__regs=0x7ffff7ff2000) at gdb
command line:1^M
#1 <function called from gdb>^M
#2 main () at /home/gdb-buildbot/fedora-x86-64-1/fedora-x86-64/build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.compile/compile.c:106^M
(gdb) PASS: gdb.compile/compile.exp: bt
but fails on my machine with gcc trunk,
bt^M
#0 _gdb_expr (__regs=0x7ffff7ff3000) at gdb command line:1^M
#1 <function called from gdb>^M
#2 main () at gdb/testsuite/gdb.compile/compile.c:106^M
(gdb) FAIL: gdb.compile/compile.exp: bt
The test should be tweaked to match both cases (pc in the start of line
vs pc in the middle of line). Note that I am not clear that why libcc1
emits debug info this way so that the address is in the middle of line.
gdb/testsuite:
2018-01-17 Yao Qi <yao.qi@linaro.org>
* gdb.compile/compile.exp: Match the address printed for
frame in the output of command "bt".
Alan Modra [Wed, 17 Jan 2018 10:54:32 +0000 (21:24 +1030)]
Warning fix
* elf64-ppc.c (ppc64_elf_build_stubs): Silence gcc warning.
Alan Modra [Wed, 17 Jan 2018 03:49:08 +0000 (14:19 +1030)]
PowerPC PLT speculative execution barriers
Spectre variant 2 mitigation for PowerPC and PowerPC64.
bfd/
* elf32-ppc.c (GLINK_ENTRY_SIZE): Handle speculation barrier.
(CRSETEQ, BEQCTRM): Define.
(is_nonpic_glink_stub): Don't check bctr.
(ppc_elf_link_hash_table_create): Init new ppc_elf_params field.
(ppc_elf_relax_section): Size speculation barrier.
(output_bctr): New function.
(write_glink_stub): Use output_bctr.
(ppc_elf_relocate_section): Use output_bctr for long branch stub.
(ppc_elf_finish_dynamic_symbol): Likewise.
(ppc_elf_finish_dynamic_sections): Use output_bctr.
* elf32-ppc.h (struct ppc_elf_params): Add speculate_indirect_jumps.
* elf64-ppc.c (CRSETEQ, BEQCTRM, BEQCTRLM): Define.
(GLINK_PLTRESOLVE_SIZE): Size speculation barrier.
(size_global_entry_stubs): Handle speculation barrier sizing.
(plt_stub_size): Likewise.
(output_bctr): New function.
(build_plt_stub, build_tls_get_addr_stub): Output speculation
barrier.
(ppc_build_one_stub): Likewise for ppc_stub_plt_branch.
(ppc_size_one_stub): Size speculation barrier in ppc_stub_plt_branch.
(build_global_entry_stubs): Output speculation barrier.
(ppc64_elf_build_stubs): Likewise in __glink_PLTresolve stub.
* elf64-ppc.h (struct ppc64_elf_params): Add speculate_indirect_jumps.
gold/
* options.h (speculate_indirect_jumps): New option.
* powerpc.cc (beqctrm, beqctrlm, crseteq): New insn constants.
(output_bctr): New function.
(Stub_table::plt_call_size): Add space for speculation barrier.
(Stub_table::branch_stub_size): Likewise.
(Output_data_glink::pltresolve_size): Likewise.
(Stub_table::do_write): Output speculation barriers.
ld/
* emultempl/ppc32elf.em (params): Init new field.
(OPTION_SPECULATE_INDIRECT_JUMPS): Define.
(OPTION_NO_SPECULATE_INDIRECT_JUMPS): Define.
(PARSE_AND_LIST_LONGOPTS): Handle new options.
(PARSE_AND_LIST_ARGS_CASES): Likewise.
(PARSE_AND_LIST_OPTIONS): Likewise.
* emultempl/ppc64elf.em (params): Init new field.
(OPTION_SPECULATE_INDIRECT_JUMPS): Define.
(OPTION_NO_SPECULATE_INDIRECT_JUMPS): Define.
(PARSE_AND_LIST_LONGOPTS): Handle --speculate-indirect-jumps.
(PARSE_AND_LIST_OPTIONS): Likewise.
(PARSE_AND_LIST_ARGS_CASES): Likewise.
* ld.texinfo (--no-plt-thread-safe): Correct itemx.
(--speculate-indirect-jumps): Document.
* testsuite/ld-powerpc/elfv2exe.d,
* testsuite/ld-powerpc/elfv2so.d,
* testsuite/ld-powerpc/relbrlt.d,
* testsuite/ld-powerpc/powerpc.exp: Disable plt alignment and
speculation barriers on various tests.
Alan Modra [Sat, 13 Jan 2018 08:23:41 +0000 (18:53 +1030)]
PowerPC PLT stub tidy
This is in preparation for the next patch adding Spectre variant 2
mitigation for PowerPC and PowerPC64. Besides tidying code involved
in stub output (to reduce the number of places where bctr is output),
the patch adds some user visible features:
1) PowerPC64 ELFv2 global entry stubs now are aligned under the
control of --plt-align, with a default alignment of 32 bytes.
2) PowerPC64 __glink_PLTresolve is no longer padded out with nops.
3) PowerPC32 PLT stubs are aligned under the control of --plt-align,
with the default alignment being 16 bytes as before.
4) The PowerPC32 branch/nop table emitted before __glink_PLTresolve
is now smaller in many cases. It was sized incorrectly when the
__tls_get_addr_opt stub was used, and unnecessarily included space
for local ifuncs.
bfd/
* elf32-ppc.c (GLINK_ENTRY_SIZE): Add parameters, handle
__tls_get_addr_opt, and alignment sizing.
(TLS_GET_ADDR_GLINK_SIZE): Delete.
(is_nonpic_glink_stub): Don't use GLINK_ENTRY_SIZE.
(ppc_elf_get_synthetic_symtab): Recognize stubs spaced at 4, 6,
or 8 insns.
(ppc_elf_link_hash_table_create): Init new ppc_elf_params field.
(allocate_dynrelocs): Use new GLINK_ENTRY_SIZE.
(ppc_elf_size_dynamic_sections): Likewise. Size branch table
by PLT reloc count.
(write_glink_stub): Handle __tls_get_addr_opt stub.
Pad out to size given by GLINK_ENTRY_SIZE.
(ppc_elf_relocate_section): Adjust write_glink_stub call.
(ppc_elf_finish_dynamic_symbol): Likewise.
(ppc_elf_finish_dynamic_sections): Write PLTresolve without using
insn array since so many need rewriting.
* elf32-ppc.h (struct ppc_elf_params): Add plt_stub_align.
* elf64-ppc.c (GLINK_PLTRESOLVE_SIZE): Rename from
GLINK_CALL_STUB_SIZE. Add htab param and evaluate to size without
nops. Adjust all uses.
(ppc64_elf_get_synthetic_symtab): Don't use GLINK_CALL_STUB_SIZE
in glink_vma calculation.
(struct ppc_link_hash_table): Add global_entry section pointer.
(create_linkage_sections): Create separate section for global
entry stubs.
(PPC_LO, PPC_HI, PPC_HA): Move earlier.
(size_global_entry_stubs): Handle sizing for aligned stubs.
(ppc64_elf_size_dynamic_sections): Handle global_entry alloc,
and don't stash end of glink branch table in rawsize.
(ppc_build_one_stub): Rewrite stub size calculations.
(build_global_entry_stubs): Use new section.
(ppc64_elf_build_stubs): Don't pad __glink_PLTresolve with nops.
Build lazy link stubs out to end of section. Build global entry
stubs in new section.
gold/
* options.h (plt_align): Support for PowerPC32 too.
* powerpc.cc (Stub_table::stub_align): Heed --plt-align for 32-bit.
(Stub_table::plt_call_size, branch_stub_size): Tidy.
(Stub_table::plt_call_align): Implement using stub_align.
(Output_data_glink::global_entry_align): New function.
(Output_data_glink::global_entry_off): New function.
(Output_data_glink::global_entry_address): Use global_entry_off.
(Output_data_glink::pltresolve_size): New function, replacing
pltresolve_size_ constant. Update all uses.
(Output_data_glink::add_global_entry): Align offset.
(Output_data_glink::set_final_data_size): Use global_entry_align.
(Stub_table::do_write): Don't pad __glink_PLTrelsolve with nops.
Tidy stub output. Use global_entry_off.
ld/
* emultempl/ppc32elf.em (params): Init new field.
(enum ppc32_opt): New enum to define OPTION_* values. Add
OPTION_PLT_ALIGN and OPTION_NO_PLT_ALIGN.
(PARSE_AND_LIST_LONGOPTS): Handle new options.
(PARSE_AND_LIST_ARGS_CASES): Likewise.
(PARSE_AND_LIST_OPTIONS): Likewise. Break up help output.
* emultempl/ppc64elf.em (ppc_add_stub_section): Init alignment
correctly for negative --plt-stub-align.
* testsuite/ld-powerpc/elfv2exe.d,
* testsuite/ld-powerpc/elfv2so.d,
* testsuite/ld-powerpc/relbrlt.d,
* testsuite/ld-powerpc/relbrlt.s,
* testsuite/ld-powerpc/tlsexe.d,
* testsuite/ld-powerpc/tlsexe.r,
* testsuite/ld-powerpc/tlsexe32.d,
* testsuite/ld-powerpc/tlsexe32.g,
* testsuite/ld-powerpc/tlsexe32.r,
* testsuite/ld-powerpc/tlsexetoc.d,
* testsuite/ld-powerpc/tlsexetoc.r,
* testsuite/ld-powerpc/tlsopt5_32.d,
* testsuite/ld-powerpc/tlsso.d,
* testsuite/ld-powerpc/tlstocso.d: Update for changed stub order.
GDB Administrator [Wed, 17 Jan 2018 00:00:42 +0000 (00:00 +0000)]
Automatic date update in version.in
Joel Brobecker [Tue, 16 Jan 2018 13:18:36 +0000 (14:18 +0100)]
binutils release procedure: Add AI to update branch name in crontab
binutils/ChangeLog:
* README-how-to-make-a-release: Add reminder to update the
branch name in gdbadmin's crontab on sourceware.
Nick Clifton [Tue, 16 Jan 2018 12:45:44 +0000 (12:45 +0000)]
Update translations for various binutils components.
ld * po/pt_BR.po: Updated Brazilian Portugese translation.
opcodes * po/pt_BR.po: Updated Brazilian Portugese translation.
* po/de.po: Updated German translation.
gas * po/fr.po: Updated French translation.
binutils* po/fr.po: Updated French translation.
Joel Brobecker [Tue, 16 Jan 2018 11:20:01 +0000 (12:20 +0100)]
Remove trailing spaces in binutils/README-how-to-make-a-release
binutils/ChangeLog:
* README-how-to-make-a-release: Remove trailing spaces.
Yao Qi [Tue, 16 Jan 2018 09:05:39 +0000 (09:05 +0000)]
Mark register unavailable when PTRACE_PEEKUSER fails
As described in PR 18749, GDB/GDBserver may get an error on accessing
memory or register because the thread may disappear. However, some
path doesn't expect the error. This patch fixes this problem by
marking the register unavailable when PTRACE_PEEKUSER fails instead
of throwing error.
gdb/gdbserver:
2018-01-16 Yao Qi <yao.qi@linaro.org>
PR gdb/18749
* linux-low.c (fetch_register): Call supply_register instead of
error.
GDB Administrator [Tue, 16 Jan 2018 00:00:34 +0000 (00:00 +0000)]
Automatic date update in version.in
Jim Wilson [Mon, 15 Jan 2018 22:53:44 +0000 (14:53 -0800)]
RISC-V: Add support for addi that compresses to c.nop.
gas/
* testsuite/gas/riscv/c-zero-imm.s: Test addi that compresses to c.nop.
* testsuite/gas/riscv/c-zero-imm.d: Likewise.
opcodes/
* riscv-opc.c (match_c_nop): New.
(riscv_opcodes) <addi>: Handle an addi that compresses to c.nop.
Pedro Alves [Mon, 15 Jan 2018 20:03:20 +0000 (20:03 +0000)]
gdb/common/signals-state-save-restore.c: Fix typos
gdb/ChangeLog:
2018-01-15 Pedro Alves <palves@redhat.com>
* common/signals-state-save-restore.c
(save_original_signals_state): Fix typos.
Tom Tromey [Wed, 3 Jan 2018 18:12:34 +0000 (11:12 -0700)]
Fix scm-ports.exp regression
In https://sourceware.org/ml/gdb-patches/2017-12/msg00215.html, Jan
pointed out that the scalar printing patches caused a regression in
scm-ports.exp on x86.
What happens is that on x86, this:
set sp_reg [get_integer_valueof "\$sp" 0]
... ends up setting sp_reg to a negative value, because
get_integer_valueof uses "print/d":
print /d $sp
$1 = -11496
Then later the test suite does:
gdb_test "guile (print (seek rw-mem-port (value->integer sp-reg) SEEK_SET))" \
"= $sp_reg" \
"seek to \$sp"
... expecting this value to be identical to the saved $sp_reg value.
However it gets:
guile (print (seek rw-mem-port (value->integer sp-reg) SEEK_SET))
=
4294955800
"print" is just a wrapper for guile's format:
gdb_test_no_output "guile (define (print x) (format #t \"= ~A\" x) (newline))"
The seek function returns a scm_t_off, the printing of which is
handled by guile, not by gdb.
Tested on x86-64 Fedora 26 using an ordinary build and also a -m32
build.
2018-01-15 Tom Tromey <tom@tromey.com>
* gdb.guile/scm-ports.exp (test_mem_port_rw): Use get_valueof to
compute sp_reg.
Cary Coutant [Mon, 15 Jan 2018 18:05:54 +0000 (10:05 -0800)]
Fix -fuse-ld option to accept string argument.
PR 22042 complained that garbage text was being printed in the help
for the -fuse-ld option; this was caused by passing an empty string
to the gettext() function, which sometimes returns garbage when passed
an empty string. The quick fix was to replace "" with NULL as the helparg,
but that changed the parsing of the option, as gold uses the helparg to
determine whether an option takes an argument. This patch adds a
non-empty helparg string to fix both problems.
gold/
PR gold/22694
* options.h (-fuse-ld): Add correct helparg.
Thomas Preud'homme [Mon, 15 Jan 2018 14:13:33 +0000 (14:13 +0000)]
[ARM] Add new macro for Thumb-only opcodes
Armv8-M Security Extensions introduced some Thumb-only opcodes
(eg. sg). These are defined using the TUE and TCE macros, setting the
Arm execution state related fields to 0/NULL.
This patch adds 2 new macros to avoid filling this field and clearly
identify Thumb-only instructions.
2018-01-15 Thomas Preud'homme <thomas.preudhomme@arm.com>
gas/
* config/tc-arm.c (ToC): Define macro.
(ToU): Likewise.
(insns): Make use of above macros for new instructions introduced in
Armv8-M.
Thomas Preud'homme [Mon, 15 Jan 2018 14:11:02 +0000 (14:11 +0000)]
[ARM] Enable conditional Armv8-M instructions
Newly introduced instructions common to ARMv8-M Baseline and Mainline
are currently all marked as unconditional. However, all instructions but
sg (ie. blxns, bxns, tt, ttt, tta, ttat, vlldm and vlstm) do actually
support conditional execution. This patch fixes the definition of these
instructions accordingly.
2018-01-15 Thomas Preud'homme <thomas.preudhomme@arm.com>
gas/
* config/tc-arm.c (insns): Make blxns, bxns, tt, ttt, tta, ttat, vlldm
and vlstm conditionally executable and reindent parameters.
* testsuite/gas/arm/archv8m-cmse-main.s: Add conditional version of
aforementionned instructions.
Thomas Preud'homme [Mon, 15 Jan 2018 14:09:28 +0000 (14:09 +0000)]
[ARM] No IT usage deprecation for ARMv8-M
Deprecations related to the use of the IT instruction introduced in
Armv8-A do not apply to Armv8-M Baseline and mainline. However the
warning logic do not distinguish between the various profiles and warn
whenever the architecture version is 8.
This patch adds a check to exclude M profile architectures from this
warning. This works as expected when -march is specified on the
command-line or a .arch/.cpu directive exist. However, in autodetection
mode the CPU/architecture targeted is only known once the instructions
have been all processed but this code is run when IT instruction is
processed. It is therefore not possible to distinguish between Armv8-M
and Armv8-A in that mode.
The approach chosen here is not to warn in autodetection mode. The udf.d
testcase that relied on that behavior to test deprecation warning for
Armv8-A is therefore updated to explicitely pass -march=armv8-a.
2018-01-15 Thomas Preud'homme <thomas.preudhomme@arm.com>
gas/
* config/tc-arm.c (it_fsm_post_encode): Do not warn if targeting M
profile architecture or if in autodetection mode. Clarify that
deprecation is for performance reason and concerns Armv8-A and Armv8-R.
* testsuite/gas/arm/armv8-ar-bad.l: Adapt to new IT deprecation warning
message.
* testsuite/gas/arm/armv8-ar-it-bad.l: Likewise.
* testsuite/gas/arm/sp-pc-validations-bad-t-v8a.l: Likewise.
* testsuite/gas/arm/udf.l: Likewise.
* testsuite/gas/arm/udf.d: Assemble for Armv8-A explicitely.
Szabolcs Nagy [Mon, 15 Jan 2018 13:06:45 +0000 (13:06 +0000)]
Fix gdb.texinfo more
Add incorrectly removed @pindex back.
gdb/doc/ChangeLog:
* gdb.texinfo (gdb-add-index man): Add pindex.
Nick Clifton [Mon, 15 Jan 2018 12:09:11 +0000 (12:09 +0000)]
Update Ukranian translations for bfd, binutils, gas, gold, ld and opcodes
Szabolcs Nagy [Mon, 15 Jan 2018 10:44:12 +0000 (10:44 +0000)]
Fix gdb.texinfo for old makeinfo (again)
With old makeinfo (version 4.13) the changes introduced in
commit
ba643918cf869fa0d064d733f69b453b6fe642ea
Author: Sergio Durigan Junior <sergiodj@redhat.com>
Install and generate docs for gdb-add-index
fail to build with
gdb/doc/gdb.texinfo:2498: warning: `.' or `,' must follow @xref, not `@'.
gdb/doc/gdb.texinfo:2517: warning: `.' or `,' must follow @xref, not `@'.
gdb/doc/gdb.texinfo:43443: Node `gdb-add-index man' requires a sectioning command (e.g., @unnumberedsubsec).
gdb/doc/gdb.texinfo:43443: `gdb-add-index man' has no Up field (perhaps incorrect sectioning?).
gdb/doc/gdb.texinfo:43350: Next field of node `gdbinit man' not pointed to (perhaps incorrect sectioning?).
gdb/doc/gdb.texinfo:43443: This node (gdb-add-index man) has the bad Prev.
This patch fixes the warnings too.
gdb/doc/ChangeLog:
* gdb.texinfo (set cwd): Add period.
(gdb-add-index man): Move anchor.
GDB Administrator [Mon, 15 Jan 2018 00:00:29 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 14 Jan 2018 00:00:44 +0000 (00:00 +0000)]
Automatic date update in version.in
Nick Clifton [Sat, 13 Jan 2018 14:29:27 +0000 (14:29 +0000)]
Update notes on how to make a release
Nick Clifton [Sat, 13 Jan 2018 13:56:48 +0000 (13:56 +0000)]
Update pot files
Nick Clifton [Sat, 13 Jan 2018 13:31:12 +0000 (13:31 +0000)]
Bump version number to 2.30.51
bfd/
* version.m4: Bump version to 2.30.51
* configure: Regenerate.
binutils/
* configure: Regenerate.
gas/
* configure: Regenerate.
gprof/
* configure: Regenerate.
ld/
* configure: Regenerate.
opcodes/
* configure: Regenerate.
Nick Clifton [Sat, 13 Jan 2018 13:26:38 +0000 (13:26 +0000)]
Add note about 2.30 branch creation to changelogs
Nick Clifton [Sat, 13 Jan 2018 13:20:55 +0000 (13:20 +0000)]
Add 2.30 markers to NEWS files.
binutils/
* NEWS: Add marker for 2.30.
gas/
* NEWS: Add marker for 2.30.
ld/
* NEWS: Add marker for 2.30.
Cary Coutant [Sat, 13 Jan 2018 02:38:11 +0000 (18:38 -0800)]
Update gold version number to 1.15.
gold/
* NEWS: Add new features in 1.15.
* version.cc (version_string): Bump to 1.15.
GDB Administrator [Sat, 13 Jan 2018 00:00:33 +0000 (00:00 +0000)]
Automatic date update in version.in
Andrew Burgess [Thu, 11 Jan 2018 18:58:10 +0000 (18:58 +0000)]
gdb/testsuite: Don't attempt tests if they fail to compile
In the gdb.base/whatis-ptype-typedefs.exp test, if the test program
fails to compile, don't run the tests.
gdb/testsuite/ChangeLog:
* gdb.base/whatis-ptype-typedefs.exp: Don't run tests if we failed
to prepare.
(prepare): Return 0 on error, 1 on success.
Sergio Durigan Junior [Thu, 11 Jan 2018 21:12:05 +0000 (16:12 -0500)]
Install and generate docs for gdb-add-index
The "gdb-add-index" script has been resurrected on:
commit
caf26be91a584ef141ac5d3cb31007731af8b8e3
Author: Samuel Bronson <naesten@gmail.com>
Date: Fri Nov 15 16:09:33 2013 -0500
Resurrect gdb-add-index as a contrib script
However, for some reason (I couldn't find it in the archives), only
the script has been checked-in; the Makefile parts responsible for
installing it in the system were left out. This commit fixes that, by
also resurrecting the Makefile and documentation bits.
This commit is part of our effort to upstream the local Fedora GDB
changes. With this commit, we'll only carry a very small
Fedora-specific modification to the script.
gdb/ChangeLog:
2017-01-12 Tom Tromey <tom@tromey.com>
Sergio Durigan Junior <sergiodj@redhat.com>
* Makefile.in (install-only): Install gdb-add-index.
gdb/doc/ChangeLog:
2017-01-12 Tom Tromey <tom@tromey.com>
Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.texinfo (Index Files): Mention gdb-add-index.
(gdb-add-index man): New section.
* Makefile.in (gdb-add-index.1): New rule to generate manpage
from gdb.texinfo.
John Baldwin [Fri, 12 Jan 2018 20:05:50 +0000 (12:05 -0800)]
Use the correct value for the offset of 'kve_protection'.
I had forgotten to convert the decimal output of 'ptype /o' to hex
(but still used a 0x prefix) for the KVE_PROTECTION constant defining
the offset of the 'kve_protection' field in the 'kinfo_vmentry'
structure. This resulted in garbage permissions for entries in 'info
proc mappings' for FreeBSD core dumps.
gdb/ChangeLog:
* fbsd-tdep.c (KVE_PROTECTION): Correct value.
Eric Christopher [Fri, 12 Jan 2018 19:05:58 +0000 (11:05 -0800)]
Apply:
2018-01-12 Sterling Augustine <saugustine@google.com>
* cref.cc (Cref_inputs::Cref_table_compare::operator): Add
conditionals and calls to is_forwarder.
Pedro Alves [Fri, 12 Jan 2018 18:52:39 +0000 (18:52 +0000)]
Add testcase for GDB hang fixed by previous commit
This adds a testcase for the previous commit. The regression was
related to in-line step overs. The reason we didn't see it on native
x86-64/s390 GNU/Linux testing is that native debugging uses displaced
stepping by default (because native debugging defaults to "maint set
target-non-stop on"), unlike remote debugging.
So in order to trigger the bug with native debugging as well, the
testcase disables displaced stepping explicitly.
Also, instead of using watchpoints to trigger the regression, the
testcase uses a breakpoint at address 0, which should be more
portable.
gdb/testsuite/ChangeLog:
2018-01-12 Pedro Alves <palves@redhat.com>
* gdb.base/continue-after-aborted-step-over.c: New.
* gdb.base/continue-after-aborted-step-over.exp: New.
Andreas Arnez [Fri, 12 Jan 2018 18:52:39 +0000 (18:52 +0000)]
Fix GDB hang with remote after error from resume
Since this commit --
Fix PR18360 - internal error when using "interrupt -a"
(https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=
c65d6b55)
-- the testsuite shows long delays on s390 with native-gdbserver when
executing certain tests, such as watchpoints.exp. These hangs have been
discussed before in the context of buildbot problems, see here:
https://sourceware.org/ml/gdb-patches/2017-12/msg00413.html
The problem can easily be triggered by stopping on a breakpoint, then
setting impossible watchpoints, and finally doing "continue". Then, after
having set the step-over state (in keep_going_pass_signal in infrun.c),
GDB tries to insert breakpoints and watchpoints into the inferior. This
fails, and the "continue" command is aborted. But the step-over state is
not cleared in this case, which causes future step-over attempts to be
skipped since GDB thinks that "we already have an in-line step-over
operation ongoing" (see start_step_over in infrun.c). Thus the next
"continue" just goes on to wait for events from the remote, which will
never occur.
The problem can also be reproduced on amd64 with native-gdbserver, using
the following change to watchpoints.exp:
-- >8 --
--- a/gdb/testsuite/gdb.base/watchpoints.exp
+++ b/gdb/testsuite/gdb.base/watchpoints.exp
@@ -61,2 +61,3 @@ with_test_prefix "before inferior start" {
gdb_test "watch ival3" ".*" ""
+ gdb_test "watch *(char \[256\] *) main"
-- >8 --
To fix the hang, this patch clears the step-over info when
insert_breakpoints has failed. Of course, with native-gdbserver the
watchpoints.exp test case still causes many FAILs on s390, because
gdbserver does not support watchpoints for that target. This is a
separate issue.
gdb/ChangeLog:
2018-01-12 Andreas Arnez <arnez@linux.vnet.ibm.com>
* infrun.c (keep_going_pass_signal): Clear step-over info when
insert_breakpoints fails.
Nick Clifton [Fri, 12 Jan 2018 17:52:38 +0000 (17:52 +0000)]
Add notes on how to make a branch and a pre-release snapshot.
* README-how-to-make-a-release: Add notes on how to make the
branch and prelease snapshot.
* BRANCHES: Add binutils-2_29-branch.
Jens Widell [Fri, 12 Jan 2018 13:16:17 +0000 (13:16 +0000)]
Optimize the performance of the group_setup function.
When processing a section that is a member of a group, the group
that contains it is looked up using a linear search. The resulting
O(n^2) complexity causes significant performance issues when
dealing with object files with very many groups.
By remembering the index of the last found group and restarting
the next search from that index, the search instead becomes O(n)
in common cases.
* elf.c (setup_group): Optimize search for group by remembering
last found group and restarting search at that index.
* elf-bfd.h (struct elf_obj_tdata): Add group_search_offset field.
Gunther Nikl [Fri, 12 Jan 2018 13:12:17 +0000 (13:12 +0000)]
Fix compile time warning building aout targeted architectures.
Occasionally I build an out-of-tree a.out target (m68k-amigaos). After
a system upgrade which included a newer compiler (clang 4) the build
produces warnings like this:
warning: macro expansion producing 'defined' has undefined behavior
[-Wexpansion-to-defined]
This is caused by the macro gas/config/aout_gnu.h:USE_EXTENDED_RELOC.
Since it is in a header file, the warning triggers for several files.
I am unsure what solution is preferable, thus I am suggesting two
patches:
a) keep the offending macro but define it explicitly to 0 and 1
b) replace the macro usage with its value where it is used.
Either patch removes the warning for clang. I did not check with a
recent GCC.
* gas/config/aout_gnu.h (USE_EXTENDED_RELOC): Explicitly
define to 0 and 1. Remove a dangling reference to "AMD 29000"
in a comment.
Alan Modra [Fri, 12 Jan 2018 10:40:48 +0000 (21:10 +1030)]
pr22374 function pointer initialization
When I added this test I said I'd look at fixing more targets.
That hasn't happened yet, so xfail to tidy results.
* testsuite/ld-elf/elf.exp: xfail "pr22374 function pointer
initialization" for currently failing targets.
Alan Modra [Fri, 12 Jan 2018 00:07:28 +0000 (10:37 +1030)]
Fix override of common symbols for a.out
The default should be bfd_link_common_skip_none, as in the original
patch at https://sourceware.org/ml/binutils/2002-07/msg00717.html
* aoutx.h (aout_link_check_ar_symbols): Remove default and handle
bfd_link_common_skip_none in switch.
Alan Modra [Fri, 12 Jan 2018 06:28:04 +0000 (16:58 +1030)]
Fixes for "Ignore dynamic references on forced local symbols"
PowerPC64 has its own mark_dynamic_ref, which needs the same change as
made by
d664fd41e1 to the generic ELF version. Some other targets
discard more than just .data, so allow for that too in expected ld
messages.
bfd/
PR ld/22649
* elf64-ppc.c (ppc64_elf_gc_mark_dynamic_ref): Ignore dynamic
references on forced local symbols.
ld/
PR ld/22649
* testsuite/ld-elf/pr22649.msg: Allow other messages.
* testsuite/ld-elf/shared.exp: Check that --gc-sections is
supported before running ld/22649 tests.
Vlad Ivanov [Fri, 12 Jan 2018 09:25:11 +0000 (09:25 +0000)]
_bfd_mips_elf_final_link: Notify user about wrong .reginfo size
One of assertions in _bfd_mips_elf_final_link could be triggered by
a combination of input files and a linker script. This happens when
either the input doesn't contain .reginfo section or when this section
is oversized. This patch replaces the assertion with a more useful
error message.
* elfxx-mips.c (_bfd_mips_elf_final_link): Notify user when
.reginfo section has wrong size.
Nick Clifton [Fri, 12 Jan 2018 08:15:55 +0000 (08:15 +0000)]
Add -z undefs option to the ELF linker.
Currently we have no obvious way to revert the action of the "-z defs"
command line option. The "--unresolved-symbols=ignore-in-object-files"
does pretty much what is needed, but it is non-obvious and it also
touches the setting for reporting unresolved symbol references from
shared libraries. So I am proposing adding a "-z undefs" option to be
the inverse of "-z defs". (I thought that "-z nodefs" might be
confusing since it implies banning all definitions, rather than
allowing them).
In addition the description of the "-z defs" option in the linker
documentation is misleading in one place, where it says:
'defs'
Disallows undefined symbols in object files. Undefined
symbols in shared libraries are still allowed.
whereas later on it gets it right:
'-z defs'
Report unresolved symbol references from regular object files.
This is done even if the linker is creating a non-symbolic shared
library. The switch '--[no-]allow-shlib-undefined' controls the
behaviour for reporting unresolved references found in shared
libraries being linked in.
* emultempl/elf32.em (_handle_option): Add support for "-z undefs"
as the opposite of "-z defs".
* ld.texinfo: Document the new option. Update the description of
the -z defs option to make it clear that it does generate an error
if an undefined symbol reference is found in an object file whilst
creating a shared library.
* NEWS: Document this new feature.
H.J. Lu [Fri, 12 Jan 2018 04:46:01 +0000 (20:46 -0800)]
ld: Replace "-z textonly" with "-z separate-code"
Although they aren't passed to linker, we should get it right.
* testsuite/ld-elf/pr22393-2a.rd: Replace "-z textonly" with
"-z separate-code".
* testsuite/ld-elf/pr22393-2b.rd: Likewise.
* testsuite/ld-x86-64/pr22393-3a.rd: Likewise.
* testsuite/ld-x86-64/pr22393-3b.rd: Likewise.
H.J. Lu [Fri, 12 Jan 2018 03:19:22 +0000 (19:19 -0800)]
x86-64: Add tests for -z separate-code -z max-page-size=0x1000
PR ld/22393
* testsuite/ld-x86-64/pr22393-3a.c: New file.
* testsuite/ld-x86-64/pr22393-3a.rd: Likewise.
* testsuite/ld-x86-64/pr22393-3b.c: Likewise.
* testsuite/ld-x86-64/pr22393-3b.rd: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run tests for -z separate-code
-z max-page-size=0x1000.
H.J. Lu [Fri, 12 Jan 2018 03:17:46 +0000 (19:17 -0800)]
ld: Add tests for -z separate-code and -z noseparate-code
Verify that -z separate-code works and -z noseparate-code doesn't disable
-z relro.
PR ld/22393
* testsuite/ld-elf/pr16322.d: Add -z noseparate-code.
* testsuite/ld-elf/pr22393-1.s: New file.
* testsuite/ld-elf/pr22393-1a.d: Likewise.
* testsuite/ld-elf/pr22393-1b.d: Likewise.
* testsuite/ld-elf/pr22393-1c.d: Likewise.
* testsuite/ld-elf/pr22393-1d.d: Likewise.
* testsuite/ld-elf/pr22393-1e.d: Likewise.
* testsuite/ld-elf/pr22393-1f.d: Likewise.
* testsuite/ld-elf/pr22393-2a.c: Likewise.
* testsuite/ld-elf/pr22393-2a.rd: Likewise.
* testsuite/ld-elf/pr22393-2b.c: Likewise.
* testsuite/ld-elf/pr22393-2b.rd: Likewise.
* testsuite/ld-elf/shared.exp: Run tests for -z separate-code.
H.J. Lu [Fri, 12 Jan 2018 03:04:55 +0000 (19:04 -0800)]
ld: Create a new LOAD segment for separate code segment
When generating separate code LOAD segment, create a new LOAD segment
if the previous section contains text and the current section doesn't
or vice versa:
Elf file type is DYN (Shared object file)
Entry point 0x200020
There are 7 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x00000000 0x00000000 0x00200 0x00200 R 0x200000
LOAD 0x200000 0x00200000 0x00200000 0x00036 0x00036 R E 0x200000
LOAD 0x400000 0x00400000 0x00400000 0x00064 0x00064 R 0x200000
LOAD 0x400f80 0x00600f80 0x00600f80 0x000a0 0x000a0 RW 0x200000
DYNAMIC 0x400f80 0x00600f80 0x00600f80 0x00080 0x00080 RW 0x4
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x10
GNU_RELRO 0x400f80 0x00600f80 0x00600f80 0x00080 0x00080 R 0x1
Section to Segment mapping:
Segment Sections...
00 .hash .gnu.hash .dynsym .dynstr .rela.plt
01 .plt .text
02 .rodata .eh_frame
03 .dynamic .got.plt
04 .dynamic
05
06 .dynamic
to prevent fetching or executing data in code pages as instructions.
Also don't put a writable section in a read-only segment if there is a
RELRO segment.
Since code segment is aligned and padded to the maximum page size on
disk, the minimum file size is bigger than the maximum page size which
is 2MB (0x200000):
-rwxr-xr-x 1 hjl hjl
4201932 Jan 10 10:41 libfoo.so
"-z max-page-size=0x1000" can be used to reduce the maximum page size to
4KB (0x1000):
-rwxr-xr-x 1 hjl hjl 15820 Jan 10 10:44 libfoo.so
PR ld/22393
* elf.c (_bfd_elf_map_sections_to_segments): When generating
separate code and read-only data LOAD segments, create a new
LOAD segment if the previous section contains text and the
current section doesn't or vice versa. Don't put a writable
section in a read-only segment if there is a RELRO segment.
H.J. Lu [Fri, 12 Jan 2018 03:01:39 +0000 (19:01 -0800)]
ld: Add "-z separate-code" option to ELF linker
The new "-z separate-code" option will generate separate code LOAD
segment which must be in wholly disjoint pages from any other data.
include/
PR ld/22393
* bfdlink.h (bfd_link_info): Add separate_code.
ld/
PR ld/22393
* NEWS: Mention "-z separate-code".
* emultempl/elf32.em (gld${EMULATION_NAME}_get_script): Get
builtin linker scripts and return linker scripts from disk for
"-z separate-code".
(gld${EMULATION_NAME}_handle_option): Handle "-z separate-code"
and "-z noseparate-code".
* genscripts.sh: Generate linker scripts for "-z separate-code".
(LD_FLAG): Set to *textonly for "-z separate-code".
* ld.texinfo: Document "-z separate-code".
* lexsup.c (elf_shlib_list_options): Add linker help messsages
for "-z separate-code" and "-z noseparate-code".
* scripttempl/elf.sc (SEPARATE_TEXT): New
(TEXT_SEGMENT_ALIGN): Likewise.
Use ${TEXT_SEGMENT_ALIGN} to align and pad text segment to
${MAXPAGESIZE}.
Simon Marchi [Fri, 12 Jan 2018 02:08:23 +0000 (21:08 -0500)]
gdb_compile_shlib: Only consider shlib= options when building executables
Trying to use gdb_compile_shlib with the shlib= option to build a shared
library that depends on another shared library does not work as of
today. See:
https://sourceware.org/ml/gdb-patches/2017-10/msg00733.html
The problem is that building the lib is done in two steps, compilation
(.c -> .o) and linking (.o -> .so) and the shlib= options are passed to
both steps. When compiling the object file (.o), it results in gcc
complaining:
gcc: warning: .../solib-vanish-lib2.so: linker input file unused because linking not done
The first solution I came up with was to filter the options inside
gdb_compile_shlib to remove the shlib= options from the options we pass
when compiling the .o file.
I then thought it would be simpler to ignore the shlib= options in
gdb_compile when not building an executable (the executable category
includes the shared libraries). For other compilation types (object
file, preprocess and generate assembly), it doesn't make sense to add
shared libraries to the source file list.
Regtested on the buildbot.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (gdb_compile): Ignore shlib= and shlib_load
options when not creating an executable.
GDB Administrator [Fri, 12 Jan 2018 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in