aboutsummaryrefslogtreecommitdiff
path: root/gas/config
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2020-10-05 10:40:07 +0100
committerNick Clifton <nickc@redhat.com>2020-10-05 10:40:07 +0100
commitb71702f1c01052b70b4fd8157982eadc2132fc24 (patch)
tree55fbf234a5e3fc887375ce3c3bcec983dce38417 /gas/config
parent1ba0655539bcbde49171691582d5e804c3e4f975 (diff)
downloadgdb-b71702f1c01052b70b4fd8157982eadc2132fc24.zip
gdb-b71702f1c01052b70b4fd8157982eadc2132fc24.tar.gz
gdb-b71702f1c01052b70b4fd8157982eadc2132fc24.tar.bz2
GAS: Update the .section directive so that a numeric section index can be provided when the "o" flag is used.
PR 26253 gas * config/obj-elf.c (obj_elf_section): Accept a numeric value for the "o" section flag. Interpret it as a section index. Allow an index of zero. * doc/as.texi: Document the new behaviour. * NEWS: Mention the new feature. Tidy entries. * testsuite/gas/elf/sh-link-zero.s: New test. * testsuite/gas/elf/sh-link-zero.d: New test driver. * testsuite/gas/elf/elf.exp: Run the new test. * testsuite/gas/elf/section21.l: Updated expected assembler output. bfd * elf.c (_bfd_elf_setup_sections): Do not complain about an sh_link value of zero when the SLF_LINK_ORDER flag is set. (assign_section_numbers): Likewise.
Diffstat (limited to 'gas/config')
-rw-r--r--gas/config/obj-elf.c39
-rw-r--r--gas/config/obj-elf.h10
2 files changed, 35 insertions, 14 deletions
diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index 45de821..f061ea6 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -519,8 +519,10 @@ struct section_stack
static struct section_stack *section_stack;
+/* Return TRUE iff SEC matches the section info INF. */
+
static bfd_boolean
-get_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *inf)
+get_section_by_match (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *inf)
{
struct elf_section_match *match = (struct elf_section_match *) inf;
const char *gname = match->group_name;
@@ -602,7 +604,7 @@ obj_elf_change_section (const char *name,
previous_section = now_seg;
previous_subsection = now_subseg;
- old_sec = bfd_get_section_by_name_if (stdoutput, name, get_section,
+ old_sec = bfd_get_section_by_name_if (stdoutput, name, get_section_by_match,
(void *) match_p);
if (old_sec)
{
@@ -1076,6 +1078,7 @@ obj_elf_section (int push)
int linkonce;
subsegT new_subsection = -1;
struct elf_section_match match;
+ unsigned long linked_to_section_index = -1UL;
if (flag_mri)
{
@@ -1215,15 +1218,24 @@ obj_elf_section (int push)
if ((attr & SHF_LINK_ORDER) != 0 && *input_line_pointer == ',')
{
- char c;
- unsigned int length;
++input_line_pointer;
SKIP_WHITESPACE ();
- c = get_symbol_name (& beg);
- (void) restore_line_pointer (c);
- length = input_line_pointer - beg;
- if (length)
- match.linked_to_symbol_name = xmemdup0 (beg, length);
+ /* Check for a numeric section index, rather than a symbol name. */
+ if (ISDIGIT (* input_line_pointer))
+ {
+ linked_to_section_index = strtoul (input_line_pointer, & input_line_pointer, 0);
+ }
+ else
+ {
+ char c;
+ unsigned int length;
+
+ c = get_symbol_name (& beg);
+ (void) restore_line_pointer (c);
+ length = input_line_pointer - beg;
+ if (length)
+ match.linked_to_symbol_name = xmemdup0 (beg, length);
+ }
}
if ((attr & SHF_GROUP) != 0 && is_clone)
@@ -1231,6 +1243,7 @@ obj_elf_section (int push)
as_warn (_("? section flag ignored with G present"));
is_clone = FALSE;
}
+
if ((attr & SHF_GROUP) != 0 && *input_line_pointer == ',')
{
++input_line_pointer;
@@ -1289,6 +1302,7 @@ obj_elf_section (int push)
if (*input_line_pointer == ',')
{
char *save = input_line_pointer;
+
++input_line_pointer;
SKIP_WHITESPACE ();
if (strncmp (input_line_pointer, "unique", 6) == 0)
@@ -1394,6 +1408,13 @@ obj_elf_section (int push)
}
elf_section_flags (now_seg) |= gnu_attr;
+ if (linked_to_section_index != -1UL)
+ {
+ elf_section_flags (now_seg) |= SHF_LINK_ORDER;
+ elf_section_data (now_seg)->this_hdr.sh_link = linked_to_section_index;
+ /* FIXME: Should we perform some sanity checking on the section index ? */
+ }
+
if (push && new_subsection != -1)
subseg_set (now_seg, new_subsection);
}
diff --git a/gas/config/obj-elf.h b/gas/config/obj-elf.h
index b39a1a1..4f29572 100644
--- a/gas/config/obj-elf.h
+++ b/gas/config/obj-elf.h
@@ -104,11 +104,11 @@ struct elf_obj_sy
field. */
struct elf_section_match
{
- const char *group_name;
- const char *linked_to_symbol_name;
- unsigned int info;
- unsigned int section_id;
- flagword flags;
+ const char * group_name;
+ const char * linked_to_symbol_name;
+ unsigned int info;
+ unsigned int section_id;
+ flagword flags;
};
#define OBJ_SYMFIELD_TYPE struct elf_obj_sy