This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Thumb32 assembler (2/69)
- From: Zack Weinberg <zack at codesourcery dot com>
- To: binutils <binutils at sourceware dot org>
- Date: Tue, 26 Apr 2005 02:52:25 -0700
- Subject: Thumb32 assembler (2/69)
This is just a cleanup, it's not directly related to the Thumb32
project. obj-elf.c now exposes an interface that start_unwind_section
can use to do what it wants without having to construct a fake
.section directive.
zw
* tc-arm.c (set_section): Delete.
(start_unwind_section): Allocate section name with malloc;
call obj_elf_change_section directly.
===================================================================
Index: gas/config/tc-arm.c
--- gas/config/tc-arm.c (revision 2)
+++ gas/config/tc-arm.c (revision 3)
@@ -12699,23 +12699,6 @@
static void add_unwind_adjustsp (offsetT);
-/* Switch to section NAME and create section if necessary. It's
- rather ugly that we have to manipulate input_line_pointer but I
- don't see any other way to accomplish the same thing without
- changing obj-elf.c (which may be the Right Thing, in the end).
- Copied from tc-ia64.c. */
-
-static void
-set_section (char *name)
-{
- char *saved_input_line_pointer;
-
- saved_input_line_pointer = input_line_pointer;
- input_line_pointer = name;
- obj_elf_section (0);
- input_line_pointer = saved_input_line_pointer;
-}
-
/* Cenerate and deferred unwind frame offset. */
static void
@@ -12852,20 +12835,26 @@
const char * text_name;
const char * prefix;
const char * prefix_once;
+ const char * group_name;
size_t prefix_len;
size_t text_len;
char * sec_name;
size_t sec_name_len;
+ int type;
+ int flags;
+ int linkonce;
if (idx)
{
prefix = ELF_STRING_ARM_unwind;
prefix_once = ELF_STRING_ARM_unwind_once;
+ type = SHT_ARM_EXIDX;
}
else
{
prefix = ELF_STRING_ARM_unwind_info;
prefix_once = ELF_STRING_ARM_unwind_info_once;
+ type = SHT_PROGBITS;
}
text_name = segment_name (text_seg);
@@ -12882,18 +12871,19 @@
prefix_len = strlen (prefix);
text_len = strlen (text_name);
sec_name_len = prefix_len + text_len;
- sec_name = alloca (sec_name_len + 1);
+ sec_name = xmalloc (sec_name_len + 1);
memcpy (sec_name, prefix, prefix_len);
memcpy (sec_name + prefix_len, text_name, text_len);
sec_name[prefix_len + text_len] = '\0';
+ flags = SHF_ALLOC;
+ linkonce = 0;
+ group_name = 0;
+
/* Handle COMDAT group. */
if (prefix != prefix_once && (text_seg->flags & SEC_LINK_ONCE) != 0)
{
- char *section;
- size_t len, group_name_len;
- const char *group_name = elf_group_name (text_seg);
-
+ group_name = elf_group_name (text_seg);
if (group_name == NULL)
{
as_bad ("Group section `%s' has no group signature",
@@ -12901,36 +12891,12 @@
ignore_rest_of_line ();
return;
}
- /* We have to construct a fake section directive. */
- group_name_len = strlen (group_name);
- if (idx)
- prefix_len = 13;
- else
- prefix_len = 16;
-
- len = (sec_name_len
- + prefix_len /* ,"aG",%sectiontype, */
- + group_name_len /* ,group_name */
- + 7); /* ,comdat */
-
- section = alloca (len + 1);
- memcpy (section, sec_name, sec_name_len);
- if (idx)
- memcpy (section + sec_name_len, ",\"aG\",%exidx,", 13);
- else
- memcpy (section + sec_name_len, ",\"aG\",%progbits,", 16);
- memcpy (section + sec_name_len + prefix_len, group_name, group_name_len);
- memcpy (section + len - 7, ",comdat", 7);
- section [len] = '\0';
- set_section (section);
+ flags |= SHF_GROUP;
+ linkonce = 1;
}
- else
- {
- set_section (sec_name);
- bfd_set_section_flags (stdoutput, now_seg,
- SEC_LOAD | SEC_ALLOC | SEC_READONLY);
- }
+ obj_elf_change_section (sec_name, type, flags, 0, group_name, linkonce, 0);
+
/* Set the setion link for index tables. */
if (idx)
elf_linked_to_section (now_seg) = text_seg;