deliverable/binutils-gdb.git
6 years agoNo longer create readonly regcache
Yao Qi [Wed, 21 Feb 2018 11:20:03 +0000 (11:20 +0000)] 
No longer create readonly regcache

Nowadays, we create a readonly regcache in get_return_value, and pass it
to gdbarch_return_value to get the return value.  In theory, we can pass a
readable_regcache instance and get the return value, because we don't need
to modify the regcache.  Unfortunately, gdbarch_return_value is designed
to multiplex regcache, according to READBUF and WRITEBUF.

 # If READBUF is not NULL, extract the return value and save it in this
 # buffer.
 #
 # If WRITEBUF is not NULL, it contains a return value which will be
 # stored into the appropriate register.

In fact, gdbarch_return_value should be split to three functions, 1) only
return return_value_convention, 2) pass regcache_readonly and readbuf, 3)
pass regcache and writebuf.  These changes are out of the scope of this
patch series, so I pass regcache to gdbarch_return_value even for read,
and trust each gdbarch backend doesn't modify regcache.

gdb:

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

* infcmd.c (get_return_value): Let stop_regs point to
get_current_regcache.
* regcache.c (regcache::regcache): Remove.
(register_dump_reg_buffer): New class.
(regcache_print): Adjust.
* regcache.h (regcache): Remove constructors.

6 years agoReplace regcache::dump with class register_dump
Yao Qi [Wed, 21 Feb 2018 11:20:03 +0000 (11:20 +0000)] 
Replace regcache::dump with class register_dump

Nowadays, we need to dump registers contents from "readwrite" regcache and
"readonly" regcache,

  if (target_has_registers)
    get_current_regcache ()->dump (out, what_to_dump);
  else
    {
      /* For the benefit of "maint print registers" & co when
         debugging an executable, allow dumping a regcache even when
         there is no thread selected / no registers.  */
      regcache dummy_regs (target_gdbarch ());
      dummy_regs.dump (out, what_to_dump);
    }

since we'll have two different types/classes for "readwrite" regcache and
"readonly" regcache, we have to move dump method to their parent class,
reg_buffer.  However, the functionality of "dump" looks unnecessary to
reg_buffer (because some dump modes like regcache_dump_none,
regcache_dump_remote and regcache_dump_groups don't need reg_buffer at
all, they need gdbarch to do the dump), so I decide to move "dump" into a
separate classes, and each sub-class is about each mode of dump.

gdb:

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

* regcache.c (class register_dump): New class.
(register_dump_regcache, register_dump_none): New class.
(register_dump_remote, register_dump_groups): New class.
(regcache_print): Update.
* regcache.h (regcache_dump_what): Move it to regcache.c.
(regcache) <dump>: Remove.

6 years agoClass detached_regcache
Yao Qi [Wed, 21 Feb 2018 11:20:03 +0000 (11:20 +0000)] 
Class detached_regcache

jit.c uses the regcache in a slightly different way, the regcache dosen't
write through to target, but it has read and write methods.  If I apply
regcache in record-full.c, it has the similar use pattern.  This patch
adds a new class detached_regcache, a register buffer, but can be
read and written.

Since jit.c doesn't want to write registers through to target, it uses
regcache as a readonly regcache (because only readonly regcache
disconnects from the target), but it adds a hole in regcache
(raw_set_cached_value) in order to modify a readonly regcache.  This patch
fixes this hole completely.

regcache inherits detached_regcache, and detached_regcache inherits
readable_regcache.  The ideal design is that both detached_regcache and
readable_regcache inherit reg_buffer, and regcache inherit
detached_regcache and regcache_read (virtual inheritance).  I concern
about the performance overhead of virtual inheritance, so I don't do it in
the patch.

gdb:

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

* jit.c (struct jit_unwind_private) <regcache>: Change its type to
 reg_buffer_rw *.
(jit_unwind_reg_set_impl): Call raw_supply.
(jit_frame_sniffer): Use reg_buffer_rw.
* record-full.c (record_full_core_regbuf): Change its type.
(record_full_core_open_1): Use reg_buffer_rw.
(record_full_close): Likewise.
(record_full_core_fetch_registers): Use regcache->raw_supply.
(record_full_core_store_registers): Likewise.
* regcache.c (regcache::get_register_status): Move it to
reg_buffer.
(regcache_raw_set_cached_value): Remove.
(regcache::raw_set_cached_value): Remove.
(regcache::raw_write): Call raw_supply.
(regcache::raw_supply): Move it to reg_buffer_rw.
* regcache.h (regcache_raw_set_cached_value): Remove.
(reg_buffer_rw): New class.

6 years agoClass readonly_detached_regcache
Yao Qi [Wed, 21 Feb 2018 11:20:03 +0000 (11:20 +0000)] 
Class readonly_detached_regcache

This patch adds a new class (type) for readonly regcache, which is
created via regcache::save.  readonly_detached_regcache inherits
readable_regcache.

gdb:

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

* dummy-frame.c (dummy_frame_cache) <prev_regcache>: Use
readonly_detached_regcache.
(dummy_frame_prev_register): Use regcache->cooked_read.
* frame.c (frame_save_as_regcache): Change return type.
(frame_pop): Update.
* frame.h (frame_save_as_regcache): Update declaration.
* inferior.h (get_infcall_suspend_state_regcache): Update
declaration.
* infrun.c (infcall_suspend_state) <registers>: use
readonly_detached_regcache.
(save_infcall_suspend_state): Don't use regcache_dup.
(get_infcall_suspend_state_regcache): Change return type.
* linux-fork.c (struct fork_info) <savedregs>: Change to
readonly_detached_regcache.
<pc>: New field.
(fork_save_infrun_state): Don't use regcache_dup.
(info_checkpoints_command): Adjust.
* mi/mi-main.c (register_changed_p): Update declaration.
(mi_cmd_data_list_changed_registers): Use
readonly_detached_regcache.
(register_changed_p): Change parameter type to
readonly_detached_regcache.
* ppc-linux-tdep.c (ppu2spu_cache) <regcache>: Use
readonly_detached_regcache.
(ppu2spu_sniffer): Construct a new readonly_detached_regcache.
* regcache.c (readonly_detached_regcache::readonly_detached_regcache):
New.
(regcache::save): Move it to reg_buffer.
(regcache::restore): Change parameter type.
(regcache_dup): Remove.
* regcache.h (reg_buffer) <save>: New method.
(readonly_detached_regcache): New class.
* spu-tdep.c (spu2ppu_cache) <regcache>: Use
readonly_detached_regcache.
(spu2ppu_sniffer): Construct a new readonly_detached_regcache.

6 years agoRemove regcache_save and regcache_cpy
Yao Qi [Wed, 21 Feb 2018 11:20:03 +0000 (11:20 +0000)] 
Remove regcache_save and regcache_cpy

... instead we start to use regcache methods save and restore.  It is
quite straightforward to replace regcache_save with regcache->save.

regcache_cpy has some asserts, some of them not necessary, like

 gdb_assert (src != dst);

because we already assert !m_readonly_p and src->m_readonly_p, so
src isn't dst.  Some of the asserts are moved to ::restore.

gdb:

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

* frame.c (frame_save_as_regcache): Use regcache method save.
(frame_pop): Use regcache method restore.
* infrun.c (restore_infcall_suspend_state): Likewise.
* linux-fork.c (fork_load_infrun_state): Likewise.
* ppc-linux-tdep.c (ppu2spu_sniffer): User regcache method
save.
* regcache.c (regcache_save): Remove.
(regcache::restore): More asserts.
(regcache_cpy): Remove.
* regcache.h (regcache_save): Remove the declaration.
(regcache::restore): Move from private to public.
Remove the friend declaration of regcache_cpy.
(regcache_cpy): Remove declaration.

6 years agoclass readable_regcache and pass readable_regcache to gdbarch pseudo_register_read...
Yao Qi [Wed, 21 Feb 2018 11:20:03 +0000 (11:20 +0000)] 
class readable_regcache and pass readable_regcache to gdbarch pseudo_register_read and pseudo_register_read_value

pseudo registers are either from raw registers or memory, so
gdbarch methods pseudo_register_read and pseudo_register_read_value
should have regcache object which only have read methods.  In other
words, we should disallow writing to regcache in these two gdbarch
methods.  In order to apply this restriction, this patch adds a new
class readable_regcache, derived from reg_buffer, and it only has
raw_read and cooked_read methods.  regcache is derived from
readable_regcache.  This patch also passes readable_regcache instead of
regcache to gdbarch methods pseudo_register_read and
pseudo_register_read_value.

This patch moves raw_read* and cooked_read* methods to readable_regcache,
which is straightforward.  One thing not straightforward is that I split
regcache::xfer_part to readable_regcache::read_part and regcache::write_part,
because readable_regcache can only have methods to read.

readable_regcache is an abstract base class, and it has a pure virtual
function raw_update, because I don't want readable_regcache know where
these raw registers are from.  They can be from either the target
(readwrite regcache) or the regcache itself (readonly regcache).

gdb:

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

* aarch64-tdep.c (aarch64_pseudo_register_read_value): Change
parameter type to 'readable_regcache *'.
* amd64-tdep.c (amd64_pseudo_register_read_value): Likewise.
* arm-tdep.c (arm_neon_quad_read): Likewise.
(arm_pseudo_read): Likewise.
* avr-tdep.c (avr_pseudo_register_read): Likewise.
* bfin-tdep.c (bfin_pseudo_register_read): Likewise.
* frv-tdep.c (frv_pseudo_register_read): Likewise.
* gdbarch.c: Re-generated.
* gdbarch.h: Re-generated.
* gdbarch.sh (pseudo_register_read): Change parameter type to
'readable_regcache *'.
(pseudo_register_read_value): Likewise.
* h8300-tdep.c (pseudo_from_raw_register): Likewise.
(h8300_pseudo_register_read): Likewise.
* hppa-tdep.c (hppa_pseudo_register_read): Likewise.
* i386-tdep.c (i386_mmx_regnum_to_fp_regnum): Likewise.
(i386_pseudo_register_read_into_value): Likewise.
(i386_pseudo_register_read_value): Likewise.
* i386-tdep.h (i386_pseudo_register_read_into_value): Update
declaration.
* ia64-tdep.c (ia64_pseudo_register_read): Likewise.
* m32c-tdep.c (m32c_raw_read): Likewise.
(m32c_read_flg): Likewise.
(m32c_banked_register): Likewise.
(m32c_banked_read): Likewise.
(m32c_sb_read): Likewise.
(m32c_part_read): Likewise.
(m32c_cat_read): Likewise.
(m32c_r3r2r1r0_read): Likewise.
(m32c_pseudo_register_read): Likewise.
* m68hc11-tdep.c (m68hc11_pseudo_register_read): Likewise.
* mep-tdep.c (mep_pseudo_cr32_read): Likewise.
(mep_pseudo_cr64_read): Likewise.
(mep_pseudo_register_read): Likewise.
* mips-tdep.c (mips_pseudo_register_read): Likewise.
* msp430-tdep.c (msp430_pseudo_register_read): Likewise.
* nds32-tdep.c (nds32_pseudo_register_read): Likewise.
* regcache.c (regcache::raw_read): Move it to readable_regcache.
(regcache::cooked_read): Likewise.
(regcache::cooked_read_value): Likewise.
(regcache_cooked_read_signed):
(regcache::cooked_read): Likewise.
* regcache.h (readable_regcache): New class.
(regcache): Inherit readable_regcache.  Move some methods to
readable_regcache.
* rl78-tdep.c (rl78_pseudo_register_read): Change
parameter type to 'readable_regcache *'.
* rs6000-tdep.c (do_regcache_raw_read): Remove.
(e500_pseudo_register_read): Change parameter type to
'readable_regcache *'.
(dfp_pseudo_register_read): Likewise.
(vsx_pseudo_register_read): Likewise.
(efpr_pseudo_register_read): Likewise.
* s390-tdep.c (s390_pseudo_register_read): Likewise.
* sh-tdep.c (sh_pseudo_register_read): Likewise.
* sh64-tdep.c (pseudo_register_read_portions): Likewise.
(sh64_pseudo_register_read): Likewise.
* sparc-tdep.c (sparc32_pseudo_register_read): Likewise.
* sparc64-tdep.c (sparc64_pseudo_register_read): Likewise.
* spu-tdep.c (spu_pseudo_register_read_spu): Likewise.
(spu_pseudo_register_read): Likewise.
* xtensa-tdep.c (xtensa_register_read_masked): Likewise.
(xtensa_pseudo_register_read): Likewise.

6 years agoClass reg_buffer
Yao Qi [Wed, 21 Feb 2018 11:20:02 +0000 (11:20 +0000)] 
Class reg_buffer

This patch adds a new class reg_buffer, and regcache inherits it.  Class
reg_buffer is a very simple class, which has the buffer for register
contents and status only.  It doesn't have any methods to set contents and
status, and it is expected that its children classes can inherit it and
add different access methods.

Another reason I keep class reg_buffer so simple is that I think
reg_buffer can be even reused in other classes which need to record the
registers contents and status, like frame cache for example.

gdb:

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

* regcache.c (regcache::regcache): Call reg_buffer ctor.
(regcache::arch): Move it to reg_buffer::arch.
(regcache::register_buffer): Likewise.
(regcache::assert_regnum): Likewise.
(regcache::num_raw_registers): Likewise.
* regcache.h (reg_buffer): New class.
(regcache): Inherit reg_buffer.

6 years agoia64 testsuite changes for --gc-sections
Alan Modra [Wed, 21 Feb 2018 07:06:29 +0000 (17:36 +1030)] 
ia64 testsuite changes for --gc-sections

* testsuite/ld-elf/group8b.d: Run test on ia64.  Use xfail rather
than notarget.
* testsuite/ld-elf/pr12851.d: Likewise.
* testsuite/ld-elf/pr12975.d: Likewise.
* testsuite/ld-elf/pr13177.d: Likewise.
* testsuite/ld-elf/pr13195.d: Likewise.
* testsuite/ld-elf/pr17615.d: Likewise.
* testsuite/ld-elf/pr21562a.d: Likewise.
* testsuite/ld-elf/pr21562b.d: Likewise.
* testsuite/ld-elf/pr21562c.d: Likewise.
* testsuite/ld-elf/pr21562d.d: Likewise.
* testsuite/ld-elf/pr21562i.d: Likewise.
* testsuite/ld-elf/pr21562j.d: Likewise.
* testsuite/ld-elf/pr21562k.d: Likewise.
* testsuite/ld-elf/pr21562l.d: Likewise.
* testsuite/ld-elf/pr21562m.d: Likewise.
* testsuite/ld-elf/pr21562n.d: Likewise.
* testsuite/ld-elf/group9a.d: Run test on ia64 and alpha.  Use xfail
rather than notarget.
* testsuite/ld-elf/group9b.d: Likewise.
* testsuite/ld-elf/pr22677.d: Likewise.

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

6 years agoMIPS16/GAS/testsuite: Add cross-section R_MIPS16_PC16_S1 relocation tests
Maciej W. Rozycki [Tue, 20 Feb 2018 20:51:37 +0000 (20:51 +0000)] 
MIPS16/GAS/testsuite: Add cross-section R_MIPS16_PC16_S1 relocation tests

Add a pair of MIPS16 branch tests to verify correct R_MIPS16_PC16_S1
relocation generation for cross-section references in a single source.
This complements commit c9775dde3277 ("MIPS16: Add R_MIPS16_PC16_S1
branch relocation support").

gas/
* testsuite/gas/mips/mips16-branch-reloc-4.d: New test.
* testsuite/gas/mips/mips16-branch-reloc-5.d: New test.
* testsuite/gas/mips/mips16-branch-reloc-4.s: New test source.
* testsuite/gas/mips/mips16-branch-reloc-5.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.

6 years agoMIPS16/opcodes: Free up `M' operand code
Maciej W. Rozycki [Tue, 20 Feb 2018 20:51:36 +0000 (20:51 +0000)] 
MIPS16/opcodes: Free up `M' operand code

The `M' and `m' MIPS16 operand codes are functionally the same, denoting
a 7-bit register list that is encoded the same way for both SAVE and
RESTORE.  Use `m' for both instructions then, making `M' available for a
different use.

opcodes/
* mips16-opc.c (decode_mips16_operand) <'M'>: Remove case.
(mips16_opcodes): Replace `M' with `m' for "restore".

include/
* opcode/mips.h: Remove `M' operand code.

6 years agogas: xtensa: limit size of auto litpools
Max Filippov [Thu, 8 Feb 2018 18:28:52 +0000 (10:28 -0800)] 
gas: xtensa: limit size of auto litpools

Literal movement code may grow auto litpool so big that it won't be
possible to jump around it. Limit the size of auto litpools by 1/2 of
the jump range.

gas/
2018-02-20  Max Filippov  <jcmvbkbc@gmail.com>

* config/tc-xtensa.c (struct litpool_frag): Add new field
literal_count.
(MAX_AUTO_POOL_LITERALS, MAX_EXPLICIT_POOL_LITERALS)
(MAX_POOL_LITERALS): New macro definitions.
(auto_litpool_limit): Initialize to 0.
(md_parse_option): Set auto_litpool_limit in the presence of
--auto-litpools option.
(xtensa_maybe_create_literal_pool_frag): Zero-initialize
literal_count field.
(xg_find_litpool): New function. Make sure that found literal
pool size is within the limit.
(xtensa_move_literals): Extract literal pool search code into
the new function.
* testsuite/gas/xtensa/all.exp: Add auto-litpools-2 test.
* testsuite/gas/xtensa/auto-litpools-2.d: New file.
* testsuite/gas/xtensa/auto-litpools-2.s: New file.
* testsuite/gas/xtensa/auto-litpools.d: Fix up changed
addresses.
* testsuite/gas/xtensa/auto-litpools.s: Change literal value so
that objdump doesn't get out of sync.

6 years agoremote-sim: Add missing ATTRIBUTE_PRINTF
Simon Marchi [Tue, 20 Feb 2018 16:41:54 +0000 (11:41 -0500)] 
remote-sim: Add missing ATTRIBUTE_PRINTF

Fixes:

/home/emaisin/src/binutils-gdb/gdb/remote-sim.c:385:34: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
  vfprintf_filtered (gdb_stdout, format, args);
                                 ^~~~~~
/home/emaisin/src/binutils-gdb/gdb/remote-sim.c:394:34: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
  vfprintf_filtered (gdb_stdout, format, ap);
                                 ^~~~~~
/home/emaisin/src/binutils-gdb/gdb/remote-sim.c:402:34: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
  vfprintf_filtered (gdb_stderr, format, ap);
                                 ^~~~~~
/home/emaisin/src/binutils-gdb/gdb/remote-sim.c:413:11: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
  verror (format, args);
          ^~~~~~
4 errors generated.

gdb/ChangeLog:

* remote-sim.c (gdb_os_printf_filtered, gdb_os_vprintf_filtered,
gdb_os_evprintf_filtered, gdb_os_error): Add ATTRIBUTE_PRINTF.

6 years agoFix typo in listing of objcopy's command line options.
Ronald Hoogenboom [Tue, 20 Feb 2018 13:33:15 +0000 (13:33 +0000)] 
Fix typo in listing of objcopy's command line options.

binutils* doc/binutils.texi (objcopy): Add missing closing square
parenthesis to listing of objcopy's command line options.

6 years agoEnable link time garbage collection support for the IA64 target.
Jason Duerstock [Tue, 20 Feb 2018 13:21:55 +0000 (13:21 +0000)] 
Enable link time garbage collection support for the IA64 target.

As suggested in long ago in a galaxy far, far away [1], I tried
turning it on and it seems to work, as is evidenced by the Mesa
package in Debian/ia64.  Please enable it with the following patch.
[1] https://sourceware.org/ml/binutils/2007-07/msg00241.html

bfd * elfnn-ia64.c (elf_backend_can_gc_sections): Enable.

6 years agognulib: import mkstemp
Markus Metzger [Tue, 20 Feb 2018 10:48:01 +0000 (11:48 +0100)] 
gnulib: import mkstemp

Older versions of MinGW do not support mkstemp causing:

    gdb/unittests/scoped_fd-selftests.c:37:29: error: \
    'mkstemp' was not declared in this scope
       int fd = mkstemp (filename);
                             ^
    gdb/unittests/scoped_fd-selftests.c: In function 'void
    selftests::scoped_fd::test_release()':
    gdb/unittests/scoped_fd-selftests.c:56:29: error: \
    'mkstemp' was not declared in this scope
       int fd = mkstemp (filename);
                             ^

Import mkstemp from gnulib.

gdb/
* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add mkstemp.
* gnulib/aclocal.m4: Regenerated.
* gnulib/config.in: Regenerated.
* gnulib/configure: Regenerated.
* gnulib/import/Makefile.am: Regenerated.
* gnulib/import/Makefile.in: Regenerated.
* gnulib/import/m4/gnulib-cache.m4: Regenerated.
* gnulib/import/m4/gnulib-comp.m4: Regenerated.
* gnulib/import/m4/mkstemp.m4: Imported.
* gnulib/import/m4/secure_getenv.m4: Imported.
* gnulib/import/m4/tempname.m4: Imported.
* gnulib/import/mkstemp.c: Imported.
* gnulib/import/secure_getenv.c: Imported.
* gnulib/import/tempname.c: Imported.
* gnulib/import/tempname.h: Imported.

6 years agobtrace, testsuite: do not force BTS
Markus Metzger [Tue, 9 Jan 2018 15:12:24 +0000 (16:12 +0100)] 
btrace, testsuite: do not force BTS

In gdb.btrace/buffer-size.exp we explicitly ask for the BTS recording format.
This may lead to spurious fails on systems where PT is being used by some other
process at the same time.

Set both PT and BTS buffer sizes to 1 and check that whatever recording format
is used will use a 4KB buffer.

testsuite/
* gdb.btrace/buffer-size.exp: Do not force BTS.

6 years agoClarify .arch_extension possible values
Thomas Preud'homme [Tue, 20 Feb 2018 12:48:50 +0000 (12:48 +0000)] 
Clarify .arch_extension possible values

Documentation for .arch_extension says it accepts the same architectural
extensions as those accepted by -mcpu. Given the name and the fact that
-march for obvious reason also accept the same extensions, I believe
it's worth mentioning that it accepts the same extensions as both
-march and -mcpu. This commit addresses that.

2018-02-20  Thomas Preud'homme  <thomas.preudhomme@arm.com>

gas/
* doc/c-arm.texi (.arch_extension): Mention extensions it accepts are
also the same as -march.

6 years agoFix make 3.81 build errors
Alan Hayward [Tue, 20 Feb 2018 10:03:56 +0000 (10:03 +0000)] 
Fix make 3.81 build errors

gdbserver/
* Makefile.in: Switch order of make rules.

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

6 years agogdb/doc: Additional information about 'info line'
Andrew Burgess [Fri, 16 Feb 2018 15:37:05 +0000 (15:37 +0000)] 
gdb/doc: Additional information about 'info line'

Extend the documentation of 'info line' command to:

    1. Make 'info line' with no argument more obvious, and make it clearer
       what this does.

    2. Cover what happens when a secod 'info line' with no argument is
       issued.

    3. Extend the example output for 'info line ...' to include
       symbolic addresses.

gdb/doc/ChangeLog:

* gdb.texinfo (Machine Code): Additional information about "info
line" command.

6 years agoRevert "_bfd_mips_elf_final_link: Notify user about wrong .reginfo size"
Maciej W. Rozycki [Mon, 19 Feb 2018 18:38:41 +0000 (18:38 +0000)] 
Revert "_bfd_mips_elf_final_link: Notify user about wrong .reginfo size"

Revert commit 58807c48a5a3 ("_bfd_mips_elf_final_link: Notify user about
wrong .reginfo size") now that the size of the `.reginfo' section has
been truly fixed in `_bfd_mips_elf_section_processing', meaning that the
offending condition can be asserted again.

bfd/
Revert
2018-01-12  Vlad Ivanov  <vlad@ivanov.email>

* elfxx-mips.c (_bfd_mips_elf_final_link): Notify user when
.reginfo section has wrong size.

6 years agoMIPS/BFD: Fix the size of `.reginfo' and `.MIPS.abiflags' sections
Maciej W. Rozycki [Mon, 19 Feb 2018 18:38:41 +0000 (18:38 +0000)] 
MIPS/BFD: Fix the size of `.reginfo' and `.MIPS.abiflags' sections

Use the SEC_FIXED_SIZE flag to actually fix the size of `.reginfo' and
`.MIPS.abiflags' sections in `_bfd_mips_elf_always_size_sections', as
originally intended, removing link failures such as:

ld: final link failed: Section has no contents

or:

ld: final link failed: Bad value

or:

ld: foo: .reginfo section size should be 24 bytes, actual size is 32

and assertion failures like:

ld: BFD (GNU Binutils) 2.30.51.20180131 assertion fail .../bfd/elfxx-mips.c:14322

in link scenarios involving a linker script that either creates an
output `.reginfo' or `.MIPS.abiflags' section from scratch or produces
either section from different sections.  If such an output section's
size turns out to be incorrect according to the psABI, then the section
is either truncated or padded out to the correct size, as relevant.

This allows people to handle these sections in a link in an unusual way,
while still addressing the issue covered by commit 58807c48a5a3
("_bfd_mips_elf_final_link: Notify user about wrong .reginfo size").

The original arrangement, coming from an unindentified change made to
what was called `mips_elf_always_size_sections' back then, between
commit 02650bd0a97e ("This adds ABI flags to MIPS/ELF object files.")
and commit 252b5132c753 ("19990502 sourceware import"), also missing
from BFD ChangeLog files, assumed that the output section size is not
going to change after return from `bfd_elf_size_dynamic_sections', the
caller of that function, called in turn from `ldemul_before_allocation'
via `gld${EMULATION_NAME}_before_allocation' in ld/emultempl/elf32.em,
and ultimately from `lang_process'.  This is because later on in
`lang_process' processing `lang_size_sections' is called , happily
recalculating the section size, and it has actually already been the
case at the time of commit 252b5132c753 ("19990502 sourceware import"),
so the assumption was clearly incorrect right from the beginning.

bfd/
* elfxx-mips.c (_bfd_mips_elf_always_size_sections): Set
SEC_FIXED_SIZE and SEC_HAS_CONTENTS flags for `.reginfo' and
`.MIPS.abiflags' sections.
(_bfd_mips_elf_final_link): Avoid reading beyond `.reginfo'
section's end.

ld/
* testsuite/ld-mips-elf/reginfo-0.d: New test.
* testsuite/ld-mips-elf/reginfo-0r.d: New test.
* testsuite/ld-mips-elf/reginfo-1.d: New test.
* testsuite/ld-mips-elf/reginfo-1r.d: New test.
* testsuite/ld-mips-elf/reginfo-2.d: New test.
* testsuite/ld-mips-elf/reginfo-2r.d: New test.
* testsuite/ld-mips-elf/mips-abiflags-0.d: New test.
* testsuite/ld-mips-elf/mips-abiflags-0r.d: New test.
* testsuite/ld-mips-elf/mips-abiflags-1.d: New test.
* testsuite/ld-mips-elf/mips-abiflags-1r.d: New test.
* testsuite/ld-mips-elf/mips-abiflags-2.d: New test.
* testsuite/ld-mips-elf/mips-abiflags-2r.d: New test.
* testsuite/ld-mips-elf/reginfo-0.ld: New test linker script.
* testsuite/ld-mips-elf/reginfo-1.ld: New test linker script.
* testsuite/ld-mips-elf/mips-abiflags-0.ld: New test linker
script.
* testsuite/ld-mips-elf/mips-abiflags-1.ld: New test linker
script.
* testsuite/ld-mips-elf/reginfo-1.s: New test source.
* testsuite/ld-mips-elf/reginfo-2.s: New test source.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.

6 years agoLD: Support fixed-size sections some psABIs may require
Maciej W. Rozycki [Mon, 19 Feb 2018 18:38:41 +0000 (18:38 +0000)] 
LD: Support fixed-size sections some psABIs may require

Define a SEC_FIXED_SIZE section flag for target backends to use for
output sections whose size has been fixed in the psABI.  The size of
such sections will not be changed anyhow by the generic linker and it is
up to the target backend to get their size right.

bfd/
* section.c (SEC_FIXED_SIZE): New macro.
* bfd-in2.h: Regenerate.

ld/
* ldlang.c (insert_pad): Do not change output section's size if
SEC_FIXED_SIZE is set in the flags.
(size_input_section): Likewise.
(lang_size_sections_1): Likewise.
(lang_reset_memory_regions): Likewise.

6 years agoBFD: Remove unused SEC_HAS_GOT_REF section flag
Maciej W. Rozycki [Mon, 19 Feb 2018 18:38:41 +0000 (18:38 +0000)] 
BFD: Remove unused SEC_HAS_GOT_REF section flag

Remove the SEC_HAS_GOT_REF section flag no longer in use since commit
a252afa4cdff ("Fix linking of PIC code on PA"),
<https://sourceware.org/ml/binutils/2003-08/msg00467.html>, to make the
bit position available for reuse.

bfd/
* section.c (SEC_HAS_GOT_REF): Remove macro.
* bfd-in2.h: Regenerate.

6 years agoAdd attribute printf to _bfd_error_handler
Alan Modra [Mon, 19 Feb 2018 13:06:55 +0000 (23:36 +1030)] 
Add attribute printf to _bfd_error_handler

and fix a few stray errors.

* elf-attrs.c (_bfd_elf_parse_attributes): Correct _bfd_error_handler
arguments.
* elfxx-mips.c (_bfd_mips_elf_final_link): Likewise.
* elfnn-riscv.c (_bfd_riscv_relax_align): Likewise.
(_bfd_riscv_relax_pc): Likewise and fix typos.
* libbfd-in.h (_bfd_error_handler): Add attribute printf.
* libbfd.h: Regenerate.

6 years agoDon't use %ll
Alan Modra [Mon, 19 Feb 2018 08:18:15 +0000 (18:48 +1030)] 
Don't use %ll

* dwarf2.c (read_section): Don't use 'll' format modifier.
(find_abstract_instance): Likewise.
* elfcore.h (elf_core_file_p): Likewise.

6 years ago%L conversions
Alan Modra [Mon, 19 Feb 2018 08:04:15 +0000 (18:34 +1030)] 
%L conversions

* bfd-in.h: Include inttypes.h or if not available define
PRId64, PRIu64 and PRIx64.
* bfd.c (_bfd_doprnt, _bfd_doprnt_scan): Remove support for L
modifier to print bfd_vma.
* coff-arm.c, * coff-mcore.c, * coff-ppc.c, * coff-rs6000.c,
* coff-sh.c, * coff-tic80.c, * coffcode.h, * coffgen.c, * cofflink.c,
* compress.c, * dwarf2.c, * elf-m10300.c, * elf.c, * elf32-arc.c,
* elf32-arm.c, * elf32-bfin.c, * elf32-cris.c, * elf32-hppa.c,
* elf32-i386.c, * elf32-ip2k.c, * elf32-lm32.c, * elf32-m32r.c,
* elf32-m68k.c, * elf32-metag.c, * elf32-nds32.c, * elf32-nios2.c,
* elf32-ppc.c, * elf32-rx.c, * elf32-s390.c, * elf32-score.c,
* elf32-score7.c, * elf32-sh.c, * elf32-sh64.c, * elf32-spu.c,
* elf32-tic6x.c, * elf32-tilepro.c, * elf32-v850.c, * elf32-vax.c,
* elf32-xtensa.c, * elf64-alpha.c, * elf64-hppa.c, * elf64-ia64-vms.c,
* elf64-mmix.c, * elf64-s390.c, * elf64-sh64.c, * elf64-x86-64.c,
* elfcode.h, * elfcore.h, * elflink.c, * elfnn-aarch64.c,
* elfnn-ia64.c, * elfnn-riscv.c, * elfxx-mips.c, * elfxx-sparc.c,
* elfxx-tilegx.c, * ieee.c, * ihex.c, * mach-o.c, * merge.c, * mmo.c,
* peXXigen.c, * xcofflink.c: Replace use of Lx modifier with PRIx64,
and cast input to uint64_t, and similarly for Ld and Lu.
* bfd-in2.h: Regenerate.

6 years agoUse %pI, %pR, %pS, %pT in place of %I, %R, %S and %T.
Alan Modra [Mon, 19 Feb 2018 08:00:41 +0000 (18:30 +1030)] 
Use %pI, %pR, %pS, %pT in place of %I, %R, %S and %T.

bfd/
* elf32-arm.c, * elf32-hppa.c, * elf32-lm32.c, * elf32-m32r.c,
* elf32-metag.c, * elf32-nds32.c, * elf32-or1k.c, * elf32-ppc.c,
* elf32-s390.c, * elf32-sh.c, * elf32-tic6x.c, * elf32-tilepro.c,
* elf64-ppc.c, * elf64-s390.c, * elflink.c, * elfnn-aarch64.c,
* elfnn-riscv.c, * elfxx-sparc.c, * elfxx-tilegx.c, * elfxx-x86.c,
* reloc.c: Replace use of %R and %T in format strings passed to
einfo and friends by %pR and %pT.
ld/
* ldmisc.c (vfinfo) Handle %pI, %pR, %pS and %pT in place of
%I, %R, %S and %T.
* ldcref.c, * ldctor.c, * ldemul.c, * ldexp.c, * ldgram.y,
* ldlang.c, * ldlex.l, * ldmain.c, * ldmisc.c, * pe-dll.c,
* emultempl/sh64elf.em: Replace use of of %I, %R, %S and %T in
format strings passed to einfo and friends by %pI, %pR, %pS and %pT.

6 years agoUse %pA and %pB in messages rather than %A and %B
Alan Modra [Mon, 19 Feb 2018 04:51:40 +0000 (15:21 +1030)] 
Use %pA and %pB in messages rather than %A and %B

First step towards compiler verification of _bfd_error_handler
arguments, and better verification of translated messages.

bfd/
* bfd.c (_bfd_doprnt, _bfd_doprnt_scan): Handle %pA and %pB in place
of %A and %B.
* aout-adobe.c: Update all messages using %A and %B.
* aout-cris.c: Likewise.
* aoutx.h: Likewise.
* archive.c: Likewise.
* binary.c: Likewise.
* cache.c: Likewise.
* coff-alpha.c: Likewise.
* coff-arm.c: Likewise.
* coff-i860.c: Likewise.
* coff-mcore.c: Likewise.
* coff-ppc.c: Likewise.
* coff-rs6000.c: Likewise.
* coff-sh.c: Likewise.
* coff-tic4x.c: Likewise.
* coff-tic54x.c: Likewise.
* coff-tic80.c: Likewise.
* coff64-rs6000.c: Likewise.
* coffcode.h: Likewise.
* coffgen.c: Likewise.
* cofflink.c: Likewise.
* coffswap.h: Likewise.
* compress.c: Likewise.
* cpu-arm.c: Likewise.
* ecoff.c: Likewise.
* elf-attrs.c: Likewise.
* elf-eh-frame.c: Likewise.
* elf-ifunc.c: Likewise.
* elf-m10300.c: Likewise.
* elf-properties.c: Likewise.
* elf-s390-common.c: Likewise.
* elf.c: Likewise.
* elf32-arc.c: Likewise.
* elf32-arm.c: Likewise.
* elf32-avr.c: Likewise.
* elf32-bfin.c: Likewise.
* elf32-cr16.c: Likewise.
* elf32-cr16c.c: Likewise.
* elf32-cris.c: Likewise.
* elf32-crx.c: Likewise.
* elf32-d10v.c: Likewise.
* elf32-d30v.c: Likewise.
* elf32-epiphany.c: Likewise.
* elf32-fr30.c: Likewise.
* elf32-frv.c: Likewise.
* elf32-gen.c: Likewise.
* elf32-hppa.c: Likewise.
* elf32-i370.c: Likewise.
* elf32-i386.c: Likewise.
* elf32-i960.c: Likewise.
* elf32-ip2k.c: Likewise.
* elf32-iq2000.c: Likewise.
* elf32-lm32.c: Likewise.
* elf32-m32c.c: Likewise.
* elf32-m32r.c: Likewise.
* elf32-m68hc11.c: Likewise.
* elf32-m68hc12.c: Likewise.
* elf32-m68hc1x.c: Likewise.
* elf32-m68k.c: Likewise.
* elf32-mcore.c: Likewise.
* elf32-mep.c: Likewise.
* elf32-metag.c: Likewise.
* elf32-microblaze.c: Likewise.
* elf32-moxie.c: Likewise.
* elf32-msp430.c: Likewise.
* elf32-mt.c: Likewise.
* elf32-nds32.c: Likewise.
* elf32-nios2.c: Likewise.
* elf32-or1k.c: Likewise.
* elf32-pj.c: Likewise.
* elf32-ppc.c: Likewise.
* elf32-rl78.c: Likewise.
* elf32-rx.c: Likewise.
* elf32-s390.c: Likewise.
* elf32-score.c: Likewise.
* elf32-score7.c: Likewise.
* elf32-sh-symbian.c: Likewise.
* elf32-sh.c: Likewise.
* elf32-sh64.c: Likewise.
* elf32-sparc.c: Likewise.
* elf32-spu.c: Likewise.
* elf32-tic6x.c: Likewise.
* elf32-tilepro.c: Likewise.
* elf32-v850.c: Likewise.
* elf32-vax.c: Likewise.
* elf32-visium.c: Likewise.
* elf32-wasm32.c: Likewise.
* elf32-xgate.c: Likewise.
* elf32-xtensa.c: Likewise.
* elf64-alpha.c: Likewise.
* elf64-gen.c: Likewise.
* elf64-hppa.c: Likewise.
* elf64-ia64-vms.c: Likewise.
* elf64-mmix.c: Likewise.
* elf64-ppc.c: Likewise.
* elf64-s390.c: Likewise.
* elf64-sh64.c: Likewise.
* elf64-sparc.c: Likewise.
* elf64-x86-64.c: Likewise.
* elfcode.h: Likewise.
* elfcore.h: Likewise.
* elflink.c: Likewise.
* elfnn-aarch64.c: Likewise.
* elfnn-ia64.c: Likewise.
* elfnn-riscv.c: Likewise.
* elfxx-mips.c: Likewise.
* elfxx-sparc.c: Likewise.
* elfxx-tilegx.c: Likewise.
* elfxx-x86.c: Likewise.
* hpux-core.c: Likewise.
* ieee.c: Likewise.
* ihex.c: Likewise.
* libbfd.c: Likewise.
* linker.c: Likewise.
* mach-o.c: Likewise.
* merge.c: Likewise.
* mmo.c: Likewise.
* oasys.c: Likewise.
* pdp11.c: Likewise.
* pe-mips.c: Likewise.
* peXXigen.c: Likewise.
* peicode.h: Likewise.
* reloc.c: Likewise.
* rs6000-core.c: Likewise.
* srec.c: Likewise.
* stabs.c: Likewise.
* vms-alpha.c: Likewise.
* xcofflink.c: Likewise.
ld/
* ldmisc.c (vfinfo): Handle %pA and %pB in place of %A and %B.
* ldcref.c: Update all messages using %A and %B.
* ldexp.c: Likewise.
* ldlang.c: Likewise.
* ldmain.c: Likewise.
* ldmisc.c: Likewise.
* pe-dll.c: Likewise.
* plugin.c: Likewise.
* emultempl/beos.em: Likewise.
* emultempl/cr16elf.em: Likewise.
* emultempl/elf32.em: Likewise.
* emultempl/m68kcoff.em: Likewise.
* emultempl/m68kelf.em: Likewise.
* emultempl/mmo.em: Likewise.
* emultempl/nds32elf.em: Likewise.
* emultempl/pe.em: Likewise.
* emultempl/pep.em: Likewise.
* emultempl/spuelf.em: Likewise.
* emultempl/sunos.em: Likewise.
* emultempl/xtensaelf.em: Likewise.

6 years agold: Add -z separate-code tests to frame.exp
H.J. Lu [Mon, 19 Feb 2018 13:07:33 +0000 (05:07 -0800)] 
ld: Add -z separate-code tests to frame.exp

On x86, "-z separate-code" leads to assertion fail at bfd/elf.c:5917.
Alsp skip tests if -shared isn't supported.

PR ld/22845
* testsuite/ld-elf/frame.exp: Skip if -shared isn't supported.
Add tests for "-z noseparate-code" and "-z separate-code".
Remove unsupported -shared check.

6 years ago[ARM] Fix bxns mask
Thomas Preud'homme [Mon, 19 Feb 2018 12:05:18 +0000 (12:05 +0000)] 
[ARM] Fix bxns mask

Bit 7 of BXNS is a fixed bit which distinguish it from BLXNS. Yet it is
not set in the disassembler entry mask. This commit fixes that.

2018-02-19  Thomas Preud'homme  <thomas.preudhomme@arm.com>

opcodes/
* arm-dis.c (thumb_opcodes): Fix BXNS mask.

6 years agoFix mistake in the declaration of the --include-all-whitespace option of the strings...
Matthias Klose [Mon, 19 Feb 2018 11:56:53 +0000 (11:56 +0000)] 
Fix mistake in the declaration of the --include-all-whitespace option of the strings utility.

* strings.c (long_options): Include-all-whitespace does not take
        an extra agument.

6 years agoAdd common/ dir in build directories
Alan Hayward [Mon, 19 Feb 2018 09:37:24 +0000 (09:37 +0000)] 
Add common/ dir in build directories

gdb/
* Makefile.in: (COMMON_SFILES): Add common/*.c files.
(SFILES): Remove common/*.c files.
(COMMON_OBS): Remove some *.o files built from common/*.c files.
* common/common.host: Add common reference.
* configure.ac: Likewise.
* configure: Regenerate.

gdbserver/
* Makefile.in: Add common directory in build.
* configure.ac: Add common reference.
* configure: Regenerate.

6 years agoPT_LOAD and PT_GNU_RELRO segment overlap
Alan Modra [Sun, 18 Feb 2018 23:22:53 +0000 (09:52 +1030)] 
PT_LOAD and PT_GNU_RELRO segment overlap

Commit 325ba6fb34 excluded degenerate zero length PT_LOAD segments,
but that only fixed part of the problem, which was that the load
segment limits were not calculated properly.

PR 22845
* elf.c (IS_TBSS): Define.
(_bfd_elf_map_sections_to_segments): Use IS_TBSS.
(assign_file_positions_for_non_load_sections): Revert last change.
Properly calculate load segment limits to compare against relro limits.

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

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

6 years agold-elf/ehdr_start: Pass --build-id to ld
H.J. Lu [Sat, 17 Feb 2018 22:54:16 +0000 (14:54 -0800)] 
ld-elf/ehdr_start: Pass --build-id to ld

ld-elf/ehdr_start fails with -z separate-code.  Since there is no data
LOAD segment before code LOAD segment:

There are 2 program headers, starting at offset 64

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
  LOAD           0x200000 0x0000000000600000 0x0000000000600000 0x000010 0x000010 R E 0x200000
  LOAD           0x400000 0x0000000000800000 0x0000000000800000 0x000008 0x000008 R   0x200000

 Section to Segment mapping:
  Segment Sections...
   00     .text
   01     .rodata

the program header isn't included in any LOAD segment.  As the result,
reference to __ehdr_start is resolved to zero.  Pass --build-id to ld
to add a data LOAD segment before code LOAD segment to put the program
header in the  data LOAD segment.

PR ld/22845
* testsuite/ld-elf/ehdr_start.d: Pass --build-id to ld.

6 years agold: Add -z separate-code test for zero size section
H.J. Lu [Sat, 17 Feb 2018 13:37:37 +0000 (05:37 -0800)] 
ld: Add -z separate-code test for zero size section

PR ld/22845
* testsuite/ld-elf/binutils.exp (tls_opts): Add tests for
"-z noseparate-code" and "-z separate-code".

6 years agold-elf/eh4: Pass -z max-page-size=0x200000 -z noseparate-code to ld
H.J. Lu [Sat, 17 Feb 2018 13:30:13 +0000 (05:30 -0800)] 
ld-elf/eh4: Pass -z max-page-size=0x200000 -z noseparate-code to ld

-z separate-code creates separate code LOAD segment, aligns it to the
maximum page size and places .plt section before .text section.  But
ld-elf/eh4 passes -Ttext 0x400 to linker to place .text section at
address 0x400, which is impossible for linker to accomplish:

$ ld -shared -Ttext 0x400 -z separate-code -o x.so eh4.o
ld: section .eh_frame LMA [0000000000200000,000000000020006b] overlaps section .plt LMA [0000000000200000,000000000020001f]

Since ld-elf/eh4 also checks exact addresses, this patch passes
-z max-page-size=0x200000 -z noseparate-code to ld.

PR ld/22845
* ld-elf/eh4.d: Pass -z max-page-size=0x200000 -z noseparate-code
to ld.

6 years agoAdd .nop assembler directive
H.J. Lu [Sat, 17 Feb 2018 13:20:42 +0000 (05:20 -0800)] 
Add .nop assembler directive

Implement the '.nop SIZE[, CONTROL]' assembler directive, which emits
SIZE bytes filled with no-op instructions.  SIZE is absolute expression.
The optional CONTROL byte controls how no-op instructions should be
generated.  If the comma and @var{control} are omitted, CONTROL is
assumed to be zero.

For Intel 80386 and AMD x86-64 targets, CONTROL byte specifies the size
limit of a single no-op instruction.  The valid values of CONTROL byte
are between 0 and 8 for 16-bit mode, between 0 and 10 for 32-bit mode,
between 0 and 11 for 64-bit mode.  When 0 is used, the no-op size limit
is set to the maximum supported size.

2 new relax states, rs_space_nop and rs_fill_nop, are added to enum
_relax_state, which are similar to rs_space and rs_fill, respectively,
but they fill with no-op instructions, instead of a single byte.  A
target backend must override the default md_generate_nops to generate
proper no-op instructions.  Otherwise, an error of unimplemented .nop
directive will be issued whenever .nop directive is used.

* NEWS: Mention .nop directive.
* as.h (_relax_state): Add rs_space_nop and rs_fill_nop.
* read.c (potable): Add .nop.
(s_nop): New function.
* read.h (s_nop): New prototype.
* write.c (cvt_frag_to_fill): Handle rs_space_nop and
rs_fill_nop.
(md_generate_nops): New function.
(relax_segment): Likewise.
(write_contents): Use md_generate_nops for rs_fill_nop.
* config/tc-i386.c (alt64_11): New.
(alt64_patt): Likewise.
(md_convert_frag): Handle rs_space_nop.
(i386_output_nops): New function.
(i386_generate_nops): Likewise.
(i386_align_code): Call i386_output_nops.
* config/tc-i386.h (i386_generate_nops): New.
(md_generate_nops): Likewise.
* doc/as.texinfo: Document .nop directive.
* testsuite/gas/i386/i386.exp: Run .nop directive tests.
* testsuite/gas/i386/nop-1.d: New file.
* testsuite/gas/i386/nop-1.s: Likewise.
* testsuite/gas/i386/nop-2.d: Likewise.
* testsuite/gas/i386/nop-2.s: Likewise.
* testsuite/gas/i386/nop-3.d: Likewise.
* testsuite/gas/i386/nop-3.s: Likewise.
* testsuite/gas/i386/nop-4.d: Likewise.
* testsuite/gas/i386/nop-4.s: Likewise.
* testsuite/gas/i386/nop-5.d: Likewise.
* testsuite/gas/i386/nop-5.s: Likewise.
* testsuite/gas/i386/nop-6.d: Likewise.
* testsuite/gas/i386/nop-6.s: Likewise.
* testsuite/gas/i386/nop-bad-1.l: Likewise.
* testsuite/gas/i386/nop-bad-1.s: Likewise.
* testsuite/gas/i386/x86-64-nop-1.d: Likewise.
* testsuite/gas/i386/x86-64-nop-2.d: Likewise.
* testsuite/gas/i386/x86-64-nop-3.d: Likewise.
* testsuite/gas/i386/x86-64-nop-4.d: Likewise.
* testsuite/gas/i386/x86-64-nop-5.d: Likewise.
* testsuite/gas/i386/x86-64-nop-6.d: Likewise.

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

6 years agoIgnore degenerate PT_LOAD segments
Alan Modra [Fri, 16 Feb 2018 22:51:17 +0000 (09:21 +1030)] 
Ignore degenerate PT_LOAD segments

Fixes a failure triggered by -z separate-code.  p_memsz is tested
rather than p_filesz for objcopy --only-keep-debug where p_filesz is
set to zero.

PR 22845
* elf.c (assign_file_positions_for_non_load_sections): Ignore
degenerate zero size PT_LOAD segments when finding one overlapping
the PT_GNU_RELRO segment.

6 years agox86-64: Add -z max-page-size=0x200000 -z noseparate-code to linker tests
H.J. Lu [Fri, 16 Feb 2018 18:02:00 +0000 (10:02 -0800)] 
x86-64: Add -z max-page-size=0x200000 -z noseparate-code to linker tests

Add -z max-page-size=0x200000 -z noseparate-code since these tests
check for exact addresses.

* testsuite/ld-x86-64/bnd-branch-1-now.d: Add  -z
max-page-size=0x200000 -z noseparate-code.
* testsuite/ld-x86-64/bnd-ifunc-1-now.d: Likewise.
* testsuite/ld-x86-64/bnd-ifunc-2-now.d: Likewise.
* testsuite/ld-x86-64/bnd-ifunc-2.d: Likewise.
* testsuite/ld-x86-64/bnd-plt-1-now.d: Likewise.
* testsuite/ld-x86-64/bnd-plt-1.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-1-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-1.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2a-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2a.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2b-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2b.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2c-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2c.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2d-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-2d.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-3a-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-3a.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-3b-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-3b.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-3c-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-3c.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-3d-x32.d: Likewise.
* testsuite/ld-x86-64/ibt-plt-3d.d: Likewise.
* testsuite/ld-x86-64/load1a.d: Likewise.
* testsuite/ld-x86-64/load1b.d: Likewise.
* testsuite/ld-x86-64/load1c.d: Likewise.
* testsuite/ld-x86-64/load1d.d: Likewise.
* testsuite/ld-x86-64/pie3.d: Likewise.
* testsuite/ld-x86-64/pr14207.d: Likewise.
* testsuite/ld-x86-64/pr17618.d: Likewise.
* testsuite/ld-x86-64/pr19162.d: Likewise.
* testsuite/ld-x86-64/pr19636-2d.d: Likewise.
* testsuite/ld-x86-64/pr19636-2l.d: Likewise.
* testsuite/ld-x86-64/pr20253-1b.d: Likewise.
* testsuite/ld-x86-64/pr20253-1d.d: Likewise.
* testsuite/ld-x86-64/pr20253-1f.d: Likewise.
* testsuite/ld-x86-64/pr20253-1h.d: Likewise.
* testsuite/ld-x86-64/pr20253-1j.d: Likewise.
* testsuite/ld-x86-64/pr20253-1l.d: Likewise.
* testsuite/ld-x86-64/pr20830a-now.d: Likewise.
* testsuite/ld-x86-64/pr20830a.d: Likewise.
* testsuite/ld-x86-64/pr20830b-now.d: Likewise.
* testsuite/ld-x86-64/pr20830b.d: Likewise.
* testsuite/ld-x86-64/pr21038a-now.d: Likewise.
* testsuite/ld-x86-64/pr21038a.d: Likewise.
* testsuite/ld-x86-64/pr21038b-now.d: Likewise.
* testsuite/ld-x86-64/pr21038b.d: Likewise.
* testsuite/ld-x86-64/pr21038c-now.d: Likewise.
* testsuite/ld-x86-64/pr21038c.d: Likewise.

6 years agox86-64: Update tests for -z separate-code
H.J. Lu [Fri, 16 Feb 2018 17:56:58 +0000 (09:56 -0800)] 
x86-64: Update tests for -z separate-code

"-z separate-code" generates different addresses.  Update these tests
to accept any addresses.

* testsuite/ld-x86-64/bnd-ifunc-1.d: Updated.
* testsuite/ld-x86-64/ilp32-4.d: Likewise.

6 years agompx.exp: Add -z max-page-size=0x200000 -z noseparate-code
H.J. Lu [Fri, 16 Feb 2018 17:54:56 +0000 (09:54 -0800)] 
mpx.exp: Add -z max-page-size=0x200000 -z noseparate-code

Add -z max-page-size=0x200000 -z noseparate-code since these tests
check for exact addresses.

* testsuite/ld-x86-64/mpx.exp: Add -z max-page-size=0x200000
-z noseparate-code.

6 years agox86-64.exp: Add -z noseparate-code -z max-page-size=0x200000
H.J. Lu [Fri, 16 Feb 2018 17:49:34 +0000 (09:49 -0800)] 
x86-64.exp: Add -z noseparate-code -z max-page-size=0x200000

Add -z noseparate-code -z max-page-size=0x200000 since these tests
check for exact addresses and don't expect extra PT_LOAD segment.  But
don't add them to nacl targets since they generate different addresses.

* testsuite/ld-x86-64/x86-64.exp: Add -z noseparate-code
-z max-page-size=0x200000, excluding NaCl target.

6 years agox86: Add -z noseparate-code to IFUNC tests
H.J. Lu [Fri, 16 Feb 2018 17:45:02 +0000 (09:45 -0800)] 
x86: Add -z noseparate-code to IFUNC tests

Add -z noseparate-code since these tests check for exact addresses.

* testsuite/ld-ifunc/ifunc-2-i386-now.d: Likewise.
* testsuite/ld-ifunc/ifunc-2-local-i386-now.d: Likewise.
* testsuite/ld-ifunc/ifunc-2-local-x86-64.d: Likewise.
* testsuite/ld-ifunc/ifunc-21-i386.d: Likewise.
* testsuite/ld-ifunc/ifunc-22-i386.d: Likewise.
* testsuite/ld-ifunc/pr17154-i386-now.d: Likewise.
* testsuite/ld-ifunc/pr17154-i386.d: Likewise.

6 years agox86-64: Add -z max-page-size=0x200000 -z noseparate-code to IFUNC tests
H.J. Lu [Fri, 16 Feb 2018 17:39:07 +0000 (09:39 -0800)] 
x86-64: Add -z max-page-size=0x200000 -z noseparate-code to IFUNC tests

Add -z max-page-size=0x200000 -z noseparate-code since these tests
check for exact addresses.

* testsuite/ld-ifunc/ifunc-2-local-x86-64-now.d: Add
 -z max-page-size=0x200000 -z noseparate-code.
* testsuite/ld-ifunc/ifunc-2-x86-64-now.d: Likewise.
* testsuite/ld-ifunc/ifunc-2-x86-64.d: Likewise.
* testsuite/ld-ifunc/ifunc-21-x86-64.d: Likewise.
* testsuite/ld-ifunc/ifunc-22-x86-64.d: Likewise.
* testsuite/ld-ifunc/pr17154-x86-64-now.d: Likewise.
* testsuite/ld-ifunc/pr17154-x86-64.d: Likewise.

6 years agoi386: Update IFUNC tests for PLT address
H.J. Lu [Fri, 16 Feb 2018 17:32:56 +0000 (09:32 -0800)] 
i386: Update IFUNC tests for PLT address

i386 generates

 161: e8 ea ff ff ff        call   150 <*ABS*@plt>

instead of

 1e1: e8 ea ff ff ff        callq  1d0 <*ABS*+0x1e0@plt>

* testsuite/ld-ifunc/ifunc-1-local-x86.d: Update PLT address
for i386.
* testsuite/ld-ifunc/ifunc-1-x86.d: Likewise.
* testsuite/ld-ifunc/ifunc-3a-x86.d: Likewise.

6 years agox86: Update IFUNC tests for -z separate-code
H.J. Lu [Fri, 16 Feb 2018 17:20:07 +0000 (09:20 -0800)] 
x86: Update IFUNC tests for -z separate-code

"-z separate-code" generates different PLT addresses.  Update these tests
to accept any PLT addresses.

* testsuite/ld-ifunc/ifunc-1-local-x86.d: Updated.
* testsuite/ld-ifunc/ifunc-1-x86.d: Likewise.
* testsuite/ld-ifunc/ifunc-3a-x86.d: Likewise.

6 years agoi386: Add -z noseparate-code to linker tests
H.J. Lu [Fri, 16 Feb 2018 17:07:46 +0000 (09:07 -0800)] 
i386: Add -z noseparate-code to linker tests

Add -z noseparate-code since these tests check for exact addresses.

* testsuite/ld-i386/ibt-plt-1.d: Add -z noseparate-code.
* testsuite/ld-i386/ibt-plt-2a.d: Likewise.
* testsuite/ld-i386/ibt-plt-2b.d: Likewise.
* testsuite/ld-i386/ibt-plt-2c.d: Likewise.
* testsuite/ld-i386/ibt-plt-2d.d: Likewise.
* testsuite/ld-i386/ibt-plt-3a.d: Likewise.
* testsuite/ld-i386/ibt-plt-3b.d: Likewise.
* testsuite/ld-i386/ibt-plt-3c.d: Likewise.
* testsuite/ld-i386/ibt-plt-3d.d: Likewise.
* testsuite/ld-i386/load1.d: Likewise.
* testsuite/ld-i386/pie1.d: Likewise.
* testsuite/ld-i386/pr20244-1a.d: Likewise.
* testsuite/ld-i386/pr20244-1b.d: Likewise.
* testsuite/ld-i386/pr20244-2a.d: Likewise.
* testsuite/ld-i386/pr20244-2b.d: Likewise.
* testsuite/ld-i386/pr20244-2c.d: Likewise.
* testsuite/ld-i386/pr20244-4a.d: Likewise.
* testsuite/ld-i386/pr20244-4b.d: Likewise.
* testsuite/ld-i386/pr20830.d: Likewise.

6 years agoi386: Update tests for -z separate-code
H.J. Lu [Fri, 16 Feb 2018 16:59:14 +0000 (08:59 -0800)] 
i386: Update tests for -z separate-code

"-z separate-code" generates:

0x00002080 00200000 00000000 00000000 00000000 . ..............

There is a space ' ', instead of '.'. Update these tests to expect ".*".

* testsuite/ld-i386/pr19636-1a.d: Updated.
* testsuite/ld-i386/pr19636-1b.d: Likewise.
* testsuite/ld-i386/pr19636-1j.d: Likewise.
* testsuite/ld-i386/pr19636-1k.d: Likewise.
* testsuite/ld-i386/pr19636-2a.d: Likewise.
* testsuite/ld-i386/pr19636-2b.d: Likewise.

6 years agoi386.exp: Add -z noseparate-code
H.J. Lu [Fri, 16 Feb 2018 16:56:25 +0000 (08:56 -0800)] 
i386.exp: Add -z noseparate-code

These tests fail due to one extra PT_LOAD segment with -z separate-code.

* testsuite/ld-i386/i386.exp: Add -z noseparate-code.

6 years agoNew class allocate_on_obstack
Yao Qi [Fri, 16 Feb 2018 16:20:58 +0000 (16:20 +0000)] 
New class allocate_on_obstack

This patch adds a new class allocate_on_obstack, and let dwarf2_per_objfile
inherit it, so that dwarf2_per_objfile is automatically allocated on
obstack, and "delete dwarf2_per_objfile" doesn't de-allocate any space.

gdb:

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

* block.c (block_namespace_info): Inherit allocate_on_obstack.
(block_initialize_namespace): Use new.
* dwarf2read.c (dwarf2_per_objfile): Inherit allocate_on_obstack.
(dwarf2_free_objfile): Use delete.
* gdbtypes.c (type_pair): Inherit allocate_on_obstack.
(copy_type_recursive): Use new.
* gdb_obstack.h (allocate_on_obstack): New.

6 years agoAdd -z noseparate-code to ld-elf tests
H.J. Lu [Fri, 16 Feb 2018 14:25:36 +0000 (06:25 -0800)] 
Add -z noseparate-code to ld-elf tests

These tests fail due to one extra PT_LOAD segment with -z separate-code.

* testsuite/ld-elf/pr19162.d: Add -z noseparate-code.
* testsuite/ld-elf/textaddr1.d: Likewise.
* testsuite/ld-elf/textaddr2.d: Likewise.
* testsuite/ld-elf/textaddr4.d: Likewise.
* testsuite/ld-elf/textaddr6.d: Likewise.

6 years agoRemove bfd stub function casts.
Alan Modra [Thu, 15 Feb 2018 00:28:06 +0000 (10:58 +1030)] 
Remove bfd stub function casts.

This patch defines a bunch of new functions to use in the BFD target
structs rather than casting bfd_false or bfd_true and similar stub
functions.  I've also renamed the stub functions to reflect their
parameters and put "error" in the name if they set bfd_error.  The
latter change is important since there were quite a few uses of
bfd_false where setting bfd_error was inappropriate, for example in
elf_backend_allow_non_load_phdr and is_target_special_symbol.

* libbfd.c (_bfd_bool_bfd_false_error): Rename from bfd_false.
(_bfd_bool_bfd_true): Rename from bfd_true.
(_bfd_ptr_bfd_null_error): Rename from bfd_nullvoidptr.
(_bfd_int_bfd_0): Rename from bfd_0.
(_bfd_uint_bfd_0): Rename from bfd_0u.
(_bfd_long_bfd_0): Rename from bfd_0l.
(_bfd_long_bfd_n1_error): Rename from _bfd_n1.
(_bfd_void_bfd): Rename from bfd_void.
(_bfd_bool_bfd_false, _bfd_bool_bfd_asymbol_false),
(_bfd_bool_bfd_link_false_error),
(_bfd_bool_bfd_link_true, _bfd_bool_bfd_bfd_true),
(_bfd_bool_bfd_uint_true, _bfd_bool_bfd_ptr_true),
(_bfd_bool_bfd_asection_bfd_asection_true),
(_bfd_bool_bfd_asymbol_bfd_asymbol_true),
(_bfd_void_bfd_link, _bfd_void_bfd_asection): New functions.
* archive.c (_bfd_noarchive_get_elt_at_index),
(_bfd_noarchive_openr_next_archived_file),
(_bfd_noarchive_construct_extended_name_table),
(_bfd_noarchive_write_ar_hdr, _bfd_noarchive_truncate_arname),
(_bfd_noarchive_write_armap): New functions.
* archures.c (_bfd_nowrite_set_arch_mach): New function.
* coff-alpha.c (alpha_ecoff_swap_coff_aux_in),
(alpha_ecoff_swap_coff_sym_in, alpha_ecoff_swap_coff_lineno_in),
(alpha_ecoff_swap_coff_aux_out, alpha_ecoff_swap_coff_sym_out),
(alpha_ecoff_swap_coff_lineno_out),
(alpha_ecoff_swap_coff_reloc_out): New functions.
* coff-mips.c (mips_ecoff_swap_coff_aux_in),
(mips_ecoff_swap_coff_sym_in, mips_ecoff_swap_coff_lineno_in),
(mips_ecoff_swap_coff_aux_out, mips_ecoff_swap_coff_sym_out),
(mips_ecoff_swap_coff_lineno_out),
(mips_ecoff_swap_coff_reloc_out): New functions.
* coffcode.h (coff_set_alignment_hook): Replace define with
new function.
(symname_in_debug_hook): Likewise.
* ecoff.c (_bfd_ecoff_set_alignment_hook): New function.
* elfxx-target.h (elf_backend_allow_non_load_phdr): Default to 0.
* elf.c (assign_file_positions_except_relocs): Test
elf_backend_allow_non_load_phdr for NULL.
* elflink.c (_bfd_elf_omit_section_dynsym_default): Rename from
_bfd_elf_link_omit_section_dynsym.  Update uses.
(_bfd_elf_omit_section_dynsym_all): New function.
* elf-bfd.h (_bfd_elf_link_omit_section_dynsym): Delete.
(_bfd_elf_omit_section_dynsym_default): Declare.
(_bfd_elf_omit_section_dynsym_all): Declare.
* linker.c (_bfd_nolink_sizeof_headers, _bfd_nolink_bfd_relax_section),
(_bfd_nolink_bfd_get_relocated_section_contents),
(_bfd_nolink_bfd_lookup_section_flags),
(_bfd_nolink_bfd_is_group_section, _bfd_nolink_bfd_discard_group),
(_bfd_nolink_bfd_link_hash_table_create),
(_bfd_nolink_bfd_link_just_syms),
(_bfd_nolink_bfd_copy_link_hash_symbol_type),
(_bfd_nolink_bfd_link_split_section),
(_bfd_nolink_section_already_linked),
(_bfd_nolink_bfd_define_common_symbol),
(_bfd_nolink_bfd_define_start_stop): New functions.
* reloc.c (_bfd_norelocs_bfd_reloc_type_lookup),
(_bfd_norelocs_bfd_reloc_name_lookup),
(_bfd_nodynamic_canonicalize_dynamic_reloc): New functions.
* section.c (_bfd_nowrite_set_section_contents): New function.
* syms.c (_bfd_nosymbols_canonicalize_symtab),
(_bfd_nosymbols_print_symbol, _bfd_nosymbols_get_symbol_info),
(_bfd_nosymbols_get_symbol_version_string),
(_bfd_nosymbols_bfd_is_local_label_name),
(_bfd_nosymbols_get_lineno, _bfd_nosymbols_find_nearest_line),
(_bfd_nosymbols_find_line, _bfd_nosymbols_find_inliner_info),
(_bfd_nosymbols_bfd_make_debug_symbol),
( _bfd_nosymbols_read_minisymbols),
( _bfd_nosymbols_minisymbol_to_symbol),
(_bfd_nodynamic_get_synthetic_symtab): New functions.
* libbfd-in.h: Declare new functions.  Update existing defines,
removing casts.
* aix386-core.c: Update to use new hooks.  Formatting.
* aout-adobe.c: Likewise.
* aout-arm.c: Likewise.
* aout-target.h: Likewise.
* aout-tic30.c: Likewise.
* aoutf1.h: Likewise.
* binary.c: Likewise.
* bout.c: Likewise.
* cisco-core.c: Likewise.
* coff-alpha.c: Likewise.
* coff-i386.c: Likewise.
* coff-i860.c: Likewise.
* coff-i960.c: Likewise.
* coff-ia64.c: Likewise.
* coff-mips.c: Likewise.
* coff-ppc.c: Likewise.
* coff-rs6000.c: Likewise.
* coff-sh.c: Likewise.
* coff-tic30.c: Likewise.
* coff-tic54x.c: Likewise.
* coff-x86_64.c: Likewise.
* coff64-rs6000.c: Likewise.
* coffcode.h: Likewise.
* elf-m10300.c: Likewise.
* elf32-cr16.c: Likewise.
* elf32-lm32.c: Likewise.
* elf32-m32r.c: Likewise.
* elf32-metag.c: Likewise.
* elf32-score.c: Likewise.
* elf32-score7.c: Likewise.
* elf32-tilepro.c: Likewise.
* elf32-xstormy16.c: Likewise.
* elf32-xtensa.c: Likewise.
* elf64-alpha.c: Likewise.
* elf64-hppa.c: Likewise.
* elf64-ia64-vms.c: Likewise.
* elf64-mmix.c: Likewise.
* elf64-sh64.c: Likewise.
* elfnn-ia64.c: Likewise.
* elfxx-sparc.c: Likewise.
* elfxx-target.h: Likewise.
* elfxx-tilegx.c: Likewise.
* elfxx-x86.h: Likewise.
* hp300hpux.c: Likewise.
* hppabsd-core.c: Likewise.
* hpux-core.c: Likewise.
* i386msdos.c: Likewise.
* i386os9k.c: Likewise.
* ieee.c: Likewise.
* ihex.c: Likewise.
* irix-core.c: Likewise.
* libaout.h: Likewise.
* libecoff.h: Likewise.
* mach-o-target.c: Likewise.
* mach-o.c: Likewise.
* mipsbsd.c: Likewise.
* mmo.c: Likewise.
* netbsd-core.c: Likewise.
* nlm-target.h: Likewise.
* oasys.c: Likewise.
* osf-core.c: Likewise.
* pdp11.c: Likewise.
* pe-mips.c: Likewise.
* pe-x86_64.c: Likewise.
* pef.c: Likewise.
* plugin.c: Likewise.
* ppcboot.c: Likewise.
* ptrace-core.c: Likewise.
* sco5-core.c: Likewise.
* som.c: Likewise.
* sparclynx.c: Likewise.
* srec.c: Likewise.
* tekhex.c: Likewise.
* trad-core.c: Likewise.
* verilog.c: Likewise.
* versados.c: Likewise.
* vms-alpha.c: Likewise.
* vms-lib.c: Likewise.
* wasm-module.c: Likewise.
* xsym.c: Likewise.
* libbfd.h: Regenerate.

6 years agoFix symbol resolution with linker plugins for defsym symbols.
Sriraman Tallam [Fri, 16 Feb 2018 01:35:16 +0000 (17:35 -0800)] 
Fix symbol resolution with linker plugins for defsym symbols.

2018-02-07  Sriraman Tallam  <tmsriram@google.com>

* expression.cc (Symbol_expression::set_expr_sym_in_real_elf):
New method.
(Unary_expression::set_expr_sym_in_real_elf): New method.
(Binary_expression::set_expr_sym_in_real_elf): New method.
(Trinary_expression::set_expr_sym_in_real_elf): New method.
* plugin.cc (get_symbol_resolution_info): Fix symbol resolution if
defined or used in defsyms.
* plugin.h (Plugin_manager::is_defsym_def): New method.
(Plugin_manager::Plugin_manager): Initialize defsym_defines_set_.
(Plugin_manager::defsym_defines_set_): New member.
(Plugin_manager::Defsym_defines_set): New typedef.
* script.cc (Script_options::set_defsym_uses_in_real_elf): New method.
(Script_options::find_defsym_defs): New method.
* script.h (Expression::set_expr_sym_in_real_elf): New method.
(Symbol_assignment::is_defsym): New method.
(Symbol_assignment::value): New method.
(Script_options::find_defsym_defs): New method.
(Script_options::set_defsym_uses_in_real_elf): New method.
* testsuite/Makefile.am (plugin_test_defsym): New test.
* testsuite/Makefile.in: Regenerate.
* testsuite/plugin_test.c: Check for new symbol resolution.
* testsuite/plugin_test_defsym.sh: New script.
* testsuite/plugin_test_defsym.c: New test source.

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

6 years agoRISC-V: Fix relocation failure with zero address sections.
Jim Wilson [Thu, 15 Feb 2018 21:48:38 +0000 (13:48 -0800)] 
RISC-V: Fix relocation failure with zero address sections.

bfd/
* elfnn-riscv.c (_bfd_riscv_relax_section): Ifdef out check to ignore
symbols whose section address is zero.

6 years agoRISC-V: Give error for ignored pcrel_lo addend.
Jim Wilson [Thu, 15 Feb 2018 18:53:46 +0000 (10:53 -0800)] 
RISC-V: Give error for ignored pcrel_lo addend.

bfd/
* elfnn-riscv.c (riscv_elf_relocate_section): Use bfd_reloc_dangerous
when pcrel_lo reloc has an addend.  Use reloc_dangerous callback for
bfd_reloc_dangerous.  Use einfo instead of warning callback for errors.
Add %X%P to error messages.

ld/
* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Run pcrel-lo-addend test.
* testsuite/ld-riscv-elf/pcrel-lo-addend.d: New.
* testsuite/ld-riscv-elf/pcrel-lo-addend.s: New.

6 years agoFix AArch32 build attributes for Armv8.4-A.
Tamar Christina [Thu, 15 Feb 2018 17:08:14 +0000 (17:08 +0000)] 
Fix AArch32 build attributes for Armv8.4-A.

The build attribute number for Armv8.4-A is currently incorrectly set to that of Armv8-M.
This patch fixes that by setting it as part of the Armv8-A family and adds a test for it.

gas/
2018-02-15  Tamar Christina  <tamar.christina@arm.com>

* config/tc-arm.c (cpu_arch_ver): Renumber ARM_ARCH_V8_4A.
* testsuite/gas/arm/attr-march-armv8_4-a.d: New.

6 years agoPR ld/22832 on SPARC.
Eric Botcazou [Thu, 15 Feb 2018 14:55:11 +0000 (15:55 +0100)] 
PR ld/22832 on SPARC.

The fix for PR ld/22727 on SPARC passed TRUE as the 'create' argument
in the call to bfd_link_hash_lookup.  It turns out this was a bad idea
because, if the symbol is created at this point, the link will abort
later in elf_link_output_extsym.  This changes the TRUE into a FALSE
and puts an assertion on the result of the call, making it easier to
debug the issue; that's exactly in keeping with what Gold does.

bfd/
* elfxx-sparc.c (_bfd_sparc_elf_check_relocs) <R_SPARC_TLS_GD_CALL>:
Pass FALSE instead of TRUE as 'create' argument to bfd_link_hash_lookup
and assert that the result of the call is not NULL.

6 years agoReset inferior::control on inferior exit
Yao Qi [Thu, 15 Feb 2018 14:48:30 +0000 (14:48 +0000)] 
Reset inferior::control on inferior exit

When we kill an inferior, the inferior is not deleted.  What is more, it
is reused when the new process is created, so we need to reset inferior's
state when it exits.

gdb:

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

PR gdb/22849
* inferior.c (exit_inferior_1): Reset inf->control.

6 years agodelete ada-lang.c::ada_to_fixed_value_create advance declaration
Joel Brobecker [Thu, 15 Feb 2018 03:58:48 +0000 (22:58 -0500)] 
delete ada-lang.c::ada_to_fixed_value_create advance declaration

This advance declaration really isn't necesary, since the implementation
of this function comes before the first reference to it.

gdb/ChangeLog:

        * ada-lang.c (ada_to_fixed_value_create): Delete advance
        declaration.

Tested by rebuilding GDB.

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

6 years agoFix GDB crash after Quit thrown from unwinder sniffer
Pedro Alves [Wed, 14 Feb 2018 18:59:00 +0000 (18:59 +0000)] 
Fix GDB crash after Quit thrown from unwinder sniffer

I ran into a GDB crash in gdb.base/bp-cmds-continue-ctrl-c.exp in my
multi-target branch, which turns out exposed a bug that exists in
master too.

That testcase has a breakpoint with a "continue" command associated.
Then the breakpoint is constantly being hit.  At the same time, the
testcase is continualy interrupting the program with Ctrl-C, and
re-resuming it, in a loop.

Running that testcase manually under Valgrind, after a few sequences
of 'Ctrl-C' + 'continue', I got:

 Breakpoint 1, Quit
 (gdb) ==21270== Invalid read of size 8
 ==21270==    at 0x4D8185: pyuw_this_id(frame_info*, void**, frame_id*) (py-unwind.c:461)
 ==21270==    by 0x6D426A: compute_frame_id(frame_info*) (frame.c:505)
 ==21270==    by 0x6D43B7: get_frame_id(frame_info*) (frame.c:537)
 ==21270==    by 0x84F3B8: scoped_restore_current_thread::scoped_restore_current_thread() (thread.c:1678)
 ==21270==    by 0x718E3D: fetch_inferior_event(void*) (infrun.c:4076)
 ==21270==    by 0x7067C9: inferior_event_handler(inferior_event_type, void*) (inf-loop.c:43)
 ==21270==    by 0x45BEF9: handle_target_event(int, void*) (linux-nat.c:4419)
 ==21270==    by 0x6C4255: handle_file_event(file_handler*, int) (event-loop.c:733)
 ==21270==    by 0x6C47F8: gdb_wait_for_event(int) (event-loop.c:859)
 ==21270==    by 0x6C3666: gdb_do_one_event() (event-loop.c:322)
 ==21270==    by 0x6C3712: start_event_loop() (event-loop.c:371)
 ==21270==    by 0x746801: captured_command_loop() (main.c:329)
 ==21270==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
 ==21270==
 ==21270==
 ==21270== Process terminating with default action of signal 11 (SIGSEGV): dumping core
 ==21270==  Access not within mapped region at address 0x0
 ==21270==    at 0x4D8185: pyuw_this_id(frame_info*, void**, frame_id*) (py-unwind.c:461)
 ==21270==    by 0x6D426A: compute_frame_id(frame_info*) (frame.c:505)
 ==21270==    by 0x6D43B7: get_frame_id(frame_info*) (frame.c:537)
 ==21270==    by 0x84F3B8: scoped_restore_current_thread::scoped_restore_current_thread() (thread.c:1678)
 ==21270==    by 0x718E3D: fetch_inferior_event(void*) (infrun.c:4076)
 ==21270==    by 0x7067C9: inferior_event_handler(inferior_event_type, void*) (inf-loop.c:43)
 ==21270==    by 0x45BEF9: handle_target_event(int, void*) (linux-nat.c:4419)
 ==21270==    by 0x6C4255: handle_file_event(file_handler*, int) (event-loop.c:733)
 ==21270==    by 0x6C47F8: gdb_wait_for_event(int) (event-loop.c:859)
 ==21270==    by 0x6C3666: gdb_do_one_event() (event-loop.c:322)
 ==21270==    by 0x6C3712: start_event_loop() (event-loop.c:371)
 ==21270==    by 0x746801: captured_command_loop() (main.c:329)
 ==21270==  If you believe this happened as a result of a stack
 ==21270==  overflow in your program's main thread (unlikely but
 ==21270==  possible), you can try to increase the size of the
 ==21270==  main thread stack using the --main-stacksize= flag.
 ==21270==  The main thread stack size used in this run was 8388608.
 ==21270==

Above, when we get to compute_frame_id, fi->unwind is non-NULL,
meaning, we found an unwinder, in this case the Python unwinder, but
somehow, fi->prologue_cache is left NULL.  pyuw_this_id then crashes
because it assumes fi->prologue_cache is non-NULL:

  static void
  pyuw_this_id (struct frame_info *this_frame, void **cache_ptr,
struct frame_id *this_id)
  {
    *this_id = ((cached_frame_info *) *cache_ptr)->frame_id;
                                      ^^^^^^^^^^

'*cache_ptr' here is 'fi->prologue_cache'.

There's a quit() call in pyuw_sniffer that I believe is the one that
sometimes triggers the crash above.  The crash can be reproduced
easily with this hack to force a quit out of the python unwinder:

 --- a/gdb/python/py-unwind.c
 +++ b/gdb/python/py-unwind.c
 @@ -497,6 +497,8 @@ pyuw_sniffer (const struct frame_unwind *self, struct frame_info *this_frame,
    struct gdbarch *gdbarch = (struct gdbarch *) (self->unwind_data);
    cached_frame_info *cached_frame;

 +  quit ();
 +
    gdbpy_enter enter_py (gdbarch, current_language);

    TRACE_PY_UNWIND (3, "%s (SP=%s, PC=%s)\n", __FUNCTION__,

After that quit is thrown, any subsequent operation that involves
unwinding results in GDB crashing with SIGSEGV like above.

The problem is that this commit:

  commit 30a9c02feff56bd58a276c2a7262f364baa558ac
  CommitDate: Sun Oct 8 23:16:42 2017 -0600
  Subject: Remove cleanup from frame_prepare_for_sniffer

missed that we need to call frame_cleanup_after_sniffer before
rethrowing the exception too.

Without the fix, the "bt" added to
gdb.base/bp-cmds-continue-ctrl-c.exp in this commit makes GDB crash:

  Running src/gdb/testsuite/gdb.base/bp-cmds-continue-ctrl-c.exp ...
  ERROR: Process no longer exists

gdb/ChangeLog:
2018-02-14  Pedro Alves  <palves@redhat.com>

* frame-unwind.c (frame_unwind_try_unwinder): Always call
frame_cleanup_after_sniffer on exception.

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

* gdb.base/bp-cmds-continue-ctrl-c.exp (do_test): Test "bt" after
getting a "Quit".

6 years agoConstify target_so_ops::bfd_open
Tom Tromey [Tue, 13 Feb 2018 20:34:45 +0000 (13:34 -0700)] 
Constify target_so_ops::bfd_open

This constifies the bfd_open method of struct target_so_ops.

gdb/ChangeLog
2018-02-14  Tom Tromey  <tom@tromey.com>

* solist.h (struct target_so_ops) <bfd_open>: Make pathname
const.
(solib_bfd_open): Make pathname const.
* solib.c (solib_bfd_open): Make pathname const.
* solib-spu.c (spu_bfd_fopen): Make name const.
(spu_bfd_open): Make pathname const.
* solib-darwin.c (darwin_bfd_open): Make pathname const.
* solib-aix.c (solib_aix_bfd_open): Make pathname const.

6 years agoChange openp et al to use a unique_xmalloc_ptr
Tom Tromey [Fri, 10 Nov 2017 20:47:05 +0000 (13:47 -0700)] 
Change openp et al to use a unique_xmalloc_ptr

This changes openp, source_full_path_of, and find_and_open_source to
take a unique_xmalloc_ptr, rather than a char*, as an outgoing
argument type.  This simplifies the API, ownership-wise, and allows
for the removal of some cleanups.

gdb/ChangeLog
2018-02-14  Tom Tromey  <tom@tromey.com>

* symfile.c (symfile_bfd_open): Update.
* source.h (openp, source_full_path_of, find_and_open_source):
Change argument type to unique_xmalloc_ptr.
* source.c (openp): Take a unique_xmalloc_ptr.
(source_full_path_of, find_and_open_source): Likewise.
(open_source_file, symtab_to_fullname): Update.
* solist.h (struct target_so_ops) <find_and_open_solib>: Take a
unique_xmalloc_ptr.
* solib.c (solib_find_1): Use unique_xmalloc_ptr.
(exec_file_find): Update.
* psymtab.c (psymtab_to_fullname): Update.
* nto-tdep.h (nto_find_and_open_solib): Update.
* nto-tdep.c (nto_find_and_open_solib): Change temp_path to a
unique_xmalloc_ptr.
* exec.c (exec_file_attach): Update.
* dwarf2read.c (try_open_dwop_file): Use unique_xmalloc_ptr.
* cli/cli-cmds.c (find_and_open_script): Use unique_xmalloc_ptr.

6 years agoMove some declarations to source.h
Tom Tromey [Fri, 10 Nov 2017 20:21:10 +0000 (13:21 -0700)] 
Move some declarations to source.h

I noticed a few declarations in defs.h that really could be put into
source.h.  I think it's generally preferable to something out of
defs.h unless it is needed by most of the files in gdb.

gdb/ChangeLog
2018-02-14  Tom Tromey  <tom@tromey.com>

* solib.c: Include source.h.
* nto-tdep.c: Include source.h.
* mi/mi-cmd-env.c: Include source.h.
* infcmd.c: Include source.h.
* exec.c: Include source.h.
* defs.h (enum openp_flag, openp, source_full_path_of, mod_path)
(add_path, directory_switch, source_path, init_source_path): Move
declarations...
* source.h (enum openp_flag, openp, source_full_path_of, mod_path)
(add_path, directory_switch, source_path, init_source_path):
...here.

6 years agoReturn unique_xmalloc_ptr from some solib.c functions
Tom Tromey [Fri, 10 Nov 2017 20:07:46 +0000 (13:07 -0700)] 
Return unique_xmalloc_ptr from some solib.c functions

This changes a couple of solib.c functions -- exec_file_find and
solib_find -- to return a unique_xmalloc_ptr, and then fixes up the
users.  This allows the removal of some cleanups.

This also changes solib_bfd_open to not take ownership of its
argument.  I think this change is somewhat cleaner.

gdb/ChangeLog
2018-02-14  Tom Tromey  <tom@tromey.com>

* solist.h (exec_file_find, solib_find): Return
unique_xmalloc_ptr.
(solib_bfd_fopen): Take a const char *.
* solib.c (solib_find_1): Return unique_xmalloc_ptr.
(exec_file_find, solib_find): Likewise.
(solib_bfd_fopen): Do not take ownership of "pathname".
(solib_bfd_open): Use unique_xmalloc_ptr.
* solib-darwin.c (darwin_bfd_open): Use unique_xmalloc_ptr.
* solib-aix.c (solib_aix_bfd_open): Use unique_xmalloc_ptr.
* infrun.c (follow_exec): Use unique_xmalloc_ptr.
* exec.c (exec_file_locate_attach): Use unique_xmalloc_ptr.

6 years agoFix compilation of the BFD sub-directory with a gcc v8 compiler by adding extra casts.
Nick Clifton [Wed, 14 Feb 2018 14:56:21 +0000 (14:56 +0000)] 
Fix compilation of the BFD sub-directory with a gcc v8 compiler by adding extra casts.

GCC v8 issues warnings about mis-matching casts of function pointers.
A previous patch tried to fix this problem by adding new dummy functions
which accepted a variable number of arguments.  But this introduces serious
problems when compiled with other versions of gcc, (notably gcc 4.4).  This
patch reverts that previous solution and instead adds extra casts (to
function types without a parameter list).

For more details see: https://sourceware.org/ml/binutils/2018-02/msg00198.html

PR 22823
Revert previous delta.  Add extra casts to avoid compile time
warnings instead.
* libbfd-in.h (_bfd_generic_bfd_copy_private_bfd_data): Add extra
cast to avoid warning from gcc v8 compiler.
(_bfd_generic_bfd_merge_private_bfd_data): Likewise.
(_bfd_generic_bfd_set_private_flags): Likewise.
(_bfd_generic_bfd_copy_private_section_data): Likewise.
(_bfd_generic_bfd_copy_private_symbol_data): Likewise.
(_bfd_generic_bfd_copy_private_header_data): Likewise.
(_bfd_generic_bfd_print_private_bfd_data): Likewise.
(_bfd_noarchive_construct_extended_name_table): Likewise.
(_bfd_noarchive_truncate_arname): Likewise.
(_bfd_noarchive_write_ar_hdr): Likewise.
(_bfd_noarchive_get_elt_at_index): Likewise.
(_bfd_nosymbols_canonicalize_symtab): Likewise.
(_bfd_nosymbols_print_symbol): Likewise.
(_bfd_nosymbols_get_symbol_info): Likewise.
(_bfd_nosymbols_get_symbol_version_string): Likewise.
(_bfd_nosymbols_bfd_is_local_label_name): Likewise.
(_bfd_nosymbols_bfd_is_target_special_symbol): Likewise.
(_bfd_nosymbols_get_lineno): Likewise.
(_bfd_nosymbols_find_nearest_line): Likewise.
(_bfd_nosymbols_find_line): Likewise.
(_bfd_nosymbols_find_inliner_info): Likewise.
(_bfd_nosymbols_bfd_make_debug_symbol): Likewise.
(_bfd_nosymbols_read_minisymbols): Likewise.
(_bfd_nosymbols_minisymbol_to_symbol): Likewise.
(_bfd_norelocs_bfd_reloc_type_lookup): Likewise.
(_bfd_norelocs_bfd_reloc_name_lookup): Likewise.
(_bfd_nowrite_set_arch_mach): Likewise.
(_bfd_nowrite_set_section_contents): Likewise.
(_bfd_nolink_sizeof_headers): Likewise.
(_bfd_nolink_bfd_get_relocated_section_contents): Likewise.
(_bfd_nolink_bfd_relax_section): Likewise.
(_bfd_nolink_bfd_gc_sections): Likewise.
(_bfd_nolink_bfd_lookup_section_flags): Likewise.
(_bfd_nolink_bfd_merge_sections): Likewise.
(_bfd_nolink_bfd_is_group_section): Likewise.
(_bfd_nolink_bfd_discard_group): Likewise.
(_bfd_nolink_bfd_link_hash_table_create): Likewise.
(_bfd_nolink_bfd_link_add_symbols): Likewise.
(_bfd_nolink_bfd_link_just_syms): Likewise.
(_bfd_nolink_bfd_copy_link_hash_symbol_type): Likewise.
(_bfd_nolink_bfd_final_link): Likewise.
(_bfd_nolink_bfd_link_split_section): Likewise.
(_bfd_nolink_section_already_linked): Likewise.
(_bfd_nolink_bfd_define_common_symbol): Likewise.
(_bfd_nolink_bfd_define_start_stop): Likewise.
(_bfd_nodynamic_canonicalize_dynamic_symtab): Likewise.
(_bfd_nodynamic_get_synthetic_symtab): Likewise.
(_bfd_nodynamic_get_dynamic_reloc_upper_bound _bfd_): Likewise.
(_bfd_nodynamic_canonicalize_dynamic_reloc): Likewise.
* libbfd.c (bfd_false_any): Delete.
(bfd_true_any, bfd_nullvoidptr_any, bfd_0_any): Delete.
(bfd_0u_any, bfd_0l_any, _bfd_n1_any, bfd_void_any): Delete.
* libbfd.h (extern): Regenerate
* aout-target.h (MY_bfd_is_target_special_symbol): Add extra
cast to avoid warning from gcc v8 compiler.
* aout-tic30.c (tic30_aout_set_arch_mach): Likewise.
* binary.c (binary_get_symbol_info): Likewise.
* coff-alpha.c (alpha_ecoff_backend_data): Likewise.
* coff-mips.c (mips_ecoff_backend_data): Likewise.
* coffcode.h (coff_set_alignment_hook): Likewise.
(symname_in_debug_hook): Likewise.
(bfd_coff_backend_data bigobj_swap_table): Likewise.
* elf-m10300.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-cr16.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-lm32.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-m32r.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-metag.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-score.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-score7.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-xstormy16.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-xtensa.c (elf_backend_omit_section_dynsym): Likewise.
* elf64-alpha.c (elf_backend_omit_section_dynsym): Likewise.
* elf64-hppa.c (elf_backend_omit_section_dynsym): Likewise.
* elf64-ia64-vms.c (elf_backend_omit_section_dynsym): Likewise.
* elf64-mmix.c (elf_backend_omit_section_dynsym): Likewise.
* elf64-sh64.c (elf_backend_omit_section_dynsym): Likewise.
* elfnn-ia64.c (elf_backend_omit_section_dynsym): Likewise.
* elfxx-target.h (bfd_elfNN_bfd_debug_info_accumulate): Likewise.
(bfd_elfNN_bfd_make_debug_symbol): Likewise.
(bfd_elfNN_bfd_merge_private_bfd_data): Likewise.
(bfd_elfNN_bfd_set_private_flags): Likewise.
(bfd_elfNN_bfd_is_target_special_symbol): Likewise.
(elf_backend_init_index_section): Likewise.
(elf_backend_allow_non_load_phdr): Likewise.
* elfxx-x86.h (elf_backend_omit_section_dynsym): Likewise.
* i386msdos.c (msdos_bfd_is_target_special_symbol): Likewise.
* ieee.c (ieee_construct_extended_name_table): Likewise.
(ieee_write_armap): Likewise.
(ieee_write_ar_hdr): Likewise.
(ieee_bfd_is_target_special_symbol): Likewise.
* ihex.c (ihex_canonicalize_symtab): Likewise.
(ihex_bfd_is_target_special_symbol): Likewise.
* libaout.h (aout_32_bfd_is_target_special_symbol): Likewise.
* libecoff.h (_bfd_ecoff_bfd_is_target_special_symbol): Likewise.
(_bfd_ecoff_set_alignment_hook): Likewise.
* mach-o-target.c (bfd_mach_o_bfd_is_target_special_symbol): Likewise.
* mmo.c (mmo_bfd_is_target_special_symbol): Likewise.
* nlm-target.h (nlm_bfd_is_target_special_symbol): Likewise.
* oasys.c (oasys_construct_extended_name_table): Likewise.
(oasys_write_armap): Likewise.
(oasys_write_ar_hdr): Likewise.
(oasys_bfd_is_target_special_symbol): Likewise.
* pef.c (bfd_pef_bfd_is_target_special_symbol): Likewise.
* plugin.c (bfd_plugin_bfd_is_target_special_symbol): Likewise.
* ppcboot.c (ppcboot_bfd_is_target_special_symbol): Likewise.
* som.c (som_bfd_is_target_special_symbol): Likewise.
* srec.c (srec_bfd_is_target_special_symbol): Likewise.
* tekhex.c (tekhex_bfd_is_target_special_symbol): Likewise.
* verilog.c (verilog_bfd_is_target_special_symbol): Likewise.
* versados.c (versados_bfd_is_target_special_symbol): Likewise.
(versados_bfd_reloc_name_lookup): Likewise.
* vms-alpha.c (vms_bfd_is_target_special_symbol): Likewise.
(vms_bfd_define_start_stop): Likewise.
(alpha_vms_bfd_is_target_special_symbol): Likewise.
* wasm-module.c (wasm_bfd_is_target_special_symbol): Likewise.
* xsym.c (bfd_sym_bfd_is_target_special_symbol): Likewise.

6 years agox86-64: Use PLT address for PC-relative reloc
H.J. Lu [Wed, 14 Feb 2018 11:50:40 +0000 (03:50 -0800)] 
x86-64: Use PLT address for PC-relative reloc

Since PLT in PDE and PC-relative PLT in PIE can be used as function
address, there is no need for dynamic PC-relative relocation against
a dynamic function definition in PIE.  Linker should resolve PC-relative
reference to its PLT address.

NB: i386 has non-PIC PLT and PIC PLT.  Only non-PIC PLT in PDE can
be used as function address.  PIC PLT in PIE can't be used as
function address.

bfd/

PR ld/22842
* elf32-i386.c (elf_i386_check_relocs): Pass FALSE for non
PC-relative PLT to NEED_DYNAMIC_RELOCATION_P.
* elf64-x86-64.c (elf_x86_64_check_relocs): Create PLT for
R_X86_64_PC32 reloc against dynamic function in data section.
Pass TRUE for PC-relative PLT to NEED_DYNAMIC_RELOCATION_P.
(elf_x86_64_relocate_section): Use PLT for R_X86_64_PC32 reloc
against dynamic function in data section.
* elfxx-x86.c (elf_x86_allocate_dynrelocs): Use PLT in PIE as
function address only if pcrel_plt is true.
(_bfd_x86_elf_link_hash_table_create): Set pcrel_plt.
* elfxx-x86.h (NEED_DYNAMIC_RELOCATION_P): Add PCREL_PLT for
PC-relative PLT.  If PLT is PC-relative, don't generate dynamic
PC-relative relocation against a function definition in data
secton in PIE.  Remove the obsolete comments.
(elf_x86_link_hash_table): Add pcrel_plt.

ld/

PR ld/22842
* testsuite/ld-i386/i386.exp: Run PR ld/22842 tests.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr22842a.c: New file.
* testsuite/ld-i386/pr22842b.S: Likewise.
* testsuite/ld-x86-64/pr22842a.c: Likewise.
* testsuite/ld-x86-64/pr22842a.rd: Likewise.
* testsuite/ld-x86-64/pr22842b.S: Likewise.
* testsuite/ld-x86-64/pr22842b.rd: Likewise.

6 years agoRemove references to ada_name_for_lookup (deleted)
Joel Brobecker [Wed, 14 Feb 2018 10:45:24 +0000 (05:45 -0500)] 
Remove references to ada_name_for_lookup (deleted)

This function was deleted on 2017-11-08, but its declaration and
a reference to it in a comment was left behind.  This patch just
removes those.

gdb/ChangeLog:

        * ada-lang.c (name_match_type_from_name): Remove reference to
        ada_name_for_lookup in function's documentation.
        * ada-lang.h (ada_name_for_lookup): Delete declaration.

Tested by rebuilding GDB.

6 years agoLD: Remove a stale `ldlex_command' prototype
Maciej W. Rozycki [Wed, 14 Feb 2018 09:13:31 +0000 (01:13 -0800)] 
LD: Remove a stale `ldlex_command' prototype

Complement commit d4e5e3c330d5 ("Use getopt instead of lex and yacc to
parse the command line.") and remove a stale `ldlex_command' prototype
for an inexistent function removed back in 1994.

ld/
* ldlex.h (ldlex_command): Remove prototype.

6 years agox86-64: Use pr22393-3a.so and pr22393-3a-now.so
H.J. Lu [Wed, 14 Feb 2018 04:32:19 +0000 (20:32 -0800)] 
x86-64: Use pr22393-3a.so and pr22393-3a-now.so

They should be pr22393-3a.so and pr22393-3a-now.so, not pr22393-2a.so
and pr22393-2a-now.so.  Since ld-elf/shared.exp creates pr22393-2a.so
and pr22393-2a-now.so, we won't notice the problem if x86-64.exp runs
after ld-elf/shared.exp.

* testsuite/ld-x86-64/x86-64.exp: Replace pr22393-2a.so and
pr22393-2a-now.so with pr22393-3a.so and pr22393-3a-now.so.

6 years agoPR22836 testcases
Alan Modra [Wed, 14 Feb 2018 01:08:03 +0000 (11:38 +1030)] 
PR22836 testcases

PR 22836
* testsuite/ld-elf/pr22836-1.s: New file.
* testsuite/ld-elf/pr22836-1a.d: Likewise.
* testsuite/ld-elf/pr22836-1b.d: Likewise.

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

6 years agox86: Properly check building shared library
H.J. Lu [Tue, 13 Feb 2018 22:31:53 +0000 (14:31 -0800)] 
x86: Properly check building shared library

If a symbol is not defined in a regular file, and we are not generating
a shared library, then set the symbol to its location in the .plt.  This
is required to make function pointers compare as equal between the normal
executable and the shared library.

* elfxx-x86.c (elf_x86_allocate_dynrelocs): Check bfd_link_dll,
instead of bfd_link_pic, for building shared library.

6 years agogas: xtensa: fix trampoline placement
Max Filippov [Sun, 11 Feb 2018 05:59:54 +0000 (21:59 -0800)] 
gas: xtensa: fix trampoline placement

For jumps requiring multiple trampolines trampoline placement code may
place multiple sequential trampolines into the same frag. Don't do that.

gas/
2018-02-13  Max Filippov  <jcmvbkbc@gmail.com>

* config/tc-xtensa.c (xg_find_best_trampoline): Skip trampoline
frag that contains source address.

6 years agoUse enum flags for flags passed to openp
Simon Marchi [Tue, 13 Feb 2018 17:13:59 +0000 (12:13 -0500)] 
Use enum flags for flags passed to openp

gdb/ChangeLog:

* defs.h (enum openp_flags): New enum.
(OPF_TRY_CWD_FIRST, OPF_SEARCH_IN_PATH, OPF_RETURN_REALPATH):
Move to enum openp_flags.
(openp_flags): New enum flags.
(openp): Change parameter type to openp_flags.
* source.c (openp): Change parameter type to openp_flags.
* cli/cli-cmds.c (find_and_open_script): Use openp_flags.
* dwarf2read.c (try_open_dwop_file): Use openp_flags.

6 years agoFix ARm assembler so that it rejects invalid immediate values for the Thumb ORR instr...
Nick Clifton [Tue, 13 Feb 2018 16:50:04 +0000 (16:50 +0000)] 
Fix ARm assembler so that it rejects invalid immediate values for the Thumb ORR instruction.

PR 22773
* config/tc-arm.c (md_apply_fix): Test Rn field of Thumb ORR
instruction before assuming that it is a MOV instruction.
* testsuite/gas/arm/pr22773.s: New test.
* testsuite/gas/arm/pr22773.d: New test driver.
* testsuite/gas/arm/pr22773.l: New expected output.

6 years agox86-64: Generate branch with PLT32 relocation
H.J. Lu [Tue, 13 Feb 2018 15:34:22 +0000 (07:34 -0800)] 
x86-64: Generate branch with PLT32 relocation

Since there is no need to prepare for PLT branch on x86-64, generate
R_X86_64_PLT32, instead of R_X86_64_PC32, if possible, which can be
used as a marker for 32-bit PC-relative branches.

To compile Linux kernel, this patch:

From: "H.J. Lu" <hjl.tools@gmail.com>
Subject: [PATCH] x86: Treat R_X86_64_PLT32 as R_X86_64_PC32

On i386, there are 2 types of PLTs, PIC and non-PIC.  PIE and shared
objects must use PIC PLT.  To use PIC PLT, you need to load
_GLOBAL_OFFSET_TABLE_ into EBX first.  There is no need for that on
x86-64 since x86-64 uses PC-relative PLT.

On x86-64, for 32-bit PC-relative branches, we can generate PLT32
relocation, instead of PC32 relocation, which can also be used as
a marker for 32-bit PC-relative branches.  Linker can always reduce
PLT32 relocation to PC32 if function is defined locally.   Local
functions should use PC32 relocation.  As far as Linux kernel is
concerned, R_X86_64_PLT32 can be treated the same as R_X86_64_PC32
since Linux kernel doesn't use PLT.

is needed.  It is available on hjl/plt32/master branch at

https://github.com/hjl-tools/linux

bfd/

PR gas/22791
* elf64-x86-64.c (is_32bit_relative_branch): Removed.
(elf_x86_64_relocate_section): Check PIC relocations in PIE.
Remove is_32bit_relative_branch usage.  Disallow PC32 reloc
against protected function in shared object.

gas/

PR gas/22791
* config/tc-i386.c (need_plt32_p): New function.
(output_jump): Generate BFD_RELOC_X86_64_PLT32 if possible.
(md_estimate_size_before_relax): Likewise.
* testsuite/gas/i386/reloc64.d: Updated.
* testsuite/gas/i386/x86-64-jump.d: Likewise.
* testsuite/gas/i386/x86-64-mpx-branch-1.d: Likewise.
* testsuite/gas/i386/x86-64-mpx-branch-2.d: Likewise.
* testsuite/gas/i386/x86-64-relax-2.d: Likewise.
* testsuite/gas/i386/x86-64-relax-3.d: Likewise.
* testsuite/gas/i386/ilp32/reloc64.d: Likewise.
* testsuite/gas/i386/ilp32/x86-64-branch.d: Likewise.

ld/

PR gas/22791
* testsuite/ld-x86-64/mpx1c.rd: Updated.
* testsuite/ld-x86-64/pr22791-1.err: New file.
* testsuite/ld-x86-64/pr22791-1a.c: Likewise.
* testsuite/ld-x86-64/pr22791-1b.s: Likewise.
* testsuite/ld-x86-64/pr22791-2.rd: Likewise.
* testsuite/ld-x86-64/pr22791-2a.s: Likewise.
* testsuite/ld-x86-64/pr22791-2b.c: Likewise.
* testsuite/ld-x86-64/pr22791-2c.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run PR ld/22791 tests.

6 years agoFix typo in Russian translation for the bfd/ sub-directory which could lead to a...
Sergei Trofimovich [Tue, 13 Feb 2018 15:13:58 +0000 (15:13 +0000)] 
Fix typo in Russian translation for the bfd/ sub-directory which could lead to a seg-fault in the linker.

PR 22828
* po/ru.po: Fix typo in Russian translation.

6 years agoFix compile time warning messages from gcc version 8 about cast between incompatible...
Nick Clifton [Tue, 13 Feb 2018 13:14:47 +0000 (13:14 +0000)] 
Fix compile time warning messages from gcc version 8 about cast between incompatible function types.

PR 22823
bfd Fix compile time warnings generated by gcc version 8.
* libbfd-in.h: Remove extraneous text from prototypes.
Add prototypes for bfd_false_any, bfd_true_any,
bfd_nullvoidptr_any, bfd_0_any, bfd_0u_any, bfd_0l_any,
bfd_n1_any, bfd_void_any.
(_bfd_generic_bfd_copy_private_bfd_data): Use vararg based dummy
function.
(_bfd_generic_bfd_merge_private_bfd_data): Likewise.
(_bfd_generic_bfd_set_private_flags): Likewise.
(_bfd_generic_bfd_copy_private_section_data): Likewise.
(_bfd_generic_bfd_copy_private_symbol_data): Likewise.
(_bfd_generic_bfd_copy_private_header_data): Likewise.
(_bfd_generic_bfd_print_private_bfd_data): Likewise.
(_bfd_noarchive_construct_extended_name_table): Likewise.
(_bfd_noarchive_truncate_arname): Likewise.
(_bfd_noarchive_write_ar_hdr): Likewise.
(_bfd_noarchive_get_elt_at_index): Likewise.
(_bfd_nosymbols_canonicalize_symtab): Likewise.
(_bfd_nosymbols_print_symbol): Likewise.
(_bfd_nosymbols_get_symbol_info): Likewise.
(_bfd_nosymbols_get_symbol_version_string): Likewise.
(_bfd_nosymbols_bfd_is_local_label_name): Likewise.
(_bfd_nosymbols_bfd_is_target_special_symbol): Likewise.
(_bfd_nosymbols_get_lineno): Likewise.
(_bfd_nosymbols_find_nearest_line): Likewise.
(_bfd_nosymbols_find_line): Likewise.
(_bfd_nosymbols_find_inliner_info): Likewise.
(_bfd_nosymbols_bfd_make_debug_symbol): Likewise.
(_bfd_nosymbols_read_minisymbols): Likewise.
(_bfd_nosymbols_minisymbol_to_symbol): Likewise.
(_bfd_norelocs_bfd_reloc_type_lookup): Likewise.
(_bfd_norelocs_bfd_reloc_name_lookup): Likewise.
(_bfd_nowrite_set_arch_mach): Likewise.
(_bfd_nowrite_set_section_contents): Likewise.
(_bfd_nolink_sizeof_headers): Likewise.
(_bfd_nolink_bfd_get_relocated_section_contents): Likewise.
(_bfd_nolink_bfd_relax_section): Likewise.
(_bfd_nolink_bfd_gc_sections): Likewise.
(_bfd_nolink_bfd_lookup_section_flags): Likewise.
(_bfd_nolink_bfd_merge_sections): Likewise.
(_bfd_nolink_bfd_is_group_section): Likewise.
(_bfd_nolink_bfd_discard_group): Likewise.
(_bfd_nolink_bfd_link_hash_table_create): Likewise.
(_bfd_nolink_bfd_link_add_symbols): Likewise.
(_bfd_nolink_bfd_link_just_syms): Likewise.
(_bfd_nolink_bfd_copy_link_hash_symbol_type): Likewise.
(_bfd_nolink_bfd_final_link): Likewise.
(_bfd_nolink_bfd_link_split_section): Likewise.
(_bfd_nolink_section_already_linked): Likewise.
(_bfd_nolink_bfd_define_common_symbol): Likewise.
(_bfd_nolink_bfd_define_start_stop): Likewise.
(_bfd_nodynamic_canonicalize_dynamic_symtab): Likewise.
(_bfd_nodynamic_get_synthetic_symtab): Likewise.
(_bfd_nodynamic_get_dynamic_reloc_upper_bound _bfd_): Likewise.
(_bfd_nodynamic_canonicalize_dynamic_reloc): Likewise.
* libbfd.c (bfd_false_any): New function.  Like bfd_false but
accepts one or more arguments.
(bfd_true_any): Likewise.
(bfd_nullvoidptr_any): Likewise.
(bfd_0_any): Likewise.
(bfd_0u_any): Likewise.
(bfd_0l_any): Likewise.
(_bfd_n1_any): Likewise.
(bfd_void_any): Likewise.
* libbfd.h (extern): Regenerate
* aout-target.h (MY_bfd_is_target_special_symbol): Use vararg
based dummy function.
* aout-tic30.c (tic30_aout_set_arch_mach): Likewise.
* binary.c (binary_get_symbol_info): Likewise.
* coff-alpha.c (alpha_ecoff_backend_data): Likewise.
* coff-mips.c (mips_ecoff_backend_data): Likewise.
* coffcode.h (coff_set_alignment_hook): Likewise.
(symname_in_debug_hook): Likewise.
(bfd_coff_backend_data bigobj_swap_table): Likewise.
* elf-m10300.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-cr16.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-lm32.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-m32r.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-metag.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-score.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-score7.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-xstormy16.c (elf_backend_omit_section_dynsym): Likewise.
* elf32-xtensa.c (elf_backend_omit_section_dynsym): Likewise.
* elf64-alpha.c (elf_backend_omit_section_dynsym): Likewise.
* elf64-hppa.c (elf_backend_omit_section_dynsym): Likewise.
* elf64-ia64-vms.c (elf_backend_omit_section_dynsym): Likewise.
* elf64-mmix.c (elf_backend_omit_section_dynsym): Likewise.
* elf64-sh64.c (elf_backend_omit_section_dynsym): Likewise.
* elfnn-ia64.c (elf_backend_omit_section_dynsym): Likewise.
* elfxx-target.h (bfd_elfNN_bfd_debug_info_accumulate): Likewise.
(bfd_elfNN_bfd_make_debug_symbol): Likewise.
(bfd_elfNN_bfd_merge_private_bfd_data): Likewise.
(bfd_elfNN_bfd_set_private_flags): Likewise.
(bfd_elfNN_bfd_is_target_special_symbol): Likewise.
(elf_backend_init_index_section): Likewise.
(elf_backend_allow_non_load_phdr): Likewise.
* elfxx-x86.h (elf_backend_omit_section_dynsym): Likewise.
* i386msdos.c (msdos_bfd_is_target_special_symbol): Likewise.
* ieee.c (ieee_construct_extended_name_table): Likewise.
(ieee_write_armap): Likewise.
(ieee_write_ar_hdr): Likewise.
(ieee_bfd_is_target_special_symbol): Likewise.
* ihex.c (ihex_canonicalize_symtab): Likewise.
(ihex_bfd_is_target_special_symbol): Likewise.
* libaout.h (aout_32_bfd_is_target_special_symbol): Likewise.
* libecoff.h (_bfd_ecoff_bfd_is_target_special_symbol): Likewise.
(_bfd_ecoff_set_alignment_hook): Likewise.
* mach-o-target.c (bfd_mach_o_bfd_is_target_special_symbol): Likewise.
* mmo.c (mmo_bfd_is_target_special_symbol): Likewise.
* nlm-target.h (nlm_bfd_is_target_special_symbol): Likewise.
* oasys.c (oasys_construct_extended_name_table): Likewise.
(oasys_write_armap): Likewise.
(oasys_write_ar_hdr): Likewise.
(oasys_bfd_is_target_special_symbol): Likewise.
* pef.c (bfd_pef_bfd_is_target_special_symbol): Likewise.
* plugin.c (bfd_plugin_bfd_is_target_special_symbol): Likewise.
* ppcboot.c (ppcboot_bfd_is_target_special_symbol): Likewise.
* som.c (som_bfd_is_target_special_symbol): Likewise.
* srec.c (srec_bfd_is_target_special_symbol): Likewise.
* tekhex.c (tekhex_bfd_is_target_special_symbol): Likewise.
* verilog.c (verilog_bfd_is_target_special_symbol): Likewise.
* versados.c (versados_bfd_is_target_special_symbol): Likewise.
(versados_bfd_reloc_name_lookup): Likewise.
* vms-alpha.c (vms_bfd_is_target_special_symbol): Likewise.
(vms_bfd_define_start_stop): Likewise.
(alpha_vms_bfd_is_target_special_symbol): Likewise.
* wasm-module.c (wasm_bfd_is_target_special_symbol): Likewise.
* xsym.c (bfd_sym_bfd_is_target_special_symbol): Likewise.
* elf32-arc.c (get_replace_function): Assign replacement function
to func pointer.
* elf32-i370.c (i370_noop): Update prototype.

gas * config/obj-elf.c (elf_pseudo_table): Remove now redundant
casts.
(obj_elf_vtable_inherit): Rename to obj_elf_get_vtable_inherit.
(obj_elf_vtable_inherit): New stub function that calls
obj_elf_get_vtable_inherit.
(obj_elf_vtable_entry): Rename to obj_elf_get_vtable_entry.
(obj_elf_vtable_entry): New stub function that calls
obj_elf_get_vtable_entry.
* config/obj-elf.h (obj_elf_vtable_inherit): Update prototype.
(obj_elf_vtable_entry) Likewise.
(obj_elf_get_vtable_inherit) Likewise.
(obj_elf_get_vtable_entry) Likewise.
* config/tc-arm.c (md_pseudo_table): Remove now redundant cast.
* config/tc-i386c (md_pseudo_table): Likewise.
* config/tc-hppa.c (pa_vtable_entry): Call
obj_elf_get_vtable_entry.
(pa_vtable_inherit): Call obj_elf_get_vtable_inherit.
* config/tc-mips.c (s_mips_file): Replace call to dwarf2_get_file
with call to dwarf2_get_filename.
* dwarf2dbg.c (dwarf2_directive_file): Rename to
dwarf2_directive_filename.
(dwarf2_directive_file): New stub function that calls
dwarf2_directive_filename.
* dwarf2dbg.h: Prototype dwarf2_directive_filename.

opcodes * metag-dis.c (print_fmmov): Double buffer size to avoid warning
about truncation of printing.

6 years agoWebAssembly: Disable subdirectory configuration for unsupported LD
Maciej W. Rozycki [Tue, 13 Feb 2018 12:56:29 +0000 (12:56 +0000)] 
WebAssembly: Disable subdirectory configuration for unsupported LD

Remove an LD subdirectory configuration error:

*** ld does not support target wasm32-unknown-none
*** see ld/configure.tgt for supported targets
make[1]: *** [configure-ld] Error 1

which prevents binutils for the WebAssembly target from being built
unless an explicit `--disable-ld' configuration option has been given.
Users must not have to disable features selected by default to get a
working configuration.

/
* configure.ac <wasm32-*-*> (noconfigdirs): Add `ld'.
* configure: Regenerate.

6 years agoWebAssembly: Correct an `index' global shadowing error for pre-4.8 GCC
Maciej W. Rozycki [Tue, 13 Feb 2018 12:56:29 +0000 (12:56 +0000)] 
WebAssembly: Correct an `index' global shadowing error for pre-4.8 GCC

Remove `-Wshadow' compilation errors:

cc1: warnings being treated as errors
.../bfd/wasm-module.c: In function 'wasm_scan_name_function_section':
.../bfd/wasm-module.c:312: error: declaration of 'index' shadows a global declaration
/usr/include/string.h:303: error: shadowed declaration is here
.../bfd/wasm-module.c: In function 'wasm_register_section':
.../bfd/wasm-module.c:494: error: declaration of 'index' shadows a global declaration
/usr/include/string.h:303: error: shadowed declaration is here
.../bfd/wasm-module.c: In function 'wasm_compute_custom_section_file_position':
.../bfd/wasm-module.c:523: error: declaration of 'index' shadows a global declaration
/usr/include/string.h:303: error: shadowed declaration is here

and:

cc1: warnings being treated as errors
.../opcodes/wasm32-dis.c: In function 'print_insn_wasm32':
.../opcodes/wasm32-dis.c:272: error: declaration of 'index' shadows a global declaration
/usr/include/string.h:303: error: shadowed declaration is here
make[4]: *** [wasm32-dis.lo] Error 1

which for versions of GCC before 4.8 prevent support for the WebAssembly
target from being built.  See also GCC PR c/53066.

bfd/
* wasm-module.c (wasm_scan_name_function_section): Rename
`index' local variable to `idx'.

opcodes/
* wasm32-dis.c (print_insn_wasm32): Rename `index' local
variable to `function_index'.

6 years agoMIPS/GAS/testsuite: Correct duplicate `Loongson-3A tests' test name
Maciej W. Rozycki [Tue, 13 Feb 2018 12:56:29 +0000 (12:56 +0000)] 
MIPS/GAS/testsuite: Correct duplicate `Loongson-3A tests' test name

Correct a duplicate `Loongson-3A tests' GAS test name introduced with
commit 986754024085 ("Add Loongson3A specific instructions"),
<https://sourceware.org/ml/binutils/2010-12/msg00447.html>, shared
between gas/testsuite/gas/mips/loongson-3a.d and
gas/testsuite/gas/mips/loongson-3a-2.d.

gas/
* testsuite/gas/mips/loongson-3a-2.d: Rename test.

6 years agoPR22836, "-r -s" doesn't work with -g3 using GCC 7
Alan Modra [Tue, 13 Feb 2018 03:39:48 +0000 (14:09 +1030)] 
PR22836, "-r -s" doesn't work with -g3 using GCC 7

This fixes the case where all of a group is removed with ld -r, the
situation in the PR, and failures where part of a group is removed
that contain relocs.

bfd/
PR 22836
* elf.c (_bfd_elf_fixup_group_sections): Account for removed
relocation sections.  If size reduces to just the flag word,
remove that too and mark with SEC_EXCLUDE.
* elflink.c (bfd_elf_final_link): Strip empty group sections.
binutils/
* testsuite/binutils-all/group-7.s,
* testsuite/binutils-all/group-7a.d,
* testsuite/binutils-all/group-7b.d,
* testsuite/binutils-all/group-7c.d: New tests.
* testsuite/binutils-all/objcopy.exp: Run them.
ld/
* testsuite/ld-elf/pr22836-2.d,
* testsuite/ld-elf/pr22836-2.s: New test.

6 years agoPR22829, objcopy/strip removes PT_GNU_RELRO from lld binaries
Alan Modra [Mon, 12 Feb 2018 02:36:07 +0000 (13:06 +1030)] 
PR22829, objcopy/strip removes PT_GNU_RELRO from lld binaries

lld lays out the relro segment differently to GNU ld, not bothering to
include the first few bytes of .got.plt and padding out to a page at
the end of the segment.  This patch teaches binutils to recognize the
different (and somewhat inferior) layout as valid.

bfd/
PR 22829
* elf.c (assign_file_positions_for_non_load_sections): Rewrite
PT_GNU_RELRO setup.
ld/
* testsuite/ld-x86-64/pr14207.d: Adjust relro p_filesz.

6 years agoFix prefix of maint set/show per-command
Simon Marchi [Tue, 13 Feb 2018 05:32:53 +0000 (00:32 -0500)] 
Fix prefix of maint set/show per-command

I noticed this:

(gdb) apropos per-command
maintenance set per-command -- Per-command statistics settings
set per-command space -- Set whether to display per-command space usage
set per-command symtab -- Set whether to display per-command symtab statistics
set per-command time -- Set whether to display per-command execution time
maintenance show per-command -- Show per-command statistics settings
show per-command space -- Show whether to display per-command space usage
show per-command symtab -- Show whether to display per-command symtab statistics
show per-command time -- Show whether to display per-command execution time

The subcommands of "maintenance set per-command" are missing the
maintenance keyword.  This is because that command is registered with
the wrong prefix.  This patch fixes that.

gdb/ChangeLog:

* maint.c (_initialize_maint_cmds): Fix prefix of maint set/show
per-command.

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

6 years agogdb: Remove cleanup from dw2_do_instantiate_symtab
Andrew Burgess [Mon, 5 Feb 2018 17:13:17 +0000 (17:13 +0000)] 
gdb: Remove cleanup from dw2_do_instantiate_symtab

When running the test gdb.dwarf2/dw2-bad-parameter-type.exp under
valgrind, I see the following issue reported (on x86-64 Fedora):

  (gdb) ptype f
  ==5203== Invalid read of size 1
  ==5203==    at 0x6931FE: process_die_scope::~process_die_scope() (dwarf2read.c:10642)
  ==5203==    by 0x66818F: process_die(die_info*, dwarf2_cu*) (dwarf2read.c:10664)
  ==5203==    by 0x66A01F: read_file_scope(die_info*, dwarf2_cu*) (dwarf2read.c:11650)
  ==5203==    by 0x667F2D: process_die(die_info*, dwarf2_cu*) (dwarf2read.c:10672)
  ==5203==    by 0x6677B6: process_full_comp_unit(dwarf2_per_cu_data*, language) (dwarf2read.c:10445)
  ==5203==    by 0x66657A: process_queue(dwarf2_per_objfile*) (dwarf2read.c:9945)
  ==5203==    by 0x6559B4: dw2_do_instantiate_symtab(dwarf2_per_cu_data*) (dwarf2read.c:3163)
  ==5203==    by 0x66683D: psymtab_to_symtab_1(partial_symtab*) (dwarf2read.c:10034)
  ==5203==    by 0x66622A: dwarf2_read_symtab(partial_symtab*, objfile*) (dwarf2read.c:9811)
  ==5203==    by 0x787984: psymtab_to_symtab(objfile*, partial_symtab*) (psymtab.c:792)
  ==5203==    by 0x786E3E: psym_lookup_symbol(objfile*, int, char const*, domain_enum_tag) (psymtab.c:522)
  ==5203==    by 0x804BD0: lookup_symbol_via_quick_fns(objfile*, int, char const*, domain_enum_tag) (symtab.c:2383)
  ==5203==  Address 0x147ed063 is 291 bytes inside a block of size 4,064 free'd
  ==5203==    at 0x4C2CD5A: free (vg_replace_malloc.c:530)
  ==5203==    by 0x444415: void xfree<void>(void*) (common-utils.h:60)
  ==5203==    by 0x9DA8C2: call_freefun (obstack.c:103)
  ==5203==    by 0x9DAD35: _obstack_free (obstack.c:280)
  ==5203==    by 0x44464C: auto_obstack::~auto_obstack() (gdb_obstack.h:73)
  ==5203==    by 0x68AFB0: dwarf2_cu::~dwarf2_cu() (dwarf2read.c:25080)
  ==5203==    by 0x68B204: free_one_cached_comp_unit(dwarf2_per_cu_data*) (dwarf2read.c:25174)
  ==5203==    by 0x66668C: dwarf2_release_queue(void*) (dwarf2read.c:9982)
  ==5203==    by 0x563A4C: do_my_cleanups(cleanup**, cleanup*) (cleanups.c:154)
  ==5203==    by 0x563AA7: do_cleanups(cleanup*) (cleanups.c:176)
  ==5203==    by 0x5646CE: throw_exception_cxx(gdb_exception) (common-exceptions.c:289)
  ==5203==    by 0x5647B7: throw_exception(gdb_exception) (common-exceptions.c:317)
  ==5203==  Block was alloc'd at
  ==5203==    at 0x4C2BBAD: malloc (vg_replace_malloc.c:299)
  ==5203==    by 0x564BE8: xmalloc (common-utils.c:44)
  ==5203==    by 0x9DA872: call_chunkfun (obstack.c:94)
  ==5203==    by 0x9DA935: _obstack_begin_worker (obstack.c:141)
  ==5203==    by 0x9DAA3C: _obstack_begin (obstack.c:164)
  ==5203==    by 0x4445E0: auto_obstack::auto_obstack() (gdb_obstack.h:70)
  ==5203==    by 0x68AE07: dwarf2_cu::dwarf2_cu(dwarf2_per_cu_data*) (dwarf2read.c:25073)
  ==5203==    by 0x661A8A: init_cutu_and_read_dies(dwarf2_per_cu_data*, abbrev_table*, int, int, void (*)(die_reader_specs const*, unsigned char const*, die_info*, int, void*), void*) (dwarf2read.c:7869)
  ==5203==    by 0x666A29: load_full_comp_unit(dwarf2_per_cu_data*, language) (dwarf2read.c:10108)
  ==5203==    by 0x655847: load_cu(dwarf2_per_cu_data*) (dwarf2read.c:3120)
  ==5203==    by 0x655928: dw2_do_instantiate_symtab(dwarf2_per_cu_data*) (dwarf2read.c:3148)
  ==5203==    by 0x66683D: psymtab_to_symtab_1(partial_symtab*) (dwarf2read.c:10034)

There's actually a series of three issues reported, but it turns out
they're all related, so we can consider on the first one.

The invalid read is triggered from a destructor which is being invoked
as part of a stack unwind after throwing an error.  At the time the
error is thrown, the stack looks like this:

    #0  0x00000000009f4ecd in __cxa_throw ()
    #1  0x0000000000564761 in throw_exception_cxx (exception=...) at ../../src/gdb/common/common-exceptions.c:303
    #2  0x00000000005647b8 in throw_exception (exception=...) at ../../src/gdb/common/common-exceptions.c:317
    #3  0x00000000005648ff in throw_it(return_reason, errors, const char *, typedef __va_list_tag __va_list_tag *) (reason=RETURN_ERROR,
        error=GENERIC_ERROR, fmt=0xb33020 "Dwarf Error: Cannot find DIE at 0x%x referenced from DIE at 0x%x [in module %s]",
        ap=0x7fff387f2d68) at ../../src/gdb/common/common-exceptions.c:373
    #4  0x0000000000564929 in throw_verror (error=GENERIC_ERROR,
        fmt=0xb33020 "Dwarf Error: Cannot find DIE at 0x%x referenced from DIE at 0x%x [in module %s]", ap=0x7fff387f2d68)
        at ../../src/gdb/common/common-exceptions.c:379
    #5  0x0000000000867be4 in verror (string=0xb33020 "Dwarf Error: Cannot find DIE at 0x%x referenced from DIE at 0x%x [in module %s]",
        args=0x7fff387f2d68) at ../../src/gdb/utils.c:251
    #6  0x000000000056879d in error (fmt=0xb33020 "Dwarf Error: Cannot find DIE at 0x%x referenced from DIE at 0x%x [in module %s]")
        at ../../src/gdb/common/errors.c:43
    #7  0x0000000000686875 in follow_die_ref (src_die=0x30bc8a0, attr=0x30bc8c8, ref_cu=0x7fff387f2ed0) at ../../src/gdb/dwarf2read.c:22969
    #8  0x00000000006844cd in lookup_die_type (die=0x30bc8a0, attr=0x30bc8c8, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:21976
    #9  0x0000000000683f27 in die_type (die=0x30bc8a0, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:21832
    #10 0x0000000000679b39 in read_subroutine_type (die=0x30bc830, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:17343
    #11 0x00000000006845fb in read_type_die_1 (die=0x30bc830, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:22035
    #12 0x0000000000684576 in read_type_die (die=0x30bc830, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:22010
    #13 0x000000000067003f in read_func_scope (die=0x30bc830, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:13822
    #14 0x0000000000667f5e in process_die (die=0x30bc830, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:10679
    #15 0x000000000066a020 in read_file_scope (die=0x30bc720, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:11650
    #16 0x0000000000667f2e in process_die (die=0x30bc720, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:10672
    #17 0x00000000006677b7 in process_full_comp_unit (per_cu=0x3089b80, pretend_language=language_minimal)
        at ../../src/gdb/dwarf2read.c:10445
    #18 0x000000000066657b in process_queue (dwarf2_per_objfile=0x30897d0) at ../../src/gdb/dwarf2read.c:9945
    #19 0x00000000006559b5 in dw2_do_instantiate_symtab (per_cu=0x3089b80) at ../../src/gdb/dwarf2read.c:3163
    #20 0x000000000066683e in psymtab_to_symtab_1 (pst=0x3089bd0) at ../../src/gdb/dwarf2read.c:10034
    #21 0x000000000066622b in dwarf2_read_symtab (self=0x3089bd0, objfile=0x3073f40) at ../../src/gdb/dwarf2read.c:9811
    #22 0x0000000000787985 in psymtab_to_symtab (objfile=0x3073f40, pst=0x3089bd0) at ../../src/gdb/psymtab.c:792
    #23 0x0000000000786e3f in psym_lookup_symbol (objfile=0x3073f40, block_index=1, name=0x30b2e30 "f", domain=VAR_DOMAIN)
        at ../../src/gdb/psymtab.c:522
    #24 0x0000000000804bd1 in lookup_symbol_via_quick_fns (objfile=0x3073f40, block_index=1, name=0x30b2e30 "f", domain=VAR_DOMAIN)
        at ../../src/gdb/symtab.c:2383
    #25 0x0000000000804fe4 in lookup_symbol_in_objfile (objfile=0x3073f40, block_index=1, name=0x30b2e30 "f", domain=VAR_DOMAIN)
        at ../../src/gdb/symtab.c:2558
    #26 0x0000000000805125 in lookup_static_symbol (name=0x30b2e30 "f", domain=VAR_DOMAIN) at ../../src/gdb/symtab.c:2595
    #27 0x0000000000804357 in lookup_symbol_aux (name=0x30b2e30 "f", match_type=symbol_name_match_type::FULL, block=0x0,
        domain=VAR_DOMAIN, language=language_c, is_a_field_of_this=0x0) at ../../src/gdb/symtab.c:2105
    #28 0x0000000000803ad9 in lookup_symbol_in_language (name=0x30b2e30 "f", block=0x0, domain=VAR_DOMAIN, lang=language_c,
        is_a_field_of_this=0x0) at ../../src/gdb/symtab.c:1887
    #29 0x0000000000803b53 in lookup_symbol (name=0x30b2e30 "f", block=0x0, domain=VAR_DOMAIN, is_a_field_of_this=0x0)
        at ../../src/gdb/symtab.c:1899
    #30 0x000000000053b246 in classify_name (par_state=0x7fff387f6090, block=0x0, is_quoted_name=false, is_after_structop=false)
        at ../../src/gdb/c-exp.y:2879
    #31 0x000000000053b7e9 in c_yylex () at ../../src/gdb/c-exp.y:3083
    #32 0x000000000053414a in c_yyparse () at c-exp.c:1903
    #33 0x000000000053c2e7 in c_parse (par_state=0x7fff387f6090) at ../../src/gdb/c-exp.y:3255
    #34 0x0000000000774a02 in parse_exp_in_context_1 (stringptr=0x7fff387f61c0, pc=0, block=0x0, comma=0, void_context_p=0, out_subexp=0x0)
        at ../../src/gdb/parse.c:1213
    #35 0x000000000077476a in parse_exp_in_context (stringptr=0x7fff387f61c0, pc=0, block=0x0, comma=0, void_context_p=0, out_subexp=0x0)
        at ../../src/gdb/parse.c:1115
    #36 0x0000000000774714 in parse_exp_1 (stringptr=0x7fff387f61c0, pc=0, block=0x0, comma=0) at ../../src/gdb/parse.c:1106
    #37 0x0000000000774c53 in parse_expression (string=0x27ff996 "f") at ../../src/gdb/parse.c:1253
    #38 0x0000000000861dc4 in whatis_exp (exp=0x27ff996 "f", show=1) at ../../src/gdb/typeprint.c:472
    #39 0x00000000008620d8 in ptype_command (type_name=0x27ff996 "f", from_tty=1) at ../../src/gdb/typeprint.c:561
    #40 0x000000000047430b in do_const_cfunc (c=0x3012010, args=0x27ff996 "f", from_tty=1) at ../../src/gdb/cli/cli-decode.c:106
    #41 0x000000000047715e in cmd_func (cmd=0x3012010, args=0x27ff996 "f", from_tty=1) at ../../src/gdb/cli/cli-decode.c:1886
    #42 0x00000000008431bb in execute_command (p=0x27ff996 "f", from_tty=1) at ../../src/gdb/top.c:630
    #43 0x00000000006bf946 in command_handler (command=0x27ff990 "ptype f") at ../../src/gdb/event-top.c:583
    #44 0x00000000006bfd12 in command_line_handler (rl=0x30bb3a0 "\240\305\v\003") at ../../src/gdb/event-top.c:774

The problem is that in `process_die` (frames 14 and 16) we create a
`process_die_scope` object, that takes a copy of the `struct
dwarf2_cu *` passed into the frame.  The destructor of the
`process_die_scope` dereferences the stored pointer.  This wouldn't be
an issue, except...

... in dw2_do_instantiate_symtab (frame 19) a clean up was registered that
clears the dwarf2_queue in case of an error.  Part of this clean up
involves deleting the `struct dwarf2_cu`s referenced from the queue..

The problem then, is that cleanups are processed at the site of the
throw, while, class destructors are invoked as we unwind their frame.
The result is that we process the frame 19 cleanup (and delete the
struct dwarf2_cu) before we process the destructors in frames 14 and 16.
When we do get back to frames 14 and 16 the objects being references
have already been deleted.

The solution is to remove the cleanup from dw2_do_instantiate_symtab, and
instead use a destructor to release the dwarf2_queue instead.  With this
patch in place, the valgrind errors are now resolved.

gdb/ChangeLog:

* dwarf2read.c (dwarf2_release_queue): Delete function, move body
into...
(class dwarf2_queue_guard): ...the destructor of this new class.
(dw2_do_instantiate_symtab): Create instance of the new class
dwarf2_queue_guard, remove cleanup.

6 years agoMIPS/GAS/test: Fix an n32 `.reginfo' size test failure
Maciej W. Rozycki [Mon, 12 Feb 2018 16:04:05 +0000 (16:04 +0000)] 
MIPS/GAS/test: Fix an n32 `.reginfo' size test failure

Correct a commit 2d6dda71611b ("MIPS/BFD: Correctly report unsupported
`.reginfo' section size") issue and avoid a GAS test failure:

regexp_diff match failure
regexp "^.*: Incorrect `\.reginfo' section size; expected 24, got 28$"
line   "../as-new: dump.o: Incorrect `.reginfo' section size; expected 24, got 32"
FAIL: MIPS assembled .reginfo section size (n32)

on MIPS targets other than bare-metal ones.  The reason for this failure
is section padding to alignment, done in `size_seg'.  For n32 `.reginfo'
the section alignment is set to 3, and therefore the section is padded
to a multiple of 8, except for bare-metal targets, for which padding is
unconditionally disabled in `md_section_align'.

Use `--no-pad-sections' then to disable padding for all targets, so that
the size of `.reginfo' is always the same, matching the message pattern.

gas/
* testsuite/gas/mips/reginfo-2-n32.d: Add `--no-pad-sections' to
`as' flags.

6 years agoMIPS: Fix encoding for MIPSr6 sigrie instruction.
Henry Wong [Mon, 12 Feb 2018 14:50:42 +0000 (14:50 +0000)] 
MIPS: Fix encoding for MIPSr6 sigrie instruction.

The instruction encoding for the MIPS r6 sigrie instruction seems to be
incorrect.  It's currently 0x4170xxxx (which overlaps with ei, di, evp,
and dvp), but should be 0x0417xxxx.  See ISA reference[1][2].

References:

[1] "MIPS Architecture for Programmers Volume II-A: The MIPS32
    Instruction Set Manual", Imagination Technologies, Inc., Document
    Number: MD00086, Revision 6.06, December 15, 2016, Table A.4 "MIPS32
    REGIMM Encoding of rt Field", p. 452

[2] "MIPS Architecture For Programmers Volume II-A: The MIPS64
    Instruction Set Reference Manual", Imagination Technologies, Inc.,
    Document Number: MD00087, Revision 6.06, December 15, 2016, Table
    A.4 "MIPS64 REGIMM Encoding of rt Field", p. 581

opcodes/
* mips-opc.c (mips_builtin_opcodes): Correct "sigrie" encoding.

gas/
* testsuite/gas/mips/r6.d: Update for "sigrie" encoding fix.
* testsuite/gas/mips/r6-n32.d: Likewise.
* testsuite/gas/mips/r6-n64.d: Likewise.

6 years agoAdd support for reading msdos MZ executables.
Zebediah Figura [Mon, 12 Feb 2018 13:12:45 +0000 (13:12 +0000)] 
Add support for reading msdos MZ executables.

See email thread starting here:  https://www.sourceware.org/ml/binutils/2018-01/msg00001.html

include * coff/msdos.h: New header.
* coff/pe.h: Move common defines to msdos.h.
* coff/powerpc.h: Likewise.

bfd * i386msdos.c (msdos_mkobject); New function.
(msdos_object_p): New function.
(i386_msdos_vec): Use msdos_object_p as the check_format
function.
* peicode.h: Rename external_PEI_DOS_hdr, DOSMAGIC, and
NT_SIGNATURE to external_DOS_hdr, IMAGE_DOS_SIGNATURE, and
IMAGE_NT_SIGNATURE.
* peXXigen.c: Likewise.
* coff-ia64.c: Likewise.

6 years agoUpdate Russian translation for the gas/ sub-directory.
Nick Clifton [Mon, 12 Feb 2018 12:10:50 +0000 (12:10 +0000)] 
Update Russian translation for the gas/ sub-directory.

6 years agoFix compile time warning: bfd/elf32-arc.c:1537]: (warning) Redundant assignment of...
Nick Clifton [Mon, 12 Feb 2018 11:57:41 +0000 (11:57 +0000)] 
Fix compile time warning: bfd/elf32-arc.c:1537]: (warning) Redundant assignment of 'rel->r_offset' to itself.

* elf32-arc.c (elf_arc_relocate_section):  Remove redundant
assignment.

6 years agooops - actually remove the assignment this time: bfd/elf32-nds32.c:9693]: (warning...
Nick Clifton [Mon, 12 Feb 2018 11:54:48 +0000 (11:54 +0000)] 
oops - actually remove the assignment this time: bfd/elf32-nds32.c:9693]: (warning) Redundant assignment of 'irel->r_addend' to itself.

6 years agoFix compile time warning: bfd/elf32-nds32.c:9693]: (warning) Redundant assignment...
Nick Clifton [Mon, 12 Feb 2018 11:51:56 +0000 (11:51 +0000)] 
Fix compile time warning: bfd/elf32-nds32.c:9693]: (warning) Redundant assignment of 'irel->r_addend' to itself.

* elf32-nds32.c (nds32_elf_relax_longjump3): Remove redundant
assignment.

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