]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
6 years agoRISC-V: Add comment for previous change.
Jim Wilson [Thu, 8 Feb 2018 21:15:10 +0000 (13:15 -0800)] 
RISC-V: Add comment for previous change.

bfd/
* elfnn-riscv.c (riscv_elf_relocate_section): Add comment for previous
change.

6 years agoRemove cleanups from solib.c
Tom Tromey [Tue, 6 Feb 2018 20:00:40 +0000 (13:00 -0700)] 
Remove cleanups from solib.c

This removes a couple of cleanups from solib.c, replacing one with
std::string and another with unique_xmalloc_ptr.

2018-02-08  Tom Tromey  <tom@tromey.com>

* solib.c (solib_find_1): Use std::string.
(solib_bfd_fopen): Use unique_xmalloc_ptr.

6 years agoUse unique_xmalloc_ptr in build_id_to_debug_bfd
Tom Tromey [Tue, 6 Feb 2018 19:54:44 +0000 (12:54 -0700)] 
Use unique_xmalloc_ptr in build_id_to_debug_bfd

This changes build_id_to_debug_bfd to use a unique_xmalloc_ptr,
removing a cleanup.

2018-02-08  Tom Tromey  <tom@tromey.com>

* build-id.c (build_id_to_debug_bfd): Use unique_xmalloc_ptr.

6 years agoUse gdb::def_vector in find_source_lines
Tom Tromey [Tue, 6 Feb 2018 19:51:42 +0000 (12:51 -0700)] 
Use gdb::def_vector in find_source_lines

This replaces an explicit malloc and a cleanup with a gdb::def_vector.

2018-02-08  Tom Tromey  <tom@tromey.com>

* source.c (find_source_lines): Use gdb::def_vector.

6 years agoRemove cleanups from macro_define_command
Tom Tromey [Tue, 6 Feb 2018 19:25:00 +0000 (12:25 -0700)] 
Remove cleanups from macro_define_command

This removes cleanups from macro_define_command, by introducing a new
struct temporary_macro_definition that cleans up after itself.

2018-02-08  Tom Tromey  <tom@tromey.com>

* macrocmd.c (struct temporary_macro_definition): New.
(macro_define_command): Use temporary_macro_definition.  Remove
cleanups.
(free_macro_definition_ptr): Remove.

6 years agoUse std::string in maybe_expand
Tom Tromey [Tue, 6 Feb 2018 19:11:21 +0000 (12:11 -0700)] 
Use std::string in maybe_expand

This patch changes maybe_expand to use std::string rather than an
explicit malloc and a cleanup.

2018-02-08  Tom Tromey  <tom@tromey.com>

* macroexp.c (maybe_expand): Use std::string.

6 years agoClass-ify macro_buffer
Tom Tromey [Tue, 6 Feb 2018 19:10:20 +0000 (12:10 -0700)] 
Class-ify macro_buffer

This patch changes macro_buffer to be a bit more of a C++ class,
adding constructors, a destructor, and some members.  Then this is
used to remove various cleanups in macroexp.c.

2018-02-08  Tom Tromey  <tom@tromey.com>

* macroexp.c (struct macro_buffer): Add initializers for some
members.
(init_buffer, init_shared_buffer, free_buffer)
(free_buffer_return_text): Remove.
(macro_buffer): New constructors.
(~macro_buffer): New destructor.
(macro_buffer::set_shared): New method.
(macro_buffer::resize_buffer, macro_buffer::appendc)
(macro_buffer::appendmem): Now methods, not free functions.
(set_token, append_tokens_without_splicing, stringify)
(macro_stringify): Update.
(gather_arguments): Change return type.  Remove argc_p argument,
add args_ptr argument.  Use std::vector.
(substitute_args): Remove argc argument.  Accept std::vector.
(expand): Update.  Use std::vector.
(scan, macro_expand, macro_expand_next): Update.

6 years agoReturn unique_xmalloc_ptr from macro scope functions
Tom Tromey [Tue, 6 Feb 2018 00:02:00 +0000 (01:02 +0100)] 
Return unique_xmalloc_ptr from macro scope functions

This changes the macro scope functions (sal_macro_scope,
user_macro_scope, and default_macro_scope) to return a
unique_xmalloc_ptr, then fixes up the users.  This allowed for the
removal of several cleanups.

2018-02-08  Tom Tromey  <tom@tromey.com>

* symtab.c (default_collect_symbol_completion_matches_break_on):
Use unique_xmalloc_ptr.
* macroscope.h: (sal_macro_scope, user_macro_scope)
(default_macro_scope): Return unique_xmalloc_ptr.
* macroscope.c (sal_macro_scope, user_macro_scope)
(default_macro_scope): Return unique_xmalloc_ptr.
* macroexp.h (macro_expand, macro_expand_once): Return
unique_xmalloc_ptr.
* macroexp.c (macro_expand, macro_expand_once): Return
unique_xmalloc_ptr.
* macrocmd.c (macro_expand_command, macro_expand_once_command)
(info_macro_command, info_macros_command): Use
unique_xmalloc_ptr.
* compile/compile-c-support.c (write_macro_definitions): Use
unique_xmalloc_ptr.
* c-exp.y (c_parse): Use unique_xmalloc_ptr.

6 years agoRemove make_cleanup_restore_current_thread from gdbserver
Tom Tromey [Mon, 5 Feb 2018 09:59:52 +0000 (10:59 +0100)] 
Remove make_cleanup_restore_current_thread from gdbserver

This removes make_cleanup_restore_current_thread from gdbserver,
replacing it with a use of scoped_restore.

2018-02-08  Tom Tromey  <tom@tromey.com>

* linux-low.c (install_software_single_step_breakpoints): Use
make_scoped_restore.
* inferiors.c (make_cleanup_restore_current_thread): Remove.
(do_restore_current_thread_cleanup): Remove.
* gdbthread.h (make_cleanup_restore_current_thread): Don't
declare.

6 years agoRemove a cleanup from gdbserver
Tom Tromey [Mon, 5 Feb 2018 09:53:57 +0000 (10:53 +0100)] 
Remove a cleanup from gdbserver

This removes a cleanup from gdbserver's set_raw_breakpoint_at,
replacing it with unique_xmalloc_ptr.

2018-02-08  Tom Tromey  <tom@tromey.com>

* mem-break.c (set_raw_breakpoint_at): Use
gdb::unique_xmalloc_ptr.

6 years agoSpeed up readelf and objdump by not looking for DWO links unless the user has request...
Nick Clifton [Thu, 8 Feb 2018 12:29:07 +0000 (12:29 +0000)] 
Speed up readelf and objdump by not looking for DWO links unless the user has requested that they be displayed/followed.

PR 22802
* dwarf.c (load_separate_debug_file): Return early if the user is
not interested in debug links.

6 years agoFix a seg-fault in the ELF note parser when a note with an excessively large alignmen...
Nick Clifton [Thu, 8 Feb 2018 10:28:25 +0000 (10:28 +0000)] 
Fix a seg-fault in the ELF note parser when a note with an excessively large alignment is encountered.

PR 22788
* elf.c (elf_parse_notes): Reject notes with excessuively large
alignments.

6 years agoPR22819, powerpc gas "instruction address is not a multiple of 4"
Alan Modra [Wed, 7 Feb 2018 23:48:59 +0000 (10:18 +1030)] 
PR22819, powerpc gas "instruction address is not a multiple of 4"

Checks for insn alignment were hopelessly confused when misaligned
data starts a new frag.  The real-world testcase happened to run out
of frag space in the middle of emitting a trace-back table via
something like:
.byte 0 /* VERSION=0 */
  .byte 9 /* LANG=C++ */
.byte 34 /* Bits on: has_tboff, fp_present */
.byte 64 /* Bits on: name_present */
.byte 128 /* Bits on: stores_bc, FP_SAVED=0 */
.byte 0 /* Bits on: GP_SAVED=0 */
.byte 2 /* FIXEDPARMS=2 */
.byte 1 /* FLOATPARMS=0, parmsonstk */
.long 0
.long 768 /* tb_offset: 0x300 */
.hword 45 /* Function name length: 45 */
  .long 0x334e5a5f
.long 0x31766f70
.long 0x65744932
.long 0x69746172
.long 0x7a5f6e6f
.long 0x64504533
.long 0x5f534e50
.long 0x72463431
.long 0x61746361
.long 0x74535f6c
.long 0x74637572
.byte 0x45
.byte 0
The trigger being those misaligned .long's output for the function
name.  A most horrible way to output a string, especially considering
endian issues..

PR 22819
* config/tc-ppc.c (md_assemble): Rewrite insn alignment checking.
(ppc_frag_check): Likewise.
* testsuite/gas/ppc/misalign.d,
* testsuite/gas/ppc/misalign.l,
* testsuite/gas/ppc/misalign.s: New test.
* testsuite/gas/ppc/misalign2.d,
* testsuite/gas/ppc/misalign2.s: New test.
* testsuite/gas/ppc/ppc.exp: Run them.

6 years agoAutomatic date update in version.in
GDB Administrator [Thu, 8 Feb 2018 00:00:32 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoFix type of values representing optimized out static members
Simon Marchi [Wed, 7 Feb 2018 13:48:14 +0000 (08:48 -0500)] 
Fix type of values representing optimized out static members

As reported here:

  https://sourceware.org/ml/gdb/2018-02/msg00019.html

the type of values representing static members that are optimized out is
wrong.  It currently assigns the type of the containing class rather
than the type of the field.  This patch fixes that.

I found a place in m-static.exp already dealing with optimized out
static members, so I just added some gdb_test there.

gdb/ChangeLog:

* value.c (value_static_field): Assign field type instead of
containing type when returning an optimized out value.

gdb/testsuite/ChangeLog:

* gdb.cp/m-static.exp: Check type of optimized out static
member.

6 years agoRevert "PowerPC PLT speculative execution barriers"
Alan Modra [Mon, 5 Feb 2018 02:47:52 +0000 (13:17 +1030)] 
Revert "PowerPC PLT speculative execution barriers"

This reverts most of commit 1be5d8d3bb.
Left in place are addition of --no-plt-align to some ppc32 ld tests
and the ld.texinfo --no-plt-thread-safe fix.

6 years agoRISC-V: Eliminate spurious error w/ reloc truncated message
Jim Wilson [Wed, 7 Feb 2018 00:53:00 +0000 (16:53 -0800)] 
RISC-V: Eliminate spurious error w/ reloc truncated message

bfd/
* elfnn-riscv.c (riscv_elf_relocate_section): Return TRUE if used
callback to report an error.

6 years agoAutomatic date update in version.in
GDB Administrator [Wed, 7 Feb 2018 00:00:39 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoRemove some $ARCH_read_pc and $ARCH_write_pc
Yao Qi [Tue, 6 Feb 2018 17:31:33 +0000 (17:31 +0000)] 
Remove some $ARCH_read_pc and $ARCH_write_pc

Nowadays, gdbarch_read_pc is called in this way,

  if (gdbarch_read_pc_p (gdbarch))
    pc_val = gdbarch_read_pc (gdbarch, regcache);
  /* Else use per-frame method on get_current_frame.  */
  else if (gdbarch_pc_regnum (gdbarch) >= 0)
    {
      ULONGEST raw_val;

      if (regcache_cooked_read_unsigned (regcache,
 gdbarch_pc_regnum (gdbarch),
 &raw_val) == REG_UNAVAILABLE)

some ports don't have to define its own gdbarch read_pc method if the
pc value is simply a unsigned value from "pc" register.  The same rule
applies to regcache_write_pc.  This patch removes these $ARCH_read_pc
and $ARCH_write_pc functions.

gdb:

2018-02-06  Yao Qi  <yao.qi@linaro.org>

* ft32-tdep.c (ft32_read_pc): Remove.
(ft32_write_pc): Remove.
(ft32_gdbarch_init): Update.
* m32r-tdep.c (m32r_read_pc): Remove.
(m32r_gdbarch_init): Update.
* mep-tdep.c (mep_read_pc): Remove.
(mep_gdbarch_init): Update.
* microblaze-tdep.c (microblaze_write_pc): Remove.
(microblaze_gdbarch_init): Update.
* mn10300-tdep.c (mn10300_read_pc): Remove.
(mn10300_write_pc): Remove.
(mn10300_gdbarch_init): Update.
* moxie-tdep.c (moxie_read_pc): Remove.
(moxie_write_pc): Remove.
(moxie_gdbarch_init): Update.

6 years agoFix PR ld/22263 on SPARC.
Eric Botcazou [Tue, 6 Feb 2018 17:15:56 +0000 (18:15 +0100)] 
Fix PR ld/22263 on SPARC.

This is -fpie -pie generating dynamic relocations in the text section,
simply because no TLS transitions are applied in PIE mode.  The meat
of the patch is to turn calls to bfd_link_pic (info) in TLS-related code
into !bfd_link_executable (info) and there are quite a lot of them...

bfd/
* elfxx-sparc.c (sparc_elf_tls_transition): Turn call to bfd_link_pic
into call to !bfd_link_executable and tidy up.
(_bfd_sparc_elf_check_relocs): Fix formatting and tidy up.
<R_SPARC_TLS_LE_HIX22>: Turn call to bfd_link_pic into call to
!bfd_link_executable.
<R_SPARC_TLS_IE_HI22>: Likewise.
<GOT relocations>: Remove useless code, tidy and merge blocks.
<R_SPARC_TLS_GD_CALL>: Turn call to bfd_link_pic into call to
!bfd_link_executable.
<R_SPARC_WPLT30>: Tidy up.
(_bfd_sparc_elf_gc_mark_hook): Turn call to bfd_link_pic into call
to !bfd_link_executable.
(allocate_dynrelocs): Likewise.
(_bfd_sparc_elf_relocate_section): Fix formatting and tidy up.
<R_SPARC_TLS_GD_HI22>: Merge into...
<R_SPARC_TLS_GD_LO10>: ...this.  Adjust 4th argument in call to
sparc_elf_tls_transition and remove redundant code.
<R_SPARC_TLS_LDM_HI22>: Turn call to bfd_link_pic into call to
!bfd_link_executable.
<R_SPARC_TLS_LDO_HIX22>: Likewise.
<R_SPARC_TLS_LE_HIX22>: Likewise.  Tidy up.
<R_SPARC_TLS_LDM_CALL>: Likewise.
<R_SPARC_TLS_GD_CALL>: Likewise.  Tidy up.
<R_SPARC_TLS_GD_ADD>: Likewise.
<R_SPARC_TLS_LDM_ADD>: Likewise.
<R_SPARC_TLS_LDO_ADD>: Likewise.
<R_SPARC_TLS_IE_LD>: Likewise.
ld/
* testsuite/ld-elf/tls.exp (AFLAGS_PIC): Define on SPARC.
(pr22263-1): Pass AFLAGS_PIC to the assembler.
* testsuite/ld-sparc/tlspie32.s: Add test for other 3 transitions.
* testsuite/ld-sparc/tlspie32.dd: Adjust to above.
* testsuite/ld-sparc/tlspie64.s: Add test for other 3 transitions.
* testsuite/ld-sparc/tlspie64.dd: Adjust to above.

6 years agoTreat OP_F77_UNDETERMINED_ARGLIST as OP_FUNCALL
Yao Qi [Tue, 6 Feb 2018 17:12:12 +0000 (17:12 +0000)] 
Treat OP_F77_UNDETERMINED_ARGLIST as OP_FUNCALL

When I debug some fortran expression parsing, I got

(gdb) set debug expression 1
(gdb) p intvla(5,5,5)
Dump of expression @ 0x205fa80, before conversion to prefix form:
Language fortran, 19 elements, 16 bytes each.
Index                Opcode         Hex Value  String Value
    0          OP_VAR_VALUE  40  (...............
    1    <unknown 31863232>  31863232  .1..............
....
   14             BINOP_REM  5  ................
   15               OP_LONG  38  &...............
   16  OP_F77_UNDETERMINED_ARGLIST  48  0...............
   17             BINOP_MUL  3  ................
   18  OP_F77_UNDETERMINED_ARGLIST  48  0...............
Dump of expression @ 0x205fa80, after conversion to prefix form:
Expression: `Invalid expression
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This patch fixes this problem by handling OP_F77_UNDETERMINED_ARGLIST in
the same way as handling OP_FUNCALL.  With this patch applied, the output
looks better,

(gdb) p intvla (5,5,5)
Dump of expression @ 0x2d75590, before conversion to prefix form:
Language fortran, 19 elements, 16 bytes each.
Index                Opcode         Hex Value  String Value
    0          OP_VAR_VALUE  40  (...............
....
   16  OP_F77_UNDETERMINED_ARGLIST  48  0...............
   17             BINOP_MUL  3  ................
   18  OP_F77_UNDETERMINED_ARGLIST  48  0...............
Dump of expression @ 0x2d75590, after conversion to prefix form:
Expression: `vla_primitives::intvla (5, 5, 5)'
Language fortran, 19 elements, 16 bytes each.

    0  OP_F77_UNDETERMINED_ARGLIST  Number of args: 3
    3    OP_VAR_VALUE          Block @0x297e1c0, symbol @0x297cd50 (intvla)
    7    OP_LONG               Type @0x2976900 (int), value 5 (0x5)
   11    OP_LONG               Type @0x2976900 (int), value 5 (0x5)
   15    OP_LONG               Type @0x2976900 (int), value 5 (0x5)

gdb:

2018-02-06  Yao Qi  <yao.qi@linaro.org>

* expprint.c (print_subexp_standard): Handle
OP_F77_UNDETERMINED_ARGLIST.
(dump_subexp_body_standard): Likewise.

6 years agoFix up one ChangeLog entry date
Yao Qi [Tue, 6 Feb 2018 17:05:59 +0000 (17:05 +0000)] 
Fix up one ChangeLog entry date

The patch was committed on 5th Feb, and the first line of ChangeLog
entry is too long.  The max line length is 74.
https://sourceware.org/gdb/wiki/ContributionChecklist#Properly_Formatted_GNU_ChangeLog

6 years agoImprove the find_nearest_line function for the MIPS target so that it tries harder...
Nick Clifton [Tue, 6 Feb 2018 17:00:25 +0000 (17:00 +0000)] 
Improve the find_nearest_line function for the MIPS target so that it tries harder to find a function name.

PR 22789
* elfxx-mips.c (_bfd_mips_elf_find_nearest_line): If the dwarf
functions failed to find the function name, try the generic elf
find function instead.

6 years agoFix GCC 8's -Wstringop-overflow on bfd/coff-rs6000.c
Sergio Durigan Junior [Tue, 6 Feb 2018 15:37:04 +0000 (10:37 -0500)] 
Fix GCC 8's -Wstringop-overflow on bfd/coff-rs6000.c

GCC 8 will bring a new warning option which will detect possible
overflow and truncation on string manipulation functions.  For more
details, see:

  https://gcc.gnu.org/ml/gcc-patches/2017-08/msg00471.html

While compiling BFD with it, I can see one place on bfd/coff-rs6000.c
where the warning is triggered.  This:

  (void) strncpy (fhdr.magic, XCOFFARMAG, SXCOFFARMAG);

will not include the trailing NUL on fhdr.magic, but that's fine
because it's a magic number.  The fix is trivial: just use memcpy
instead.

OK to push?

2018-02-06  Sergio Durigan Junior  <sergiodj@redhat.com>

* coff-rs6000.c (xcoff_write_archive_contents_old): Use
'memcpy' instead of 'strncpy' when writing the magic number.

6 years agoReplace reachable assertion with a test and return of NULL.
Nick Clifton [Tue, 6 Feb 2018 16:05:13 +0000 (16:05 +0000)] 
Replace reachable assertion with a test and return of NULL.

PR 22793
* readelf.c (find_section): Replace assertion with test and return
of NULL.
(find_section_by_address): Add test of section header table
existance.
(find_section_by_type): Likewise.
(find_section_in_set): Likewise.

6 years agoPrevent attempts to call strncpy with a zero-length field by chacking the size of...
Nick Clifton [Tue, 6 Feb 2018 15:48:29 +0000 (15:48 +0000)] 
Prevent attempts to call strncpy with a zero-length field by chacking the size of debuglink sections.

PR 22794
* opncls.c (bfd_get_debug_link_info_1): Check the size of the
section before attempting to read it in.
(bfd_get_alt_debug_link_info): Likewise.

6 years agoAllow the find_abstract_instance_name() function in the BFD library to also return...
Paul Carroll [Tue, 6 Feb 2018 15:45:31 +0000 (15:45 +0000)] 
Allow the find_abstract_instance_name() function in the BFD library to also return file and line number information.

The nm utility supports -l for using debug information to obtain file and line information for each symbol, if available.
We have a tool that consumes this information and displays it.
This identified a problem with the 'nm' utility.

When a source is compiled with -O2, functions can be inlined.  The compiler also produces an uninlined copy of the function, normally for linking to other object files.
In the case of DWARF2 debug information, the compiler generates debug information to describe a function.  If that function is inlined, the compiler then references that debug information from the inlined and uninlined copies of the routine through the use of the DW_AT_abstract_origin reference.
When nm is used on such a file, it is not able to find file and line information because that information is present in the common debug information and not at each actual implementation of the function.
The 'nm' utility only retrieves the name of the function from the abstract origin debug information and no more.

What I am proposing is to modify the find_abstract_instance_name() function (which I renamed to find_abstract_instance() ) to return the name of the function as well as any file and line information.  The routine is already parsing all of the debug information in the abstract instance, so it is easy to pick up the file and line information at that time. If, for some reason, the file and line information is not present, the routine behaves as before.

For example, if I have a simple test case:

int foo(int j)
{
        if (j < 15)
                j += j << 2;
        else
                j += j << 6;
        return j;
}

int main (int argc,char **argv)
{
        int i = argc;
        i += foo(i);
        return i;
}

If that test case is compiled with -O2 and then 'nm -l' reads that executable, it currently produces this symbol output (ignoring a lot of library symbols):

8048400 T foo
080482e0 T main /scratch/pcarroll/its254/test/mytest.c:12

If I modify 'nm' to return file and line information for abstract instances, it produces the following output:

08048400 T foo  /scratch/pcarroll/its254/test/mytest.c:1
080482e0 T main /scratch/pcarroll/its254/test/mytest.c:12
--------------------------------------------------------------------------
bfd * bfd/dwarf2.c (find_abstract_name): Modified to return file and
line information in addition to name, if they can be found.

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 6 Feb 2018 00:00:23 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoppc64: Fix stwux encoding
Jan Kratochvil [Mon, 5 Feb 2018 19:19:49 +0000 (20:19 +0100)] 
ppc64: Fix stwux encoding

With gcc-8.0.1-0.9.fc28.x86_64 I get:

../../gdb/rs6000-tdep.c: In function 'CORE_ADDR skip_prologue(gdbarch*, CORE_ADDR, CORE_ADDR, rs6000_framedata*)':
../../gdb/rs6000-tdep.c:1911:34: error: bitwise comparison always evaluates to false [-Werror=tautological-compare]
       else if ((op & 0xfc1f016a) == 0x7c01016e)
                ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~

https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/com.ibm.aix.alangref/idalangref_stwux_stux_instrs.htm
says
bit 21 - 30 = 183
Those are bits 1..10 in normal bit order: 183<<1 = 0x16e

gdb/ChangeLog
2018-02-04  Jan Kratochvil  <jan.kratochvil@redhat.com>

* rs6000-tdep.c (skip_prologue): Fix stwux encoding.

6 years ago[PR22764][LD][AARCH64]Allow R_AARCH64_ABS16 and R_AARCH64_ABS32 against absolution...
Renlin Li [Sat, 3 Feb 2018 13:18:17 +0000 (13:18 +0000)] 
[PR22764][LD][AARCH64]Allow R_AARCH64_ABS16 and R_AARCH64_ABS32 against absolution symbol or undefine symbol in shared object.

The assumption that R_AARCH64_ABS16 and R_AARCH64_ABS32 relocation in LP64 abi
will be used to generate an address does not hold for absolute symbol.
In this case, it is a value fixed at static linking time.

The condition to check the relocations is relax to allow absolute symbol and
undefined symbol case.

bfd/

2018-02-05  Renlin Li  <renlin.li@arm.com>

PR ld/22764
* elfnn-aarch64.c (elfNN_aarch64_check_relocs): Relax the
R_AARCH64_ABS32 and R_AARCH64_ABS16 for absolute symbol. Apply the
check for writeable section as well.

ld/

2018-02-05  Renlin Li  <renlin.li@arm.com>

PR ld/22764
* testsuite/ld-aarch64/emit-relocs-258.s: Define symbol as an address.
* testsuite/ld-aarch64/emit-relocs-259.s: Likewise.
* testsuite/ld-aarch64/aarch64-elf.exp: Run new test.
* testsuite/ld-aarch64/pr22764.s: New.
* testsuite/ld-aarch64/pr22764.d: New.

6 years agoRemove myself as a write-after-approval GDB maintainer.
Antoine Tremblay [Mon, 5 Feb 2018 16:38:08 +0000 (11:38 -0500)] 
Remove myself as a write-after-approval GDB maintainer.

Since I'll be leaving Ericsson.

gdb/
* MAINTAINERS (Write After Approval): Remove Antoine Tremblay.

6 years agox86: Remove the unused _GLOBAL_OFFSET_TABLE_
H.J. Lu [Mon, 5 Feb 2018 16:38:16 +0000 (08:38 -0800)] 
x86: Remove the unused _GLOBAL_OFFSET_TABLE_

Since _GLOBAL_OFFSET_TABLE_ may be referenced implicitly on x86,
checking ref_regular_nonweak leaves the unused _GLOBAL_OFFSET_TABLE_
in output.  This patch checks explicit GOT references instead.

ld-i386/discarded1.s and ld-x86-64/discarded1.s are updated to avoid
linker optimization which removes GOT references.

bfd/

PR ld/22782
* elf32-i386.c (elf_i386_check_relocs): Set got_referenced if
_GLOBAL_OFFSET_TABLE_ is referenced or GOT is needed to resolve
undefined weak symbol to 0.
* elf64-x86-64.c (elf_x86_64_check_relocs): Set got_referenced
if _GLOBAL_OFFSET_TABLE_ is referenced.
* elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Check
got_referenced instead of ref_regular_nonweak.  Remove the
unused _GLOBAL_OFFSET_TABLE_ from symbol table.
* elfxx-x86.h (elf_x86_link_hash_table): Add got_referenced.

ld/

PR ld/22782
* testsuite/ld-i386/discarded1.s: Replace mov with div.
* testsuite/ld-x86-64/discarded1.s: Likewise.
* testsuite/ld-i386/i386.exp: Run pr22782.
* testsuite/ld-i386/load1-nacl.d: Updated for removing
_GLOBAL_OFFSET_TABLE_ from output.
* testsuite/ld-i386/load1.d: Likewise.
* testsuite/ld-x86-64/load1a-nacl.d: Likewise.
* testsuite/ld-x86-64/load1a.d: Likewise.
* testsuite/ld-x86-64/load1b-nacl.d: Likewise.
* testsuite/ld-x86-64/load1b.d: Likewise.
* testsuite/ld-i386/pr22782.d: New file.
* testsuite/ld-i386/pr22782.s: Likewise.
* testsuite/ld-x86-64/pr22782.s: Likewise.
* testsuite/ld-x86-64/pr22782a.d: Likewise.
* testsuite/ld-x86-64/pr22782b.d: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run pr22782a and pr22782b.

6 years agoUse visitors for make_gdb_type
Alan Hayward [Mon, 5 Feb 2018 16:33:04 +0000 (16:33 +0000)] 
Use visitors for make_gdb_type

Remove the make_gdb_type functions from the tdesc_type_ classes.
Replace with a static make_gdb_type function that uses a element
visitor called gdb_type_creator.

gdb/
* target-descriptions.c (tdesc_element_visitor) Add empty implementations.
(tdesc_type): Move make_gdb_type from here.
(tdesc_type_builtin): Likewise.
(tdesc_type_vector): Likewise.
(tdesc_type_with_fields): Move make_gdb_type_ functions from here.
(make_gdb_type_struct): Move from tdesc_type_with_fields.
(make_gdb_type_union): Likewise.
(make_gdb_type_flags): Likewise.
(make_gdb_type_enum): Likewise.
(make_gdb_type): New function.
(tdesc_register_type): Use static make_gdb_type.

6 years agoRISC-V/GAS: Correct an `expr' global shadowing error for pre-4.8 GCC
Maciej W. Rozycki [Mon, 5 Feb 2018 14:05:51 +0000 (14:05 +0000)] 
RISC-V/GAS: Correct an `expr' global shadowing error for pre-4.8 GCC

Correct a commit f0531ed6a429 ("Compress loads/stores with implicit 0
offset.") regression and remove a `-Wshadow' compilation error:

cc1: warnings being treated as errors
.../gas/config/tc-riscv.c: In function 'riscv_handle_implicit_zero_offset':
.../gas/config/tc-riscv.c:1194: error: declaration of 'expr' shadows a global declaration
.../gas/expr.h:180: error: shadowed declaration is here
make[4]: *** [tc-riscv.o] Error 1

which for versions of GCC before 4.8 prevents GAS for RISC-V targets
from being built.  See also GCC PR c/53066.

gas/
* config/tc-riscv.c (riscv_handle_implicit_zero_offset): Rename
`expr' parameter to `ep'.

6 years agoRISC-V/BFD: Correct a missing initializer error with pre-4.7 GCC
Maciej W. Rozycki [Mon, 5 Feb 2018 14:05:51 +0000 (14:05 +0000)] 
RISC-V/BFD: Correct a missing initializer error with pre-4.7 GCC

Correct a commit 9d06997adb88 ("RISC-V: Relax RISCV_PCREL_* to
RISCV_GPREL_*") regression and remove a `-Wmissing-field-initializers'
compilation error:

cc1: warnings being treated as errors
.../bfd/elfnn-riscv.c: In function '_bfd_riscv_relax_pc':
.../bfd/elfnn-riscv.c:3117: error: missing initializer
.../bfd/elfnn-riscv.c:3117: error: (near initialization for 'hi_reloc.hi_addend')
make[4]: *** [elf64-riscv.lo] Error 1

which for versions of GCC before 4.7 prevents support for RISC-V targets
from being built.  See also GCC PR c/36750.

bfd/
* elfnn-riscv.c (_bfd_riscv_relax_pc): Use `memset' to
initialize `hi_reloc'.

6 years agoMIPS/BFD: Correctly report unsupported `.reginfo' section size
Maciej W. Rozycki [Mon, 5 Feb 2018 14:00:21 +0000 (14:00 +0000)] 
MIPS/BFD: Correctly report unsupported `.reginfo' section size

Report an error when an unsupported `.reginfo' section size is found in
`_bfd_mips_elf_section_processing', removing an assertion that triggers
at elfxx-mips.c:7105 in GAS when assembling input like:

.section .reginfo
.word 0xdeadbeef

and in `objcopy --rename-section' when renaming an incorrectly sized
section to `.reginfo'.

bfd/
* elfxx-mips.c (_bfd_mips_elf_section_processing): For
SHT_MIPS_REGINFO sections don't assert the correct size and
report an error instead.

binutils/
* testsuite/binutils-all/mips/mips-reginfo.d: New test.
* testsuite/binutils-all/mips/mips-reginfo-n32.d: New test.
* testsuite/binutils-all/mips/mips-reginfo.s: New test source.
* testsuite/binutils-all/mips/mips.exp: Run the new tests.

gas/
* testsuite/gas/mips/reginfo-2.d: New test.
* testsuite/gas/mips/reginfo-2-n32.d: New test.
* testsuite/gas/mips/reginfo-2.l: New test stderr output.
* testsuite/gas/mips/reginfo-2.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.

6 years agoELF/BFD: Propagate the return status from backend section processing
Maciej W. Rozycki [Mon, 5 Feb 2018 14:00:21 +0000 (14:00 +0000)] 
ELF/BFD: Propagate the return status from backend section processing

Fix the issue of any failure from `->elf_backend_section_processing'
not being propagated by `_bfd_elf_write_object_contents'.  The MIPS
`_bfd_mips_elf_section_processing' handler can actually potentially
fail, however the caller currently ignores that.

bfd/
* elf.c (_bfd_elf_write_object_contents): Propagate a failure
status from `->elf_backend_section_processing'.

6 years agobinutils/testsuite: Support stderr options with `run_dump_test'
Maciej W. Rozycki [Mon, 5 Feb 2018 14:00:21 +0000 (14:00 +0000)] 
binutils/testsuite: Support stderr options with `run_dump_test'

Add support for the `error', `error_output', `warning' and
`warning_output' options for `run_dump_test' input files, based on the
version of the procedure in ld/testsuite/lib/ld-lib.exp and providing
compatible semantics.  These options apply to PROG under test and let
test cases specify output expected on stderr as well as express a
requirement for PROG to exit unsuccessfully.  Messages to match against
can be supplied either inline or fetched from a named file.  Update
procedure description in the introductory comment accordingly.

As the exit status from `remote_exec' is regrettably lost in our default
implementation of `binutils_run', which is user-overridable, avoid
changing this procedure's API and use a global `binutils_run_status'
variable to pass the status up to the caller, similarly to how
`binutils_run_failed' is handled.  Document the new variable in the
respective introductory comments.

binutils/
* testsuite/config/default.exp (binutils_run): Document
`binutils_run_status'.
* testsuite/lib/utils-lib.exp (default_binutils_run): Likewise,
and set it.
(run_dump_test): Add `error', `error_output', `warning' and
`warning_output' options.  Update documentation accordingly.

6 years agoUpdated Brazillian portuguese and Russian translation
Nick Clifton [Mon, 5 Feb 2018 13:09:15 +0000 (13:09 +0000)] 
Updated Brazillian portuguese and Russian translation

6 years agoAlign natural-format register values to the same column
Ruslan Kabatsayev [Fri, 19 Jan 2018 06:15:39 +0000 (09:15 +0300)] 
Align natural-format register values to the same column

Currently, commands such as "info reg", "info all-reg", as well as register
window in the TUI print badly aligned columns, like here:

eax            0x1      1
ecx            0xffffd3e0       -11296
edx            0xffffd404       -11260
ebx            0xf7fa5ff4       -134586380
esp            0xffffd390       0xffffd390
ebp            0xffffd3c8       0xffffd3c8
esi            0x0      0
edi            0x0      0
eip            0x8048b60        0x8048b60 <main+16>
eflags         0x286    [ PF SF IF ]
cs             0x23     35
ss             0x2b     43
ds             0x2b     43
es             0x2b     43
fs             0x0      0
gs             0x63     99

After this patch, these commands print the third column values consistently
aligned one under another, provided the second column is not too long.
Originally, the third column was (attempted to be) aligned using a simple tab
character. This patch changes the alignment to spaces only. The tests checking
the output and expecting the single tab have been fixed in a previous patch, so
this change doesn't break any.

gdb/ChangeLog:

* infcmd.c (default_print_one_register_info): Align natural-format
column values consistently one under another.
(pad_to_column): New function.

6 years agoMove comment in gdb/dwarf2read.c::dwarf2_physname
Joel Brobecker [Mon, 5 Feb 2018 04:45:06 +0000 (23:45 -0500)] 
Move comment in gdb/dwarf2read.c::dwarf2_physname

This commit just moves a comment right next to where it is actually
relevant. No actual code change.

gdb/ChangeLog:

        * dwarf2read.c (dwarf2_physname): Move commment.

Tested by rebuilding GDB.

6 years agoAutomatic date update in version.in
GDB Administrator [Mon, 5 Feb 2018 00:00:32 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agold/testsuite: Replace -Sw with -SW for readelf
H.J. Lu [Sun, 4 Feb 2018 15:51:10 +0000 (07:51 -0800)] 
ld/testsuite: Replace -Sw with -SW for readelf

-Sw is a typo.  It should be -SW for readelf.

* testsuite/ld-i386/lea1d.d: Replace -Sw with -SW.
* testsuite/ld-i386/lea1e.d: Likewise.
* testsuite/ld-i386/lea1f.d: Likewise.
* testsuite/ld-x86-64/lea1g.d: Likewise.
* testsuite/ld-x86-64/lea1h.d: Likewise.
* testsuite/ld-x86-64/lea1i.d: Likewise.
* testsuite/ld-x86-64/lea1j.d: Likewise.
* testsuite/ld-x86-64/lea1k.d: Likewise.
* testsuite/ld-x86-64/lea1l.d: Likewise.

6 years agoAutomatic date update in version.in
GDB Administrator [Sun, 4 Feb 2018 00:01:03 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 years agogdb/testsuite: Remove use of dejagnu cleanup proc
Andrew Burgess [Fri, 2 Feb 2018 12:51:10 +0000 (12:51 +0000)] 
gdb/testsuite: Remove use of dejagnu cleanup proc

The 'cleanup' proc has been removed from dejagnu (Feb 15 2016).  The
proc has not done anything useful since at least 2001 so removing
these calls should be harmless.

gdb/testsuite/ChangeLog:

* config/sid.exp (gdb_target_sid): Remove use of cleanup.
* config/sim.exp (gdb_target_sim): Remove use of cleanup.

6 years agoRemove PROVIDE() qualifiers from definition of __CTOR_LIST__ and __DTOR_LIST__ symbol...
Nick Clifton [Sat, 3 Feb 2018 13:11:35 +0000 (13:11 +0000)] 
Remove PROVIDE() qualifiers from definition of __CTOR_LIST__ and __DTOR_LIST__ symbols in PE linker scripts.

PR 22762
* scripttempl/pe.sc: Remove PROVIDE()s from __CTOR_LIST__ and
__DTOR_LIST__ symbols.  Add a comment explaining why this is
necessary.
* scripttemp/pep.sc: Likewise.
* ld.texinfo (PROVIDE): Add a note about the effect of common
symbols.

6 years agoDisable -shared support in nios2-elf-ld.
Sandra Loosemore [Sat, 3 Feb 2018 07:00:02 +0000 (23:00 -0800)] 
Disable -shared support in nios2-elf-ld.

2018-02-03  Sandra Loosemore  <sandra@codesourcery.com>

* emulparams/nios2elf.sh (GENERATE_SHLIB_SCRIPT): Don't set.

6 years agoAdd support for DWARF-4 line number tables.
Cary Coutant [Sat, 3 Feb 2018 01:44:27 +0000 (17:44 -0800)] 
Add support for DWARF-4 line number tables.

Reads the maximum_operations_per_instruction field, added in DWARF-4 to the
line number program header.

gold/
* PR gold/22776
* dwarf_reader.cc (Sized_dwarf_line_info::read_header_prolog): Add
support for DWARF-4 line number tables.
* dwarf_reader.h (Sized_dwarf_line_info::max_ops_per_insn): New field.

6 years agoAutomatic date update in version.in
GDB Administrator [Sat, 3 Feb 2018 00:00:31 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoRISC-V: Fix --wrap and relaxation conflict.
Jim Wilson [Fri, 2 Feb 2018 20:43:09 +0000 (12:43 -0800)] 
RISC-V: Fix --wrap and relaxation conflict.

bfd/
PR ld/22756
* elfnn-riscv.c (riscv_relax_delete_bytes): New parameter link_info.
If link_info->wrap_hash, check for a duplicate symbol and ignore.
(_bfd_riscv_relax_call, bfd_riscv_relax_lui, _bfd_riscv_relax_tls_le):
Pass new argument to riscv_relax_delete_bytes.
(_bfd_riscv_relax_align, _bfd_riscv_relax_delete): Likewise.  Remove
ATTRIBUTE_UNUSED from link_info parameter.

6 years agoMI: Allow non-raw varobj evaluation
Leszek Swirski via gdb-patches [Fri, 2 Feb 2018 04:23:28 +0000 (23:23 -0500)] 
MI: Allow non-raw varobj evaluation

Make the MI variable object expression evaluation, with the
-var-evaluate-expression command, recursively call pretty printers, to
match the output of normal expression printing.

Consider the following code:

        struct Foo { int val; };
        struct Wrapper { Foo foo; };

        int main() {
                Wrapper w;
                w.foo.val = 23;
        }

and this pretty printer file:

        import gdb.printing

        class FooPrinter:
          def __init__(self, val):
            self.val = val
          def to_string(self):
            return "Foo" + str(self.val["val"])

        class WrapperPrinter:
          def __init__(self, val):
            self.val = val
          def to_string(self):
            return self.val["foo"]

        test_printer = gdb.printing.RegexpCollectionPrettyPrinter("test")
        test_printer.add_printer('Foo', '^Foo$', FooPrinter)
        test_printer.add_printer('Wrapper', '^Wrapper$', WrapperPrinter)

        gdb.printing.register_pretty_printer(None, test_printer)

Setting a breakpoint at the end of the function, we call the following commands:

        -enable-pretty-printing
        ^done

        -var-create var_w @ w
        ^done,name="var_w",numchild="0",value="{val = 23}",type="Wrapper",dynamic="1",has_more="0"
        -var-create var_w_foo @ w.foo
        ^done,name="var_w_foo",numchild="0",value="Foo23",type="Foo",dynamic="1",has_more="0"

        -var-evaluate-expression var_w
        ^done,value="{val = 23}"
        -var-evaluate-expression var_w_foo
        ^done,value="Foo23"

        -data-evaluate-expression w
        ^done,value="Foo23"
        -data-evaluate-expression w.foo
        ^done,value="Foo23"

So, in the -var-evaluate-expression var_w case, we print the "raw" value
of w.foo, while in the -data-evaluate-expression w case, we print the
pretty printed w.foo value. After this patch, all of the above print
"Foo23".

gdb/ChangeLog:

* varobj.c (varobj_formatted_print_options): Allow recursive
pretty printing if pretty printing is enabled.

gdb/testsuite/ChangeLog:

* gdb.python/py-prettyprint.c
(struct to_string_returns_value_inner,
struct to_string_returns_value_wrapper): New.
(main): Add tsrvw variable.
* gdb.python/py-prettyprint.py (ToStringReturnsValueInner,
ToStringReturnsValueWrapper): New classes.
(register_pretty_printers): Register new pretty-printers.
* gdb.python/py-prettyprint.exp (run_lang_tests): Test printing
recursive pretty printer.
* gdb.python/py-mi.exp: Likewise.

6 years agobinutils/riscv: Register names in DWARF output
Andrew Burgess [Fri, 2 Feb 2018 15:25:31 +0000 (15:25 +0000)] 
binutils/riscv: Register names in DWARF output

Adds a register name table for RiscV so that objdump and readelf can
both use better register names.

binutils/ChangeLog:

* dwarf.c (dwarf_regnames_riscv): New register name table.
(init_dwarf_regnames_riscv): New function.
(init_dwarf_regnames): Add call to initialise RiscV register
names.
* dwarf.h (init_dwarf_regnames_riscv): Declare.
* objdump.c (dump_dwarf): Add call to initialise RiscV register
names.

6 years agoLD/testsuite: Pass $AFLAGS_PIC to GAS for PIC assembly
Maciej W. Rozycki [Fri, 2 Feb 2018 18:08:04 +0000 (18:08 +0000)] 
LD/testsuite: Pass $AFLAGS_PIC to GAS for PIC assembly

Add $AFLAGS_PIC flags for PIC assembly to a number of tests missing them
and remove `tic6x-*-*' XFAIL annotations from them, previously added to
paper over:

.../ld-new: warning: generating a shared library containing non-PID code

error messages produced due to `-mpic -mpid=near' GAS options having not
been used.  Such errors now do not happen anymore, removing:

XFAIL: Build shared library for pr14170
XFAIL: PR ld/21703 shared
XFAIL: Build shared library for broken linker script test
XFAIL: Build pr17068.so
XFAIL: -Bsymbolic-functions
XFAIL: Build pr20995.so
XFAIL: Build pr22374 shared library

with `tic6x-elf' and `tic6x-uclinux' targets.  These tests now pass all
except for:

FAIL: PR ld/21703 shared

which is now due to a different reason, as follows:

extra regexps in .../ld/testsuite/ld-elf/pr21703-shared.sd starting with "^Symbol table '\.dynsym' contains [0-9]+ entries:$"
EOF from dump.out
FAIL: PR ld/21703 shared

The addition of $AFLAGS_PIC requires the affected test cases to use the
`list' command rather than `{}' characters to create a list, to avoid
the quoting property `{}' also have in TCL.  Consequently the change is
slightly more extensive than it could otherwise be.

ld/
* testsuite/ld-elf/shared.exp: Add $AFLAGS_PIC throughout to PIC
assembly builds where missing and remove `tic6x-*-*' XFAIL
markings accordingly.

6 years agoPowerPC64, don't relocate nops
Alan Modra [Fri, 2 Feb 2018 06:25:21 +0000 (16:55 +1030)] 
PowerPC64, don't relocate nops

This fixes a "bug" in that nops emitted as part of code optimization
were being relocated.  As it happens the relocation value was always
zero so the nop wasn't changed.  Whew!  I've also moved the use of
"howto" later since I was caught out in some recent code changes with
the howto not matching r_type.

* elf64-ppc.c (ppc64_elf_relocate_section): Don't relocate nops
emitted for toc sequence optimization.  Set and use "howto" later.

6 years agoDo not classify C struct members as a filename
Leszek Swirski [Thu, 25 Jan 2018 16:20:47 +0000 (16:20 +0000)] 
Do not classify C struct members as a filename

There is existing logic in C/C++ expression parsing to avoid classifying
names as a filename when they are a field on the this object. This
change extends this logic to also avoid classifying names after a
struct-op (-> or .) as a filename, which otherwise causes a syntax
error.

Thus, it is now possible in the file

    #include <map>
    struct D {
        void map();
    }
    D d;

to call

    (gdb) print d.map()

where previously this would have been a syntax error.

Tested on gdb.cp/*.exp

gdb/ChangeLog:

        * c-exp.y (lex_one_token, classify_name, yylex): Don't classify
        names after a structop as a filename

gdb/testsuite/ChangeLog:

        * gdb.cp/filename.cc, gdb.cp/filename.exp: Test that member
        functions with the same name as an include file are parsed
        correctly.

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 2 Feb 2018 00:00:29 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoRewrite arm_record_coproc_data_proc and arm_record_data_proc_misc_ld_str
Yao Qi [Thu, 1 Feb 2018 15:51:01 +0000 (15:51 +0000)] 
Rewrite arm_record_coproc_data_proc and arm_record_data_proc_misc_ld_str

When I triage some reverse debugging test fails on arm-linux, I find
arm_record_coproc_data_proc and arm_record_data_proc_misc_ld_str is not
friendly to instruction encoding on ARM ARM.  This patch rewrites them, in
a way match more closely to the manual.

gdb:

2018-02-01  Yao Qi  <yao.qi@linaro.org>

* arm-tdep.c (arm_record_data_proc_misc_ld_str): Rewrite it.
(arm_record_coproc_data_proc): Likewise.

6 years agoset ret signed in arm_record_extension_space
Yao Qi [Thu, 1 Feb 2018 15:09:44 +0000 (15:09 +0000)] 
set ret signed in arm_record_extension_space

Variable 'ret' should be int rather than unsigned, as it can be -1.

gdb:

2018-02-01  Yao Qi  <yao.qi@linaro.org>

* arm-tdep.c (arm_record_extension_space): Change ret to signed.

6 years agoFix gdb.base/attach.exp fails when gdb is configured --with-sysroot=/
Yao Qi [Thu, 1 Feb 2018 14:50:23 +0000 (14:50 +0000)] 
Fix gdb.base/attach.exp fails when gdb is configured --with-sysroot=/

I see some test fails in gdb.base/attach.exp when gdb is configured
--with-sysroot=/.

FAIL: gdb.base/attach.exp: attach2, with no file
FAIL: gdb.base/attach.exp: load file manually, after attach2 (re-read) (got interactive prompt)
FAIL: gdb.base/attach.exp: attach when process' a.out not in cwd

If gdb is configured this way, sysroot is "/" in default, and if binfile
is a absolute path, the regexp pattern $sysroot$escapedbinfile is
incorrect.

There are different ways to fix it, but I don't want to complicate the
test, so I choose this naive way.

gdb/testsuite:

2018-02-01  Yao Qi  <yao.qi@linaro.org>

* gdb.base/attach.exp (do_attach_tests): Set sysroot to
"\[^\r\n\]*".

6 years agoFix compile time warnings building the binutils with clang.
Simon Marchi [Thu, 1 Feb 2018 13:21:41 +0000 (13:21 +0000)] 
Fix compile time warnings building the binutils with clang.

bfdI would like to fix instances of the following warning, when building
with clang with no special CFLAGS other than -g3 -O0.

/home/emaisin/src/binutils-gdb/bfd/elflink.c:5425:45: error: performing pointer arithmetic on a null pointer has undefined behavior [-Werror,-Wnull-pointer-arithmetic]
    return (struct elf_link_hash_entry *) 0 - 1;
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^

Replacing those with "(struct elf_link_hash_entry *) -1" gets rid of the
warning.  I wanted to check that it didn't change the resulting code, so
I tried to build this:

  $ cat test.c
  int *before()
  {
          return (int *) 0 - 1;
  }

  int *after()
  {
          return (int *) - 1;
  }

  $ gcc -c test.c -g
  $ objdump -d test.o

  test.o:     file format elf64-x86-64

  Disassembly of section .text:

  0000000000000000 <before>:
     0:   55                      push   %rbp
     1:   48 89 e5                mov    %rsp,%rbp
     4:   48 c7 c0 fc ff ff ff    mov    $0xfffffffffffffffc,%rax
     b:   5d                      pop    %rbp
     c:   c3                      retq

  000000000000000d <after>:
     d:   55                      push   %rbp
     e:   48 89 e5                mov    %rsp,%rbp
    11:   48 c7 c0 ff ff ff ff    mov    $0xffffffffffffffff,%rax
    18:   5d                      pop    %rbp
    19:   c3                      retq

This shows that the previous code doesn't actually return -1 as the
function documentation says, but the new one does, so it's kind of a
bugfix.

bfd * elf64-ppc.c (ppc64_elf_archive_symbol_lookup): Avoid pointer
arithmetic on NULL pointer.
* elflink.c (_bfd_elf_archive_symbol_lookup,
elf_link_add_archive_symbols): Likewise.

ld * ldexp.c (fold_name, exp_fold_tree_1): Avoid pointer arithmetic
on NULL pointer.

6 years agoPR22769, crash when running 32-bit objdump on corrupted file
Alan Modra [Thu, 1 Feb 2018 07:31:00 +0000 (18:01 +1030)] 
PR22769, crash when running 32-bit objdump on corrupted file

PR 22769
* objdump.c (load_specific_debug_section): Check for overflow
when adding one to section size for a string section terminator.

6 years agoAutomatic date update in version.in
GDB Administrator [Thu, 1 Feb 2018 00:00:21 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoFix testsuite/ld-elf/pr21964-5.c
H.J. Lu [Wed, 31 Jan 2018 20:42:28 +0000 (12:42 -0800)] 
Fix testsuite/ld-elf/pr21964-5.c

Mark my_var as used.  Otherwise it fails at -O2.

* testsuite/ld-elf/pr21964-5.c (my_var): Mark as used.

6 years agoFix for prologue processing on PowerPC
Nikola Prica [Wed, 31 Jan 2018 18:23:00 +0000 (19:23 +0100)] 
Fix for prologue processing on PowerPC

One of conditions in skip_prologue() was never visited if there was mflr
instruction that moves the link register to a register different than r0.
This condition expects non shifted value of `lr_reg`. Previously offset
of link register was never saved for registers different than r0.

gdb/ChangeLog:

2018-01-31  Nikola Prica  <nikola.prica@rt-rk.com>

* rs6000-tdep.c (skip_prologue): Remove shifting for lr_reg and
assign shifted lr_reg to fdata->lr_register when lr_reg is set.

gdb/testsuite/ChangeLog:

2018-01-31  Nikola Prica  <nikola.prica@rt-rk.com>

* gdb.arch/powerpc-prologue-frame.s: New file.
* gdb.arch/powerpc-prologue-frame.c: Likewise.
* gdb.arch/powerpc-prologue-frame.exp: Likewise.

6 years agoLD/testsuite: Fix a typo s/scrip/script/ in `note-3.so' build test name
Maciej W. Rozycki [Wed, 31 Jan 2018 14:47:12 +0000 (14:47 +0000)] 
LD/testsuite: Fix a typo s/scrip/script/ in `note-3.so' build test name

ld/
* testsuite/ld-elf/shared.exp: Fix a typo s/scrip/script/.

6 years agoMIPS/LD/testsuite: Correct dynamic links with VR4100, VR4300 and VR5000
Maciej W. Rozycki [Wed, 31 Jan 2018 14:47:12 +0000 (14:47 +0000)] 
MIPS/LD/testsuite: Correct dynamic links with VR4100, VR4300 and VR5000

Correct LD test suite failures with VR4100, VR4300 and VR5000 bare metal
MIPS/ELF targets which do not default to linking with shared libraries,
which leads to link failures like:

.../ld/ld-new: cannot find -lcomm-data
FAIL: Common symbol override test

or:

.../ld/ld-new: attempted static link of dynamic object `tmpdir/pr14170.so'
FAIL: PR ld/14170

removing:

FAIL: Build pr22471b.so
FAIL: Build pr22471
FAIL: Build pr22649-2b.so
FAIL: Build pr22649-2d.so
FAIL: Build pr22150
FAIL: PR ld/14170
FAIL: --gc-sections with __gxx_personality

test failures.

ld/
* testsuite/ld-elf/comm-data.exp: Pass `-call_shared' to links
involving a shared library for `mips*vr4100*-*-elf*',
`mips*vr4300*-*-elf*' and `mips*vr5000*-*-elf*' targets.
* testsuite/ld-elf/provide-hidden.exp: Likewise.
* testsuite/ld-elf/shared.exp: Likewise.
* testsuite/ld-gc/gc.exp: Likewise.
* testsuite/ld-mips-elf/comm-data.exp: Likewise.

6 years agoLD/testsuite: Move ELF shared library tests from elf.exp to shared.exp
Maciej W. Rozycki [Wed, 31 Jan 2018 14:47:12 +0000 (14:47 +0000)] 
LD/testsuite: Move ELF shared library tests from elf.exp to shared.exp

Move those ELF shared library tests that are in ld-elf/elf.exp over to
ld-elf/shared.exp, to keep them all together and make the maintenance of
extra flags needed with some targets and shared library builds easier,
and also removing the need for the large:

if { [check_shared_lib_support] } then {
    [...]
}

conditional block and consequently reducing indentation, which always
helps with TCL code.  No functional change, except for the order of
individual test case execution which has changed accordingly, i.e. the
test results are shuffled.

ld/
* testsuite/ld-elf/elf.exp: Move shared library tests over to...
* testsuite/ld-elf/shared.exp: ... here.

6 years agogdb: Fix remote-sim/MinGW/Darwin builds
Pedro Alves [Wed, 31 Jan 2018 13:50:34 +0000 (13:50 +0000)] 
gdb: Fix remote-sim/MinGW/Darwin builds

(Add missing ChangeLog entry)

The recent commit e671cd59 ("Per-inferior target_terminal state, fix
PR gdb/13211, more") missed adjusting a few targets to the new
target_ops->to_interrupt interface, breaking the build for those
targets.  This fixes it.

Note: remote-sim doesn't really support async execution, so I don't
think gdbsim_interrupt is ever reached via target_interrupt.  (It is
reached via gdbsim_cntrl_c though).

The inflow.c changes are a bit ugly, but they're just doing what other
parts of the file already do to handle the same missing functions.
Targets that don't have 'kill', like mingw have their own
target_ops->to_interrupt implementation, so it's fine to make
child_interrupt be a nop.

gdb/ChangeLog:
2018-01-31  Pedro Alves  <palves@redhat.com>

* darwin-nat.c (darwin_interrupt): Remove ptid_t parameter.
* inflow.c (child_terminal_save_inferior): Wrap reference to
tcgetpgrp in HAVE_TERMIOS_H.
(child_interrupt, child_pass_ctrlc): Wrap references to signal in
_WIN32.
* remote-sim.c (gdbsim_interrupt): Remove ptid_t parameter and
always iterate over all inferiors.
(gdbsim_cntrl_c): Adjust.
* windows-nat.c (windows_interrupt): Remove 'ptid_t' parameter.

6 years agogdb: Fix remote-sim/MinGW/Darwin builds
Pedro Alves [Wed, 31 Jan 2018 13:45:06 +0000 (13:45 +0000)] 
gdb: Fix remote-sim/MinGW/Darwin builds

The recent commit e671cd59 ("Per-inferior target_terminal state, fix
PR gdb/13211, more") missed adjusting a few targets to the new
target_ops->to_interrupt interface, breaking the build for those
targets.  This fixes it.

Note: remote-sim doesn't really support async execution, so I don't
think gdbsim_interrupt is ever reached via target_interrupt.  (It is
reached via gdbsim_cntrl_c though).

The inflow.c changes are a bit ugly, but they're just doing what other
parts of the file already do to handle the same missing functions.
Targets that don't have 'kill', like mingw have their own
target_ops->to_interrupt implementation, so it's fine to make
child_interrupt be a nop.

gdb/ChangeLog:
2018-01-31  Pedro Alves  <palves@redhat.com>

* darwin-nat.c (darwin_interrupt): Remove ptid_t parameter.
* inflow.c (child_terminal_save_inferior): Wrap reference to
tcgetpgrp in HAVE_TERMIOS_H.
(child_interrupt, child_pass_ctrlc): Wrap references to signal in
_WIN32.
* remote-sim.c (gdbsim_interrupt): Remove ptid_t parameter and
always iterate over all inferiors.
(gdbsim_cntrl_c): Adjust.
* windows-nat.c (windows_interrupt): Remove 'ptid_t' parameter.

6 years agobfd_elf_define_start_stop: Fix check
Michael Matz [Wed, 31 Jan 2018 13:26:46 +0000 (14:26 +0100)] 
bfd_elf_define_start_stop: Fix check

We really need to check for a dynamic def, not only a ref.
See added testcase.

bfd/
* elflink.c (bfd_elf_define_start_stop): Fix check of
def_dynamic.

ld/
* testsuite/ld-elf/pr21964-5.c: New test.
* testsuite/ld-elf/shared.exp: Run it.

6 years agoCheck if __start/__stop symbols are referenced by shared objects
H.J. Lu [Wed, 31 Jan 2018 13:10:40 +0000 (05:10 -0800)] 
Check if __start/__stop symbols are referenced by shared objects

Define  __start/__stop symbols if they are referenced by shared objects,
not if they are also defined in shared objects.

bfd/

PR ld/21964
* elflink.c (bfd_elf_define_start_stop): Check if __start and
__stop symbols are referenced by shared objects.

ld/

PR ld/21964
* testsuite/ld-elf/pr21964-4.c: New file.
* testsuite/ld-elf/shared.exp: Run pr21964-4 test on Linux.

6 years ago(Ada) Add gdb-mi support for stopping at start of exception handler.
Xavier Roirand [Fri, 26 Jan 2018 10:13:11 +0000 (11:13 +0100)] 
(Ada) Add gdb-mi support for stopping at start of exception handler.

Following my previous commit which add support for stopping at start of
exception handler, this commit adds required gdb-mi support for this
feature.

gdb/ChangeLog:

    * mi/mi-cmd-catch.c (mi_cmd_catch_handlers): New function.
    * mi/mi-cmds.c (mi_cmds): Add catch-handlers command.
    * mi/mi-cmds.h (mi_cmd_catch_handlers): Add external declaration.
    * NEWS: Document "-catch-handlers" command.

gdb/doc/ChangeLog:

    * gdb.texinfo (Ada Exception gdb/mi Catchpoints): Add
    documentation for new "-catch-handlers" command.

gdb/testsuite/ChangeLog:

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

Tested on x86_64-linux.

6 years ago(Ada) C++fy conditional string when catching exception.
Xavier Roirand [Thu, 25 Jan 2018 10:09:23 +0000 (11:09 +0100)] 
(Ada) C++fy conditional string when catching exception.

This commit C++fy the conditional string used when catching Ada exception.

gdb/ChangeLog:

        * ada-lang.c (catch_ada_exception_command_split)
        (create_ada_exception_catchpoint) <cond_string>: Change parameter
        type.  Update code accordingly.
        (catch_ada_exception_command, catch_ada_handlers_command): Use
        C++ string instead of char* for conditional var.
        (catch_ada_assert_command_split) <cond_string>: Change parameter
        type.  Update code accordingly.
        (catch_assert_command): Use C++ string instead of char* for
        conditional var.
        * ada-lang.h (create_ada_exception_catchpoint) <cond_string>:
        Update declaration.
        * mi/mi-cmd-catch.c (mi_cmd_catch_assert, mi_cmd_catch_exception):
        Use std::string instead of char* for condition string.

Tested on x86_64-linux.

6 years ago(Ada/MI) Add testcase for mi catch assert with condition
Xavier Roirand [Mon, 29 Jan 2018 12:31:58 +0000 (13:31 +0100)] 
(Ada/MI) Add testcase for mi catch assert with condition

gdb/testsuite/ChangeLog:

    * gdb.ada/mi_catch_assert.exp: New testcase.
    * gdb.ada/mi_catch_assert/bla.adb: New file.
    * gdb.ada/mi_catch_assert/pck.ads: New file.

Tested on x86_64-linux.

6 years ago(Ada) Add testcase for catch assert with condition
Xavier Roirand [Mon, 29 Jan 2018 09:43:21 +0000 (10:43 +0100)] 
(Ada) Add testcase for catch assert with condition

gdb/testsuite/ChangeLog:

    * gdb.ada/catch_assert_if.exp: New testcase.
    * gdb.ada/catch_assert_if/bla.adb: New file.
    * gdb.ada/catch_assert_if/pck.ads: New file.

Tested on x86_64-linux.

6 years agointernal-error using '@' (repeat) operator on array of dynamic objects
Joel Brobecker [Wed, 31 Jan 2018 07:18:56 +0000 (02:18 -0500)] 
internal-error using '@' (repeat) operator on array of dynamic objects

Using the following Ada declarations (the same as in
gdb.ada/dyn_stride.exp)...

      subtype Small_Type is Integer range L .. U;
      type Record_Type (I : Small_Type := L) is record
         S : String (1 .. I);
      end record;
      type Array_Type is array (Integer range <>) of Record_Type;

      A1 : Array_Type :=
        (1 => (I => U, S => (others => ASCII.NUL)),
         2 => (I => 1, S => "A"),
         3 => (I => 2, S => "AB"));

... where "L" and "U" are variables, trying to apply the repeat
operator to "A1(1)" yields to an internal error:

  | (gdb) print a1(1)@3
  | $5 = /[...]/gdbtypes.c:4883: internal-error: type* copy_type(const type*):
  | Assertion `TYPE_OBJFILE_OWNED (type)' failed.

What happens first is that the ada-lang module evaluated the "A1(1)"
sub-expression returning a structure where "I" (one of the fields
in that structure) has a type which is dynamic, because it is
a range type whose bounds are not statically known.

Next, we apply the repeat ('@') operator, which is done via
allocate_repeat_value, which creates an array type with the correct
bounds to associate to our value, by calling lookup_array_range_type:

  | struct type *
  | lookup_array_range_type (struct type *element_type,
  |                          LONGEST low_bound, LONGEST high_bound)
  | {
  |   struct gdbarch *gdbarch = get_type_arch (element_type);
  |   struct type *index_type = builtin_type (gdbarch)->builtin_int;
  |   struct type *range_type
  |     = create_static_range_type (NULL, index_type, low_bound, high_bound);
  |
  |   return create_array_type (NULL, element_type, range_type);
  | }

As we can see, this creates an array type whose index type is
always owned by the gdbarch. This is where the problem lies.

Next, we use that type to construct a struct value. That value
then gets passed to the valprint module, which then checks
whether our object is dynamic or not. And because field "I" above
had a dynamic range type, we end up determining by association
that the artificial repeat array itself is also dynamic. So
we attempt to resolve the type, which leads to trying to copying
that type. And because the artifical array created by
lookup_array_range_type has an index which is not objfile-owned,
we trip the assertion.

This patch fixes the issue by enhancing lookup_array_range_type
to create an index type which has the same owner as the element
type.

gdb/ChangeLog:

        * gdbtypes.c (lookup_array_range_type): Make sure the array's
        index type is objfile-owned if the element type is as well.

gdb/testsuite/ChangeLog:

        * testsuite/gdb.ada/dyn_stride.exp: Add "print a1(1)@3" test.

6 years agoPR22714, Assembler preprocessor loses track of \@
Alan Modra [Wed, 31 Jan 2018 03:04:18 +0000 (13:34 +1030)] 
PR22714, Assembler preprocessor loses track of \@

The PR22714 testcase is such that the input buffer processed by
do_scrub_chars ends on this line

1: bug "Returning to usermode but unexpected PSR bits set?", \@

right at the backslash.  (The line is part of a macro definition.)
The next input buffer then starts with '@' which starts a comment on
ARM, and the check for \@ fails due to to == tostart.  Now it would be
possible to simply access to[-1] in this particular case, but that's
ugly, and to be absolutely safe from people deliberately trying to
crash gas we'd need the read.c:read_a_source_file buffer passed to
do_scrub_chars to have a single byte pad at the start.

PR 22714
* app.c (last_char): New static var.
(struct app_save): Add last_char field.
(app_push, app_pop): Handle it.
(do_scrub_chars): Use last_char in test for "\@".  Set last_char.

6 years agoDocument the GDB 8.1 release in gdb/ChangeLog
Joel Brobecker [Wed, 31 Jan 2018 03:08:07 +0000 (07:08 +0400)] 
Document the GDB 8.1 release in gdb/ChangeLog

gdb/ChangeLog:

GDB 8.1 released.

6 years agoAutomatic date update in version.in
GDB Administrator [Wed, 31 Jan 2018 00:00:40 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoImprove junk file removal in source tarball creation script.
Nick Clifton [Tue, 30 Jan 2018 17:48:24 +0000 (17:48 +0000)] 
Improve junk file removal in source tarball creation script.

* src-release.sh (do_proto_toplev): Add patterns for more junk files
to delete before creating the tarball.

6 years agoUpdate description of nm's symbol bss type letters.
Nick Clifton [Tue, 30 Jan 2018 17:22:41 +0000 (17:22 +0000)] 
Update description of nm's symbol bss type letters.

PR 22734
* doc/binutils.texi (nm): Update description to point out that
zero-initialized values can also be shown as type B, b, S or s
since they can be stored in the BSS section.

6 years agos390: Fix gdb.base/all-architectures.exp with --enable-targets=all
Philipp Rudo [Tue, 30 Jan 2018 16:10:08 +0000 (17:10 +0100)] 
s390: Fix gdb.base/all-architectures.exp with --enable-targets=all

With 7042632bf79 (s390: Hook s390 into OSABI mechanism) assigning a
default target description was moved from s390_gdbarch_init to
s390_linux_init_abi_*.  This causes problems when GDB is built with
--enable-targets=all and the user sets an unsupported OSABI, e.g. "set
osabi AIX".  In this case there is no valid tdesc, and GDB crashes with an
internal error.  Fix this by reverting parts of 7042632bf79.

gdb/ChangeLog:

* s390-linux-tdep.c: Remove includes "features/s390-linux32.c" and
"features/s390x-linux64.c".
(_initialize_s390_linux_tdep): Remove initialization of tdescs
s390_linux32 and s390x_linux64.
(s390_linux_init_abi_31, s390_linux_init_abi_64): Don't set
default tdesc.
* s390-tdep.c: Include "features/s390-linux32.c" and
"features/s390x-linux64.c".
(s390_tdesc_valid): Add check for tdesc_has_registers.
(s390_gdbarch_init): Make sure there is always a valid tdesc.
(_initialize_s390_tdep): Initialize tdesc_s390_linux32 and
tdesc_s390x_linux64.
* s390-linux-tdep.h: Move export of tdesc_s390_linux32 and
tdesc_s390x_linux64 to...
* s390-tdep.h: ...here.

6 years agoPer-inferior target_terminal state, fix PR gdb/13211, more
Pedro Alves [Tue, 30 Jan 2018 14:23:51 +0000 (14:23 +0000)] 
Per-inferior target_terminal state, fix PR gdb/13211, more

In my multi-target branch I ran into problems with GDB's terminal
handling that exist in master as well, with multi-inferior debugging.

This patch adds a testcase for said problems
(gdb.multi/multi-term-settings.exp), fixes the problems, fixes PR
gdb/13211 as well (and adds a testcase for that too,
gdb.base/interrupt-daemon.exp).

The basis of the problem I ran into is the following.  Consider a
scenario where you have:

 - inferior 1 - started with "attach", process is running on some
   other terminal.

 - inferior 2 - started with "run", process is sharing gdb's terminal.

In this scenario, when you stop/resume both inferiors, you want GDB to
save/restore the terminal settings of inferior 2, the one that is
sharing GDB's terminal.  I.e., you want inferior 2 to "own" the
terminal (in target_terminal::is_ours/target_terminal::is_inferior
sense).

Unfortunately, that's not what you get currently.  Because GDB doesn't
know whether an attached inferior is actually sharing GDB's terminal,
it tries to save/restore its settings anyway, ignoring errors.  In
this case, this is pointless, because inferior 1 is running on a
different terminal, but GDB doesn't know better.

And then, because it is only possible to have the terminal settings of
a single inferior be in effect at a time, or make one inferior/pgrp be
the terminal's foreground pgrp (aka, only one inferior can "own" the
terminal, ignoring fork children here), if GDB happens to try to
restore the terminal settings of inferior 1 first, then GDB never
restores the terminal settings of inferior 2.

This patch fixes that and a few things more along the way:

 - Moves enum target_terminal::terminal_state out of the
   target_terminal class (it's currently private) and makes it a
   scoped enum so that it can be easily used elsewhere.

 - Replaces the inflow.c:terminal_is_ours boolean with a
   target_terminal_state variable.  This allows distinguishing is_ours
   and is_ours_for_output states.  This allows finally making
   child_terminal_ours_1 do something with its "output_only"
   parameter.

 - Makes each inferior have its own copy of the
   is_ours/is_ours_for_output/is_inferior state.

 - Adds a way for GDB to tell whether the inferior is sharing GDB's
   terminal.  Works best on Linux and Solaris; the fallback works just
   as well as currently.

 - With that, we can remove the inf->attach_flag tests from
   child_terminal_inferior/child_terminal_ours.

 - Currently target_ops.to_ours is responsible for both saving the
   current inferior's terminal state, and restoring gdb's state.
   Because each inferior has its own terminal state (possibly handled
   by different targets in a multi-target world, even), we need to
   split the inferior-saving part from the gdb-restoring part.  The
   patch adds a new target_ops.to_save_inferior target method for
   that.

 - Adds a new target_terminal::save_inferior() function, so that
   sequences like:

     scoped_restore_terminal_state save_state;
     target_terminal::ours_for_output ();

   ... restore back inferiors that were
   target_terminal_state::is_inferior before back to is_inferior, and
   leaves inferiors that were is_ours alone.

 - Along the way, this adds a default implementation of
   target_pass_ctrlc to inflow.c (for inf-child.c), that handles
   passing the Ctrl-C to a process running on GDB's terminal or to
   some other process otherwise.

 - Similarly, adds a new target default implementation of
   target_interrupt, for the "interrupt" command.  The current
   implementation of this hook in inf-ptrace.c kills the whole process
   group, but that's incorrect/undesirable because we may not be
   attached to all processes in the process group.  And also, it's
   incorrect because inferior_process_group() doesn't really return
   the inferior's real process group id if the inferior is not a
   process group leader...  This is the cause of PR gdb/13211 [1],
   which this patch fixes.  While at it, that target method's "ptid"
   parameter is eliminated, because it's not really used.

 - A new test is included that exercises and fixes PR gdb/13211, and
   also fixes a GDB issue reported on stackoverflow that I ran into
   while working on this [2].  The problem is similar to PR gdb/13211,
   except that it also triggers with Ctrl-C.  When debugging a daemon
   (i.e., a process that disconnects from the controlling terminal and
   is not a process group leader, then Ctrl-C doesn't work, you just
   can't interrupt the inferior at all, resulting in a hung debug
   session.  The problem is that since the inferior is no longer
   associated with gdb's session / controlling terminal, then trying
   to put the inferior in the foreground fails.  And so Ctrl-C never
   reaches the inferior directly.  pass_signal is only used when the
   inferior is attached, but that is not the case here.  This is fixed
   by the new child_pass_ctrlc.  Without the fix, the new
   interrupt-daemon.exp testcase fails with timeout waiting for a
   SIGINT that never arrives.

[1] PR gdb/13211 - Async / Process group and interrupt not working
https://sourceware.org/bugzilla/show_bug.cgi?id=13211

[2] GDB not reacting Ctrl-C when after fork() and setsid()
https://stackoverflow.com/questions/46101292/gdb-not-reacting-ctrl-c-when-after-fork-and-setsid

Note this patch does _not_ fix:

 - PR gdb/14559 - The 'interrupt' command does not work if sigwait is in use
   https://sourceware.org/bugzilla/show_bug.cgi?id=14559

 - PR gdb/9425 - When using "sigwait" GDB doesn't trap SIGINT. Ctrl+C terminates program when should break gdb.
   https://sourceware.org/bugzilla/show_bug.cgi?id=9425

The only way to fix that that I know of (without changing the kernel)
is to make GDB put inferiors in a separate session (create a
pseudo-tty master/slave pair, make the inferior run with the slave as
its terminal, and have gdb pump output/input on the master end).

gdb/ChangeLog:
2018-01-30  Pedro Alves  <palves@redhat.com>

PR gdb/13211
* config.in, configure: Regenerate.
* configure.ac: Check for getpgid.
* go32-nat.c (go32_pass_ctrlc): New.
(go32_target): Install it.
* inf-child.c (inf_child_target): Install
child_terminal_save_inferior, child_pass_ctrlc and
child_interrupt.
* inf-ptrace.c (inf_ptrace_interrupt): Delete.
(inf_ptrace_target): No longer install it.
* infcmd.c (interrupt_target_1): Adjust.
* inferior.h (child_terminal_save_inferior, child_pass_ctrlc)
(child_interrupt): Declare.
(inferior::terminal_state): New.
* inflow.c (struct terminal_info): Update comments.
(inferior_process_group): Delete.
(terminal_is_ours): Delete.
(gdb_tty_state): New.
(child_terminal_init): Adjust.
(is_gdb_terminal, sharing_input_terminal_1)
(sharing_input_terminal): New functions.
(child_terminal_inferior): Adjust.  Use sharing_input_terminal.
Set the process's actual process group in the foreground if
possible.  Handle is_ours_for_output/is_ours distinction.  Don't
mark terminal as the inferior's if not sharing GDB's terminal.
Don't check attach_flag.
(child_terminal_ours_for_output, child_terminal_ours): Adjust to
pass down a target_terminal_state.
(child_terminal_save_inferior): New, factored out from ...
(child_terminal_ours_1): ... this.  Handle
target_terminal_state::is_ours_for_output.
(child_interrupt, child_pass_ctrlc): New.
(inflow_inferior_exit): Clear the inferior's terminal_state.
(copy_terminal_info): Copy the inferior's terminal state.
(_initialize_inflow): Remove reference to terminal_is_ours.
* inflow.h (inferior_process_group): Delete.
* nto-procfs.c (nto_handle_sigint, procfs_interrupt): Adjust.
* procfs.c (procfs_target): Don't install procfs_interrupt.
(procfs_interrupt): Delete.
* remote.c (remote_serial_quit_handler): Adjust.
(remote_interrupt): Remove ptid parameter.  Adjust.
* target-delegates.c: Regenerate.
* target.c: Include "terminal.h".
(target_terminal::terminal_state): Rename to ...
(target_terminal::m_terminal_state): ... this.
(target_terminal::init): Adjust.
(target_terminal::inferior): Adjust to per-inferior
terminal_state.
(target_terminal::restore_inferior, target_terminal_is_ours_kind): New.
(target_terminal::ours, target_terminal::ours_for_output): Use
target_terminal_is_ours_kind.
(target_interrupt): Remove ptid parameter.  Adjust.
(default_target_pass_ctrlc): Adjust.
* target.h (target_ops::to_terminal_save_inferior): New field.
(target_ops::to_interrupt): Remove ptid_t parameter.
(target_interrupt): Remove ptid_t parameter.  Update comment.
(target_pass_ctrlc): Update comment.
* target/target.h (target_terminal_state): New scoped enum,
factored out of ...
(target_terminal::terminal_state): ... here.
(target_terminal::inferior): Update comments.
(target_terminal::restore_inferior): New.
(target_terminal::is_inferior, target_terminal::is_ours)
(target_terminal::is_ours_for_output): Adjust.
(target_terminal::scoped_restore_terminal_state): Adjust to
rename, and call restore_inferior() instead of inferior().
(target_terminal::scoped_restore_terminal_state::m_state): Change
type.
(target_terminal::terminal_state): Rename to ...
(target_terminal::m_terminal_state): ... this and change type.

gdb/gdbserver/ChangeLog:
2018-01-30  Pedro Alves  <palves@redhat.com>

PR gdb/13211
* target.c (target_terminal::terminal_state): Rename to ...
(target_terminal::m_terminal_state): ... this.

gdb/testsuite/ChangeLog:
2018-01-30  Pedro Alves  <palves@redhat.com>

PR gdb/13211
* gdb.base/interrupt-daemon.c: New.
* gdb.base/interrupt-daemon.exp: New.
* gdb.multi/multi-term-settings.c: New.
* gdb.multi/multi-term-settings.exp: New.

6 years agolinux-nat: Eliminate custom target_terminal_{inferior,ours}, stop using set_sigint_trap
Pedro Alves [Tue, 30 Jan 2018 14:23:51 +0000 (14:23 +0000)] 
linux-nat: Eliminate custom target_terminal_{inferior,ours}, stop using set_sigint_trap

This patch gets rid of linux-nat.c's custom
target_terminal_inferior/target_terminal_ours implementations.

The only remaining reason those overrides exist is to install
clear_sigint_trap in order to pass Ctrl-C/SIGINT to the inferior
process in case the inferior is not sharing GDB's terminal (and
target_wait was called without TARGET_WNOHANG).

However, I think that's better handled by QUIT / target_pass_ctrlc
nowadays.  Going that route avoids the issue with set_sigint_trap only
looking at the current inferior to know whether to override SIGINT or
not, which doesn't really work correctly with multi-inferior in the
picture.  Also centralizing on a single SIGINT handler as much as
possible seems better considering a future multi-target world.

Tested on x86-64 GNU/Linux.

gdb/ChangeLog:
2018-01-30  Pedro Alves  <palves@redhat.com>

* linux-nat.c (wait_for_signal): New function.
(wait_lwp, linux_nat_wait_1): Use it instead of calling sigsuspend
directly.
(async_terminal_is_ours)
(linux_nat_terminal_inferior, linux_nat_terminal_ours): Delete.
(linux_nat_add_target): Don't override
to_terminal_inferior/to_terminal_ours.

6 years agoAdd --gc-sections test checking removal of __start/__stop symbols.
Alan Modra [Tue, 30 Jan 2018 11:41:00 +0000 (22:11 +1030)] 
Add --gc-sections test checking removal of __start/__stop symbols.

Well, just __stop__foo but that should be good enough.

* testsuite/ld-gc/stop.d,
* testsuite/ld-gc/stop.s: New test.
* testsuite/ld-gc/gc.exp: Run it.

6 years agoPR22758, FAIL: Run pr22393-2
Alan Modra [Tue, 30 Jan 2018 05:32:32 +0000 (16:02 +1030)] 
PR22758, FAIL: Run pr22393-2

We can't map different disk pages into the same memory page; The last
page mapped will simply overwrite any previous pages.  The
executable/non-executable new_segment test ignored this fact, leading
to a ld.so segfault on hppa when .dynamic is overwritten with zeros.

This patch moves existing tests for demand paging with lma on the same
memory page, to a new test performed before any case where we want a
new segment due to protection or loadable conflicts.

PR 22758
* elf.c (_bfd_elf_map_sections_to_segments): Don't start a new
segment when demand paged with lma on the same page.  Test this
before load/non-load, executable/non-executable,
writable/non-writable tests and simplify.  Delete bogus relro
condition in writable/non-writable test.  Delete outdated
comment.  Formatting.

6 years agogdb.base/break.exp: fix last "info break" test failure on Ubuntu 16.04
Joel Brobecker [Tue, 30 Jan 2018 04:03:09 +0000 (23:03 -0500)] 
gdb.base/break.exp: fix last "info break" test failure on Ubuntu 16.04

The last test of this testcase fails when run on Ubuntu 16.04 using
the system compiler (16.04):

    FAIL: gdb.base/break.exp: verify that they were cleared

This is because the testcase expected that a breakpoint on line 47 of break.c...

    printf ("%d\n", factorial (atoi ("6")));  /* set breakpoint 1 here */

... would actually be inserted on an instruction belonging to
that line. However, what actually happens is that system GCC on
that version of Ubuntu ends up inlining everything, including
the call to printf, thus reporting every instruction of generated
for this line of code as belonging to a different function. As
a result, GDB ends up insering the breakpoint on the next line
of code, which is line 49:

    (gdb) break break.c:$l
    Breakpoint 3 at 0x4005c1: file /[...]/gdb.base/break.c, line 49.

This causes a spurious failure in the "info break" test later on,
as it assumed that the breakpoint above is inserted on line 47:

    gdb_test "info break" "$srcfile:$line" "verify that they were cleared"

This patch fixes the issue by saving the actual source location where
the breakpoint was inserted.

gdb/testsuite/ChangeLog:

        * gdb.base/break.exp: Save the location where the breakpoint
        on break.c:47 was actually inserted when debugging the version
        compiled at -O2 and use it in the expected output of the "info
        break" test performed soon after.

tested on x86_64-linux, with two configurations:
  - Ubuntu 16.04 with the system compiler (breakpoint lands on line 49)
  - Ubuntu 16.04 with GCC 7.3.1 (breakpoint lands on line 47)

6 years agoMIPS/LD/testsuite: Correct PR ld/22649 test case failures
Maciej W. Rozycki [Tue, 30 Jan 2018 01:31:23 +0000 (01:31 +0000)] 
MIPS/LD/testsuite: Correct PR ld/22649 test case failures

Fix commit d664fd41e15f ("Ignore dynamic references on forced local
symbols") and use alternative test actions and match patterns to
correctly handle messages like:

.../ld/ld-new: Removing unused section '.reginfo' in file 'tmpdir/pr22649-2b.o'

or:

.../ld/ld-new: Removing unused section '.MIPS.options' in file 'tmpdir/pr22649-2b.o'

produced by LD on MIPS targets, removing:

FAIL: Build pr22649-2c.so
FAIL: Build pr22649-2d.so

test suite failures and tightening checks made with `pr22649-2a.so' and
`pr22649-2b.so' test cases.

Keep the original empty action with `pr22649-2c.so' and `pr22649-2d.so'
links and MIPS/ELF targets though, because for them the linker does not
garbage-collect the `.reginfo' section.  This is because the section has
its flags set differently by code in GAS in `md_begin':

    if (strncmp (TARGET_OS, "elf", 3) != 0)
      flags |= SEC_ALLOC | SEC_LOAD;

and consequently BFD linker code in `_bfd_elf_gc_mark_extra_sections':

  else if (((isec->flags & SEC_DEBUGGING) != 0
    || (isec->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0)
   && elf_next_in_group (isec) == NULL)
    isec->gc_mark = 1;

marks these sections to be kept due to their SEC_ALLOC, SEC_LOAD and
SEC_RELOC flags all being zero (`.reginfo' sections never have
relocations attached).

ld/
PR ld/22649
* testsuite/ld-elf/pr22649-2ab-mips.msg: New stderr output.
* testsuite/ld-elf/pr22649-2cd-mips.msg: New stderr output.
* testsuite/ld-elf/shared.exp: Use the new outputs with
`mips*-*-*' targets.

6 years agoMIPS/LD/testsuite: Adjust match patterns for special section indexes
Maciej W. Rozycki [Tue, 30 Jan 2018 00:38:12 +0000 (00:38 +0000)] 
MIPS/LD/testsuite: Adjust match patterns for special section indexes

Update `readelf' symbol table dump match patterns to handle SHN_MIPS_DATA
and SHN_MIPS_TEXT special section indexes produced by the IRIX ELF format
variation used with a number of MIPS targets and printed by `readelf' as
PRC[0xff02] and PRC[0xff01] respectively, correcting LD test suite
failures:

extra regexps in .../ld/testsuite/ld-elf/comm-data1.sd starting with "^ +[0-9]+: +[0-9a-f]+ +0 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo$"
EOF from dump.out
FAIL: Common symbol override test (auxiliary shared object build)

extra regexps in .../ld/testsuite/ld-elf/pr21703-shared.sd starting with "^ +[0-9]+: +[0-9a-f]+ +4 +FUNC +GLOBAL +DEFAULT +[0-9] +foo@FOO$"
EOF from dump.out
FAIL: PR ld/21703 shared

extra regexps in .../ld/testsuite/ld-elf/comm-data1.sd starting with "^ +[0-9]+: +[0-9a-f]+ +0 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo$"
EOF from dump.out
FAIL: MIPS o32/copyreloc common symbol override test (auxiliary shared object build)

extra regexps in .../ld/testsuite/ld-elf/comm-data1.sd starting with "^ +[0-9]+: +[0-9a-f]+ +0 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo$"
EOF from dump.out
FAIL: MIPS o32/nocopyreloc common symbol override test (auxiliary shared object build)

observed due to file contents like:

     7: 5ffe02e8     0 OBJECT  GLOBAL DEFAULT PRC[0xff02] foo

shown by `readelf -s' vs:

 +[0-9]+: +[0-9a-f]+ +0 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo

pattern expected, triggered by widening testing to these targets by commit
05a5feafdd38 ("Rewrite check_shared_lib_support").

ld/
* testsuite/ld-elf/comm-data1.sd: Alternatively accept
`PRC[0xff02]' in place of a regular section index.
* testsuite/ld-elf/pr21703-shared.sd: Likewise `PRC[0xff01]'.

6 years ago32-bit objcopy build fail
Alan Modra [Mon, 29 Jan 2018 05:18:03 +0000 (15:48 +1030)] 
32-bit objcopy build fail

* objcopy.c (merge_gnu_build_notes): Use (bfd_vma) -1 as
"artificially large" end address.

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 30 Jan 2018 00:00:25 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoMake __start/__stop symbols dynamic and add testcase
Alan Modra [Mon, 29 Jan 2018 11:15:09 +0000 (21:45 +1030)] 
Make __start/__stop symbols dynamic and add testcase

bfd/
* elflink.c (bfd_elf_define_start_stop): Make __start and __stop
symbols dynamic.
ld/
* testsuite/ld-elf/pr21964-3a.c: New file.
* testsuite/ld-elf/pr21964-3c.c: New file.
* testsuite/ld-elf/shared.exp: Run new __start/__stop testcase.

6 years ago Adjust test for PR ld/22269.
Eric Botcazou [Mon, 29 Jan 2018 23:21:57 +0000 (00:21 +0100)] 
 Adjust test for PR ld/22269.

 On the SPARC architecture, you need to pass a special flag to GNU as
 when you're assembling PIC/PIE code or else you get a wrong relocation
 for the GOT symbol.

ld/
* testsuite/ld-elf/shared.exp (AFLAGS_PIC): Define on SPARC.
(pr22269-1): Pass AFLAGS_PIC to the assembler.

6 years agoFix PR gas/22738 (.dc.a directive has wrong size on SPARC 64-bit).
Eric Botcazou [Mon, 29 Jan 2018 23:13:51 +0000 (00:13 +0100)] 
Fix PR gas/22738 (.dc.a directive has wrong size on SPARC 64-bit).

The .dc.a directive has wrong size (32 bits) on SPARC 64-bit because
the assembler sets the correct BFD architecture only at the very end
of the processing and it's too late for the directive.  It's fixed by
defining TARGET_MACH and making it return a sensible default value.

gas/
* config/tc-sparc.h (sparc_mach): Declare.
(TARGET_MACH): Define to above.
* config/tc-sparc.c (sparc_mach): New function.
(sparc_md_end): Minor tweak.
ld/
* testsuite/ld-elf/pr22450.d: Remove reference to SPARC64.

6 years agoMIPS/LD/testsuite: Correct comm-data.exp test ABI/emul/endian arrangement
Maciej W. Rozycki [Mon, 29 Jan 2018 20:10:19 +0000 (12:10 -0800)] 
MIPS/LD/testsuite: Correct comm-data.exp test ABI/emul/endian arrangement

Update the ld-mips-elf/comm-data.exp test script to correctly select
emulations for targets using non-traditional MIPS emulation and also
correctly select ABIs for targets that do not support all of them, and
finally use the default endianness selection to benefit targets which
support only one, complementing commit 05a5feafdd38 ("Rewrite
check_shared_lib_support") and removing numerous test failures such as:

FAIL: MIPS o32/copyreloc common symbol override test (auxiliary shared object build)
FAIL: MIPS o32/copyreloc common symbol override test
FAIL: MIPS o32/nocopyreloc common symbol override test (auxiliary shared objectbuild)
FAIL: MIPS o32/nocopyreloc common symbol override test
FAIL: MIPS n32/copyreloc common symbol override test (auxiliary shared object build)
FAIL: MIPS n32/copyreloc common symbol override test
FAIL: MIPS n32/nocopyreloc common symbol override test (auxiliary shared objectbuild)
FAIL: MIPS n32/nocopyreloc common symbol override test

due to:

.../ld/ld-new: unrecognised emulation mode: elf32btsmip
Supported emulations: elf64btsmip elf64ltsmip

or:

.../ld/ld-new: unrecognised emulation mode: elf32btsmip
Supported emulations: elf32ebmip

or:

.../ld/ld-new: unrecognised emulation mode: elf32btsmip
Supported emulations: elf32l4300

etc., and:

ERROR: -n32 -march=mips3 -EB -call_shared .../ld/testsuite/ld-mips-elf/../ld-elf/comm-data1.s: assembly failed
UNRESOLVED: MIPS n32/copyreloc common symbol override test (auxiliary shared object build)
ERROR: -n32 -march=mips3 -EB -call_nonpic .../ld/testsuite/ld-mips-elf/../ld-elf/comm-data2.s: assembly failed
UNRESOLVED: MIPS n32/copyreloc common symbol override test
ERROR: -n32 -march=mips3 -EB -call_shared .../ld/testsuite/ld-mips-elf/../ld-elf/comm-data1.s: assembly failed
UNRESOLVED: MIPS n32/nocopyreloc common symbol override test (auxiliary shared object build)
ERROR: -n32 -march=mips3 -EB -call_nonpic .../ld/testsuite/ld-mips-elf/../ld-elf/comm-data2.s: assembly failed
UNRESOLVED: MIPS n32/nocopyreloc common symbol override test

due to:

Assembler messages:
Fatal error: selected target format 'elf32-nbigmips' unknown

and:

ERROR: -64 -march=mips3 -EB -call_shared .../ld/testsuite/ld-mips-elf/../ld-elf/comm-data1.s: assembly failed
UNRESOLVED: MIPS n64/copyreloc common symbol override test (auxiliary shared object build)
ERROR: -64 -march=mips3 -EB --defsym ELF64=1 -call_nonpic .../ld/testsuite/ld-mips-elf/../ld-elf/comm-data2.s:assembly failed
UNRESOLVED: MIPS n64/copyreloc common symbol override test
ERROR: -64 -march=mips3 -EB -call_shared .../ld/testsuite/ld-mips-elf/../ld-elf/comm-data1.s: assembly failed
UNRESOLVED: MIPS n64/nocopyreloc common symbol override test (auxiliary shared object build)
ERROR: -64 -march=mips3 -EB --defsym ELF64=1 -call_nonpic .../ld/testsuite/ld-mips-elf/../ld-elf/comm-data2.s:assembly failed
UNRESOLVED: MIPS n64/nocopyreloc common symbol override test

due to:

Assembler messages:
Fatal error: no compiled in support for 64 bit object file format

ld/
* testsuite/ld-mips-elf/comm-data.exp: Correct support for
targets using non-traditional MIPS emulation or having a limited
selection of ABIs available.  Don't force big endianness, use
defaults.

6 years agoDon't call "detach_inferior" on "remote_follow_fork"
Sergio Durigan Junior [Mon, 29 Jan 2018 17:29:21 +0000 (12:29 -0500)] 
Don't call "detach_inferior" on "remote_follow_fork"

This patch fixes a regression that has been introduced by:

  commit bc09b0c14fb713a9aec25e09b78499f3bc2441b5
  Date:   Fri Jan 19 11:48:11 2018 -0500

      Make linux_nat_detach/thread_db_detach use the inferior parameter

It is possible to trigger this failure with gdb.base/foll-fork.exp (in
which case a bunch of ERROR's will be printed), but one can also use
the test below.

Consider the following example program:

  #include <unistd.h>

  int
  main (int argc, char *argv[])
  {
    fork ();

    return 0;
  }

When running it under gdbserver:

  # ./gdb/gdbserver/gdbserver --multi --once :2345

And debugging it under GDB, we see a segmentation fault:

  # ./gdb/gdb -q -batch -ex 'set remote exec-file ./a.out' -ex 'tar extended-remote :2345' -ex r ./a.out
  Starting program:
  ...
  [Detaching after fork from child process 16102.]
  Segmentation fault (core dumped)

The problem happens on inferior.c:detach_inferior:

  void
  detach_inferior (inferior *inf)
  {
    /* Save the pid, since exit_inferior_1 will reset it.  */
    int pid = inf->pid;
              ^^^^^^^^^

    exit_inferior_1 (inf, 0);

    if (print_inferior_events)
      printf_unfiltered (_("[Inferior %d detached]\n"), pid);
  }

When this code is called from remote.c:remote_follow_fork, the PID is
valid but there is no 'inferior' associated with it, which means that
'inf == NULL'.

The proper fix here is to not call "detach_inferior" when doing remote
follow-fork, because we don't have an inferior to detach on the host
side.

Before bc09b0c1, that call was already a nop (exit_inferior_1 bails
out early if you pass it a NULL inferior), except that it printed
"Inferior PID detached" when "set print inferior-events" is on.  Since
native debugging doesn't call detach_inferior in this case, removing
the call from remote aligns remote debugging output with native
debugging output further.

This has been regtested using BuildBot and no regressions were found.

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

* remote.c (remote_follow_fork): Don't call "detach_inferior".

6 years agoUpdate Russian translation for the gas sub-directory
Nick Clifton [Mon, 29 Jan 2018 13:51:47 +0000 (13:51 +0000)] 
Update Russian translation for the gas sub-directory

6 years agoPrevent patch remnants from being included in release tarballs.
Nick Clifton [Mon, 29 Jan 2018 13:19:02 +0000 (13:19 +0000)] 
Prevent patch remnants from being included in release tarballs.

* src-release.sh (do_proto_toplev): Strip patch remnant files from
the sources before creating the tarball.

6 years agold: Skip unsupported static executable tests
H.J. Lu [Mon, 29 Jan 2018 12:54:57 +0000 (04:54 -0800)] 
ld: Skip unsupported static executable tests

Skip static executable tests if static executable is unsupported.
Tested on Linux/x86 without libc.a.

PR ld/22732
* testsuite/config/default.exp (STATIC_LDFLAGS): New.  Set to
"-static" if target compiler supports it.
* testsuite/ld-bootstrap/bootstrap.exp: Skip static executable
tests if target compiler doesn't support it.
* testsuite/ld-ifunc/ifunc.exp: Likewise.
* testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Likewise.
(run_cc_link_tests): Likewise.

6 years agoPR22741, objcopy segfault on fuzzed COFF object
Alan Modra [Fri, 26 Jan 2018 21:49:33 +0000 (08:19 +1030)] 
PR22741, objcopy segfault on fuzzed COFF object

PR 22741
* coffgen.c (coff_pointerize_aux): Ensure auxent tagndx is in
range before converting to a symbol table pointer.