This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[Xtensa] handle non-existent property tables
- From: Bob Wilson <bwilson at tensilica dot com>
- To: binutils at sources dot redhat dot com
- Date: Wed, 07 May 2008 16:18:48 -0700
- Subject: [Xtensa] handle non-existent property tables
I've committed this patch for Xtensa. At some point I had forgotten about the
need to handle objects without the Xtensa-specific property sections. The
assembler always creates those sections so they're almost always present. The
function in BFD to retrieve a property section was attempting to create it if it
did not exist. That is wrong in contexts where the object is just being read as
an input.
2008-05-07 Bob Wilson <bob.wilson@acm.org>
bfd/
* elf32-xtensa.c (xtensa_property_section_name): New.
(xtensa_make_property_section): New.
(xtensa_get_property_section): Make static. Do not create a new
section if it does not exist.
gas/
* config/tc-xtensa.c (xtensa_create_property_segments): Use
xtensa_make_property_section instead of xtensa_get_property_section.
(xtensa_create_xproperty_segments): Likewise.
Index: bfd/elf32-xtensa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-xtensa.c,v
retrieving revision 1.109
diff -u -p -r1.109 elf32-xtensa.c
--- bfd/elf32-xtensa.c 11 Mar 2008 23:23:23 -0000 1.109
+++ bfd/elf32-xtensa.c 6 May 2008 22:35:41 -0000
@@ -108,7 +108,8 @@ static bfd_boolean xtensa_is_littable_se
static bfd_boolean xtensa_is_proptable_section (asection *);
static int internal_reloc_compare (const void *, const void *);
static int internal_reloc_matches (const void *, const void *);
-extern asection *xtensa_get_property_section (asection *, const char *);
+static asection *xtensa_get_property_section (asection *, const char *);
+extern asection *xtensa_make_property_section (asection *, const char *);
static flagword xtensa_get_property_predef_flags (asection *);
/* Other functions called directly by the linker. */
@@ -9716,12 +9717,11 @@ match_section_group (bfd *abfd ATTRIBUTE
static int linkonce_len = sizeof (".gnu.linkonce.") - 1;
-asection *
-xtensa_get_property_section (asection *sec, const char *base_name)
+static char *
+xtensa_property_section_name (asection *sec, const char *base_name)
{
const char *suffix, *group_name;
char *prop_sec_name;
- asection *prop_sec;
group_name = elf_group_name (sec);
if (group_name)
@@ -9763,10 +9763,36 @@ xtensa_get_property_section (asection *s
else
prop_sec_name = strdup (base_name);
+ return prop_sec_name;
+}
+
+
+static asection *
+xtensa_get_property_section (asection *sec, const char *base_name)
+{
+ char *prop_sec_name;
+ asection *prop_sec;
+
+ prop_sec_name = xtensa_property_section_name (sec, base_name);
+ prop_sec = bfd_get_section_by_name_if (sec->owner, prop_sec_name,
+ match_section_group,
+ (void *) elf_group_name (sec));
+ free (prop_sec_name);
+ return prop_sec;
+}
+
+
+asection *
+xtensa_make_property_section (asection *sec, const char *base_name)
+{
+ char *prop_sec_name;
+ asection *prop_sec;
+
/* Check if the section already exists. */
+ prop_sec_name = xtensa_property_section_name (sec, base_name);
prop_sec = bfd_get_section_by_name_if (sec->owner, prop_sec_name,
match_section_group,
- (void *) group_name);
+ (void *) elf_group_name (sec));
/* If not, create it. */
if (! prop_sec)
{
@@ -9779,7 +9805,7 @@ xtensa_get_property_section (asection *s
if (! prop_sec)
return 0;
- elf_group_name (prop_sec) = group_name;
+ elf_group_name (prop_sec) = elf_group_name (sec);
}
free (prop_sec_name);
Index: gas/config/tc-xtensa.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-xtensa.c,v
retrieving revision 1.100
diff -u -p -r1.100 tc-xtensa.c
--- gas/config/tc-xtensa.c 4 Apr 2008 23:25:49 -0000 1.100
+++ gas/config/tc-xtensa.c 6 May 2008 22:35:42 -0000
@@ -492,7 +492,7 @@ static segT cache_literal_section (bfd_b
/* Import from elf32-xtensa.c in BFD library. */
-extern asection *xtensa_get_property_section (asection *, const char *);
+extern asection *xtensa_make_property_section (asection *, const char *);
/* op_placement_info functions. */
@@ -10395,7 +10395,7 @@ xtensa_create_property_segments (frag_pr
{
segment_info_type *xt_seg_info;
xtensa_block_info **xt_blocks;
- segT prop_sec = xtensa_get_property_section (sec, section_name_base);
+ segT prop_sec = xtensa_make_property_section (sec, section_name_base);
prop_sec->output_section = prop_sec;
subseg_set (prop_sec, 0);
@@ -10497,7 +10497,7 @@ xtensa_create_xproperty_segments (frag_f
{
segment_info_type *xt_seg_info;
xtensa_block_info **xt_blocks;
- segT prop_sec = xtensa_get_property_section (sec, section_name_base);
+ segT prop_sec = xtensa_make_property_section (sec, section_name_base);
prop_sec->output_section = prop_sec;
subseg_set (prop_sec, 0);