aboutsummaryrefslogtreecommitdiff
path: root/ld/ldgram.y
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2017-07-28 13:01:10 +0100
committerNick Clifton <nickc@redhat.com>2017-07-28 13:01:10 +0100
commit2b94abd48aef2d91bae1c35c8c10ebfb8757247d (patch)
tree6d1abfbf1470194ed0473dedbc483adee48644e5 /ld/ldgram.y
parenta808670465869100d4178a572da8a1503d727f3b (diff)
downloadgdb-2b94abd48aef2d91bae1c35c8c10ebfb8757247d.zip
gdb-2b94abd48aef2d91bae1c35c8c10ebfb8757247d.tar.gz
gdb-2b94abd48aef2d91bae1c35c8c10ebfb8757247d.tar.bz2
Make some improvements to how SORT_* specifiers and EXCLUDE_FILE specifiers are handled in the linker script grammar.
* ldgram.y (ldgram_had_keep): Make static. (ldgram_vers_current_lang): Likewise. (filename_spec): New rule. (input_section_spec_no_keep): Use filename_spec. (wildcard_maybe_exclude): New rule. (wildcard_spec): Rename to... (section_name_spec): ...this. (section_NAME_list): Rename to... (section_name_list): ...this. (section_name_spec): Simplifiy and use wildcard_maybe_exclude. * ldlang.c (placed_commons): Delete. (lang_add_wild): No longer set placed_commons. (print_wild_statement): Use full names for SORT specifiers. * testsuite/ld-scripts/align.exp: Run new tests. * testsuite/ld-scripts/align3.d: New file. * testsuite/ld-scripts/align3.t: New file. * testsuite/ld-scripts/align4.d: New file. * testsuite/ld-scripts/align4.t: New file. * testsuite/ld-scripts/align5.d: New file. * testsuite/ld-scripts/align5.t: New file. * testsuite/ld-scripts/exclude-file-5.d: New file. * testsuite/ld-scripts/exclude-file-5.map: New file. * testsuite/ld-scripts/exclude-file-5.t: New file. * testsuite/ld-scripts/exclude-file-6.d: New file. * testsuite/ld-scripts/exclude-file-6.map: New file. * testsuite/ld-scripts/exclude-file-6.t: New file. * NEWS: Mention the changes.
Diffstat (limited to 'ld/ldgram.y')
-rw-r--r--ld/ldgram.y97
1 files changed, 46 insertions, 51 deletions
diff --git a/ld/ldgram.y b/ld/ldgram.y
index 4c1efdc..771d990 100644
--- a/ld/ldgram.y
+++ b/ld/ldgram.y
@@ -48,8 +48,8 @@
static enum section_type sectype;
static lang_memory_region_type *region;
-bfd_boolean ldgram_had_keep = FALSE;
-char *ldgram_vers_current_lang = NULL;
+static bfd_boolean ldgram_had_keep = FALSE;
+static char *ldgram_vers_current_lang = NULL;
#define ERROR_NAME_MAX 20
static char *error_names[ERROR_NAME_MAX];
@@ -92,13 +92,13 @@ static int error_index;
%type <etree> opt_exp_without_type opt_subalign opt_align
%type <fill> fill_opt fill_exp
%type <name_list> exclude_name_list
-%type <wildcard_list> section_NAME_list
+%type <wildcard_list> section_name_list
%type <flag_info_list> sect_flag_list
%type <flag_info> sect_flags
%type <name> memspec_opt casesymlist
%type <name> memspec_at_opt
%type <cname> wildcard_name
-%type <wildcard> wildcard_spec
+%type <wildcard> section_name_spec filename_spec wildcard_maybe_exclude
%token <bigint> INT
%token <name> NAME LNAME
%type <integer> length
@@ -447,7 +447,7 @@ wildcard_name:
}
;
-wildcard_spec:
+wildcard_maybe_exclude:
wildcard_name
{
$$.name = $1;
@@ -462,68 +462,63 @@ wildcard_spec:
$$.exclude_name_list = $3;
$$.section_flag_list = NULL;
}
- | SORT_BY_NAME '(' wildcard_name ')'
+ ;
+
+filename_spec:
+ wildcard_maybe_exclude
+ | SORT_BY_NAME '(' wildcard_maybe_exclude ')'
{
- $$.name = $3;
+ $$ = $3;
$$.sorted = by_name;
- $$.exclude_name_list = NULL;
- $$.section_flag_list = NULL;
}
- | SORT_BY_ALIGNMENT '(' wildcard_name ')'
+ | SORT_NONE '(' wildcard_maybe_exclude ')'
+ {
+ $$ = $3;
+ $$.sorted = by_none;
+ }
+ ;
+
+section_name_spec:
+ wildcard_maybe_exclude
+ | SORT_BY_NAME '(' wildcard_maybe_exclude ')'
{
- $$.name = $3;
+ $$ = $3;
+ $$.sorted = by_name;
+ }
+ | SORT_BY_ALIGNMENT '(' wildcard_maybe_exclude ')'
+ {
+ $$ = $3;
$$.sorted = by_alignment;
- $$.exclude_name_list = NULL;
- $$.section_flag_list = NULL;
}
- | SORT_NONE '(' wildcard_name ')'
+ | SORT_NONE '(' wildcard_maybe_exclude ')'
{
- $$.name = $3;
+ $$ = $3;
$$.sorted = by_none;
- $$.exclude_name_list = NULL;
- $$.section_flag_list = NULL;
}
- | SORT_BY_NAME '(' SORT_BY_ALIGNMENT '(' wildcard_name ')' ')'
+ | SORT_BY_NAME '(' SORT_BY_ALIGNMENT '(' wildcard_maybe_exclude ')' ')'
{
- $$.name = $5;
+ $$ = $5;
$$.sorted = by_name_alignment;
- $$.exclude_name_list = NULL;
- $$.section_flag_list = NULL;
}
- | SORT_BY_NAME '(' SORT_BY_NAME '(' wildcard_name ')' ')'
+ | SORT_BY_NAME '(' SORT_BY_NAME '(' wildcard_maybe_exclude ')' ')'
{
- $$.name = $5;
+ $$ = $5;
$$.sorted = by_name;
- $$.exclude_name_list = NULL;
- $$.section_flag_list = NULL;
}
- | SORT_BY_ALIGNMENT '(' SORT_BY_NAME '(' wildcard_name ')' ')'
+ | SORT_BY_ALIGNMENT '(' SORT_BY_NAME '(' wildcard_maybe_exclude ')' ')'
{
- $$.name = $5;
+ $$ = $5;
$$.sorted = by_alignment_name;
- $$.exclude_name_list = NULL;
- $$.section_flag_list = NULL;
}
- | SORT_BY_ALIGNMENT '(' SORT_BY_ALIGNMENT '(' wildcard_name ')' ')'
+ | SORT_BY_ALIGNMENT '(' SORT_BY_ALIGNMENT '(' wildcard_maybe_exclude ')' ')'
{
- $$.name = $5;
+ $$ = $5;
$$.sorted = by_alignment;
- $$.exclude_name_list = NULL;
- $$.section_flag_list = NULL;
}
- | SORT_BY_NAME '(' EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name ')'
+ | SORT_BY_INIT_PRIORITY '(' wildcard_maybe_exclude ')'
{
- $$.name = $7;
- $$.sorted = by_name;
- $$.exclude_name_list = $5;
- $$.section_flag_list = NULL;
- }
- | SORT_BY_INIT_PRIORITY '(' wildcard_name ')'
- {
- $$.name = $3;
+ $$ = $3;
$$.sorted = by_init_priority;
- $$.exclude_name_list = NULL;
- $$.section_flag_list = NULL;
}
;
@@ -598,8 +593,8 @@ exclude_name_list:
}
;
-section_NAME_list:
- section_NAME_list opt_comma wildcard_spec
+section_name_list:
+ section_name_list opt_comma section_name_spec
{
struct wildcard_list *tmp;
tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
@@ -608,7 +603,7 @@ section_NAME_list:
$$ = tmp;
}
|
- wildcard_spec
+ section_name_spec
{
struct wildcard_list *tmp;
tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
@@ -637,11 +632,11 @@ input_section_spec_no_keep:
tmp.section_flag_list = $1;
lang_add_wild (&tmp, NULL, ldgram_had_keep);
}
- | '[' section_NAME_list ']'
+ | '[' section_name_list ']'
{
lang_add_wild (NULL, $2, ldgram_had_keep);
}
- | sect_flags '[' section_NAME_list ']'
+ | sect_flags '[' section_name_list ']'
{
struct wildcard_spec tmp;
tmp.name = NULL;
@@ -650,11 +645,11 @@ input_section_spec_no_keep:
tmp.section_flag_list = $1;
lang_add_wild (&tmp, $3, ldgram_had_keep);
}
- | wildcard_spec '(' section_NAME_list ')'
+ | filename_spec '(' section_name_list ')'
{
lang_add_wild (&$1, $3, ldgram_had_keep);
}
- | sect_flags wildcard_spec '(' section_NAME_list ')'
+ | sect_flags filename_spec '(' section_name_list ')'
{
$2.section_flag_list = $1;
lang_add_wild (&$2, $4, ldgram_had_keep);