aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorMax Filippov <jcmvbkbc@gmail.com>2018-05-22 21:48:09 -0700
committerMax Filippov <jcmvbkbc@gmail.com>2018-06-04 10:36:39 -0700
commit8255c61b8ad5ac933672d26e5c9454aaf09ccaeb (patch)
tree4943f03256f08b0ec0bd4729b5a5b6eaa8e9616c /bfd
parent95da9854466ada2572b42f5528711a06a2d42db1 (diff)
downloadgdb-8255c61b8ad5ac933672d26e5c9454aaf09ccaeb.zip
gdb-8255c61b8ad5ac933672d26e5c9454aaf09ccaeb.tar.gz
gdb-8255c61b8ad5ac933672d26e5c9454aaf09ccaeb.tar.bz2
xtensa: add separate property sections option
It is currently not possible to correctly match .xt.prop information for sections with identical VMA. Allow creation of separate property sections in the BFD. Add assembler option --separate-prop-tables to allow creation of separate property sections. 2018-06-04 Volodymyr Arbatov <arbatov@cadence.com> bfd/ * elf32-xtensa.c (elf32xtensa_separate_props): New global variable. (xtensa_add_names): New function. (xtensa_property_section_name): Add new parameter separate_sections, use it to choose property section name. (xtensa_get_separate_property_section): New function. (xtensa_get_property_section): Invoke xtensa_get_separate_property_section to get individual property section if it exists, common property section otherwise. (xtensa_make_property_section): Pass elf32xtensa_separate_props to xtensa_property_section_name. gas/ * config/tc-xtensa.c (elf32xtensa_separate_props): New declaration. (option_separate_props, option_no_separate_props): New enumeration constants. (md_longopts): Add separate-prop-tables option. (md_parse_option): Add cases for option_separate_props and option_no_separate_props. (md_show_usage): Add help for [no-]separate-prop-tables options.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog14
-rw-r--r--bfd/elf32-xtensa.c62
2 files changed, 66 insertions, 10 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index b36cdab..f373b8b 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,17 @@
+2018-06-04 Volodymyr Arbatov <arbatov@cadence.com>
+
+ * elf32-xtensa.c (elf32xtensa_separate_props): New global
+ variable.
+ (xtensa_add_names): New function.
+ (xtensa_property_section_name): Add new parameter
+ separate_sections, use it to choose property section name.
+ (xtensa_get_separate_property_section): New function.
+ (xtensa_get_property_section): Invoke
+ xtensa_get_separate_property_section to get individual property
+ section if it exists, common property section otherwise.
+ (xtensa_make_property_section): Pass elf32xtensa_separate_props
+ to xtensa_property_section_name.
+
2018-06-04 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/23146
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index c12b2f5..db3c8f4 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -154,6 +154,11 @@ static bfd_boolean relaxing_section = FALSE;
int elf32xtensa_no_literal_movement = 1;
+/* Place property records for a section into individual property section
+ with xt.prop. prefix. */
+
+bfd_boolean elf32xtensa_separate_props = FALSE;
+
/* Rename one of the generic section flags to better document how it
is used here. */
/* Whether relocations have been processed. */
@@ -10987,10 +10992,30 @@ match_section_group (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *inf)
}
+static char *
+xtensa_add_names (const char *base, const char *suffix)
+{
+ if (suffix)
+ {
+ size_t base_len = strlen (base);
+ size_t suffix_len = strlen (suffix);
+ char *str = bfd_malloc (base_len + suffix_len + 1);
+
+ memcpy (str, base, base_len);
+ memcpy (str + base_len, suffix, suffix_len + 1);
+ return str;
+ }
+ else
+ {
+ return strdup (base);
+ }
+}
+
static int linkonce_len = sizeof (".gnu.linkonce.") - 1;
static char *
-xtensa_property_section_name (asection *sec, const char *base_name)
+xtensa_property_section_name (asection *sec, const char *base_name,
+ bfd_boolean separate_sections)
{
const char *suffix, *group_name;
char *prop_sec_name;
@@ -11001,11 +11026,7 @@ xtensa_property_section_name (asection *sec, const char *base_name)
suffix = strrchr (sec->name, '.');
if (suffix == sec->name)
suffix = 0;
- prop_sec_name = (char *) bfd_malloc (strlen (base_name) + 1
- + (suffix ? strlen (suffix) : 0));
- strcpy (prop_sec_name, base_name);
- if (suffix)
- strcat (prop_sec_name, suffix);
+ prop_sec_name = xtensa_add_names (base_name, suffix);
}
else if (strncmp (sec->name, ".gnu.linkonce.", linkonce_len) == 0)
{
@@ -11033,19 +11054,24 @@ xtensa_property_section_name (asection *sec, const char *base_name)
strcat (prop_sec_name + linkonce_len, suffix);
}
else
- prop_sec_name = strdup (base_name);
+ {
+ prop_sec_name = xtensa_add_names (base_name,
+ separate_sections ? sec->name : NULL);
+ }
return prop_sec_name;
}
static asection *
-xtensa_get_property_section (asection *sec, const char *base_name)
+xtensa_get_separate_property_section (asection *sec, const char *base_name,
+ bfd_boolean separate_section)
{
char *prop_sec_name;
asection *prop_sec;
- prop_sec_name = xtensa_property_section_name (sec, base_name);
+ prop_sec_name = xtensa_property_section_name (sec, base_name,
+ separate_section);
prop_sec = bfd_get_section_by_name_if (sec->owner, prop_sec_name,
match_section_group,
(void *) elf_group_name (sec));
@@ -11053,6 +11079,21 @@ xtensa_get_property_section (asection *sec, const char *base_name)
return prop_sec;
}
+static asection *
+xtensa_get_property_section (asection *sec, const char *base_name)
+{
+ asection *prop_sec;
+
+ /* Try individual property section first. */
+ prop_sec = xtensa_get_separate_property_section (sec, base_name, TRUE);
+
+ /* Refer to a common property section if individual is not present. */
+ if (!prop_sec)
+ prop_sec = xtensa_get_separate_property_section (sec, base_name, FALSE);
+
+ return prop_sec;
+}
+
asection *
xtensa_make_property_section (asection *sec, const char *base_name)
@@ -11061,7 +11102,8 @@ xtensa_make_property_section (asection *sec, const char *base_name)
asection *prop_sec;
/* Check if the section already exists. */
- prop_sec_name = xtensa_property_section_name (sec, base_name);
+ prop_sec_name = xtensa_property_section_name (sec, base_name,
+ elf32xtensa_separate_props);
prop_sec = bfd_get_section_by_name_if (sec->owner, prop_sec_name,
match_section_group,
(void *) elf_group_name (sec));