]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
8 years agoRemove features/i386/amd64-*linux.c and features/i386/x32-*linux.c users/qiyao/target-desc-2
Yao Qi [Fri, 9 Jun 2017 09:53:25 +0000 (10:53 +0100)] 
Remove features/i386/amd64-*linux.c and features/i386/x32-*linux.c

gdb:

2017-06-09  Yao Qi  <yao.qi@linaro.org>

* features/Makefile (XMLTOC): Remove i386/amd64XXX-linux.xml a
* features/i386/amd64-avx-avx512-linux.c: Removed.
* features/i386/amd64-avx-linux.c: Removed.
* features/i386/amd64-avx-mpx-avx512-pku-linux.c: Removed.
* features/i386/amd64-avx-mpx-linux.c: Removed.
* features/i386/amd64-linux.c: Removed.
* features/i386/amd64-mpx-linux.c: Removed.
* features/i386/x32-avx-avx512-linux.c: Removed.
* features/i386/x32-avx-linux.c: Removed.
* features/i386/x32-linux.c: Removed.

8 years ago[GDBserver] Use pre-generated amd64-linux tdesc as test
Yao Qi [Fri, 9 Jun 2017 09:15:59 +0000 (10:15 +0100)] 
[GDBserver] Use pre-generated amd64-linux tdesc as test

Now, all these amd64-linux pre-generated tdesc can be used as test, so
don't need to build them if $development is false.

Note that this patch wants to remove ipa_x32_linux_regobj, but it was
removed by mistake by 22049425ce40324139be82d9a6ec518c46b65815.

gdb/gdbserver:

2017-06-09  Yao Qi  <yao.qi@linaro.org>

* configure.srv: Empty srv_amd64_linux_regobj if $development is
false.
(ipa_amd64_linux_regobj): Remove.

8 years ago[GDBserver] Convert amd64-linux target descriptions
Yao Qi [Fri, 9 Jun 2017 08:50:28 +0000 (09:50 +0100)] 
[GDBserver] Convert amd64-linux target descriptions

This patch changes amd64-linux target descriptions so that they can be
dynamically generated.

gdb/gdbserver:

2017-06-09  Yao Qi  <yao.qi@linaro.org>

* linux-amd64-ipa.c (get_ipa_tdesc): Remove.
(initialize_low_tracepoint): Don't call init_registers_x32_XXX
and init_registers_amd64_XXX.
* linux-x86-low.c (x86_linux_read_description): Call
amd64_get_ipa_tdesc.
(x86_get_ipa_tdesc_idx): Likewise.
(initialize_low_arch): Don't call init_registers_x32_XXX and
init_registers_amd64_XXX.
* linux-x86-tdesc-selftest.c: Declare init_registers_amd64_XXX
and tdesc_amd64_XXX.
[__x86_64__] (amd64_tdesc_test): New function.
(initialize_low_tdesc) [__x86_64__]: Call init_registers_x32_XXX
and init_registers_amd64_XXX.
* linux-x86-tdesc.c: Include feature c files.
(amd64_get_ipa_tdesc): New function.
(get_ipa_tdesc): Call amd64_get_ipa_tdesc.
(amd64_get_ipa_tdesc_idx): New function.
* linux-x86-tdesc.h (amd64_get_ipa_tdesc_idx): Declare.
(amd64_get_ipa_tdesc): Declare.

8 years agoRegenerate two regformats/i386/.dat files
Yao Qi [Fri, 9 Jun 2017 08:38:17 +0000 (09:38 +0100)] 
Regenerate two regformats/i386/.dat files

The self tests which compare pre-generated target descriptions and dynamically
created target descriptions fail, and it turns out that two pre-generated
target descriptions are wrong, so regenerate them.

gdb:

2017-06-09  Yao Qi  <yao.qi@linaro.org>

* regformats/i386/amd64-avx-mpx-avx512-pku-linux.dat: Regenerated.
* regformats/i386/amd64-avx-mpx-avx512-pku.dat: Regenerated.

8 years agoLazily and dynamically create amd64-linux target descriptions
Yao Qi [Thu, 8 Jun 2017 13:09:34 +0000 (14:09 +0100)] 
Lazily and dynamically create amd64-linux target descriptions

This patch starts to use the generate c feature files to dynamically
create amd64-linux target descriptions.

gdb:

2017-06-08  Yao Qi  <yao.qi@linaro.org>

* amd64-linux-tdep.c: Don't include amd64-XXX-linux and
x32-XXX-linux.c.  Include 64bit-XX.c and x32-XX.c.
(amd64_linux_read_description): Create target descriptions.
(_initialize_amd64_linux_tdep): Don't call initialize_tdesc_XXX
functions.  Add unit tests.
* features/Makefile (FEATURE_XMLFILES): Append 64bit-XXX.xml and
x32-core.xml.  Echo the right architecture for amd64 and x32.
* features/i386/64bit-avx.c: Generated.
* features/XXXX
* target-descriptions.c (maint_print_c_tdesc_cmd): Print feature
c files for amd64-linux and x32-linux.

8 years agoCentralize amd64-linux target descriptions
Yao Qi [Wed, 7 Jun 2017 22:00:27 +0000 (23:00 +0100)] 
Centralize amd64-linux target descriptions

This patch adds a new function amd64_linux_read_description, which
creates amd64-linux target descriptions according to its two
arguments, xcr0 and is_x32.

gdb:

2017-06-07  Yao Qi  <yao.qi@linaro.org>

* amd64-linux-tdep.c (amd64_linux_read_description): New
function.
(amd64_linux_core_read_description): Call
amd64_linux_read_description.
(amd64_linux_init_abi): Likewise.
(amd64_x32_linux_init_abi): Likewise.
* amd64-linux-tdep.h (amd64_linux_read_description): Declare.
* x86-linux-nat.c (x86_linux_read_description): Call
amd64_linux_read_description.

8 years agoGDBserver: remove srv_i386_linux_xmlfiles
Yao Qi [Fri, 26 May 2017 11:47:36 +0000 (12:47 +0100)] 
GDBserver: remove srv_i386_linux_xmlfiles

Now, GDBserver is able to create XML contents for target descriptions,
so that the list of XML files about i386-linux are not needed.

gdb/gdbserver:

2017-05-26  Yao Qi  <yao.qi@linaro.org>

* configure.srv: Remove srv_i386_linux_xmlfiles.

8 years ago[GDBserver] Use pre-generated tdesc as test
Yao Qi [Fri, 26 May 2017 11:38:38 +0000 (12:38 +0100)] 
[GDBserver] Use pre-generated tdesc as test

Now, these *-generate.c files are only used in GDBserver for unit test.
If $development is false (in release), these *-generate.c files won't be
used at all.

gdb/gdbserver:

2017-05-26  Yao Qi  <yao.qi@linaro.org>

* configure.srv: Set srv_i386_linux_regobj empty if $development
is false.
* linux-x86-tdesc.c: TODO.

8 years agoRemove features/i386/i386-*linux.c
Yao Qi [Fri, 26 May 2017 11:55:55 +0000 (12:55 +0100)] 
Remove features/i386/i386-*linux.c

Now, features/i386/i386-XXX-linux.c are not used, remove them.

gdb:

2017-05-26  Yao Qi  <yao.qi@linaro.org>

* features/Makefile (XMLTOC): Remove i386/i386-XX-linux.xml.
* features/i386/i386-avx-avx512-linux.c: Remove.
* features/i386/i386-avx-linux.c: Remove.
* features/i386/i386-avx-mpx-avx512-pku-linux.c: Remove.
* features/i386/i386-avx-mpx-linux.c: Remove.
* features/i386/i386-linux.c: Remove.
* features/i386/i386-mmx-linux.c: Remove.
* features/i386/i386-mpx-linux.c: Remove.

8 years agoDynamically composite xml in reply to GDB
Yao Qi [Wed, 24 May 2017 13:59:37 +0000 (14:59 +0100)] 
Dynamically composite xml in reply to GDB

GDBserver still uses pre-generated target descriptions in order to
reply to GDB's query on target description (see xml-builtin-generated.c
in GDBserver build directory).  This patch teaches GDBserver to
create XML contents according to the target descriptions rather than
using pre-generated ones.

First, change target feature c files to pass the feature xml file
name to tdesc_create_feature, so that target description in GDBserver
can record them, and create XML contents from these features in
buffer, like

  ...
  <xi:include href="$FEATURE1_XML_NAME"/>
  <xi:include href="$FEATURE2_XML_NAME"/>
  ...

and send this buffer back to GDB.

gdb/gdbserver:

2017-05-24  Yao Qi  <yao.qi@linaro.org>

* linux-x86-tdesc.c (i386_get_ipa_tdesc): Call
set_tdesc_architecture and set_tdesc_osabi.  Don't set
xmltarget field.
* server.c (get_features_xml): Call tdesc_get_features_xml.
* tdesc.c (set_tdesc_architecture): New function.
(set_tdesc_osabi): New function.
(tdesc_get_features_xml): New function.
(tdesc_create_feature): Add one argument.
* tdesc.h (struct target_desc) <features>: New field.
<arch>: New field.
<osabi>: New field.
(target_desc::~target_desc): xfree arch, osabi, and
features.
(set_tdesc_architecture): Declare.
(set_tdesc_osabi): Declare.
(tdesc_get_features_xml): Declare.
* target-descriptions.c (tdesc_create_feature): Add one
argument.
* target-descriptions.h (tdesc_create_feature): Update
the declaration.

8 years ago[RFC] GDBserver unit test to i386_tdesc
Yao Qi [Tue, 6 Jun 2017 22:07:19 +0000 (23:07 +0100)] 
[RFC] GDBserver unit test to i386_tdesc

This patch adds a unit test in GDBserver to test dynamically created
target descriptions equal to these pre-generated ones.

gdb/gdbserver:

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

* linux-x86-tdesc.c (i386_tdesc_test): New function.
(initialize_low_tdesc): Call register_self_test.
* tdesc.h: TODO.

8 years ago[RFC] GDBserver self test
Yao Qi [Fri, 26 May 2017 10:56:58 +0000 (11:56 +0100)] 
[RFC] GDBserver self test

This patch uses GDB self test in GDBserver.  The self tests are run if
GDBserver is started with option --self-test.

gdb/gdbserver:

2017-05-26  Yao Qi  <yao.qi@linaro.org>

* configure.ac: AC_DEFINE GDB_SELF_TEST if $development.
* configure, config.in: Re-generated.
* server.c: Include sefltest.h and selftest.c.
(captured_main): Handle option --self-test.
gdb:

2017-05-26  Yao Qi  <yao.qi@linaro.org>

* selftest.c: Adjust it for GDBserver.

gdb/testsuite:

2017-05-26  Yao Qi  <yao.qi@linaro.org>

* gdb.server/unittest.exp: New.

8 years agoDynamically create tdesc in GDBserver
Yao Qi [Tue, 6 Jun 2017 22:05:32 +0000 (23:05 +0100)] 
Dynamically create tdesc in GDBserver

In this patch, GDBserver starts to use gdb/features/*.c feature files
by including them, so that GDBserver can create target descriptions
from features dynamically, like GDB does.  Adjust these feature .c
files for GDBserver.

These feature .c files calls some target description APIs only defined
GDB, so this patch also adds them in GDBserver.

TODO: complete ChangeLog.

gdb:

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

* features/i386/32bit-avx.c: Re-generated.
* features/i386/32bit-avx512.c: Re-generated.
* features/i386/32bit-core.c: Re-generated.
* features/i386/32bit-linux.c: Re-generated.
* features/i386/32bit-mpx.c: Re-generated.
* features/i386/32bit-pkeys.c: Re-generated.
* features/i386/32bit-sse.c: Re-generated.

gdb/gdbserver:

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

* linux-x86-tdesc.c: Include ../features/i386/32bit-*.c.
(initialize_low_tdesc): Don't use tdesc_i386_XXX_linux.
(i386_get_ipa_tdesc): Create target descriptions.
* tdesc.c (init_target_desc):
(current_target_desc):
(tdesc_create_feature): +
(tdesc_create_flags): +
(tdesc_add_flag): +
(tdesc_named_type): +
(tdesc_create_reg): +
(tdesc_create_vector): +
(tdesc_add_bitfield): +
(tdesc_add_field): +
(tdesc_set_struct_size): +
* tdesc.h (target_desc::target_desc): New.
(target_desc::~target_desc): New.
* regformats/regdat.sh: Generate code to call
tdesc_create_reg.
* target-descriptions.c (print_c_feature::visit): Print
code for GDB.

8 years ago[GDBserver] Centralize tdesc for i386-linux
Yao Qi [Tue, 23 May 2017 15:21:12 +0000 (16:21 +0100)] 
[GDBserver] Centralize tdesc for i386-linux

tdesc_i386_XXX_linux is spread in linux-x86-low.c and this patch adds
a new function i386_get_ipa_tdesc to return the right tdesc according to
tdesc index.  Note that GDB has a similar function returning tdesc, but
with different argument.  Ultimately, GDB and GDBserver should share
this function.

gdb/gdbserver:

2017-06-07  Yao Qi  <yao.qi@linaro.org>

* configure.srv (srv_tgtobj): Append linux-x86-tdesc.o.
(ipa_obj): Likewise.
* linux-i386-ipa.c (get_ipa_tdesc): Move it to
linux-x86-tdesc.c.
(initialize_low_tracepoint): Don't call  init_registers_XXX
functions, call initialize_low_tdesc instead.
* linux-x86-low.c (x86_linux_read_description): Call
i386_get_ipa_tdesc.
(initialize_low_arch): Don't call init_registers_i386_XXX
functions, call initialize_low_tdesc.
* linux-x86-tdesc.c: New file.
* linux-x86-tdesc.h (x86_linux_tdesc): New X86_TDESC_LAST.
(i386_get_ipa_tdesc_idx): Declare.
(i386_get_ipa_tdesc): Declare.
(initialize_low_tdesc): Declare.

8 years agoUse VEC for target_desc.reg_defs
Yao Qi [Tue, 23 May 2017 09:45:58 +0000 (10:45 +0100)] 
Use VEC for target_desc.reg_defs

Nowadays, target_desc.reg_defs is a pointer points to a pre-generated
array, which is not flexible.  This patch changes it from an array
to a VEC so that GDBserver can create target descriptions dynamically
later.  Instead of using pre-generated array, the -generated.c calls
VEC_safe_push to add each register to vector.

Since target_desc.reg_defs is used in IPA, we need to build common/vec.c
for IPA too.

gdb/gdbserver:

2017-05-23  Yao Qi  <yao.qi@linaro.org>

* Makefile.in (IPA_OBJS): Add vec-ipa.o
* regcache.c (get_thread_regcache): Use VEC_length.
(init_register_cache): Likewise.
(regcache_cpy): Likewise.
(registers_to_string): Iterate reg_defs via VEC_iterate.
(find_regno): Likewise.
(find_register_by_number): Use VEC_index.
(register_size): Call find_register_by_number.
(register_data): Call find_register_by_number.
(supply_regblock): Use VEC_length.
(regcache_raw_read_unsigned): Likewise.
* tdesc.c (init_target_desc): Iterate reg_defs via
VEC_iterate.
(default_description): Update initializer.
(copy_target_description): Don't update field num_registers.
* tdesc.h (struct target_desc) <reg_defs>: Change it to VEC.
<num_registers>: Remove.

gdb:

2017-05-23  Yao Qi  <yao.qi@linaro.org>

* regformats/regdat.sh: Update generated code.

8 years agoAdjust code generated by regformats/regdat.sh
Yao Qi [Tue, 23 May 2017 08:06:55 +0000 (09:06 +0100)] 
Adjust code generated by regformats/regdat.sh

regformats/regdat.sh generate some *-generated.c files when GDBserver
is built.  Each .c file has some static variables, which are only used
within function init_registers_XXX, like this,

static struct reg regs_i386_linux[] = {
  { "eax", 0, 32 },
  { "ecx", 32, 32 },
  ...
};

static const char *expedite_regs_i386_linux[] = { "ebp", "esp", "eip", 0 };
static const char *xmltarget_i386_linux = "i386-linux.xml";

void
init_registers_i386_linux (void)
{
  ...
}

This patch moves these static variables' definitions to function
init_registers_XXX, so the generated files look like this,

void
init_registers_i386_linux (void)
{
  static struct target_desc tdesc_i386_linux_s;
  struct target_desc *result = &tdesc_i386_linux_s;
static struct reg regs_i386_linux[] = {
  ...
};

static const char *expedite_regs_i386_linux[] = { "ebp", "esp", "eip", 0 };
static const char *xmltarget_i386_linux = "i386-linux.xml";

  ...
}

gdb:

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

* regformats/regdat.sh: Adjust code order.

8 years agoUse target_desc fields expedite_regs and xmltarget ifndef IN_PROCESS_AGENT
Yao Qi [Mon, 22 May 2017 21:42:51 +0000 (22:42 +0100)] 
Use target_desc fields expedite_regs and xmltarget ifndef IN_PROCESS_AGENT

struct target_desc is used by both GDBserver and IPA, but fields expedite_regs
and xmltarget are only used in GDBserver, so this patch wraps these two fields
by ifndef IN_PROCESS_AGENT.  This patch also changes regformats/regdat.sh to
generate .c files in this way too.

gdb/gdbserver:

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

* tdesc.h (struct target_desc) [IN_PROCESS_AGENT] <expedite_regs>:
Remove.
[IN_PROCESS_AGENT] <xmltarget>: Likewise.

gdb:

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

* regformats/regdat.sh: Generate code with "ifndef IN_PROCESS_AGENT".

8 years agoAdd "maint check xml-descriptions" to test builtin xml target descriptions
Yao Qi [Thu, 25 May 2017 20:55:32 +0000 (21:55 +0100)] 
Add "maint check xml-descriptions" to test builtin xml target descriptions

Now, GDB is able to dynamically create i386-linux target descriptions
from features, instead of using pre-generated target descriptions.  These
pre-generated target descriptions are no longer used by GDB (note that
they are still used by GDBserver).

This patch add a new maint command "maint check xml-descriptions" to test
dynamically generated tdesc are identical to these generated from xml files.

gdb:

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

* cli/cli-cmds.c (maintenancechecklist): New variable.
* gdbcmd.h (maintenancechecklist): Declare it.
* i386-linux-tdep.c (_initialize_i386_linux_tdep) [GDB_SELF_TEST]:
Call i386_linux_read_description with different masks.
* maint.c (maintenance_check_command): New function.
(_initialize_maint_cmds): Call add_prefix_cmd.
* target-descriptions.c (tdesc_reg): override operator != and ==.
(tdesc_type): Likewise.
(tdesc_feature): Likewise.
(target_desc): Likewise.
[GDB_SELF_TEST] (selftests::record_xml_tdesc): New function.
(maintenance_check_xml_descriptions): New function.
(_initialize_target_descriptions) Add command "xml-descriptions".
* target-descriptions.h (selftests::record_xml_tdesc): Declare.

gdb/testsuite:

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

* gdb.gdb/unittest.exp: Invoke command
"maintenance check xml-descriptions".

gdb/doc:

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

* gdb.texinfo (Maintenance Commands): Document command
"maint check xml-descriptions".

8 years agoLazily and dynamically create i386-linux target descriptions
Yao Qi [Sun, 7 May 2017 21:56:43 +0000 (22:56 +0100)] 
Lazily and dynamically create i386-linux target descriptions

Instead of using pre-generated target descriptions, this patch
changes GDB to lazily and dynamically create target descriptions
according to the target hardware capability (xcr0 in i386).
This support any combination of target features.

This patch also adds a unit test to make sure dynamically generated
tdesc are identical to these generated from xml files.

gdb:

2017-04-27  Yao Qi  <yao.qi@linaro.org>

* i386-linux-tdep.c (i386_linux_read_description): Generate
target description if it doesn't exist.
        [GDB_SELF_TEST] (i386_linux_read_description_test): New unit test.
        (_initialize_i386_linux_tdep) [GDB_SELF_TEST]: Register unit test.

8 years agoGenerate c for feature instead of tdesc
Yao Qi [Thu, 15 Jun 2017 16:05:04 +0000 (17:05 +0100)] 
Generate c for feature instead of tdesc

gdb/doc:

2017-06-15  Yao Qi  <yao.qi@linaro.org>
:
* gdb.texinfo (a C source file.  By default, the target description is for the current):

8 years agoGenerate c for feature instead of tdesc
Yao Qi [Tue, 13 Jun 2017 13:01:01 +0000 (14:01 +0100)] 
Generate c for feature instead of tdesc

gdb:

2017-06-13  Yao Qi  <yao.qi@linaro.org>
:
* NEWS
gdb/doc:

2017-06-13  Yao Qi  <yao.qi@linaro.org>
:
* gdb.texinfo (Print the entire architecture configuration.  The optional argument):

8 years agoGenerate c for feature instead of tdesc
Yao Qi [Fri, 19 May 2017 20:31:24 +0000 (21:31 +0100)] 
Generate c for feature instead of tdesc

This patch changes Makefile and command "maint print c-files" so
that GDB can print c files for features instead target description.
Previously, we feed GDB a target description xml file, which generate
c files including multiple features.

With this patch, in Makefile, we wrap each feature xml file, and
create a temp target description which include only one feature.
Then, adjust the target description printer for them, and print
a c function for each given feature, so that we can use these
c functions later to create target description in a flexible way.

Before GDB prints c-tdesc, we need to set tdesc.  However, this involves
some validations in each gdbarch on these target descriptions, and this
make troubles to generate c file for each target feature when we feed GDB
a target description only including an optional feature (without some
mandatory feature), GDB just reject it, and don't print the c file.

What we need here is to translate xml file to object target_desc, and
translate the object target_desc to c file.  We don't have to involve
gdbarch validation in this process at all, so I modify command
"maint print c-tdesc" to have an optional argument which is the filename
of xml target description.  If the file name is provided, parse the
xml target description, create target_desc object, and print c file from
it.

gdb:

2017-05-22  Yao Qi  <yao.qi@linaro.org>

* features/Makefile (FEATURE_XMLFILES): New.
(FEATURE_CFILES): New.
New rules.
* features/i386/32bit-avx.c: Generated.
  * features/i386/32bit-avx512.c: Generated.
  * features/i386/32bit-core.c: Generated.
  * features/i386/32bit-linux.c: Generated.
  * features/i386/32bit-mpx.c: Generated.
  * features/i386/32bit-pkeys.c: Generated.
  * features/i386/32bit-sse.c: Generated.
  * target-descriptions.c: Include algorithm.
(tdesc_element_visitor): Add method visit_end.
(print_c_tdesc): Implement visit_end.
(print_c_tdesc:: m_filename_after_features): Move it to
protected.
(print_c_feature): New class.
(maint_print_c_tdesc_cmd): Use print_c_feature if XML file
name starts with "i386/32bit-".

gdb/doc:

2017-06-08  Yao Qi  <yao.qi@linaro.org>

* gdb.texinfo (Maintenance Commands): Document optional
argument of "maint print c-tdesc".

8 years agoUse visitor pattern for "maint print c-tdesc"
Yao Qi [Thu, 25 May 2017 15:08:44 +0000 (16:08 +0100)] 
Use visitor pattern for "maint print c-tdesc"

Target description can be modeled as a tree, the target description
is the root node, features are children nodes, registers and types are
grand-children nodes.  So command "maint print c-tdesc" in effect
traverse/visit each node, and print them in c.  This can be
implemented by visitor pattern, this is the first reason.  Secondly,
I want to this command prints c files in a different way for some
specific xml files, but still print c files the same way for the rest
of xml files.  Third, I even want to print xml files from target
descriptions, so that GDBserver can use it to reply GDB's query
qXfer:features:read:target.xml.

After this change, all features/*.c should be re-generated, but
this patch only includes part changes features/*.c files.

gdb:

2017-05-25  Yao Qi  <yao.qi@linaro.org>

* target-descriptions.c (tdesc_element_visitor): New class.
(tdesc_element): New class.
(tdesc_reg): Inherit from tdesc_element.
(tdesc_reg::accept): New function.
(tdesc_type): Inherit from tdesc_element.
(tdesc_type::accept): New function.
(tdesc_feature): Inherit from tdesc_element.
(tdesc_feature::accept): New function.
(target_desc): Inherit from tdesc_element.
(target_desc::target_desc): New.
(target_desc::~target_desc): New.
(target_desc::accept): New.
(allocate_target_description): Use new.
(free_target_description): Use delete.
(print_c_tdesc): New class.
(maint_print_c_tdesc_cmd): Adjust.

* features/i386/i386-avx-avx512-linux.c: Re-generated.
* features/i386/i386-avx-linux.c: Re-generated.
* features/i386/i386-avx-mpx-avx512-pku-linux.c: Re-generated.
* features/i386/i386-avx-mpx-linux.c: Re-generated.
* features/i386/i386-linux.c: Re-generated.
* features/i386/i386-mmx-linux.c: Re-generated.

8 years agoCentralize i386 linux target descriptions
Yao Qi [Thu, 27 Apr 2017 14:40:35 +0000 (15:40 +0100)] 
Centralize i386 linux target descriptions

This patch moves all the tdesc_i386*_linux target descriptions to a
function i386_linux_read_description, which returns the right target
description according to xcr0.  This also remove the duplication in
getting target descriptions in corefile and native target.

gdb:

2017-04-27  Yao Qi  <yao.qi@linaro.org>

* i386-linux-tdep.c (i386_linux_read_description): New function.
(i386_linux_core_read_description): Call
i386_linux_read_description.
* i386-linux-tdep.h (i386_linux_read_description): Declare.
(tdesc_i386_linux, tdesc_i386_mmx_linux): Remove declarations.
(tdesc_i386_avx_linux, tdesc_i386_mpx_linux): Likewise
(tdesc_i386_avx_mpx_linux, tdesc_i386_avx_avx512_linux): Likewise.
(tdesc_i386_avx_mpx_avx512_pku_linux): Likewise.
* x86-linux-nat.c (x86_linux_read_description): Call
i386_linux_read_description.

8 years agoAdjust the order of 32bit-linux.xml and 32bit-sse.xml in i386/i386-linux.xml
Yao Qi [Tue, 9 May 2017 09:22:52 +0000 (10:22 +0100)] 
Adjust the order of 32bit-linux.xml and 32bit-sse.xml in i386/i386-linux.xml

Exchange the order of 32bit-linux.xml and 32bit-sse.xml in
i386/i386-linux.xml, to align with other i386 linux .xml files.

gdb:

2017-04-27  Yao Qi  <yao.qi@linaro.org>

* features/i386/i386-linux.xml: Exchange the order of including
32bit-linux.xml and 32bit-sse.xml.
* features/i386/i386-linux.c: Regenerated.

8 years agoClass-fy tdesc_reg tdesc_type and tdesc_feature
Yao Qi [Tue, 20 Jun 2017 10:29:17 +0000 (11:29 +0100)] 
Class-fy tdesc_reg tdesc_type and tdesc_feature

This patch class-fies them, adding ctor, dtor, and deleting
copy ctor and assignment operator.

gdb:

2017-06-20  Yao Qi  <yao.qi@linaro.org>

* target-descriptions.c (tdesc_reg): Add ctor, dtor.
Delete copy ctor and assignment operator.
(tdesc_type): Likewise.
(tdesc_feature): Likewise.
(tdesc_free_reg): Remove.
(tdesc_create_reg): Use new.
(tdesc_free_type): Remove.
(tdesc_create_vector): Use new.
(tdesc_create_union): Likewise.
(tdesc_create_flags): Likewise.
(tdesc_create_enum): Likewise.
(tdesc_free_feature): Delete.
(free_target_description): Use delete.

8 years ago[GOLD] Avoid duplicate PLT stub symbols on ppc32
James Clarke [Tue, 20 Jun 2017 08:31:52 +0000 (18:01 +0930)] 
[GOLD] Avoid duplicate PLT stub symbols on ppc32

If two objects are compiled with -fPIC or -fPIE and call the same
function, two different PLT entries are created, one for each object,
but the same stub symbol name is used for both.

* powerpc.cc (Stub_table::define_stub_syms): Always include object's
uniq_ value.

8 years agoCheck the DYNAMIC bit for input shared objects
H.J. Lu [Tue, 20 Jun 2017 03:30:20 +0000 (20:30 -0700)] 
Check the DYNAMIC bit for input shared objects

Since the BFD section count may not be cleared for shared objects during
linking, we should check the DYNAMIC bit for input shared objects.

bfd/

PR ld/21626
* elf-properties.c (_bfd_elf_link_setup_gnu_properties): Check
the DYNAMIC bit instead of bfd_count_sections.

ld/

PR ld/21626
* testsuite/ld-i386/i386.exp: Run ld/21626 tests.
* testsuite/ld-x86-64/x86-64.exp: Likewise.

8 years agoAutomatic date update in version.in
GDB Administrator [Tue, 20 Jun 2017 00:00:38 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agoDon't throw an error in 'info registers' for unavailable MIPS registers.
John Baldwin [Mon, 19 Jun 2017 21:30:24 +0000 (14:30 -0700)] 
Don't throw an error in 'info registers' for unavailable MIPS registers.

'info registers' for MIPS throws an error and when it first encounters
an unavailable register.  This does not match other architectures
which annotate unavailable registers and continue to print out the
values of subsequent registers.  Replace the error by displaying an
aligned "<unavailable>".  This string is truncated to "<unavl>" when
displaying a 32-bit register.

gdb/ChangeLog:

* mips-tdep.c (print_gp_register_row): Don't error for unavailable
registers.

8 years agoUpdate GDB test case for new lnia extended mnemonic.
Peter Bergner [Mon, 19 Jun 2017 18:04:13 +0000 (13:04 -0500)] 
Update GDB test case for new lnia extended mnemonic.

When I added the new lnia extended mnemonic for addpcis, I updated the
assembler/disassembler test cases, but overlooked the GDB test cases.
This patch fixes that oversight and associated test case failure.

* gdb.arch/powerpc-power9.exp: Update test case for new lnia
extended mnemonic.
* gdb.arch/powerpc-power9.s: Likewise.

8 years agoFix address violation when attempting to display disassembled data.
Nick Clifton [Mon, 19 Jun 2017 14:57:19 +0000 (15:57 +0100)] 
Fix address violation when attempting to display disassembled data.

PR binutils/21619
* objdump.c (disassemble_bytes): Check that there is sufficient
data available before attempting to display it.

8 years agoFix address violations when reading corrupt VMS records.
Nick Clifton [Mon, 19 Jun 2017 13:52:36 +0000 (14:52 +0100)] 
Fix address violations when reading corrupt VMS records.

PR binutils/21618
* vms-alpha.c (evax_bfd_print_emh): Check for insufficient record
length.
(evax_bfd_print_eeom): Likewise.
(evax_bfd_print_egsd): Check for an overlarge record length.
(evax_bfd_print_etir): Likewise.

8 years agoPrevent address violation when attempting to disassemble a corrupt score binary.
Nick Clifton [Mon, 19 Jun 2017 13:15:57 +0000 (14:15 +0100)] 
Prevent address violation when attempting to disassemble a corrupt score binary.

PR binutils/21614
* score-dis.c (score_opcodes): Add sentinel.

8 years agoFix access violation when parsing a corrupt IEEE binary.
Nick Clifton [Mon, 19 Jun 2017 13:06:53 +0000 (14:06 +0100)] 
Fix access violation when parsing a corrupt IEEE binary.

PR binutils/21612
* libieee.h (struct common_header_type): Add end_p field.
* ieee.c (this_byte_and_next): Do not advance input_p beyond
end_p.
(read_id): Check for a length that exceeds the remaining bytes in
the input buffer.
(ieee_seek): Initialise end_p.
(ieee_archive_p): Likewise.
(ieee_object_p): Likewise.

8 years agoFix access violation disassembling a corrupt VMS binary.
Nick Clifton [Mon, 19 Jun 2017 12:01:57 +0000 (13:01 +0100)] 
Fix access violation disassembling a corrupt VMS binary.

PR binutils/21611
* vms-alpha.c (_bfd_vms_slurp_eihs): Check for invalid offset
before reading the EIHS structure entries.

8 years ago.gdb_index writer: close the file before unlinking it
Pedro Alves [Mon, 19 Jun 2017 11:46:47 +0000 (12:46 +0100)] 
.gdb_index writer: close the file before unlinking it

We should close the file before unlinking because on MS-Windows one
cannot delete a file that is still open.

I considered making 'gdb::unlinker::unlinker(const char *)'
'noexcept(true)' and then adding
  static_assert (noexcept (gdb::unlinker (filename.c_str ())), "");

but that doesn't really work because gdb::unlinker has a gdb_assert,
which can throw a QUIT if/when the assertion fails.  'noexcept(true)'
would cause GDB to abruptly terminate if/when the assertion fails.

gdb/ChangeLog:
2017-06-19  Pedro Alves  <palves@redhat.com>

* dwarf2read.c (write_psymtabs_to_index): Construct file_closer
after gdb::unlinker.

8 years agoFix access violation when disassembling a corrupt VMS binary.
Nick Clifton [Mon, 19 Jun 2017 11:31:07 +0000 (12:31 +0100)] 
Fix access violation when disassembling a corrupt VMS binary.

PR 21615
* vms-alpha.c (_bfd_vms_slurp_egsd): Use unsigned int for
gsd_size.  Check that there are enough bytes remaining to read the
type and size of the next egsd.  Check that the size of the egsd
does not exceed the size of the record.

8 years agoCorrect target_underscore for cris
Alan Modra [Mon, 19 Jun 2017 06:34:16 +0000 (16:04 +0930)] 
Correct target_underscore for cris

* config.bfd: Correct targ_underscore for cris.

8 years agoUse getenv instead of gdb_environ on mi-cmd-env.c
Sergio Durigan Junior [Fri, 16 Jun 2017 22:10:27 +0000 (18:10 -0400)] 
Use getenv instead of gdb_environ on mi-cmd-env.c

This is a spinoff of
<https://sourceware.org/ml/gdb-patches/2017-06/msg00437.html>.
mi-cmd-env.c is using the whole gdb_environ machinery in order to
access just one variable, which can be easily replaced by a simple
call to getenv.  This patch does that, and doesn't cause regressions.

gdb/ChangeLog:
2017-06-18  Sergio Durigan Junior  <sergiodj@redhat.com>

* mi/mi-cm-env.c (_initialize_mi_cmd_env): Use getenv instead of
gdb_environ to access an environment variable.

8 years agoAutomatic date update in version.in
GDB Administrator [Mon, 19 Jun 2017 00:00:23 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agonat/linux-ptrace.c: add missing gdb_byte* cast
Thomas Petazzoni [Sun, 18 Jun 2017 21:28:56 +0000 (23:28 +0200)] 
nat/linux-ptrace.c: add missing gdb_byte* cast

On noMMU platforms, the following code gets compiled:

  child_stack = xmalloc (STACK_SIZE * 4);

Where child_stack is a gdb_byte*, and xmalloc() returns a void*. While
the lack of cast is valid in C, it is not in C++, causing the
following build failure:

../nat/linux-ptrace.c: In function 'int linux_fork_to_function(gdb_byte*, int (*)(void*))':
../nat/linux-ptrace.c:273:29: error: invalid conversion from 'void*' to 'gdb_byte* {aka unsigned char*}' [-fpermissive]
       child_stack = xmalloc (STACK_SIZE * 4);

Therefore, this commit adds the appropriate cast.

gdb/ChangeLog:

* nat/linux-ptrace.c (linux_fork_to_function): Add cast to
gdb_byte*.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
8 years agois_underscore_target for ld-elf tests
Alan Modra [Sat, 17 Jun 2017 23:49:34 +0000 (09:19 +0930)] 
is_underscore_target for ld-elf tests

and correct targ_underscore in config.bfd

bfd/
* config.bfd: Correct targ_underscore for epiphany, ip2k,
m32c, mn10200, pru, rl78, rx, crisv32 and v850.
ld/
* testsuite/lib/ld-lib.exp (is_underscore_target): New.
* testsuite/ld-elf/elf.exp (ASFLAGS): Define UNDERSCORE.
* testsuite/ld-elf/pr21562a.s: If UNDERSCORE defined,
reference sym with prefix.
* testsuite/ld-elf/pr21562b.s: Likewise.
* testsuite/ld-elf/sizeof.s: Likewise.
* testsuite/ld-elf/startof.s: Likewise.
* testsuite/ld-elf/pr14156a.d: Adjust for extra symbols.
* testsuite/ld-elf/pr21562a.d: Remove underscore target from
xfails, and match prefixed symbol.
* testsuite/ld-elf/pr21562b.d: Likewise.
* testsuite/ld-elf/pr21562c.d: Likewise.
* testsuite/ld-elf/pr21562d.d: Likewise.
* testsuite/ld-elf/pr21562e.d: Likewise.
* testsuite/ld-elf/pr21562f.d: Likewise.
* testsuite/ld-elf/pr21562g.d: Likewise.
* testsuite/ld-elf/pr21562h.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/sizeofa.d: Likewise.
* testsuite/ld-elf/sizeofb.d: Likewise.
* testsuite/ld-elf/sizeofc.d: Likewise.
* testsuite/ld-elf/startofa.d: Likewise.
* testsuite/ld-elf/startofb.d: Likewise.
* testsuite/ld-elf/startofc.d: Likewise.

8 years agoAutomatic date update in version.in
GDB Administrator [Sun, 18 Jun 2017 00:00:37 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agoAdd ATTRIBUTE_PRINTF to trace_start_error
Simon Marchi [Sat, 17 Jun 2017 21:19:25 +0000 (23:19 +0200)] 
Add ATTRIBUTE_PRINTF to trace_start_error

clang complains that the fmt passed to vwarning in trace_start_error is
not a literal.  This looks like a fair warning, which can be removed by
adding ATTRIBUTE_PRINTF to the declaration of trace_start_error.

gdb/ChangeLog:

* nat/fork-inferior.h (trace_start_error): Add ATTRIBUTE_PRINTF.

8 years agolinux-low: Remove usage of "register" keyword
Simon Marchi [Sat, 17 Jun 2017 21:19:08 +0000 (23:19 +0200)] 
linux-low: Remove usage of "register" keyword

AFAIK, the register keyword is not relevant today, and clang complains
about it:

/home/emaisin/src/binutils-gdb/gdb/gdbserver/linux-low.c:5873:3: error: 'register' storage class specifier is deprecated and incompatible with C++1z
      [-Werror,-Wdeprecated-register]
  register PTRACE_XFER_TYPE *buffer;
  ^~~~~~~~~

I think we can safely remove it.

gdb/gdbserver/ChangeLog:

* linux-low.c (linux_read_memory, linux_write_memory): Remove
usage of "register" keyword.

8 years agogdb: Add -Wno-mismatched-tags
Simon Marchi [Sat, 17 Jun 2017 21:18:49 +0000 (23:18 +0200)] 
gdb: Add -Wno-mismatched-tags

clang complains that for some types, we use both the class and struct
keywords in different places.  It's not really a problem, so I think we
can safely turn this warning off.

gdb/ChangeLog:

* configure: Re-generate.
* warning.m4 (build_warnings): Add -Wno-mismatched-tags.

gdb/gdbserver/ChangeLog:

* configure: Re-generate.

8 years agogdb: Use -Werror when checking for (un)supported warning flags
Simon Marchi [Sat, 17 Jun 2017 21:18:20 +0000 (23:18 +0200)] 
gdb: Use -Werror when checking for (un)supported warning flags

In warning.m4, we pass all the warning flags one by one to the compiler
to test if they are supported by this particular compiler.  If the
compiler exits with an error, we conclude that this warning flag is not
supported and exclude it.  This allows us to use warning flags without
having to worry about which versions of which compilers support each
flag.

clang, by default, only emits a warning if an unknown flag is passed:

  warning: unknown warning option '-Wfoo' [-Wunknown-warning-option]

The result is that we think that all the warning flags we use are
supported by clang (they are not), and the compilation fails later when
building with -Werror, since the aforementioned warning becomes an
error.  The fix is to also pass -Werror when probing for supported
flags, then we'll correctly get an error when using an unknown warning,
and we'll exclude it:

  error: unknown warning option '-Wfoo' [-Werror,-Wunknown-warning-option]

I am not sure why there is a change in a random comment in
gdbserver/configure, but I suppose it's a leftfover from a previous
patch, so I included it.

gdb/ChangeLog:

* configure: Re-generate.
* warning.m4: Pass -Werror to compiler when checking for
supported warning flags.

gdb/gdbserver/ChangeLog:

* configure: Re-generate.

8 years agogdb: Pass -x c++ to the compiler
Simon Marchi [Sat, 17 Jun 2017 21:17:00 +0000 (23:17 +0200)] 
gdb: Pass -x c++ to the compiler

Because we are compiling .c files containing C++ code, clang++ complains
with:

  clang: error: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated

If renaming all the source files to .cpp is out of the question, an
alternative is to pass "-x c++" to convince the compiler that we are
really compiling C++.  It works fine with GCC too.

gdb/ChangeLog:

* Makefile.in (COMPILE.pre): Add "-x c++".

gdb/gdbserver/ChangeLog:

* Makefile.in (COMPILE.pre): Add "-x c++".

8 years agoAutomatic date update in version.in
GDB Administrator [Sat, 17 Jun 2017 00:00:41 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agoextract/store integer function template
Yao Qi [Fri, 16 Jun 2017 14:38:42 +0000 (15:38 +0100)] 
extract/store integer function template

This patch converts functions extract_{unsigned,signed}_integer
to a function template extract_integer, which has two instantiations.  It
also does the similar changes to store__{unsigned,signed}_integer,
regcache::raw_read_{unsigned,signed}, regcache::raw_write_{unsigned,signed},
regcache::cooked_read_{unsigned,signed},
regcache::cooked_write_{unsigned,signed}.

This patch was posted here
https://sourceware.org/ml/gdb-patches/2017-05/msg00492.html but the
problem was fixed in a different way.  However, I think the patch is still
useful to shorten the code.

gdb:

2017-06-16  Alan Hayward  <alan.hayward@arm.com>
    Pedro Alves  <palves@redhat.com>
    Yao Qi  <yao.qi@linaro.org>

* defs.h (RequireLongest): New.
(extract_integer): Declare function template.
(extract_signed_integer): Remove the declaration, but define it
static inline.
(extract_unsigned_integer): Likewise.
(store_integer): Declare function template.
(store_signed_integer): Remove the declaration, but define it
static inline.
(store_unsigned_integer): Likewise.
* findvar.c (extract_integer): New function template.
(extract_signed_integer): Remove.
(extract_unsigned_integer): Remove.
(extract_integer<LONGEST>, extract_integer<ULONGEST>): Explicit
instantiations.
(store_integer): New function template.
(store_signed_integer): Remove.
(store_unsigned_integer): Remove.
(store_integer): Explicit instantiations.
* regcache.c (regcache_raw_read_signed): Update.
(regcache::raw_read): New function.
(regcache::raw_read_signed): Remove.
(regcache::raw_read_unsigned): Remove.
(regcache_raw_read_unsigned): Update.
(regcache_raw_write_unsigned): Update.
(regcache::raw_write_signed): Remove.
(regcache::raw_write): New function.
(regcache_cooked_read_signed): Update.
(regcache::raw_write_unsigned): Remove.
(regcache::cooked_read_signed): Remove.
(regcache_cooked_read_unsigned): Update.
(regcache::cooked_read_unsigned): Remove.
(regcache_cooked_write_signed): Update.
(regcache_cooked_write_unsigned): Update.
* regcache.h (regcache) <raw_read_signed>: Remove.
<raw_write_signed, raw_read_unsigned, raw_write_unsigned>: Remove.
<raw_read, raw_write>: New.
<cooked_read_signed, cooked_write_signed>: Remove.
<cooked_write_unsigned, cooked_read_unsigned>: Remove.
<cooked_read, cooked_write>: New.
* sh64-tdep.c (sh64_pseudo_register_read): Update.
(sh64_pseudo_register_write): Update.

8 years agoRegen rx-decode.c
Alan Modra [Fri, 16 Jun 2017 12:20:43 +0000 (21:50 +0930)] 
Regen rx-decode.c

opcodes/
* rx-decode.c: Regenerate.

8 years agoFixing linking configure generated tests of ifunc support.
Nick Clifton [Fri, 16 Jun 2017 14:16:19 +0000 (15:16 +0100)] 
Fixing linking configure generated tests of ifunc support.

* elflink.c (bfd_elf_size_dynsym_hash_dynstr): Do not fail if the
bucketlist is empty because there are no symbols to add to the
list.

8 years agoRewrite __start and __stop symbol handling
Alan Modra [Fri, 16 Jun 2017 10:11:41 +0000 (19:41 +0930)] 
Rewrite __start and __stop symbol handling

This arranges for __start and __stop symbols to be defined before
garbage collection, for all target formats.  That should allow the
COFF and PE --gc-sections to keep a singleton orphan input section,
a feature lost by 2017-06-13 commit cbd0eecf26.  The fancier ELF
treatment of keeping all input sections associated with a __start or
__stop symbol, from 2015-10-23 commit 1cce69b9dc, is retained.

.startof. and .sizeof. symbols are deliberately not defined before
garbage collection, so these won't affect garbage collection of
sections.

The patch also ensures __start, __stop, .startof. and .sizeof. symbols
are defined before target size_dynamic_sections is called, albeit
with a preliminary value, so that target code doesn't need to cope
with a symbol changing from undefined at size_dynamic_sections to
defined at relocate_section.

Also, a number of problems with the testcases have been fixed.

PR ld/20022
PR ld/21557
PR ld/21562
PR ld/21571
include/
* bfdlink.h (struct bfd_link_hash_entry): Delete undef.section.
bfd/
* targets.c (struct bfd_target): Add _bfd_define_start_stop.
(BFD_JUMP_TABLE_LINK): Likewise.
* elf-bfd.h (bfd_elf_define_start_stop): Declare.
* elflink.c (_bfd_elf_gc_mark_rsec): Update comment.
(bfd_elf_define_start_stop): New function.
* linker.c (bfd_generic_define_start_stop): New function.
* coff64-rs6000.c (rs6000_xcoff64_vec, rs6000_xcoff64_aix_vec): Init
new field.
* aout-adobe.c (aout_32_bfd_define_start_stop): Define.
* aout-target.h (MY_bfd_define_start_stop): Define.
* aout-tic30.c (MY_bfd_define_start_stop): Define.
* binary.c (binary_bfd_define_start_stop): Define.
* bout.c (b_out_bfd_define_start_stop): Define.
* coff-alpha.c (_bfd_ecoff_bfd_define_start_stop): Define.
* coff-mips.c (_bfd_ecoff_bfd_define_start_stop): Define.
* coff-rs6000.c (_bfd_xcoff_bfd_define_start_stop): Define.
* coffcode.h (coff_bfd_define_start_stop): Define.
* elfxx-target.h (bfd_elfNN_bfd_define_start_stop): Define.
* i386msdos.c (msdos_bfd_define_start_stop): Define.
* i386os9k.c (os9k_bfd_define_start_stop): Define.
* ieee.c (ieee_bfd_define_start_stop): Define.
* ihex.c (ihex_bfd_define_start_stop): Define.
* libbfd-in.h (_bfd_nolink_bfd_define_start_stop): Define.
* mach-o-target.c (bfd_mach_o_bfd_define_start_stop): Define.
* mmo.c (mmo_bfd_define_start_stop): Define.
* nlm-target.h (nlm_bfd_define_start_stop): Define.
* oasys.c (oasys_bfd_define_start_stop): Define.
* pef.c (bfd_pef_bfd_define_start_stop): Define.
* plugin.c (bfd_plugin_bfd_define_start_stop): Define.
* ppcboot.c (ppcboot_bfd_define_start_stop): Define.
* som.c (som_bfd_define_start_stop): Define.
* srec.c (srec_bfd_define_start_stop): Define.
* tekhex.c (tekhex_bfd_define_start_stop): Define.
* versados.c (versados_bfd_define_start_stop): Define.
* vms-alpha.c (vms_bfd_define_start_stop): Define.
(alpha_vms_bfd_define_start_stop): Define.
* xsym.c (bfd_sym_bfd_define_start_stop): Define.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
ld/
* emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Don't set
__start/__stop syms here.
* ldlang.c (lang_set_startof): Delete.
(start_stop_syms, start_stop_count, start_stop_alloc): New vars.
(lang_define_start_stop, lang_init_start_stop, foreach_start_stop,
undef_start_stop, lang_undef_start_stop, lang_init_startof_sizeof,
set_start_stop, lang_finalize_start_stop): New functions.
(lang_process): Call _start_stop functions.
* testsuite/ld-elf/pr21562a.d: Use xfail rather than notarget.
Correct typos and list of xfail targets.
* testsuite/ld-elf/pr21562b.d: Likewise.
* testsuite/ld-elf/pr21562c.d: Likewise.
* testsuite/ld-elf/pr21562d.d: Likewise.
* testsuite/ld-elf/pr21562e.d: Likewise.
* testsuite/ld-elf/pr21562f.d: Likewise.
* testsuite/ld-elf/pr21562g.d: Likewise.
* testsuite/ld-elf/pr21562h.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/sizeofa.d: Likewise.  Adjust to pass for generic ELF.
* testsuite/ld-elf/sizeofb.d: Likewise.
* testsuite/ld-elf/startofa.d: Likewise.
* testsuite/ld-elf/startofb.d: Likewise.

8 years ago[AArch64] Use SYMBOL_REFERENCES_LOCAL in one symbol check
Jiong Wang [Fri, 16 Jun 2017 13:20:38 +0000 (14:20 +0100)] 
[AArch64] Use SYMBOL_REFERENCES_LOCAL in one symbol check

For some pc-relative relocations we want to allow them under PIC mode while
a normal global symbol defined in the same dynamic object can still bind
externally through copy relocation.  So, we should not allow pc-relative
relocation against such symbol.

SYMBOL_REFERENCES_LOCAL should be used and is more accurate than the original
individual checks.

bfd/
* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Use
SYMBOL_REFERENCES_LOCAL.
ld/
* testsuite/ld-aarch64/aarch64-elf.exp: Update test name
* testsuite/ld-aarch64/pcrel.s: Add new testcases.
* testsuite/ld-aarch64/pcrel_pic_undefined.d: Update the expected
warnings.
* testsuite/ld-aarch64/pcrel_pic_defined_local.d: Rename ...
* testsuite/ld-aarch64/pcrel_pic_defined.d: ... to this.
Update expected warnings.

8 years agoarc: Select CPU model properly before disassembling
Anton Kolesov [Fri, 10 Feb 2017 11:11:55 +0000 (14:11 +0300)] 
arc: Select CPU model properly before disassembling

Enforce CPU model for disassembler via its options, if it was specified in XML
target description, otherwise use default method of determining CPU implemented
in disassembler - scanning ELF private header.  The latter requires
disassemble_info->section to be properly initialized.  To make sure that
info->section is set in all cases this patch partially reverts [1] for ARC: it
reinstates arc_delayed_print_insn as a "print_insn" function for ARC, but
now this function only sets disassemble_info->section and then calls
default_print_insn to do the rest of the job.

Support for CPU in disassembler options for ARC has been added in [2].

[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=39503f82427e22ed8e04d986ccdc8562091ec62e
[2] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=10045478d984f9924cb945423388ba25b7dd3ffe

gdb/ChangeLog:

yyyy-mm-dd  Anton Kolesov  <anton.kolesov@synopsys.com>

* arc-tdep.c (arc_disassembler_options): New variable.
(arc_gdbarch_init): Set and use it. Use arc_delayed_print_insn instead
of default_print_insn.
(arc_delayed_print_insn): Set info->section when needed,
use default_print_insn to retrieve a disassembler.

8 years ago2017-06-15 Eric Christopher <echristo@gmail.com>
Eric Christopher [Fri, 16 Jun 2017 01:46:17 +0000 (18:46 -0700)] 
2017-06-15  Eric Christopher  <echristo@gmail.com>

        * aarch64.cc: Fix a few typos and grammar-os.

8 years agoAutomatic date update in version.in
GDB Administrator [Fri, 16 Jun 2017 00:00:27 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agoCorrect "ld --help" to display "-z stack-size=SIZE"
H.J. Lu [Thu, 15 Jun 2017 19:30:53 +0000 (12:30 -0700)] 
Correct "ld --help" to display "-z stack-size=SIZE"

ELF Linker command line option to set stack size is "-z stack-size=SIZE",
not "-z stacksize=SIZE".

* exsup.c (elf_shlib_list_options): Display "-z stack-size=SIZE"
instead of "-z stacksize=SIZE".

8 years ago[AArch64] Allow COPY relocation elimination
Jiong Wang [Thu, 15 Jun 2017 15:51:01 +0000 (16:51 +0100)] 
[AArch64] Allow COPY relocation elimination

  As discussed at the PR, this patch tries to avoid COPY relocation generation
and propagate the original relocation into runtime if it was relocating on
writable section.  The ELIMINATE_COPY_RELOCS has been set to true and it's
underlying infrastructure has been improved so that the COPY reloc elimination
at least working on absoluate relocations (ABS64) on AArch64.

  BFD linker copy relocation elimination framwork requires the backend to always
allocate dynrelocs for all those relocation types that are possible to introduce
copy relocations.  This is for adjust_dynamic_symbol hook to be able to get all
symbol reference information.  Should one symbol is referenced by more than one
relocations, if there is any of them needs copy relocation then linker should
generate it.

bfd/
PR ld/21532
* elfnn-aarch64.c (ELIMINATE_COPY_RELOCS): Set to 1.
(elfNN_aarch64_final_link_relocate): Also propagate relocations to
runtime for if there needs copy relocation elimination.
(need_copy_relocation_p): New function.  Return true for symbol with
pc-relative references and if it's against read-only sections.
(elfNN_aarch64_adjust_dynamic_symbol): Use need_copy_relocation_p.
(elfNN_aarch64_check_relocs): Allocate dynrelocs for relocation types
that are related with accessing external objects.
(elfNN_aarch64_gc_sweep_hook): Sync the relocation types with the change
in elfNN_aarch64_check_relocs.

ld/
* testsuite/ld-aarch64/copy-reloc-exe-2.s: New test source file.
* testsuite/ld-aarch64/copy-reloc-2.d: New test.
* testsuite/ld-aarch64/copy-reloc-exe-eliminate.s: New test source file.
* testsuite/ld-aarch64/copy-reloc-eliminate.d: New test.
* testsuite/ld-aarch64/copy-reloc-so.s: Define new global objects.
* testsuite/ld-aarch64/aarch64-elf.exp: Run new tests.

8 years agoi386-dis: Add 2 tests with invalid bnd register
H.J. Lu [Thu, 15 Jun 2017 15:21:48 +0000 (08:21 -0700)] 
i386-dis: Add 2 tests with invalid bnd register

PR binutils/21594
* testsuite/gas/i386/mpx.s: Add 2 tests with invalid bnd
register.
* testsuite/gas/i386/x86-64-mpx.s: Likewise.
* testsuite/gas/i386/mpx.d: Updated.
* testsuite/gas/i386/x86-64-mpx.d: Likewise.

8 years agoi386-dis: Check valid bnd register
H.J. Lu [Thu, 15 Jun 2017 13:40:17 +0000 (06:40 -0700)] 
i386-dis: Check valid bnd register

Since there are only 4 bnd registers, return "(bad)" for register
number > 3.

PR binutils/21594
* i386-dis.c (OP_E_register): Check valid bnd register.
(OP_G): Likewise.

8 years agoPrevent address violation problem when disassembling corrupt aarch64 binary.
Nick Clifton [Thu, 15 Jun 2017 12:26:54 +0000 (13:26 +0100)] 
Prevent address violation problem when disassembling corrupt aarch64 binary.

PR binutils/21595
* aarch64-dis.c (aarch64_ext_ldst_reglist): Check for an out of
range value.

8 years agoFix address violation parsing a corrupt ieee binary.
Nick Clifton [Thu, 15 Jun 2017 12:08:47 +0000 (13:08 +0100)] 
Fix address violation parsing a corrupt ieee binary.

PR binutils/21581
(ieee_archive_p): Use a static buffer to avoid compiler bugs.

8 years agoAvoid a possible compiler bug by using a static buffer instead of a stack local buffer.
Nick Clifton [Thu, 15 Jun 2017 11:44:23 +0000 (12:44 +0100)] 
Avoid a possible compiler bug by using a static buffer instead of a stack local buffer.

PR binutils/21582
* ieee.c (ieee_object_p): Use a static buffer to avoid compiler
bugs.

8 years agoFix address violation when disassembling a corrupt RL78 binary.
Nick Clifton [Thu, 15 Jun 2017 11:37:01 +0000 (12:37 +0100)] 
Fix address violation when disassembling a corrupt RL78 binary.

PR binutils/21588
* rl78-decode.opc (OP_BUF_LEN): Define.
(GETBYTE): Check for the index exceeding OP_BUF_LEN.
(rl78_decode_opcode): Use OP_BUF_LEN as the length of the op_buf
array.
* rl78-decode.c: Regenerate.

8 years agoHandle EITR records in VMS Alpha binaries with overlarge command length parameters.
Nick Clifton [Thu, 15 Jun 2017 11:08:57 +0000 (12:08 +0100)] 
Handle EITR records in VMS Alpha binaries with overlarge command length parameters.

PR binutils/21579
* vms-alpha.c (_bfd_vms_slurp_etir): Extend check of cmd_length.

8 years agoPrevent invalid array accesses when disassembling a corrupt bfin binary.
Nick Clifton [Thu, 15 Jun 2017 10:52:02 +0000 (11:52 +0100)] 
Prevent invalid array accesses when disassembling a corrupt bfin binary.

PR binutils/21586
* bfin-dis.c (gregs): Clip index to prevent overflow.
(regs): Likewise.
(regs_lo): Likewise.
(regs_hi): Likewise.

8 years ago[GOLD] Don't install branch-to-stub for TLS relaxed ERRATUM 843419 sequences on AArch64
Jiong Wang [Thu, 15 Jun 2017 09:35:28 +0000 (10:35 +0100)] 
[GOLD] Don't install branch-to-stub for TLS relaxed ERRATUM 843419 sequences on AArch64

TLS relaxation may change erratum 843419 sequences that those offending ADRP
instructions actually transformed into other instructions in which case there
is erratum 843419 risk anymore that we should avoid installing unnecessary
branch-to-stub.

gold/
        * aarch64.cc (Insn_utilities::is_mrs_tpidr_el0): New method.
        (AArch64_relobj<size, big_endian>::try_fix_erratum_843419_optimized):
        Return ture for some TLS relaxed sequences.

8 years agoPR gdb/21574: Mention $SHELL and startup-with-shell on "help run"
Sergio Durigan Junior [Wed, 14 Jun 2017 20:45:20 +0000 (16:45 -0400)] 
PR gdb/21574: Mention $SHELL and startup-with-shell on "help run"

This simple patch updates the documentation of "help run" in order to
mention that the shell used to start the inferior comes from the
$SHELL environment variable.  It also mentions that this behaviour can
be disabled by using the "set startup-with-shell off" command.

gdb/ChangeLog:
2017-06-14  Sergio Durigan Junior  <sergiodj@redhat.com>

PR gdb/21574
* infcmd.c (_initialize_infcmd): Expand "help run" documentation
to mention $SHELL and startup-with-shell.

8 years agoAutomatic date update in version.in
GDB Administrator [Thu, 15 Jun 2017 00:00:48 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agoxtensa: don't expect XCHAL_* macros to be constant
Max Filippov [Wed, 17 May 2017 09:09:14 +0000 (02:09 -0700)] 
xtensa: don't expect XCHAL_* macros to be constant

Get rid of the assumption that XCHAL_* macros are preprocessor
constants: don't use them in preprocessor conditionals or in static
variable initializers.

2017-06-14  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
* elf32-xtensa.c (elf_xtensa_be_plt_entry,
elf_xtensa_le_plt_entry): Add dimension for the ABI to arrays,
keep both windowed and call0 ABI PLT definitions.
(elf_xtensa_create_plt_entry): Use selected ABI to choose upper
elf_xtensa_*_plt_entry endex.
(ELF_MAXPAGESIZE): Fix at minimal supported MMU page size.

gas/
* config/tc-xtensa.c (density_supported, xtensa_fetch_width,
absolute_literals_supported): Leave definitions uninitialized.
(directive_state): Leave entries for directive_density and
directive_absolute_literals initialized to false.
(xg_init_global_config, xtensa_init): New functions.
* config/tc-xtensa.h (TARGET_BYTES_BIG_ENDIAN): Define as 0.
(HOST_SPECIAL_INIT): New definition.
(xtensa_init): New declaration.

8 years agoMaxim Grigoriev stepping down as Xtensa maintainer
Max Filippov [Tue, 13 Jun 2017 17:26:55 +0000 (10:26 -0700)] 
Maxim Grigoriev stepping down as Xtensa maintainer

gdb/
2017-06-14  Max Filippov  <jcmvbkbc@gmail.com>

* MAINTAINERS: Move Maxim Grigoriev to the Past Maintainers.

8 years agoFix seg-fault when trying to disassemble a corrupt score binary.
Nick Clifton [Wed, 14 Jun 2017 16:10:28 +0000 (17:10 +0100)] 
Fix seg-fault when trying to disassemble a corrupt score binary.

PR binutils/21576
* score7-dis.c (score_opcodes): Add sentinel.

8 years agoFix address violation bug when disassembling a corrupt SH binary.
Nick Clifton [Wed, 14 Jun 2017 16:01:54 +0000 (17:01 +0100)] 
Fix address violation bug when disassembling a corrupt SH binary.

PR binutils/21578
* elf32-sh.c (sh_elf_set_mach_from_flags): Fix check for invalid
flag value.

8 years agoFix address violation when disassembling a corrupt binary.
Nick Clifton [Wed, 14 Jun 2017 15:50:03 +0000 (16:50 +0100)] 
Fix address violation when disassembling a corrupt binary.

PR binutils/21580
binutils * objdump.c (disassemble_bytes): Check for buffer overrun when
printing out rae insns.

ld * testsuite/ld-nds32/diff.d: Adjust expected output.

8 years agoDon't use print_insn_XXX in GDB
Yao Qi [Wed, 14 Jun 2017 15:28:30 +0000 (16:28 +0100)] 
Don't use print_insn_XXX in GDB

This is a follow-up to

  [PATCH 0/6] Unify the disassembler selection in gdb and objdump
  https://sourceware.org/ml/binutils/2017-05/msg00192.html

that is, opcodes is able to select the right disassembler, so gdb
doesn't have to select them.  Instead, gdb can just use
default_print_insn.  As a result, these print_insn_XXX are not used
out of opcodes, so this patch also moves their declarations from
include/dis-asm.h to opcodes/disassemble.h.  With this change,
GDB doesn't use any print_insn_XXX directly any more.

gdb:

2017-06-14  Yao Qi  <yao.qi@linaro.org>

* aarch64-tdep.c (aarch64_gdb_print_insn): Call
default_print_insn instead of print_insn_aarch64.
* arm-tdep.c (gdb_print_insn_arm): Call
default_print_insn instead of print_insn_big_arm
and print_insn_little_arm.
* i386-tdep.c (i386_print_insn): Call default_print_insn
instead of print_insn_i386.
* ia64-tdep.c (ia64_print_insn): Call
default_print_insn instead of print_insn_ia64.
* mips-tdep.c (gdb_print_insn_mips): Call
default_print_insn instead of print_insn_big_mips
and print_insn_little_mips.
* spu-tdep.c (gdb_print_insn_spu): Call default_print_insn
instead of print_insn_spu.

include:

2017-06-14  Yao Qi  <yao.qi@linaro.org>

* dis-asm.h (print_insn_aarch64): Move it to opcodes/disassemble.h.
(print_insn_big_arm, print_insn_big_mips): Likewise.
(print_insn_i386, print_insn_ia64): Likewise.
(print_insn_little_arm, print_insn_little_mips): Likewise.
(print_insn_spu): Likewise.

opcodes:

2017-06-14  Yao Qi  <yao.qi@linaro.org>

* aarch64-dis.c: Include disassemble.h instead of dis-asm.h.
* arm-dis.c: Likewise.
* ia64-dis.c: Likewise.
* mips-dis.c: Likewise.
* spu-dis.c: Likewise.
* disassemble.h (print_insn_aarch64): New declaration, moved from
include/dis-asm.h.
(print_insn_big_arm, print_insn_big_mips): Likewise.
(print_insn_i386, print_insn_ia64): Likewise.
(print_insn_little_arm, print_insn_little_mips): Likewise.

8 years agoxfail pr20022.d on targets without dynamic relocs in .text
H.J. Lu [Wed, 14 Jun 2017 13:11:48 +0000 (06:11 -0700)] 
xfail pr20022.d on targets without dynamic relocs in .text

ld-gc/pr20022.d requires support for dynamic relocations in .text
section.

PR ld/20022
* testsuite/ld-gc/pr20022.d: Skip on targets without dynamic
relocations in .text section.

8 years agoSkip PR ld/21562 tests on targets with leading char or without --gc-sections
H.J. Lu [Wed, 14 Jun 2017 11:36:17 +0000 (04:36 -0700)] 
Skip PR ld/21562 tests on targets with leading char or without --gc-sections

Symbol lookup in linker will always fail on targets with leading char
in symbol name since __start_SECNAME and __stop_SECNAME in C may be
___start_SECNAME and ___stop_SECNAME in assembly.  Also tests with
--gc-sections always fails on targets without --gc-sections support.

* testsuite/ld-elf/pr21562a.d: Skip on targets with leading char
in in symbol name or without --gc-sections.
* 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/pr21562e.d: Skip on targets with leading char
in symbol name.
* testsuite/ld-elf/pr21562f.d: Likewise.
* testsuite/ld-elf/pr21562g.d: Likewise.
* testsuite/ld-elf/pr21562h.d: Likewise.

8 years agoAdd size to bar in ld-gc/pr20022a.s
H.J. Lu [Wed, 14 Jun 2017 12:51:59 +0000 (05:51 -0700)] 
Add size to bar in ld-gc/pr20022a.s

Some linker backends require size info on dynamic symbols.

* testsuite/ld-gc/pr20022a.s: Add size to bar.

8 years agoSkip sizeof/startof tests on targets with leading char
H.J. Lu [Wed, 14 Jun 2017 12:49:02 +0000 (05:49 -0700)] 
Skip sizeof/startof tests on targets with leading char

Symbol lookup in linker will always fail on targets with leading char
in symbol name since __start_SECNAME and __stop_SECNAME in C may be
___start_SECNAME and ___stop_SECNAME in assembly.

* testsuite/ld-elf/sizeofa.d: Skip on targets with leading char
in symbol name.
* testsuite/ld-elf/sizeofb.d: Likewise.
* testsuite/ld-elf/startofa.d: Likewise.
* testsuite/ld-elf/startofb.d: Likewise.

8 years agoFix address violation problems when disassembling a corrupt RX binary.
Nick Clifton [Wed, 14 Jun 2017 12:35:06 +0000 (13:35 +0100)] 
Fix address violation problems when disassembling a corrupt RX binary.

PR binutils/21587
* rx-decode.opc: Include libiberty.h
(GET_SCALE): New macro - validates access to SCALE array.
(GET_PSCALE): New macro - validates access to PSCALE array.
(DIs, SIs, S2Is, rx_disp): Use new macros.
* rx-decode.c: Regenerate.

8 years agoFix register selection in var-access.exp
Andreas Arnez [Wed, 14 Jun 2017 12:24:03 +0000 (14:24 +0200)] 
Fix register selection in var-access.exp

The new test var-access.exp causes FAILs on i686.  This is because the
test chooses the wrong name for DWARF register number 1: It uses
"edx" (which corresponds to DWARF register number 2), but should have used
"ecx" instead.

Also, the current logic in var-access.exp does not correctly distinguish
between a 64-bit and a 32-bit program on an x86-64 target.  It uses the
64-bit register names for both.

These problems are fixed.  In order to address the latter, the convenience
macros is_*_target are exploited where appropriate.

gdb/testsuite/ChangeLog:

* gdb.dwarf2/var-access.exp: Use register name ecx instead of edx
on 32-bit x86 targets.  Exploit is_*_target macros where
appropriate.

8 years agoMove location of .jumptables section and add .hightext section to AVR linker script.
Georg-Johann Lay [Wed, 14 Jun 2017 11:23:39 +0000 (12:23 +0100)] 
Move location of .jumptables section and add .hightext section to AVR linker script.

PR ld/21583
* scripttempl/avr.sc (.jumptables): Move down in text section.
(.hightext): New in text.

8 years agoFix potential address violations when processing a corrupt Alpha VMA binary.
Nick Clifton [Wed, 14 Jun 2017 10:27:15 +0000 (11:27 +0100)] 
Fix potential address violations when processing a corrupt Alpha VMA binary.

PR binutils/21589
* vms-alpha.c (_bfd_vms_get_value): Add an extra parameter - the
maximum value for the ascic pointer.  Check that name processing
does not read beyond this value.
(_bfd_vms_slurp_etir): Add checks for attempts to read beyond the
end of etir record.

8 years agoIntroduce gdb::byte_vector, add allocator that default-initializes
Pedro Alves [Wed, 14 Jun 2017 10:08:52 +0000 (11:08 +0100)] 
Introduce gdb::byte_vector, add allocator that default-initializes

In some cases we've been replacing heap-allocated gdb_byte buffers
managed with xmalloc/make_cleanup(xfree) with gdb::vector<gdb_byte>.
That usually pessimizes the code a little bit because std::vector
value-initializes elements (which for gdb_byte means
zero-initialization), while if you're creating a temporary buffer,
you're most certaintly going to fill it in with some data.  An
alternative is to use

  unique_ptr<gdb_byte[]> buf (new gdb_byte[size]);

but it looks like that's not very popular.

Recently, a use of obstacks in dwarf2read.c was replaced with
std::vector<gdb_byte> and that as well introduced a pessimization for
always memsetting the buffer when it's garanteed that the zeros will
be overwritten immediately.  (see dwarf2read.c change in this patch to
find it.)

So here's a different take at addressing this issue "by design":

#1 - Introduce default_init_allocator<T>

I.e., a custom allocator that does default construction using default
initialization, meaning, no more zero initialization.  That's the
default_init_allocation<T> class added in this patch.

See "Notes" at
<http://en.cppreference.com/w/cpp/container/vector/resize>.

#2 - Introduce def_vector<T>

I.e., a convenience typedef, because typing the allocator is annoying:

  using def_vector<T> = std::vector<T, gdb::default_init_allocator<T>>;

#3 - Introduce byte_vector

Because gdb_byte vectors will be the common thing, add a convenience
"byte_vector" typedef:

  using byte_vector = def_vector<gdb_byte>;

which is really the same as:

  std::vector<gdb_byte, gdb::default_init_allocator<gdb_byte>>;

The intent then is to make "gdb::byte_vector" be the go-to for dynamic
byte buffers.  So the less friction, the better.

#4 - Adjust current code to use it.

To set the example going forward.  Replace std::vector uses and also
unique_ptr<byte[]> uses.

One nice thing is that with this allocator, for changes like these:

  -std::unique_ptr<byte[]> buf (new gdb_byte[some_size]);
  +gdb::byte_vector buf (some_size);
   fill_with_data (buf.data (), buf.size ());

the generated code is the same as before.  I.e., the compiler
de-structures the vector and gets rid of the unused "reserved vs size"
related fields.

The other nice thing is that it's easier to write
  gdb::byte_vector buf (size);
than
  std::unique_ptr<gdb_byte[]> buf (new gdb_byte[size]);
or even (C++14):
  auto buf = std::make_unique<gdb_byte[]> (size); // zero-initializes...

#5 - Suggest s/std::vector<gdb_byte>/gdb::byte_vector/ going forward.

Note that this commit actually fixes a couple of bugs where the current
code is incorrectly using "std::vector::reserve(new_size)" and then
accessing the vector's internal buffer beyond the vector's size: see
dwarf2loc.c and charset.c.  That's undefined behavior and may trigger
debug mode assertion failures.  With default_init_allocator,
"resize()" behaves like "reserve()" performance wise, in that it
leaves new elements with unspecified values, but, it does that safely
without triggering undefined behavior when you access those values.

gdb/ChangeLog:
2017-06-14  Pedro Alves  <palves@redhat.com>

* ada-lang.c: Include "common/byte-vector.h".
(ada_value_primitive_packed_val): Use gdb::byte_vector.
* charset.c (wchar_iterator::iterate): Resize the vector instead
of reserving it.
* common/byte-vector.h: Include "common/def-vector.h".
(wchar_iterator::m_out): Now a gdb::def_vector<gdb_wchar_t>.
* cli/cli-dump.c: Include "common/byte-vector.h".
(dump_memory_to_file, restore_binary_file): Use gdb::byte_vector.
* common/byte-vector.h: New file.
* common/def-vector.h: New file.
* common/default-init-alloc.h: New file.
* dwarf2loc.c: Include "common/byte-vector.h".
(rw_pieced_value): Use gdb::byte_vector, and resize the vector
instead of reserving it.
* dwarf2read.c: Include "common/byte-vector.h".
(data_buf::m_vec): Now a gdb::byte_vector.
* gdb_regex.c: Include "common/def-vector.h".
(compiled_regex::compiled_regex): Use gdb::def_vector<char>.
* mi/mi-main.c: Include "common/byte-vector.h".
(mi_cmd_data_read_memory): Use gdb::byte_vector.
* printcmd.c: Include "common/byte-vector.h".
(print_scalar_formatted): Use gdb::byte_vector.
* valprint.c: Include "common/byte-vector.h".
(maybe_negate_by_bytes, print_decimal_chars): Use
gdb::byte_vector.

8 years ago[opcodes][arm] Remove bogus entry added by accident in former patch
Andre Vieira [Wed, 14 Jun 2017 09:52:40 +0000 (10:52 +0100)] 
[opcodes][arm] Remove bogus entry added by accident in former patch

2017-07-14  Andre Vieira  <andre.simoesdiasvieira@arm.com>

* arm-dis.c (print_insn_arm): Remove bogus entry for bx.

8 years agoFix seg-faults in objdump when disassembling a corrupt versados binary.
Nick Clifton [Wed, 14 Jun 2017 09:35:16 +0000 (10:35 +0100)] 
Fix seg-faults in objdump when disassembling a corrupt versados binary.

PR binutils/21591
* versados.c (versados_mkobject): Zero the allocated tdata structure.
(process_otr): Check for an invalid offset in the otr structure.

8 years agoAccept more epiphany targets
Sebastian Huber [Tue, 13 Jun 2017 05:48:40 +0000 (07:48 +0200)] 
Accept more epiphany targets

In particular this adds support for the epiphany-rtems target.

bfd/
* config.bfd (epiphany-*-elf): Accept epiphany-*-*.

ld/
* configure.tgt (epiphany-*-elf): Accept epiphany-*-*.

8 years agoAutomatic date update in version.in
GDB Administrator [Wed, 14 Jun 2017 00:00:25 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 years agold: Don't define __start_SECNAME/__stop_SECNAME for -r
H.J. Lu [Tue, 13 Jun 2017 20:04:56 +0000 (13:04 -0700)] 
ld: Don't define __start_SECNAME/__stop_SECNAME for -r

__start_SECNAME and __stop_SECNAME shouldn't be defined for "ld -r".

* ldlang.c (lang_set_startof): Skip if config.build_constructors
is FALSE.
* testsuite/ld-elf/sizeofc.d: New file.
* testsuite/ld-elf/startofc.d: Likewise.

8 years agodarwin-nat: Add missing include
Simon Marchi [Tue, 13 Jun 2017 19:14:50 +0000 (21:14 +0200)] 
darwin-nat: Add missing include

I forgot this one, which is kind of related.

The function trace_start_error_with_name has moved in commit "Share
fork_inferior et al with gdbserver", so this additional include is
needed.

Fixes:

darwin-nat.c:1735:5: error: use of undeclared identifier 'trace_start_error_with_name'
    trace_start_error_with_name ("close");

gdb/ChangeLog:

* darwin-nat.c: Include "nat/fork-inferior.h".

8 years agodarwin: Add fork-inferior.o to NATDEPFILES
Simon Marchi [Tue, 13 Jun 2017 19:14:35 +0000 (21:14 +0200)] 
darwin: Add fork-inferior.o to NATDEPFILES

I happened to be build-testing on macOS and found this:

  Undefined symbols for architecture x86_64:

    "fork_inferior(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char**, void (*)(), void (*)(int), void (*)(), char const*, void (*)(char const*, char* const*, char* const*))", referenced from:

        darwin_create_inferior(target_ops*, char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char**, int) in darwin-nat.o

    "startup_inferior(int, int, target_waitstatus*, ptid_t*)", referenced from:

        gdb_startup_inferior(int, int) in fork-child.o

    "trace_start_error(char const*, ...)", referenced from:

        darwin_ptrace_me() in darwin-nat.o

    "trace_start_error_with_name(char const*)", referenced from:

        darwin_ptrace_me() in darwin-nat.o

  ld: symbol(s) not found for architecture x86_64

  clang: error: linker command failed with exit code 1 (use -v to see invocation)

Adding fork-inferior.o fixes it.  I factored out the Darwin bits that
are no architecture-specific in the section meant for that at the top.

I only built-tested this using Travis-CI, since I don't have access to
this platform.

gdb/ChangeLog:

* configure.nat: Factor out Darwin bits that are not
architecture-specific.  Add fork-inferior.o.

8 years agoaix: Add fork-inferior.o to NATDEPFILES
Simon Marchi [Tue, 13 Jun 2017 19:14:25 +0000 (21:14 +0200)] 
aix: Add fork-inferior.o to NATDEPFILES

Trying to build on AIX gives:

ld: 0711-317 ERROR: Undefined symbol: .trace_start_error_with_name(char const*)
ld: 0711-317 ERROR: Undefined symbol: .fork_inferior(char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char**, void (*)(), void (*)(int), void (*)(), char const*, void (*)(char const*, char* const*, char* const*))
ld: 0711-317 ERROR: Undefined symbol: .startup_inferior(int, int, target_waitstatus*, ptid_t*)

Including fork-inferior.o in the build should help.  I also factored out
the AIX bits that are not architecture-specific to be consistent with the other
OSes.

gdb/ChangeLog:

* configure.nat: Factor out AIX bits that are not
architecture-specific.  Add fork-inferior.o.

8 years agold: Add tests for .startof.SECNAME/.sizeof.SECNAME
H.J. Lu [Tue, 13 Jun 2017 19:03:40 +0000 (12:03 -0700)] 
ld: Add tests for .startof.SECNAME/.sizeof.SECNAME

* testsuite/ld-elf/sizeof.d: Renamed to ...
* testsuite/ld-elf/sizeofa.d: This.  Updated.
* testsuite/ld-elf/startof.d: Renamed to ...
* testsuite/ld-elf/startofa.d: This.  Updated.
* testsuite/ld-elf/sizeofb.d: New file.
* testsuite/ld-elf/startofb.d: Likewise.

8 years agoAlways define referenced __start_SECNAME/__stop_SECNAME
H.J. Lu [Tue, 13 Jun 2017 15:53:22 +0000 (08:53 -0700)] 
Always define referenced __start_SECNAME/__stop_SECNAME

Currently, linker will define __start_SECNAME and __stop_SECNAME symbols
only for orphaned sections.

However, during garbage collection, ELF linker marks all sections with
references to __start_SECNAME and __stop_SECNAME symbols as used even
when section SECNAME isn't an orphaned section and linker won't define
__start_SECNAME nor __stop_SECNAME.  And ELF linker stores the first
input section whose name matches __start_SECNAME or __stop_SECNAME in
u.undef.section for garbage collection.  If these symbols are provided
in linker script, u.undef.section is set to the section where they will
defined by linker script, which leads to the incorrect output.

This patch changes linker to always define referenced __start_SECNAME and
__stop_SECNAME if the input section name is the same as the output section
name, which is always true for orphaned sections, and SECNAME is a C
identifier.  Also __start_SECNAME and __stop_SECNAME symbols are marked
as hidden by ELF linker so that __start_SECNAME and __stop_SECNAME symbols
for section SECNAME in different modules are unique.  For garbage
collection, ELF linker stores the first matched input section in the
unused vtable field.

bfd/

PR ld/20022
PR ld/21557
PR ld/21562
PR ld/21571
* elf-bfd.h (elf_link_hash_entry): Add start_stop.  Change the
vtable field to a union.
(_bfd_elf_is_start_stop): Removed.
* elf32-i386.c (elf_i386_convert_load_reloc): Also check for
__start_SECNAME and __stop_SECNAME symbols.
* elf64-x86-64.c (elf_x86_64_convert_load_reloc): Likewise.
* elflink.c (_bfd_elf_is_start_stop): Removed.
(_bfd_elf_gc_mark_rsec): Check start_stop instead of calling
_bfd_elf_is_start_stop.
(elf_gc_propagate_vtable_entries_used): Skip __start_SECNAME and
__stop_SECNAME symbols.  Updated.
(elf_gc_smash_unused_vtentry_relocs): Likewise.
(bfd_elf_gc_record_vtinherit): Likewise.
(bfd_elf_gc_record_vtentry): Likewise.

ld/

PR ld/20022
PR ld/21557
PR ld/21562
PR ld/21571
* ld.texinfo: Update __start_SECNAME/__stop_SECNAME symbols.
* ldlang.c (lang_insert_orphan): Move handling of __start_SECNAME
and __stop_SECNAME symbols to ...
(lang_set_startof): Here.  Also define __start_SECNAME and
__stop_SECNAME for -Ur.
* emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Mark
referenced __start_SECNAME and __stop_SECNAME symbols as hidden
and set start_stop for garbage collection.
* testsuite/ld-elf/pr21562a.d: New file.
* testsuite/ld-elf/pr21562a.s: Likewise.
* testsuite/ld-elf/pr21562a.t: Likewise.
* testsuite/ld-elf/pr21562b.d: Likewise.
* testsuite/ld-elf/pr21562b.s: Likewise.
* testsuite/ld-elf/pr21562b.t: Likewise.
* testsuite/ld-elf/pr21562c.d: Likewise.
* testsuite/ld-elf/pr21562c.t: Likewise.
* testsuite/ld-elf/pr21562d.d: Likewise.
* testsuite/ld-elf/pr21562d.t: Likewise.
* testsuite/ld-elf/pr21562e.d: Likewise.
* testsuite/ld-elf/pr21562f.d: Likewise.
* testsuite/ld-elf/pr21562g.d: Likewise.
* testsuite/ld-elf/pr21562h.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-gc/pr20022.d: Likewise.
* testsuite/ld-gc/pr20022a.s: Likewise.
* testsuite/ld-gc/pr20022b.s: Likewise.
* testsuite/ld-gc/gc.exp: Run PR ld/20022 tests.
* testsuite/ld-gc/pr19161.d: Also accept local __start_SECNAME
symbol.
* testsuite/ld-gc/start.d: Likewise.
* testsuite/ld-x86-64/lea1a.d: Updated.
* testsuite/ld-x86-64/lea1b.d: Updated.
* testsuite/ld-x86-64/lea1d.d: Updated.
* testsuite/ld-x86-64/lea1e.d: Likewise.

8 years agoReplace multiple AVR scripts with a single, customizable linker script.
Georg-Johann Lay [Tue, 13 Jun 2017 15:50:26 +0000 (16:50 +0100)] 
Replace multiple AVR scripts with a single, customizable linker script.

PR ld/21569
        * scripttempl/avrtiny.sc: Remove file.
* Makefile.am (eavrtiny.c): Depend on avr.sc, no more on avrtiny.sc.
* Makefile.in: Regenerate.
* emulparams/avrtiny.sh (SCRIPT_NAME): Set var to "avr".
(TEXT_ORIGIN): Remove var.
(FUSE_NAME, FUSE_LENGTH, LOCK_LENGTH, SIGNATURE_LENGTH)
(RODATA_PM_OFFSET): Set new vars.
* emulparams/avr1.sh (FUSE_NAME, EEPROM_LENGTH, FUSE_LENGTH)
(LOCK_LENGTH, SIGNATURE_LENGTH, USER_SIGNATURE_LENGTH): Set new vars.
* emulparams/avr2.sh: Same.
* emulparams/avr25.sh: Same.
* emulparams/avr3.sh: Same.
* emulparams/avr31.sh: Same.
* emulparams/avr35.sh: Same.
* emulparams/avr4.sh: Same.
* emulparams/avr5.sh: Same.
* emulparams/avr51.sh: Same.
* emulparams/avr6.sh: Same.
* emulparams/avrxmega1.sh: Same.
* emulparams/avrxmega2.sh: Same.
* emulparams/avrxmega3.sh: Same.
* emulparams/avrxmega4.sh: Same.
* emulparams/avrxmega5.sh: Same.
* emulparams/avrxmega6.sh: Same.
* emulparams/avrxmega7.sh: Same.
* scripttempl/avr.sc (__EEPROM_REGION_LENGTH__): Only define
if EEPROM_LENGTH is set.
(MEMORY) [eeprom]: Same.
(SECTIONS) [.eeprom]: Same for output section.
(__USER_SIGNATURE_REGION_LENGTH__): Only define if
USER_SIGNATURE_LENGTH is set.
(MEMORY) [user_signatures]: Same.
(SECTIONS) [.fuse]: Only define output section if FUSE_NAME = fuse.
(SECTIONS) [.config]: Only define output section if FUSE_NAME = config.

8 years agold: Add tests for -Ur
H.J. Lu [Tue, 13 Jun 2017 15:18:19 +0000 (08:18 -0700)] 
ld: Add tests for -Ur

Test -Ur with __start_SECNAME, __stop_SECNAME, .startof.SECNAME and
.sizeof.SECNAME.  __start_SECNAME and __stop_SECNAME should be defined
to the start and the end of section SECNAME.  .startof.SECNAME and
.sizeof.SECNAME should be undefined.

* testsuite/ld-elf/sizeof.d: New file.
* testsuite/ld-elf/sizeof.s: Likewise.
* testsuite/ld-elf/startof.d: Likewise.
* testsuite/ld-elf/startof.s: Likewise.

8 years ago[LD][Testsuite] Add --no-dynamic-linker option to dynamic-1 rdynamic-1 test case.
Renlin Li [Tue, 13 Jun 2017 13:03:47 +0000 (14:03 +0100)] 
[LD][Testsuite] Add --no-dynamic-linker option to dynamic-1 rdynamic-1 test case.

arm-none-eabi-ld supports shared libraries. However, the toolchain may be
configured to generate statically linked executable by default.

It is required to have --no-dynamic-linker option before adding dynamic symbol
to static executable.
For dynamically linked executable, the behavior won't change.

ld/ChangeLog
2017-06-13  Renlin Li  <renlin.li@arm.com>

* testsuite/ld-elf/shared.exp (build_tests): Add --no-dynamic-linker
option to rdynamic-1 and dynamic-1 tests.

8 years agoread/write_pieced_value: Merge into one function
Andreas Arnez [Tue, 13 Jun 2017 13:20:32 +0000 (15:20 +0200)] 
read/write_pieced_value: Merge into one function

Since read_pieced_value and write_pieced_value share significant logic,
this patch merges them into a single function rw_pieced_value.

gdb/ChangeLog:

* dwarf2loc.c (rw_pieced_value): New.  Merge logic from...
(read_pieced_value, write_pieced_value): ...here.  Reduce to
wrappers that just call rw_pieced_value.